/** * List down files and folders from a given path. * * @access public * @param null * */ public function listItems() { $ajax = EasyBlogHelper::getHelper('Ajax'); // force loading frontend language file. JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT); // This let's us know the type of folder we should lookup to $place = JRequest::getString('place'); if ($place == 'jomsocial') { return $this->listJomSocialItems(); } if ($place == 'easysocial') { return $this->listEasySocialItems(); } if ($place == 'flickr') { return $this->listFlickrItems(); } // The source of the original image $source = JRequest::getVar('path'); if ($source == DIRECTORY_SEPARATOR) { $source = ''; } // Let's us know if we need to get the image variation. $variation = JRequest::getVar('variation') == '1' ? true : false; // Detect if there's any filter $filters = JRequest::getVar('filters', ''); // @task: Create the media object. $media = new EasyBlogMediaManager(); // @task: Let's find the exact path first as there could be 2 possibilities here. // 1. Shared folder // 2. User folder $absolutePath = EasyBlogMediaManager::getAbsolutePath($source, $place); $absoluteURI = EasyBlogMediaManager::getAbsoluteURI($source, $place); // @task: Let's test if the source item really exist. if (!$media->exists($absolutePath) || !$absolutePath) { return $ajax->fail(JText::_('COM_EASYBLOG_FILE_OR_FOLDER_DOES_NOT_EXIST')); } $withFileSize = $variation ? true : false; $items = $media->getItem($absolutePath, $absoluteURI, $source, $variation, $place, false, false, $withFileSize)->toArray(); require_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php'; $json = new Services_JSON(); // Get a list of paginated items here. $paginatedItems = $media->getItem($absolutePath, $absoluteURI, $source, $variation, $place, false, true, $withFileSize)->toArray(); $table = EasyBlogHelper::getTable('MediaManager'); $table->load($absolutePath, 'files'); $table->set('path', $absolutePath); $table->set('type', 'files'); $table->set('params', $json->encode($paginatedItems)); $table->store(); return $ajax->success($items); }