/** * Handles uploads from media manager. * * @since 4.0 * @access public * @param string * @return */ public function upload() { // Ensure that the user is logged in EB::requireLogin(); // Only allowed users who are allowed to upload images if (!$this->acl->get('upload_image')) { $this->output(EB::exception('COM_EASYBLOG_NOT_ALLOWED', EASYBLOG_MSG_ERROR)); } // Load up media manager $mm = EB::mediamanager(); // Get uri $key = $this->input->getRaw('key'); // Get the target folder $placeId = EBMM::getUri($key); // Get the file input $file = $this->input->files->get('file'); // Check if the file is really allowed to be uploaded to the site. $state = EB::image()->canUploadFile($file); if ($state instanceof Exception) { return $this->output($state); } // MM should check if the user really has access to upload to the target folder $allowed = EBMM::hasAccess($placeId); if ($allowed instanceof Exception) { return $this->output($allowed); } // Check the image name is it got contain space, if yes need to replace to '-' $fileName = $file['name']; $file['name'] = str_replace(' ', '-', $fileName); // Upload the file now $file = $mm->upload($file, $placeId); // Response object is intended to also include // other properties like status message and status code. // Right now it only inclues the media item. $response = new stdClass(); $response->media = EBMM::getMedia($file->uri); return $this->output($response); }
/** * Normalizes an URI * * @since 5.0 * @access public * @param string * @return */ public function normalizeURI($uri) { // If the url is already a hyperlink, just skip this $url = $uri; // If the url is not a hyperlink, MM uri format, we need to get the correct url if (!EB::string()->isHyperlink($uri)) { $url = EBMM::getUrl($uri); } return $url; }
/** * Retrieves the media item * * @since 5.0 * @access public * @param string * @return */ public static function getMedia($uri) { $file = self::getFile($uri); $media = new stdClass(); $media->uri = $uri; $media->meta = EBMM::getFile($uri); $media->file = EBMM::renderFile($uri); $media->info = ''; $media->variations = EBMM::renderVariations($uri); if ($file->type == 'folder') { $media->folder = EBMM::renderFolder($uri); } else { $media->info = EBMM::renderInfo($uri); } return $media; }
echo EB::date($file->modified)->toMySQL(); ?> )</span> <?php } ?> </div> </div> </div> </div> <div class="col-cell cell-tight toolbar-right"> <div class="eb-composer-toolbar-group row-table"> <?php if (!EBMM::isExternalPlace($place->id) && ($place->acl->canRenameItem || $place->acl->canMoveItem || $place->acl->canRemoveItem)) { ?> <div class="eb-composer-toolbar-item is-button col-cell dropdown_"> <div class="eb-mm-info-menu-button dropdown-toggle_" data-bp-toggle="dropdown" > <span> <i class="fa fa-bars"></i> <span>Actions</span> </span> </div> <ul class="dropdown-menu pull-right"> <?php if ($place->acl->canRenameItem) { ?> <li> <a data-eb-mm-file-rename-button><span><?php echo JText::_('COM_EASYBLOG_MM_RENAME');
/** * Remove a single variation file from an image * * @since 5.0 * @access public * @param string * @return */ public function deleteVariation($uri, $name) { // We only allow deletion of user prefixes. $fileName = EBLOG_USER_VARIATION_PREFIX . '_' . $name . '_' . basename($uri); $filePath = EBMM::getPath(dirname($uri)) . '/' . $fileName; // Test if the file really exists on the site $exists = JFile::exists($filePath); if (!$exists) { return EB::exception('COM_EASYBLOG_FAILED_TO_DELETE_VARIATION_AS_IT_DOESNT_EXISTS'); } // Try to delete the variation now $state = JFile::delete($filePath); if (!$state) { return EB::exception('COM_EASYBLOG_FAILED_TO_DELETE_VARIATION_PERMISSIONS'); } return true; }
/** * * * @since 5.0 * @access public * @param string * @return */ public function decorateImage(SocialTablePhoto $photo, SocialTableAlbum $album) { $obj = new stdClass(); $obj->place = 'easysocial'; $obj->title = $photo->get('title'); $obj->url = rtrim(JURI::root(), '/') . str_ireplace(JPATH_ROOT, '', $photo->getStoragePath($album)); $obj->key = EBMM::getKey('easysocial:' . $photo->album_id . '/' . $photo->id); $obj->type = 'image'; $obj->icon = EBMM::getIcon('image'); $obj->modified = $photo->created; $obj->size = 0; // Thumbnails are larger than preview $obj->thumbnail = $photo->getSource(); // Preview is used in the listing $obj->preview = $photo->getSource(); $obj->variations = $this->getVariations($photo); return $obj; }
* EasyBlog is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ defined('_JEXEC') or die('Unauthorized Access'); ?> <div class="eb-mm-foldertree" data-eb-mm-foldertree> <div class="eb-mm-tree" data-eb-mm-tree> <?php foreach ($places as $place) { ?> <?php if (!EBMM::isMoveablePlace($place->id)) { continue; } ?> <div class="eb-mm-tree-item" data-eb-mm-tree-item data-key="<?php echo $place->key; ?> "> <span> <i class="fa fa-folder"></i> <i class="fa fa-circle-o-notch fa-spin"></i> <span><?php echo $place->title; ?> </span>
/** * Relocate media files into "My Media" * * @since 5.0 * @access public * @param string * @return */ public function relocateMediaFiles() { require_once JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/mediamanager/mediamanager.php'; // Get a list of folders for this post $uri = 'post:' . $this->id; // Get the absolute path to the post's folder $path = EBMM::getPath($uri); // Check if it exists. jimport('joomla.filesystem.folder'); // If it doesn't exist, we wouldn't want to do anything if (!JFolder::exists($path)) { return true; } // Construct the new uri $newUri = 'user:'******'/' . $title; // Move the old folder to the new folder now $state = JFolder::move($path, $newPath); return $state; }
public function uploadImage($key) { // Load up media manager $mm = EB::mediamanager(); // Get the target folder $placeId = EBMM::getUri($key); // Get the file input $file = JRequest::getVar('file', '', 'FILES', 'array'); // Check if the file is really allowed to be uploaded to the site. $state = EB::image()->canUploadFile($file); if ($state instanceof Exception) { //add error code return $state; //return $this->output($state); } // MM should check if the user really has access to upload to the target folder $allowed = EBMM::hasAccess($placeId); if ($allowed instanceof Exception) { //add error code return $state; //return $this->output($allowed); } // Check the image name is it got contain space, if yes need to replace to '-' $fileName = $file['name']; $file['name'] = str_replace(' ', '-', $fileName); // Upload the file now $file = $mm->upload($file, $placeId); // Response object is intended to also include // other properties like status message and status code. // Right now it only inclues the media item. $response = new stdClass(); $response->media = EBMM::getMedia($file->uri); //code for future use //header('Content-type: text/x-json; UTF-8'); //$resp = json_encode($response, JSON_HEX_TAG); return $response; }
/** * Returns information about a photo in an album * * @since 5.0 * @access public * @param string * @return */ public function getItem($uri) { if (!$this->exists()) { return false; } if ($this->isAlbum($uri)) { return $this->getItems($uri); } // Get the photo id $id = (int) EBMM::getFilename($uri); $photo = JTable::getInstance('Photo', 'CTable'); $photo->load($id); // Get the filesize $size = @filesize(JPATH_ROOT . '/' . $photo->original); $album = JTable::getInstance('Album', 'CTable'); $album->load($photo->albumid); $item = EBMM::file($uri, 'image'); $item->place = 'jomsocial'; $item->title = $photo->caption; $item->url = $photo->getOriginalURI(); $item->path = 'jomsocial'; $item->size = $size; $item->modified = $photo->created; $item->thumbnail = $photo->getThumbURI(); $item->preview = $photo->getThumbURI(); $item->size = 0; $item->variations = $this->getVariations($photo, $album); return $item; }
/** * Creates a new variation on the site * * @since 5.0 * @access public * @param string * @return */ public function createVariation() { $name = $this->input->getCmd('name'); $key = $this->input->getRaw('key'); // Convert the key into uri $uri = EBMM::getUri($key); // Get the width and height $width = $this->input->get('width'); $height = $this->input->get('height'); $params = new stdClass(); $params->width = $width; $params->height = $height; $media = EB::mediamanager(); $item = $media->createVariation($uri, $name, $params); if ($item instanceof EasyBlogException) { return $this->ajax->reject($state); } // Response object is intended to also include // other properties like status message and status code. // Right now it only inclues the media item. $info = EBMM::getMedia($uri); return $this->ajax->resolve($info); }
/** * Given a raw format of a flickr object and convert it into a media manager object. * * @since 5.0 * @access public * @param string * @return */ public function decorate(&$item, $uri) { $obj = new stdClass(); $obj->uri = $uri; $obj->place = 'flickr'; $obj->title = $item->title; // Url should be the original source $obj->url = $item->sizes['Original']->source; $obj->key = EBMM::getKey('flickr/' . $item->id); $obj->type = 'image'; $obj->icon = EBMM::getIcon('image'); $obj->modified = $item->dateupload; $obj->size = 0; $obj->thumbnail = $item->sizes['Thumbnail']->source; $obj->preview = $item->sizes['Medium']->source; $obj->variations = array(); foreach ($item->sizes as $size) { $key = 'system/' . strtolower($size->title); // Create variation $variation = new stdClass(); $variation->key = $key; $variation->name = $size->title; $variation->type = 'system'; $variation->url = $size->source; $variation->width = $size->width; $variation->height = $size->height; $variation->size = 0; $obj->variations[$key] = $variation; } return $obj; }