Esempio n. 1
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
 */
/* @var $this JModuleHelper */
defined('_JEXEC') or die;
echo '<div id="joomdocExplorer" ' . ($moduleConfig->moduleclass_sfx ? 'class="' . htmlspecialchars($moduleConfig->moduleclass_sfx, ENT_QUOTES) . '"' : '') . '>';
$folders = JHtml::_('joomdoc.folders', $root, $parent);
echo JHtml::_('joomdoc.mootree', $folders, JoomDOCFileSystem::getRelativePath($parent));
echo '</div>';
Esempio n. 2
0
 /**
  * Create and init object. Set absolute path.
  * 
  * @param string $absolutePath file absolute path
  * @return void
  */
 public function __construct($absolutePath, $isSymLink = false)
 {
     $this->absolutePath = JPath::clean($absolutePath);
     $this->relativePath = JoomDOCFileSystem::getRelativePath($this->absolutePath);
     $this->isSymLink = $isSymLink;
     $this->name = parent::getName($this->absolutePath);
     $this->extension = parent::getExt($this->absolutePath);
     $this->size = JoomDOCFileSystem::getFileSize($this->absolutePath);
     $this->url = JoomDOCFileSystem::getURL($this->relativePath);
     $this->document = null;
     $this->hits = 0;
     $this->uploaded = filemtime($this->absolutePath);
     $this->mimetype = function_exists('mime_content_type') && is_readable($this->absolutePath) ? mime_content_type($this->absolutePath) : '';
 }
Esempio n. 3
0
 /**
  * Filter folder list for frontend (published, ACL etc)
  * 
  * @param JoomDOCFolder $root
  * @param string $parent
  * @return array
  */
 public static function folders($root, $parent)
 {
     $folders = array();
     $root->initIteration();
     $parents = array(JoomDOCFileSystem::getRelativePath($parent));
     while ($root->hasNext()) {
         $item = $root->getNext();
         $access = new JoomDOCAccessHelper($item);
         $itemParent = JoomDOCFileSystem::getParentPath($access->relativePath);
         if (!(empty($itemParent) || in_array($itemParent, $parents))) {
             // parent has to be visible
             continue;
         }
         if ($access->docid && $item->document->published == JOOMDOC_STATE_UNPUBLISHED) {
             // item has to published
             continue;
         }
         $folder = new JObject();
         // prepare data for MooTree
         $folder->set('ident', $access->relativePath);
         $folder->set('route', JoomDOCRoute::viewDocuments($access->relativePath, $access->alias));
         $folder->set('title', $access->docid ? $item->document->title : $item->getFileName());
         $folder->set('entry', $access->canEnterFolder);
         $folders[] = $folder;
         $parents[] = $access->relativePath;
         // save into visible parents
     }
     return $folders;
 }
Esempio n. 4
0
 public static function refresh($folder = null)
 {
     static $count;
     if (is_null($count)) {
         $count = 0;
     }
     if (JoomDOCAccessFileSystem::refresh()) {
         $config = JoomDOCConfig::getInstance();
         /* @var $config JoomDOCConfig */
         $model = JModelLegacy::getInstance(JOOMDOC_DOCUMENTS, JOOMDOC_MODEL_PREFIX);
         /* @var $model JoomDOCModelDocuments */
         $file = JTable::getInstance(JOOMDOC_FILE, JOOMDOC_TABLE_PREFIX);
         /* @var $file JoomDOCTableFile */
         $mainframe = JFactory::getApplication();
         /* @var $mainframe JApplication */
         if (is_null($folder)) {
             $folder = $config->docroot;
         }
         if (JFolder::exists($folder)) {
             // scandir for folders
             $folderpaths = JFolder::folders($folder, '.', false, true);
             foreach ($folderpaths as $folderpath) {
                 // for folders the same recursive
                 $foldername = JFile::getName($folderpath);
                 if ($foldername[0] != '.') {
                     // no hidden folders
                     JoomDOCFileSystem::refresh($folderpath);
                 }
             }
             // scandir for files
             $filepaths = JFolder::files($folder, '.', false, true);
             foreach ($filepaths as $i => $filepath) {
                 $filename = JFile::getName($filepath);
                 if ($filename[0] == '.') {
                     // no hidden files
                     unset($filepaths[$i]);
                 } else {
                     $filepaths[$i] = JoomDOCFileSystem::getRelativePath($filepath);
                 }
             }
             if ($folder != $config->docroot) {
                 // docroot hasn't db row
                 $filepaths[] = JoomDOCFileSystem::getRelativePath($folder);
             }
             // search exist's paths in db
             $exists = $model->searchPaths($filepaths);
             foreach ($filepaths as $filepath) {
                 if (!in_array($filepath, $exists)) {
                     // file not in db
                     $file->path = $filepath;
                     $file->store();
                     $count++;
                 }
             }
         }
     }
     return $count;
 }
