예제 #1
0
 /**
  * Display page with folder content.
  *
  * @param $tpl used template
  * @return void
  */
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JAdministrator */
     $config = JoomDOCConfig::getInstance();
     /* @var $config JoomDOCConfig */
     $model = $this->getModel();
     /* @var $model JoomDOCModelDocuments */
     $document = JFactory::getDocument();
     /* @var $document JDocumentHTML */
     if ($this->getLayout() != 'modal') {
         //$mainframe->enqueueMessage(JText::_('JOOMDOC_KEEP_FLAT'));
     }
     // relative path from request or user session
     $path = JoomDOCRequest::getPath();
     if ($path == JText::_('JOOMDOC_ROOT')) {
         $path = '';
     }
     // convert to absolute path
     $path = JoomDOCFileSystem::getFullPath($path);
     //if folder not exists (e.g. was renamed), fallback to root
     if (!JFolder::exists($path)) {
         $path = JoomDOCFileSystem::getFullPath('');
     }
     $this->filter = $mainframe->getUserStateFromRequest(JoomDOCRequest::getSessionPrefix() . 'filter', 'filter', '', 'string');
     $this->root = JoomDOCFileSystem::getFolderContent($path, '');
     // control if select folder is subfolder of docroot
     if ((!JoomDOCFileSystem::isSubFolder($path, $config->docroot) || $this->root === false) && $config->docroot !== false) {
         JError::raiseError(403, JText::_('JOOMDOC_UNABLE_ACCESS_FOLDER'));
     }
     // search filter setting
     $this->search = new JObject();
     $this->search->keywords = $this->filter;
     // search areas (search everywhere - don't use frontend detail setting)
     $this->search->areaTitle = $this->search->areaText = $this->search->areaFull = true;
     $this->search->areaMeta = false;
     // looking for any word
     $this->search->type = JOOMDOC_SEARCH_ANYKEY;
     $model->setState(JoomDOCView::getStateName(JOOMDOC_FILTER_PATHS), $this->root->getPaths());
     $model->setState(JoomDOCView::getStateName(JOOMDOC_FILTER_SEARCH), $this->search);
     $model->setState(JOOMDOC_FILTER_STATE, $mainframe->getUserStateFromRequest(JoomDOCRequest::getSessionPrefix() . 'state', 'state', JOOMDOC_STATE_PUBLISHED, 'int'));
     $this->documents = $model->getItems();
     $this->state = $model->getState();
     $this->pagination = new JPagination($model->getTotal(), $this->state->get(JOOMDOC_FILTER_START), $this->state->get(JOOMDOC_FILTER_LIMIT));
     $this->access = new JoomDOCAccessHelper($this->root);
     $this->root->setDocuments($this->documents);
     $this->root->reorder($this->state->get(JOOMDOC_FILTER_ORDERING), $this->state->get(JOOMDOC_FILTER_ORDERING), $this->state->get(JOOMDOC_FILTER_DIRECTION), $this->pagination->limitstart, $this->pagination->limit, $this->pagination->total, $config->foldersFirstAdmin);
     // control permissions to access folder
     if (!$this->access->canEnterFolder) {
         $mainframe->setUserState('joomdoc_documents_path', null);
         JError::raiseError(403, JText::_('JOOMDOC_UNABLE_ACCESS_FOLDER'));
     }
     $this->addToolbar();
     JoomDOCHelper::setSubmenu(JOOMDOC_DOCUMENTS, true);
     JoomDOCHelper::clipboardInfo();
     JoomDOCHelper::folderInfo($this->access->absolutePath);
     parent::display($tpl);
 }