Ejemplo n.º 1
0
 /**
  * Display browse table of file versions with extended filter.
  *
  * @param string $tpl used template
  */
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JAdministrator */
     $modelFile = $this->getModel();
     /* @var $modelFile JoomDOCModelFile */
     $this->filter = new JObject();
     $this->filter->path = JoomDOCRequest::getPath();
     $this->item = new JoomDOCFile(JoomDOCFileSystem::getFullPath($this->filter->path));
     $sessionPrefix = JoomDOCRequest::getSessionPrefix(true);
     $this->filter->offset = $mainframe->getUserStateFromRequest($sessionPrefix . 'offset', 'limitstart', 0, 'int');
     //var_dump($sessionPrefix);
     $this->filter->limit = $mainframe->getUserStateFromRequest($sessionPrefix . 'limit', 'limit', 10, 'int');
     //var_dump($this->filter->limit);
     $this->filter->listOrder = $mainframe->getUserStateFromRequest($sessionPrefix . 'listOrder', 'filter_order', 'version', 'string');
     //var_dump($this->filter->listOrder);
     $this->filter->listDirn = $mainframe->getUserStateFromRequest($sessionPrefix . 'listDirn', 'filter_order_Dir', 'asc', 'string');
     //var_dump($this->filter->listDirn);
     $this->filter->uploader = $mainframe->getUserStateFromRequest($sessionPrefix . 'uploader', 'uploader', '', 'string');
     //var_dump($this->filter->uploader);
     $this->filter->state = $mainframe->getUserStateFromRequest($sessionPrefix . 'state', 'state', 0, 'int');
     //var_dump($this->filter->state);
     $this->data = $modelFile->getData($this->filter);
     $this->document = $modelFile->getDocument($this->filter);
     $this->item->document = $this->document;
     $this->maxVersion = $modelFile->getMaxVersion($this->filter->path);
     $this->access = new JoomDOCAccessHelper($this->item);
     if (!JoomDOCAccessFileSystem::viewFileInfo($this->document ? $this->document->id : null, $this->filter->path)) {
         JError::raiseError(403, JText::sprintf('JOOMDOC_VIEW_FILE_INFO_NOT_ALLOW'));
     }
     $this->addToolbar();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 /**
  * Get Prefix for Variables stored in Joomla session storage (database, file, APC etc.).
  * Prefix is unique for concrete component and view.
  * For example: com_joomdoc_documents_
  *
  * @param boolean $usePath add into session Prefix Variable Path
  * @return string
  */
 public static function getSessionPrefix($usePath = false)
 {
     $pieces = array(JRequest::getString('option'), JRequest::getString('view'), JRequest::getString('layout'));
     if ($usePath) {
         $pieces[] = JoomDOCRequest::getPath();
     }
     return implode('.', array_filter($pieces, 'JString::trim')) . '.';
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 /**
  * Create new subfolder in current parent folder.
  *
  * @return void
  */
 public function newFolder()
 {
     $app = JFactory::getApplication();
     $success = JoomDOCFileSystem::newFolder();
     if ($success && JRequest::getInt('doccreate')) {
         $this->setRedirect(JoomDOCRoute::addDocument($app->getUserState('com_joomdoc.new.folder')));
     } else {
         $this->setRedirect(JoomDOCRoute::viewDocuments(JoomDOCRequest::getPath(), false));
     }
 }
Ejemplo n.º 5
0
 /**
  * Allow save document.
  */
 protected function allowSave($data, $key = 'id')
 {
     $document = $this->getModel()->getItem(JRequest::getInt('id'));
     // can create new document
     if (!$document->id && JoomDOCAccessDocument::create(JoomDOCRequest::getPath())) {
         return true;
     }
     // can edit exists document
     if ($document->id && JoomDOCAccessDocument::canEdit($document)) {
         return true;
     }
     return false;
 }
Ejemplo n.º 6
0
 function webdav()
 {
     /* webdav list URL */
     // session id
     $session = JRequest::getString('s');
     // parent folder path
     $path = JoomDOCRequest::getPath();
     if (!$session) {
         /* webdav edit url */
         // file path
         $file = JRequest::getString('file');
         // file path segments
         $segments = explode('/', $file);
         // cleanup
         $segments = array_map('JString::trim', $segments);
         $segments = array_filter($segments);
         // reindexing
         $segments = array_merge($segments);
         // session id is first file path segment
         $session = $segments[0];
         // remove session id
         unset($segments[0]);
         // file path in JoomDOC standard
         $path = implode(DIRECTORY_SEPARATOR, $segments);
         //$model = JModelLegacy::getInstance(JOOMDOC_FILE, JOOMDOC_MODEL_PREFIX);
         /* @var $model JoomDOCSiteModelFile */
         //$path = $model->getPathById($path); // since 4.0.3 is path as ID
         //$segments = explode(DIRECTORY_SEPARATOR, $path);
         // file path in webdav framework usage (with slash on the begin)
         $file = '/' . implode('/', $segments);
         // set file param in get for webdav framework
         JRequest::setVar('path', $file, 'get');
     }
     $webDavUser = JFactory::getUser(JoomDOCUser::getUserIdBySessionId($session));
     if (JoomDOCAccessFileSystem::editWebDav(null, JoomDOCFileSystem::clean($path), $session)) {
         if (!JRequest::getVar('path')) {
             JRequest::setVar('path', '/');
         }
         require_once JOOMDOC_WEBDAV . DIRECTORY_SEPARATOR . 'index.php';
     } else {
         die('{"error":"","files":""}');
     }
 }
Ejemplo n.º 7
0
 /**
  * Display page with folder content.
  *
  * @param $tpl used template
  * @return void
  */
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JSite */
     $document = JFactory::getDocument();
     /* @var $documents JDocumentHTML */
     $config = JoomDOCConfig::getInstance();
     /* @var $config JoomDOCConfig */
     $modelDocument = JModelLegacy::getInstance(JOOMDOC_DOCUMENT, JOOMDOC_MODEL_PREFIX);
     /* @var $modelDocument JoomDOCModelDocument */
     $modelDocuments = JModelLegacy::getInstance(JOOMDOC_DOCUMENTS, JOOMDOC_MODEL_SITE_PREFIX);
     /* @var $modelDocuments JoomDOCSiteModelDocuments */
     $modelFile = JModelLegacy::getInstance(JOOMDOC_FILE, JOOMDOC_MODEL_PREFIX);
     /* @var $modelFile JoomDOCModelFile */
     $this->filter = $this->getLayout() == 'modal' ? $mainframe->getUserStateFromRequest(JoomDOCRequest::getSessionPrefix() . 'filter', 'filter', '', 'string') : '';
     $path = JoomDOCRequest::getPath();
     // convert to absolute path, if path si empty use document root path
     $path = $path ? JoomDOCFileSystem::getFullPath($path) : $config->path;
     // request path value isn't subfolder of document root
     if (!JoomDOCFileSystem::isSubFolder($path, $config->path)) {
         JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR ' . $path . ' ' . $config->path));
     }
     $this->searchablefields = $this->get('searchablefields');
     $this->publishedfields = $this->get('publishedfields');
     foreach ($this->searchablefields as $field) {
         $field->name = 'joomdoc_field' . $field->id;
     }
     if ($config->useSearch || $this->getLayout() == 'modal') {
         $this->search = new JObject();
         // load setting from request or Joomla session storage (server session, database, apc etc.)
         $this->search->search = $this->getSearchParam('joomdoc_search', 0, 'int');
         if ($config->searchKeyword == 1) {
             $this->search->keywords = $this->getSearchParam('joomdoc_keywords', $this->filter, 'string');
         } elseif ($config->searchKeyword == 2) {
             // separate keywords for each area
             $this->search->keywords_title = $this->getSearchParam('joomdoc_keywords_title', $this->filter, 'string');
             $this->search->keywords_text = $this->getSearchParam('joomdoc_keywords_text', $this->filter, 'string');
             $this->search->keywords_meta = $this->getSearchParam('joomdoc_keywords_meta', $this->filter, 'string');
             $this->search->keywords_full = $this->getSearchParam('joomdoc_keywords_full', $this->filter, 'string');
             foreach ($this->searchablefields as $field) {
                 if ($field->type == JOOMDOC_FIELD_TEXT || $field->type == JOOMDOC_FIELD_TEXTAREA || $field->type == JOOMDOC_FIELD_EDITOR) {
                     $this->search->set('keywords_field' . $field->id, $this->getSearchParam('joomdoc_keywords_field' . $field->id, $this->filter, 'string'));
                 }
             }
         }
         // selected parent (folder)
         $this->search->parent = $config->searchShowParent ? $this->getSearchParam('path', '', 'string') : '';
         // path to load items list, if not select parent use document root
         $this->search->path = JoomDOCFileSystem::getFullPath($this->search->parent);
         // search areas (document title or file path), text and metadata, file content
         $this->search->areaTitle = $config->searchShowTitle ? $this->getSearchParam('joomdoc_area_title', 1, 'int', true, 'joomdoc_search') : 0;
         $this->search->areaText = $config->searchShowText ? $this->getSearchParam('joomdoc_area_text', 1, 'int', true, 'joomdoc_search') : 0;
         $this->search->areaMeta = $config->searchShowMetadata ? $this->getSearchParam('joomdoc_area_meta', 1, 'int', true, 'joomdoc_search') : 0;
         $this->search->areaFull = $config->searchShowFulltext ? $this->getSearchParam('joomdoc_area_full', 1, 'int', true, 'joomdoc_search') : 0;
         // searching type (any/all word, complet phrase, regular expresion
         $this->search->type = $this->getSearchParam('joomdoc_type', $config->searchDefaultType, 'int');
         // ordering
         $this->search->ordering = $this->getSearchParam('joomdoc_ordering', $config->searchDefaultOrder, 'string');
         foreach ($this->searchablefields as $field) {
             if ($field->type == JOOMDOC_FIELD_TEXT) {
                 $this->search->fields[$field->id] = array('type' => $field->type, 'value' => $this->getSearchParam($field->name, 1, 'int', true, 'joomdoc_search'));
             } elseif ($field->type == JOOMDOC_FIELD_CHECKBOX || $field->type == JOOMDOC_FIELD_MULTI_SELECT || $field->type == JOOMDOC_FIELD_SUGGEST) {
                 $this->search->fields[$field->id] = array('type' => $field->type, 'value' => $this->getSearchParam($field->name, array(), 'array'));
             } else {
                 $this->search->fields[$field->id] = array('type' => $field->type, 'value' => $this->getSearchParam($field->name, '', 'string'));
             }
         }
         // set ordering from search setting
         switch ($this->search->ordering) {
             case JOOMDOC_ORDER_NEWEST:
                 /* Newest items */
                 // files order upload date and documents order publish up date descending
                 $documentOrdering = JOOMDOC_ORDER_PUBLISH_UP;
                 $fileOrdering = JOOMDOC_ORDER_UPLOAD;
                 $orderingDirection = JOOMDOC_ORDER_DESC;
                 break;
             case JOOMDOC_ORDER_OLDEST:
                 /* Oldest items */
                 // files order upload date and documents order publish up date ascending
                 $documentOrdering = JOOMDOC_ORDER_PUBLISH_UP;
                 $fileOrdering = JOOMDOC_ORDER_UPLOAD;
                 $orderingDirection = JOOMDOC_ORDER_ASC;
                 break;
             case JOOMDOC_ORDER_HITS:
                 /* Most popular (downloaded) */
                 // files order hits descending
                 $documentOrdering = null;
                 $fileOrdering = JOOMDOC_ORDER_HITS;
                 $orderingDirection = JOOMDOC_ORDER_DESC;
                 break;
             case JOOMDOC_ORDER_TITLE:
                 /* Alphabetical */
                 // files order path and documents order title ascending
                 $documentOrdering = JOOMDOC_ORDER_TITLE;
                 $fileOrdering = JOOMDOC_ORDER_PATH;
                 $orderingDirection = JOOMDOC_ORDER_ASC;
                 break;
         }
     }
     $searchActive = $config->useSearch && $this->search->search;
     if (!$searchActive) {
         // if search isnt't set use ordering from configuration
         $documentOrdering = $config->documentOrdering;
         $fileOrdering = $config->fileOrdering;
         $orderingDirection = $config->orderingDirection;
     }
     // get content of selected folder
     $this->root = JoomDOCFileSystem::getFolderContent($path, '', $searchActive);
     if (JoomDOCFileSystem::isFolder($this->root)) {
         // selected path is folder
         $modelDocuments->setState(JoomDOCView::getStateName(JOOMDOC_FILTER_PATHS), $this->root->getPaths(false));
         // get child documents
         $modelDocuments->setState(JoomDOCView::getStateName(JOOMDOC_FILTER_SEARCH), $config->useSearch || $this->getLayout() == 'modal' ? $this->search : null);
         $this->documents = $modelDocuments->getItems($searchActive);
         $this->listfields = $modelDocuments->getListFields();
         $this->state = $modelDocuments->getState();
         // add documents to given subfolders and files
         $this->root->setDocuments($this->documents);
         $this->access = new JoomDOCAccessHelper($this->root);
         // control permissions to access folder
         if (!$this->access->canEnterFolder) {
             JError::raiseError(403, JText::_('JOOMDOC_UNABLE_ACCESS_FOLDER'));
         }
         $this->pagination = new JPagination($modelDocuments->getTotal($searchActive), $mainframe->getUserStateFromRequest('com_joomdoc.documents.limitstart', 'limitstart', 0, 'int'), $mainframe->getUserStateFromRequest('com_joomdoc.documents.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'));
         // reorder
         $this->root->reorder($documentOrdering, $fileOrdering, $orderingDirection, $this->pagination->limitstart, $this->pagination->limit, $this->pagination->total, $config->foldersFirstSite);
         // set root parent
         $this->root->parent = $modelDocument->getParent(JoomDOCFileSystem::getParentPath($this->root->getRelativePath()));
         $this->root->document = $modelDocument->getItemByPath($this->root->getRelativePath());
     } elseif (JoomDOCFileSystem::isFile($this->root)) {
         // use different layout
         $this->setLayout('file');
         // search document by path
         $this->root->document = $modelDocument->getItemByPath($this->root->getRelativePath());
         $this->publishedfields = $modelDocument->getPublishedFields();
         $this->access = new JoomDOCAccessHelper($this->root);
         // document unpublished
         $this->root->parent = $modelDocument->getParent(JoomDOCFileSystem::getParentPath($this->root->getRelativePath()));
     } else {
         JError::raiseError(404, JText::_('JERROR_LAYOUT_PAGE_NOT_FOUND'));
     }
     // control root access
     if ($this->access->docid) {
         // item with document
         if (!$this->access->canAnyEditOp && $this->root->document->published == JOOMDOC_STATE_UNPUBLISHED) {
             // root unpublished and user hasn't admin rights
             JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
         }
         if ($this->root->document->state == JOOMDOC_STATE_TRASHED) {
             // root trashed
             JError::raiseError(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     } elseif (isset($this->root->document->file_state)) {
         // item without document but with file
         if ($this->root->document->file_state == JOOMDOC_STATE_TRASHED) {
             // file is trashed
             JError::raiseError(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     } elseif (!$this->access->inRoot && !$searchActive && $this->getLayout() != 'modal') {
         // item without file can be total root but it's not root
         JError::raiseError(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // take a configuration of an active menu item
     $active = $mainframe->getMenu()->getActive();
     $this->pageHeading = $this->pageclassSfx = '';
     if ($active) {
         if ($active->params->get('show_page_heading')) {
             $this->pageHeading = JString::trim($active->params->get('page_heading'));
             if (!$this->pageHeading) {
                 $this->pageHeading = JString::trim($active->params->get('page_title'));
             }
         }
         $this->pageclassSfx = JString::trim($active->params->get('pageclass_sfx'));
         $titles[] = JString::trim($active->params->get('page_title'));
         $metakeywords[] = JString::trim($active->params->get('menu-meta_keywords'));
         $metadescriptions[] = JString::trim($active->params->get('menu-meta_description'));
     }
     // take candidates for metadata sort on priority
     if ($this->access->docid and $this->root->document->published == JOOMDOC_STATE_PUBLISHED) {
         //use document only if published. (but for owner is published always).
         // from document data
         $params = new JRegistry($this->root->document->params);
         $titles[] = JString::trim($this->root->document->title);
         $metakeywords[] = JString::trim($params->get('metakeywords'));
         $metadescriptions[] = JString::trim($params->get('metadescription'));
         $metadescriptions[] = JoomDOCHelper::getMetaDescriptions($this->root->document->description);
     }
     // default candidates
     $titles[] = $this->access->name;
     $titles[] = $config->defaultTitle;
     $metakeywords[] = $config->defaultMetakeywords;
     $metadescriptions[] = $config->defaultMetadescription;
     // set meta data from candidates acording to priority
     // set meta keywords
     $document->setMetaData('keywords', JoomDOCHelper::getFirstNoEmpty($metakeywords));
     // set page title
     $document->setTitle(JoomDOCHelper::getCompletTitle(JoomDOCHelper::getFirstNoEmpty($titles)));
     // set head meta description
     $document->setDescription(JoomDOCHelper::getFirstNoEmpty($metadescriptions));
     $modelDocuments->setPathway($this->root->getRelativePath());
     if ($this->access->canCopyMove) {
         JoomDOCHelper::clipboardInfo();
     }
     parent::display($tpl);
 }
Ejemplo n.º 8
0
 /**
  * Revert selected Version as last Version.
  *
  * @return void
  */
 public function revert()
 {
     $path = JoomDOCRequest::getPath();
     $result = false;
     if (JoomDOCAccessFileSystem::manageVersions(false, $path)) {
         JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
         $cid = JRequest::getVar('cid', array(), 'default', 'array');
         $id = reset($cid);
         $model = $this->getModel();
         $result = $model->revert($id, $path);
     }
     $msg = $result ? JText::sprintf('JOOMDOC_REVERT_SUCCESS', $result->revertVersion, $result->newLastVersion, $result->oldLastVersion) : JText::_('JOOMDOC_REVERT_UNSUCCESS');
     $type = $result ? 'message' : 'error';
     $this->setRedirect(JoomDOCRoute::viewFileInfo($path), $msg, $type);
 }
Ejemplo n.º 9
0
    /**
     * Folders navigator with MooTree.
     * 
     * @param array $folders data in this format: JObject('ident' => 'relative path', 'route' => 'URL to open folder', 'title' => 'Folder name', 'entry' => 'Is accessible')
     * @param string $parent root folder 
     * @param bool $expandable if tree is hide-able (only for J2.5 admin layout)
     * @param bool $ajax generate one tree list only
     * @return string source of tree
     */
    public static function mooTree($folders = null, $parent = '', $expandable = false, $ajax = false)
    {
        $config = JoomDOCConfig::getInstance();
        $document = JFactory::getDocument();
        $mainframe = JFactory::getApplication();
        $document->addScript(JURI::root(true) . '/media/system/js/mootree' . (JDEBUG ? '-uncompressed' : '') . '.js');
        $document->addStyleSheet(JURI::root(true) . '/media/system/css/mootree.css');
        $path = JoomDOCRequest::getPath();
        $code = '';
        if (!$ajax) {
            $code .= '<div id="MooTree" style="position: relative; overflow: visible;"></div>';
            // here MooTree will draw tree
            $code .= '<ul id="MooTreeSrc">';
            // start of source of tree
        }
        if (is_null($folders)) {
            $folders = JoomDOCFileSystem::getNonTrashedParents($parent, 1, $ajax ? null : $path);
            if (empty($folders)) {
                return '';
            }
            // nothing to do
            foreach ($folders as $i => $item) {
                $folder = new JObject();
                $folder->set('ident', $item);
                $folder->set('route', JoomDOCRoute::viewDocuments($item));
                $folder->set('title', basename($item));
                $folder->set('entry', JoomDOCAccessFileSystem::enterFolder(false, $item));
                $folders[$i] = $folder;
            }
        }
        foreach ($folders as $i => $folder) {
            // all folders into deep
            $currentLevel = count(explode(DIRECTORY_SEPARATOR, $folder->get('ident')));
            // level of folder deep (folders in doc root have 1)
            if (!empty($lastLevel)) {
                // not for root folder
                if ($currentLevel > $lastLevel) {
                    $code .= '<ul>';
                } elseif ($currentLevel < $lastLevel) {
                    $code .= str_repeat('</li></ul>', $lastLevel - $currentLevel) . '</li>';
                    // end of subfolder, close previous subfolders
                } else {
                    $code .= '</li>';
                }
                // at the same level as previous
            }
            if ($folder->get('entry')) {
                $code .= '<li id="' . str_replace(DIRECTORY_SEPARATOR, '-', $folder->get('ident')) . '"' . ($folder->get('ident') == $path ? ' class="selected"' : '') . '>
						<a href="' . JRoute::_($folder->get('route')) . '" target="folderframe" name="' . $folder->get('ident') . '">' . $folder->get('title') . '</a>';
            }
            // current item, tag leave open to append subfolder
            $lastLevel = $currentLevel;
        }
        if (empty($lastLevel)) {
            $lastLevel = 0;
        }
        $code .= str_repeat('</li></ul>', $lastLevel);
        // end of source tree
        if ($ajax) {
            ob_clean();
            die($code);
        }
        // start MooTree after completely loading page
        $js = "\n\t\t\twindow.addEvent('domready', function() {\n\t\t\t\tvar tree = new MooTreeControl(\n\t\t\t\t{\n\t\t\t\t\tdiv: 'MooTree', \n\t\t\t\t\tmode: 'folders', \n\t\t\t\t\tgrid: true, \n\t\t\t\t\ttheme: '" . htmlspecialchars(JURI::root(true), ENT_QUOTES) . "/media/system/images/mootree.gif', \n\t\t\t\t\tloader: { // set up Ajax loader\n\t\t\t\t\t\ticon: null, \n\t\t\t\t\t\ttext: '" . JText::_('JOOMDOC_LOADING', true) . "', \n\t\t\t\t\t\tcolor:'#FF0000'\n    \t\t\t\t},\n\t\t\t\t\tonClick: function(node) { // event after click on folder\n\t\t\t\t\t\twindow.location = node.data.url; \n\t\t\t\t\t},\n\t\t\t\t\tonExpand: function(node, state) { // event after expand tree node\n\t\t\t\t\t\tif (state && treeLoading < 0) { // opening\n\t\t\t\t\t\t\tnode.loading = true;\n\t\t\t\t\t\t\tnode.clear(); // clear the node to append loader\n\t\t\t\t\t\t\tnode.insert(node.control.loader); // insert loader into the node\n\t\t\t\t\t\t\tnew Request({\n\t\t\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t\t\t\turl: '" . JRoute::_(JoomDOCRoute::updatemootree(), false) . "',\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\tpath: node.data.name\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tonSuccess: function(html, xml) {\n\t\t\t\t\t\t\t\t\tnode.clear(); // clear loader from the node\n\t\t\t\t\t\t\t\t\tnode.loading = false;\n\t\t\t\t\t\t\t\t\tvar ul = new Element('ul#MooTreeSrc');\n\t\t\t\t\t\t\t\t\tul.set('html', html);\n\t\t\t\t\t\t\t\t\t\$\$('body').adopt(ul);\n\t\t\t\t\t\t\t\t\ttree.adopt('MooTreeSrc', node);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}).send();\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttreeLoading --;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttext: '" . ($parent ? $parent : $config->explorerRoot) . "', \n\t\t\t\t \topen: true, \n\t\t\t\t \tdata: {\n\t\t\t\t\t\turl: '" . JRoute::_(JoomDOCRoute::viewDocuments($mainframe->isSite() ? $parent : 'JoomDOC'), false) . "', \n\t\t\t\t\t\ttarget: 'folderframe'\n    \t\t\t\t}\n    \t\t\t}\n\t\t\t);\n\t\t\ttree.adopt('MooTreeSrc'); // load source in ul structure\n\t\t\ttree.selected = tree.get('node_" . htmlspecialchars(str_replace(DIRECTORY_SEPARATOR, '-', $path), ENT_QUOTES) . "');\n\t\t";
        //make current folder highlighted
        if ($path) {
            $toSelect = JoomDOCFileSystem::getFullPath($path);
            if (JFile::exists($toSelect)) {
                $toSelect = JoomDOCFileSystem::getParentPath($toSelect);
            }
            // select parent folder if file is selected
            $toSelect = JoomDOCFileSystem::getRelativePath($toSelect);
            $js .= "\n\t\t\t\ttree.get('node_" . htmlspecialchars(str_replace(DIRECTORY_SEPARATOR, '-', $toSelect), ENT_QUOTES) . "').selected = true;\n\t\t\t";
        }
        // open actual folder path
        $breadCrumbs = JoomDOCFileSystem::getPathBreadCrumbs($path);
        foreach ($breadCrumbs as $i => $breadCrumb) {
            if ($i) {
                $js .= "\n\t\t\t\t\tvar node = tree.get('node_" . htmlspecialchars(str_replace(DIRECTORY_SEPARATOR, '-', $breadCrumb->path), ENT_QUOTES) . "');\n\t\t\t\t\tif (node) node.toggle(false, true);\n\t\t\t\t";
            }
        }
        $js .= '});
			var treeLoading = ' . (count($breadCrumbs) - 2) . ';';
        //tree expandable - only in admin view and J2.5. In joomla 3.0, tree is fixed part of sidebar
        if ($expandable) {
            $js .= "window.addEvent('domready', function() {\n\n                \t\t\t//add show/hide button to pathway\n                \t\t\tels = Elements.from('<span class=\"hideMooTree\">" . JText::_('JOOMDOC_SHOW_HIDE_TREE') . "</span>');\n                \t\t\tels.inject(\$('pathway'), 'bottom');\n\n                \t\t\t//add own wrapper for fx.Slide, so we can set float and wifth by css\n                \t\t\tmyWrapper = new Element('div', {id: 'MooTreeWrap'}).wraps(\$('MooTree'), 'top');\n                \t\t\n                \t\t\t//create fx.Slide instance and store it inside element 'storage' (MooTools)\n                \t\t\t\$('MooTree').store('slide', new Fx.Slide(\$('MooTree'), {\n                \t\t\t\tmode: 'horizontal', \n                \t\t\t\tduration: 1000, \n                \t\t\t\ttransition: Fx.Transitions.Pow.easeOut, \n                \t\t\t\tresetHeight: true, \n    \t\t\t\t\t\t\twrapper: myWrapper}).show());\n\n                \t\t\t//hide MooTree, if stored so in HTML5 localstorage\n                \t\t\tif (window.localStorage && localStorage.getItem('hidden')=='true')\n\t\t\t\t\t\t\t\t\$('MooTree').retrieve('slide').hide();\n\n                \t\t\t//add event to remember opened/closed state in localStorage\n                            els.addEvent('click', function() {\n\t\n                \t\t\t\tif (\$('MooTree').retrieve('slide').open){ \n                \t\t\t\t\t\$('MooTree').retrieve('slide').slideOut();\n                \t\t\t\t\tlocalStorage.setItem('hidden', 'true'); } \n                \t\t\t\telse {\n                \t\t\t\t\t\$('MooTree').retrieve('slide').slideIn();\n                \t\t\t\t\tlocalStorage.setItem('hidden', 'false');}\n\n                            });\n                \t\t\t\t\t\n                        });";
        }
        $document->addScriptDeclaration($js);
        return $code;
    }
Ejemplo n.º 10
0
 public static function copyMove($move = false)
 {
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     $tableFile = JTable::getInstance(JOOMDOC_FILE, JOOMDOC_TABLE_PREFIX);
     /* @var $tableFile JoomDOCTableFile */
     // current folder copy into
     $folder = JoomDOCRequest::getPath();
     $folderAbsolutePath = JoomDOCFileSystem::getFullPath($folder);
     // current folder acces
     $folderCanCreateSubfolders = JoomDOCAccessFileSystem::newFolder(false, $folder);
     $folderCanUploadFiles = JoomDOCAccessFileSystem::uploadFile(false, $folder);
     // items to copy
     $paths = JoomDOCFileSystem::getOperationPaths();
     foreach ($paths as $path) {
         $absolutePath = JoomDOCFileSystem::getFullPath($path);
         $parent = JoomDOCFileSystem::getParentPath($absolutePath);
         $parentLength = JString::strlen($parent);
         $items = array($absolutePath);
         if (JFolder::exists($absolutePath)) {
             if (!$folderCanCreateSubfolders) {
                 // copied/moved item is folder and current folder aren't allowed to create subfolders
                 $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE_SUBFOLDERS', $folder, $path), 'notice');
                 continue;
             }
             // unable copy/move folder into own subfolder
             if (JoomDOCFileSystem::isSubFolder($folderAbsolutePath, $absolutePath)) {
                 $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE_INTO_SELF', $folder, $path), 'notice');
                 continue;
             }
             $items = array_merge($items, JFolder::folders($absolutePath, '', true, true, array('.svn', 'CVS', '.DS_Store', '__MACOSX', JOOMDOC_VERSION_DIR)));
             $items = array_merge($items, JFolder::files($absolutePath, '', true, true));
         } elseif (!JFile::exists($absolutePath)) {
             continue;
         }
         foreach ($items as $item) {
             $itemRelativePath = JoomDOCFileSystem::getRelativePath($item);
             if (!JoomDOCAccessFileSystem::copyMove(false, $itemRelativePath)) {
                 $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE', $itemRelativePath), 'notice');
                 continue;
             }
             // get relative path from copied path parent
             $relativePath = JString::substr($item, $parentLength);
             // destination is current folder + relative path
             $destination = $folderAbsolutePath . $relativePath;
             $destinationRelativePath = JoomDOCFileSystem::getRelativePath($destination);
             if (JFolder::exists($item)) {
                 // is folder only create
                 if (JFolder::exists($destination)) {
                     $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_FOLDER_EXISTS', $destinationRelativePath), 'notice');
                     continue;
                 }
                 JFolder::create($destination);
             }
             if (JFile::exists($item)) {
                 if (!$folderCanUploadFiles) {
                     // copied/moved item is file or contain files and current folder aren't allowed to upload files
                     $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE_UPLOAD', $itemRelativePath, $folder), 'notice');
                     continue;
                 }
                 if (JFile::exists($destination)) {
                     $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_FILE_EXISTS', $destinationRelativePath), 'notice');
                     continue;
                 }
                 JFile::copy($item, $destination);
                 // get file versions
             }
             // copy/move table rows
             $tableFile->copyMove($itemRelativePath, $destinationRelativePath, $move);
         }
         if ($move) {
             // move item delete source after copy
             JoomDOCFileSystem::deleteItem($absolutePath);
         }
     }
     JoomDOCFileSystem::resetOperation();
 }
Ejemplo n.º 11
0
 /**
  * Reset operation from clipboard.
  */
 public function reset()
 {
     JoomDOCFileSystem::resetOperation();
     $this->setRedirect(JoomDOCRoute::viewDocuments(JoomDOCRequest::getPath(), false));
 }
Ejemplo n.º 12
0
JModelLegacy::addIncludePath(JOOMDOC_SITE_MODELS);
JTable::addIncludePath(JOOMDOC_TABLES);
$document = JFactory::getDocument();
/* @var $document JDocument */
$document->addStyleSheet(JOOMDOC_ASSETS . 'css/general.css?' . JOOMDOC_VERSION_ALIAS);
// Module and JoomDOC comfiguration.
$moduleConfig = JoomDOCModuleExplorerConfig::getInstance($params, $module->id);
$globalConfig = JoomDOCConfig::getInstance();
$modelDocuments = JModelLegacy::getInstance(JOOMDOC_DOCUMENTS, JOOMDOC_MODEL_SITE_PREFIX);
/* @var $modelDocuments JoomDOCSiteModelDocuments */
// Only folders are loaded.
$parent = $moduleConfig->parent ? JoomDOCFileSystem::getFullPath($moduleConfig->parent) : $globalConfig->docroot;
if (!JFolder::exists($parent)) {
    // invalid or expired module config
    $parent = '';
}
// reset to root
$path = JoomDOCRequest::getPath();
// on file detail get parent folder path
if (JFile::exists(JoomDOCFileSystem::getFullPath($path)) && JFolder::exists(JoomDOCFileSystem::getFullPath(JoomDOCFileSystem::getParentPath($path)))) {
    $path = JoomDOCFileSystem::getParentPath($path);
}
$root = JoomDOCFileSystem::getFolderContent($parent, '', 1, true, false, $path);
// Model searchs in database for founded paths.
$modelDocuments->setState(JoomDOCView::getStateName(JOOMDOC_FILTER_PATHS), $root->getPaths());
// Filesystem extends items informations from documents.
$root->setDocuments($modelDocuments->getItems());
// Filesystem reordes items for given setting.
$root->reorder(null, JOOMDOC_ORDER_PATH, JOOMDOC_ORDER_ASC, 0, PHP_INT_MAX);
// Active module template displayed.
require JModuleHelper::getLayoutPath('mod_joomdoc_explorer', $moduleConfig->layout);
Ejemplo n.º 13
0
<?php

/**
 * @version		$Id$
 * @package		Joomla.Administrator
 * @subpackage	JoomDOC
 * @author      ARTIO s.r.o., info@artio.net, http:://www.artio.net
 * @copyright	Copyright (C) 2011 Artio s.r.o.. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
/* @var $this JoomDOCViewLicense */
// test if property realy exist in request
$path = JRequest::getVar('path', false) !== false ? JoomDOCRequest::getPath() : null;
echo '<h1>' . $this->license->title . '</h1>';
if ($path) {
    echo '<h2>' . JText::_('JOOMDOC_MUST_CONFIRM') . '</h2>';
}
echo JoomDOCHelper::applyContentPlugins($this->license->text);
if ($path) {
    echo '<div class="confirm">';
    echo '<input type="checkbox" name="confirm" id="confirm" value="1" onclick="JoomDOC.confirmLicense(this)" />';
    echo '<label for="confirm">' . JText::_('JOOMDOC_CONFIRM') . '</label>';
    echo '<a id="download" class="blind" href="' . JRoute::_(JoomDOCRoute::download($path)) . '" title="">' . JText::_('JOOMDOC_DOWNLOAD_FILE') . '</a>';
    echo '</div>';
}