Esempio n. 5
0
 /**
  * Create and init object. Set absolute path.
  *
  * @param string $abspath absolute path
  * @return void
  */
 public function __construct($absolutePath, $isSymLink = false)
 {
     $this->absolutePath = JPath::clean($absolutePath);
     $this->relativePath = JoomDOCFileSystem::getRelativePath($this->absolutePath);
     $this->isSymLink = $isSymLink;
     $this->name = JoomDOCFileSystem::getLastPathItem($this->absolutePath);
     $this->files = array();
     $this->folders = array();
     $this->filesPaths = array();
     $this->foldersPaths = array();
     $this->documentsOrderSetting = array(JOOMDOC_ORDER_TITLE, JOOMDOC_ORDER_ORDERING, JOOMDOC_ORDER_PUBLISH_UP);
     foreach ($this->documentsOrderSetting as $param) {
         $this->documentsOrderValues[$param] = array();
     }
     $this->itemsOrderSetting = array(JOOMDOC_ORDER_PATH, JOOMDOC_ORDER_UPLOAD, JOOMDOC_ORDER_HITS, JOOMDOC_ORDER_FILE_STATE);
     foreach ($this->itemsOrderSetting as $param) {
         $this->itemsOrderValues[$param] = array();
     }
     $this->complet = array();
     $this->filesIndex = 0;
     $this->foldersIndex = 0;
     $this->document = null;
     $this->hits = 0;
     $this->uploaded = filemtime($this->absolutePath);
 }
Esempio n. 6
0
 /**
  * Search file relative path by document full alias.
  *
  * @param string $fullAlias value from table #__joomdoc column full_alias
  * @return string value from table #__joomdoc column columns parent_path and path
  */
 public function searchRelativePathByFullAlias($fullAlias)
 {
     if (!JString::trim($fullAlias)) {
         return null;
     }
     $config = JoomDOCConfig::getInstance();
     if ($config->virtualFolder) {
         // if turn on virtual folder try to complete full document alias
         if ($rootPath = JoomDOCFileSystem::getRelativePath($config->path)) {
             // search for full alias of virtual root parent
             $rootFullAlias = $this->searchFullAliasByPath($rootPath);
             if ($rootFullAlias) {
                 // add parent full alias on begin of document virtual full alias
                 $fullAlias = $rootFullAlias . DIRECTORY_SEPARATOR . $fullAlias;
             } else {
                 // add virtual root path parent on begin of document virtual full alias
                 $fullAlias = $rootPath . DIRECTORY_SEPARATOR . $fullAlias;
             }
         }
     }
     // search for file relative path by document full alias
     $this->_db->setQuery('SELECT `path` FROM `#__joomdoc` WHERE `full_alias` = ' . $this->_db->quote($fullAlias) . ' ORDER BY `version` DESC', 0, 1);
     return $this->_db->loadResult();
 }