Пример #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);
 }
Пример #2
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));
     }
 }
Пример #3
0
 /**
  * Rename file/folder.
  */
 public function rename()
 {
     $renamePath = JString::trim(JRequest::getString('renamePath'));
     if (JoomDOCAccessFileSystem::rename(false, $renamePath)) {
         if ($success = JoomDOCFileSystem::rename($renamePath, JString::trim($newName = JRequest::getString('newName')))) {
             //if renamed directory, do refresh, else it will appear empty
             $newPath = ($parentPath = JoomDOCFileSystem::getParentPath($renamePath)) ? $parentPath . DIRECTORY_SEPARATOR . JRequest::getString('newName') : $newName;
             if (JFolder::exists(JoomDOCFileSystem::getFullPath($newPath))) {
                 $mainfrane = JFactory::getApplication();
                 $mainfrane->enqueueMessage(JText::sprintf('JOOMDOC_REFRESHED', JoomDOCFileSystem::refresh()));
             }
         }
         $this->setRedirect(JoomDOCRoute::viewDocuments(), JText::_($success ? 'JOOMDOC_RENAME_SUCCESS' : 'JOOMDOC_RENAME_FAILED'), $success ? 'message' : 'error');
     } else {
         JError::raiseError(403, JText::_('JOOMDOC_UNABLE_RENAME'));
     }
 }
Пример #4
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":""}');
     }
 }
Пример #5
0
 /**
  * Get path paremeter from request. Test if parameter is relative path or document alias.
  * Test if path is virtual path.
  *
  * @param string $path path to control, if null use param path from request
  * @return string
  */
 public static function getPath($path = null)
 {
     static $model;
     /* @var $model JoomDOCModelDocument */
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication (JSite or JAdministrator) */
     if ($mainframe->isSite() && is_null($model)) {
         $model = JModelLegacy::getInstance(JOOMDOC_DOCUMENT, JOOMDOC_MODEL_PREFIX);
     }
     // get root path from request or config
     if (!$path) {
         $path = JString::trim(JRequest::getString('path'));
     }
     $path = JoomDOCString::urldecode($path);
     // frontend
     if ($mainframe->isSite()) {
         // path from request can be document full alias - search for path in document table
         $candidate = $model->searchRelativePathByFullAlias($path);
         if ($candidate) {
             $path = $candidate;
         } else {
             // if request param is path convert from virtual to full relative path
             $path = JoomDOCFileSystem::getNonVirtualPath($path);
         }
     } else {
         // backend
         $path = $mainframe->getUserStateFromRequest(JoomDOCRequest::getSessionPrefix() . 'path', 'path', '', 'string');
         if ($path == JText::_('JOOMDOC_ROOT')) {
             return '';
         }
     }
     $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
     //windows
     if ($path) {
         $path = JPath::clean($path);
     }
     return $path;
 }
Пример #6
0
 echo ($access->docid and $item->document->published == JOOMDOC_STATE_PUBLISHED) ? $item->document->title : $item->getFileName();
 if ($access->canOpenFile || $access->canOpenFolder) {
     echo '</a>';
 }
 if ($this->access->canCopyMove) {
     echo '<input type="checkbox" name="paths[]" id="cbb' . $i . '" value="' . $this->escape($access->relativePath) . '" class="blind" />';
     echo '<input type="checkbox" name="cid[]" id="cb' . $i . '" value="' . $access->docid . '" onclick="Joomla.isChecked(this.checked);JoomDOC.check(this,' . $i . ')" class="pull-right" />';
 }
 echo '</h2>';
 if ($access->canViewFileInfo && ($access->docid && $this->access->canShowFileDates || !$access->isFolder && $this->access->canShowFileInfo || $access->isFavorite)) {
     echo '<div class="info">';
     if ($access->isFavorite) {
         echo '<span class="favorite">' . JText::_('JOOMDOC_FAVORITE') . '</span>';
     }
     if ($config->showFilesize && !$access->isFolder) {
         echo '<span class="filesize">' . JText::sprintf('JOOMDOC_FILESIZE', JoomDOCFileSystem::getFileSize($access->absolutePath)) . '</span>';
     }
     if ($access->docid) {
         if ($config->showCreated) {
             echo '<span class="created">' . JText::sprintf('JOOMDOC_CREATED', JHtml::date($item->document->created, JText::_('JOOMDOC_UPLOADED_DATE_J16'))) . '</span>';
         }
         if ($config->showModified && JoomDOCHelper::canViewModified($item->document->created, $item->document->modified)) {
             echo '<span class="modified">' . JText::sprintf('JOOMDOC_MODIFIED', JHtml::date($item->document->modified, JText::_('JOOMDOC_UPLOADED_DATE_J16'))) . '</span>';
         }
     }
     if ($config->showHits && !$access->isFolder) {
         echo '<span class="hits">' . JText::sprintf('JOOMDOC_HITS_INFO', JoomDOCHelper::number($item->hits)) . '</span>';
     }
     foreach ($this->listfields as $field) {
         if ($value = JHtml::_('joomdoc.showfield', $field, $item->document)) {
             echo '<span class="field">' . $field->title . ': ' . $value . '</span>';
Пример #7
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);
Пример #8
0
    if ($moduleConfig->link_type == 'detail') {
        $url = JoomDOCRoute::viewDocuments($access->relativePath, $access->alias);
    } elseif ($moduleConfig->link_type == 'download' && $access->canDownload) {
        // download link is displayed only if file can be download in ACL setting
        $url = JoomDOCRoute::download($access->relativePath, $access->alias);
    } else {
        $url = null;
    }
    if ($url) {
        echo '<a href="' . JRoute::_($url) . '" title="">' . ($access->docid ? $item->document->title : $item->getFileName()) . '</a>';
    } else {
        // Name is displayed as document title or file path.
        echo $access->docid ? $item->document->title : $item->getFileName();
    }
    if ($moduleConfig->show_filesize) {
        echo '<strong>' . JText::sprintf('JOOMDOC_MODULE_FILESIZE', JoomDOCFileSystem::getFileSize($access->absolutePath)) . '</strong>';
    }
    if ($moduleConfig->show_listfields) {
        echo '<table class="fields"><tbody>';
        foreach ($listFields as $field) {
            if ($value = JHtml::_('joomdoc.showfield', $field, $item->document)) {
                echo '<tr><th>' . $field->title . ':</th><td>' . $value . '</td></tr>';
            }
        }
        echo '</tbody></table>';
    }
    if ($moduleConfig->show_text && $access->docid && ($description = JString::trim($item->document->description))) {
        echo '<p>' . JoomDOCString::crop($description, $moduleConfig->crop_length) . '</p>';
    }
    echo '</li>';
}
Пример #9
0
 /**
  * Overloaded bind function to pre-process the params.
  *
  * @param array Named array
  * @return null|string	null is operation was satisfactory, otherwise returns an error
  */
 public function bind($array, $ignore = '')
 {
     if (isset($array['params']) && is_array($array['params'])) {
         $registry = new JRegistry();
         $registry->loadArray($array['params']);
         $array['params'] = (string) $registry->toString();
     }
     $this->favorite = isset($array['favorite']) ? 1 : 0;
     $this->download = isset($array['download']) ? 1 : 0;
     if (isset($array['rules']) && is_array($array['rules'])) {
         $rules = new JRules($array['rules']);
         $this->setRules($rules);
     }
     parent::bind($array, $ignore);
     $this->parent_path = JoomDOCFileSystem::getParentPath($this->path);
     return true;
 }
Пример #10
0
 /**
  * Get ID of document of last path parent.
  *
  * @param string $path relative file path
  * @return int document ID, null of not found
  */
 public function getParentDocumentID($path)
 {
     static $results;
     // last parent path of path
     $parentPath = $subParentPath = JoomDOCFileSystem::getParentPath($path);
     // search in cache
     if (is_array($results)) {
         foreach ($results as $result) {
             if ($result->subparentPath == $subParentPath) {
                 return $result->documentID;
             }
         }
     }
     // generate parents tree
     while ($parentPath) {
         $where[] = '`path` = ' . $this->_db->quote($parentPath);
         $parentPath = JoomDOCFileSystem::getParentPath($parentPath);
     }
     if (isset($where)) {
         // search last parent path with document
         $this->_db->setQuery('SELECT `id`, `path` 
        			              FROM 
        							  (SELECT `id`, `path` 
        			                   FROM `#__joomdoc` 
        			                   WHERE (' . implode(' OR ', $where) . ') 
        			                   ORDER BY `id` ASC /* latest version */
        			                  ) AS s 
        						  ORDER BY `path` DESC /* nearest parent */');
         $row = $this->_db->loadObject();
         // cache result
         $result = new JObject();
         $result->parentPath = $row ? $row->path : false;
         $result->subparentPath = $subParentPath;
         $result->documentID = $row ? $row->id : false;
         $results[] = $result;
         return $result->documentID;
     }
     return false;
 }
Пример #11
0
 /**
  * Revert selected Version as last Version.
  *
  * @param int $id restored Version row ID
  * @param string $path restored Version Path
  * @return JObject
  *     revertVersion   reverted Version Number
  *     oldLastVersion  archived last Version Number
  *     newLastVersion  new last Version from reverted Version number
  */
 function revert($id, $path)
 {
     $safePath = $this->_db->quote($path);
     $this->_db->setQuery('SELECT MAX(`id`) FROM `#__joomdoc_file` WHERE `path` = ' . $safePath . ' GROUP BY `path`');
     $cid = $this->_db->loadColumn();
     // the latest file version list
     // get Row with given ID and given Path which isn't last Version - candidate to revert as last Version
     $query = 'SELECT `id`, `version` FROM `#__joomdoc_file` WHERE `id` = ' . (int) $id . ' AND `path` = ' . $safePath;
     if ($cid) {
         $query .= ' AND `id` NOT IN (' . implode(', ', $cid) . ')';
     }
     $this->_db->setQuery($query);
     $candidate = $this->_db->loadObject();
     if (is_null($candidate)) {
         return false;
     }
     // get last Version number
     $query = 'SELECT MAX(`version`) FROM `#__joomdoc_file` WHERE `path` = ' . $safePath;
     $this->_db->setQuery($query);
     $lastVersion = $this->_db->loadResult();
     if (is_null($lastVersion)) {
         return false;
     }
     // full Path of last Version
     $lastVersionPath = JoomDOCFileSystem::getFullPath($path);
     // full Path of revert Version
     $revertVersionPath = JoomDOCFileSystem::getVersionPath($lastVersionPath, $candidate->version, true);
     // full Path to archive last Version
     $archiveVersionPath = JoomDOCFileSystem::getVersionPath($lastVersionPath, $lastVersion, true);
     // move last Version as archive Version
     if (!JFile::move($lastVersionPath, $archiveVersionPath)) {
         return false;
     }
     // copy revert Version as last Version
     if (!JFile::copy($revertVersionPath, $lastVersionPath)) {
         return false;
     }
     // copy revert Version DB Row
     $newLastVersionID = JoomDOCModelList::copyRow('#__joomdoc_file', 'id', $candidate->id);
     // increment new last Version number
     $newLastVersion = $lastVersion + 1;
     $query = 'UPDATE `#__joomdoc_file` SET `version` = ' . $newLastVersion . ', `state` = ' . JOOMDOC_STATE_PUBLISHED . ' WHERE `id` = ' . $newLastVersionID;
     $this->_db->setQuery($query);
     $this->_db->query();
     $output = new JObject();
     $output->revertVersion = $candidate->version;
     $output->oldLastVersion = $lastVersion;
     $output->newLastVersion = $newLastVersion;
     JModelLegacy::getInstance(JOOMDOC_DOCUMENTS, JOOMDOC_MODEL_PREFIX)->flat($path);
     return $output;
 }
Пример #12
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);
 }
Пример #13
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;
 }
Пример #14
0
}
if ($this->access->canCreateFolder) {
    $method = 'return JoomDOC.mkdir(this, ' . ($this->access->canCreate ? 'true' : 'false') . ')';
    echo '<span class="input-append" style="margin-left:20px">';
    echo '<input style="width: 130px;' . (JOOMDOC_ISJ3 ? '' : 'margin-left:20px;') . '" class="hasTip" type="text" name="newfolder" id="newfolder" placeholder="' . JText::_('JOOMDOC_DOCUMENTS_NEW_FOLDER') . '"
                		value="' . $this->escape(JRequest::getString('newfolder')) . '" onchange="' . $method . '"  title="' . $this->getTooltip('JOOMDOC_DOCUMENTS_NEW_FOLDER') . '" />';
    echo '<button type="submit" class="btn  " onclick="' . $method . '">' . JText::_('JOOMDOC_CREATE') . '</button>';
    echo '</span>';
}
echo '</fieldset>';
echo '</fieldset>';
echo '<div class="clearfix"></div>';
echo '<div id="pathway">';
$separator = '';
$separatorValue = JText::_('JOOMDOC_PATHWAY_SEPARATOR');
$breadCrumbs = JoomDOCFileSystem::getPathBreadCrumbs($this->access->relativePath);
foreach ($breadCrumbs as $breadCrumb) {
    echo '<span class="item">';
    echo $separator;
    echo '<a href="' . JRoute::_(JoomDOCRoute::viewDocuments($breadCrumb->path)) . '" class="hasTip" title="' . $this->getTooltip($breadCrumb->path, 'JOOMDOC_DOCUMENTS_OPEN_FOLDER') . '">' . $breadCrumb->name . '</a>';
    echo '</span>';
    $separator = $separatorValue;
}
$count = count($breadCrumbs);
if (!$this->access->inRoot && $count > 1) {
    $breadCrumb = $breadCrumbs[$count - 2];
    echo '<a class="back" href="' . JRoute::_(JoomDOCRoute::viewDocuments($breadCrumb->path)) . '" title="">' . JText::_('JOOMDOC_BACK') . '</a>';
}
echo '</div>';
echo '<div class="clearfix"></div>';
if ($config->useExplorer and !JOOMDOC_ISJ3) {
Пример #15
0
 public function __construct(&$item)
 {
     $config = JoomDOCConfig::getInstance();
     /* @var $config JoomDOCConfig */
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     $user = JFactory::getUser();
     $this->isFile = JoomDOCFileSystem::isFile($item);
     $this->isFolder = JoomDOCFileSystem::isFolder($item);
     $isFileSystemItem = $this->isFile || $this->isFolder;
     $this->docid = $isFileSystemItem ? JoomDOCHelper::getDocumentID($item) : $item->id;
     if (isset($item->document)) {
         $document = new JObject();
         $document->setProperties($item->document);
     } elseif (!$isFileSystemItem) {
         if ($item instanceof JObject) {
             $document = $item;
         } else {
             $document = new JObject($item);
             $document->setProperties($item);
         }
     } else {
         $document = new JObject();
     }
     $this->isTrashed = $isFileSystemItem ? @$item->file_state == JOOMDOC_STATE_TRASHED : $document->get('file_state') == JOOMDOC_STATE_TRASHED;
     if ($mainframe->isSite() && $document->get('state') == JOOMDOC_STATE_TRASHED) {
         $this->docid = null;
     }
     $this->relativePath = $isFileSystemItem ? $item->getRelativePath() : $item->path;
     $this->absolutePath = $isFileSystemItem ? $item->getAbsolutePath() : JoomDOCFileSystem::getFullPath($this->relativePath);
     $this->inRoot = $this->absolutePath == $config->path;
     $this->name = $isFileSystemItem ? $item->getFileName() : JFile::getName($this->relativePath);
     $this->alias = JoomDOCHelper::getDocumentAlias($item);
     $this->isChecked = JoomDOCHelper::isChecked($item);
     $this->isLocked = false;
     $this->fileType = JoomDOCHelper::getFileType($this->name);
     $this->canViewFileInfo = JoomDOCAccessFileSystem::viewFileInfo($this->docid, $this->relativePath);
     $this->fileVersion = JoomDOCHelper::getMaxVersion($this->relativePath);
     $this->canRename = JoomDOCAccessFileSystem::rename($this->docid, $this->relativePath);
     $this->canWebDav = JoomDOCAccessFileSystem::editWebDav($this->docid, $this->relativePath);
     $this->canEdit = $this->docid && JoomDOCAccessDocument::canEdit($document);
     $this->canCreate = !$this->docid && JoomDOCAccessDocument::create($this->relativePath);
     if ($config->documentAccess == 2 && $mainframe->isSite()) {
         $this->canDownload = $this->isFile && $document && $user->id == $document->get('access') && $document->get('download');
     } else {
         $this->canDownload = $this->isFile && JoomDOCAccessFileSystem::download($this->docid, $this->relativePath);
     }
     $this->canEnterFolder = JoomDOCAccessFileSystem::enterFolder($this->docid, $this->relativePath);
     $this->canOpenFolder = $this->isFolder && $this->canEnterFolder;
     $this->canOpenFile = $this->isFile;
     $this->canEditStates = JoomDOCAccessDocument::editState($this->docid, $document->get('checked_out'));
     $this->canEditState = $this->docid && JoomDOCAccessDocument::editState($this->docid, $document->get('checked_out'));
     if ($mainframe->isAdmin()) {
         $this->canEditState = JoomDOCAccessDocument::editState();
     }
     $this->canCopyMove = JoomDOCAccessFileSystem::copyMove($this->docid, $this->relativePath);
     $this->canDeleteDocs = JoomDOCAccessDocument::delete($this->docid);
     $this->canDeleteDoc = $this->docid && JoomDOCAccessDocument::delete($this->docid);
     $this->canDeleteFile = JoomDOCAccessFileSystem::deleteFile($this->docid, $this->relativePath);
     $this->canUpload = JoomDOCAccessFileSystem::uploadFile($this->docid, $this->relativePath);
     $this->canCreateFolder = JoomDOCAccessFileSystem::newFolder($this->docid, $this->relativePath);
     $this->canViewVersions = JoomDOCAccessDocument::viewVersions($this->docid);
     $this->canShowFileDates = $config->showCreated || $config->showModified;
     $this->canShowFileInfo = $config->showFilesize || $config->showHits;
     $this->canShowAllDesc = $config->showFolderDesc && $config->showFileDesc;
     $this->isFavorite = $document->get('favorite') == 1;
     $this->canDisplayFavorite = $this->isFavorite && $config->displayFavorite;
     $this->canAnyEditOp = $config->accessHandling && ($this->canEdit || $this->canWebDav || $this->canEditState || $this->canCreate || $this->canDeleteFile || $this->canDeleteDoc);
     if (!$this->docid || !$document->get('license_id')) {
         $license = JoomDOCHelper::license($this->relativePath);
         if ($license) {
             $this->licenseID = $license->id;
             $this->licenseAlias = $license->alias;
             $this->licenseTitle = $license->title;
         }
     } elseif ($document->get('license_state') == JOOMDOC_STATE_PUBLISHED) {
         $this->licenseID = $document->get('license_id');
         $this->licenseAlias = $document->get('license_alias');
         $this->licenseTitle = $document->get('license_title');
     }
     $this->canManageVersions = false;
     $this->canUntrash = JoomDOCAccessFileSystem::untrash($this->docid, $this->relativePath);
 }
Пример #16
0
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     if (!JString::trim($text) || is_array($areas) && !array_intersect($areas, array_keys(plgSearchJoomDOC::onContentSearchAreas()))) {
         return array();
     }
     // import component JoomDOC framework
     $jdcAdm = JPATH_ADMINISTRATOR . '/components/com_joomdoc/';
     $jdcSit = JPATH_SITE . '/components/com_joomdoc/';
     $jdcLib = $jdcAdm . 'libraries/joomdoc/';
     $includes['JoomDOCRoute'] = $jdcLib . 'application/route.php';
     $includes['JoomDOCMenu'] = $jdcLib . 'application/menu.php';
     $includes['JoomDOCConfig'] = $jdcLib . 'application/config.php';
     $includes['JoomDOCFileSystem'] = $jdcLib . 'filesystem/filesystem.php';
     $includes['JoomDOCString'] = $jdcLib . 'utilities/string.php';
     $includes['JoomDOCHelper'] = $jdcLib . 'utilities/helper.php';
     $includes['JoomDOCModelList'] = $jdcLib . 'application/component/modellist.php';
     $includes[] = $jdcAdm . 'defines.php';
     foreach ($includes as $classname => $include) {
         $include = JPath::clean($include);
         if (!JFile::exists($include)) {
             // JoomDOC is propably uninstalled or corupted
             return array();
         }
         is_string($classname) ? JLoader::register($classname, $include) : (include_once $include);
     }
     JModelLegacy::addIncludePath(JPath::clean($jdcAdm . 'models'));
     JTable::addIncludePath(JPath::clean($jdcAdm . 'tables'));
     $db = JFactory::getDbo();
     $nullDate = $db->getNullDate();
     // prepare SQL WHERE criteria
     $wheres = array();
     // according to type of searching
     switch ($phrase) {
         case 'exact':
             // exactly phrase
             $keywords = $db->q('%' . JString::strtolower(JString::trim($text)) . '%');
             $items[] = 'LOWER(`document`.`title`) LIKE ' . $keywords;
             $items[] = 'LOWER(`document`.`description`) LIKE ' . $keywords;
             $items[] = 'LOWER(`document`.`path`) LIKE ' . $keywords;
             $items[] = 'LOWER(`document`.`content`) LIKE ' . $keywords;
             $where[] = '(' . implode(') OR (', $items) . ') ';
             break;
         case 'all':
         case 'any':
         default:
             // all words or any word or default
             $keywords = explode(' ', $text);
             // split to words
             $wheres = array();
             // search for each word
             foreach ($keywords as $keyword) {
                 $keyword = JString::trim($keyword);
                 if ($keyword) {
                     $keyword = $db->q('%' . JString::strtolower($keyword) . '%');
                     $items[] = 'LOWER(`document`.`title`) LIKE ' . $keyword;
                     $items[] = 'LOWER(`document`.`description`) LIKE ' . $keyword;
                     $items[] = 'LOWER(`document`.`path`) LIKE ' . $keyword;
                     $items[] = 'LOWER(`document`.`content`) LIKE ' . $keyword;
                     $parts[] = implode(' OR ', $items);
                 }
             }
             if (isset($parts)) {
                 if ($phrase == 'all') {
                     $where[] = '(' . implode(') AND (', $parts) . ') ';
                 } else {
                     $where[] = '(' . implode(') OR (', $parts) . ') ';
                 }
             }
             break;
     }
     $where[] = '(' . JoomDOCModelList::getDocumentPublished() . ')';
     $where = ' WHERE ' . implode(' AND ', $where) . ' ';
     // prepare SQL ORDER BY criteria
     switch ($ordering) {
         case 'oldest':
             // oldest items first (oldest documents created or oldest file uploaded)
             $order = ' ORDER BY `document`.`created` ASC, `document`.`upload` ASC ';
             break;
         case 'popular':
             // most hits items first
             $order = ' ORDER BY `document`.`hits` DESC, `document`.`title` ASC, `document`.`path` ASC ';
             break;
         case 'alpha':
             // alphabetically (document title or file name)
             $order = ' ORDER BY `document`.`title` ASC, `document`.`path` ASC ';
             break;
         case 'category':
             // by parent folder (parent folder name or document title)
             $order = ' ORDER BY `parent`.`title` ASC, `parent`.`path` ASC ';
             break;
         case 'newest':
         default:
             // newest items first (newest documents created or file uploaded)
             $order = ' ORDER BY `document`.`created` DESC, `document`.`upload` DESC ';
             break;
     }
     $query = 'SELECT `document`.`title`,`document`.`path`, ';
     $query .= '`document`.`description`, `document`.`content`, ';
     $query .= '`document`.`created`,`document`.`upload`,  ';
     $query .= '`parent`.`title` AS `ptitle`,  ';
     // document folder title
     $query .= '`document`.`full_alias` ';
     $query .= 'FROM `#__joomdoc_flat` AS `document` ';
     $query .= 'LEFT JOIN `#__joomdoc_flat` AS `parent` ON `document`.`parent_path` = `parent`.`path`  ';
     // document folder
     $query .= $where . ' GROUP BY `document`.`path` ' . $order;
     $rows = $db->setQuery($query)->loadObjectList();
     foreach ($rows as $row) {
         $GLOBALS['joomDOCPath'] = $row->path;
         $row->title = JString::trim($row->title) ? $row->title : JFile::getName($row->path);
         $row->text = JString::trim($row->description) ? $row->description : $row->content;
         $row->created = $row->created == $nullDate ? $row->upload : $row->created;
         $row->section = JString::trim($row->ptitle) ? $row->ptitle : JoomDOCFileSystem::getParentPath($row->path);
         if ($this->params->get('document_link', 1) == 1) {
             $row->href = JRoute::_(JoomDOCRoute::viewDocuments($row->path, empty($row->full_alias) ? $row->path : $row->full_alias));
         } else {
             $row->href = JRoute::_(JoomDOCRoute::download($row->path, empty($row->full_alias) ? $row->path : $row->full_alias));
         }
         $row->browsernav = 2;
         // open document title in the same window
     }
     unset($GLOBALS['joomDOCPath']);
     return $rows;
 }
Пример #17
0
 /**
  * Show mainframe message with information about set clipboard operation.
  */
 public static function clipboardInfo()
 {
     $operation = JoomDOCFileSystem::getOperation();
     $paths = JoomDOCFileSystem::getOperationPaths();
     if (!is_null($operation) && count($paths)) {
         $mainframe = JFactory::getApplication();
         /* @var $mainframe JApplication */
         $msg = 'JOOMDOC_CPMV_INFO_' . JString::strtoupper($operation);
         $paths = implode(', ', $paths);
         $mainframe->enqueueMessage(JText::sprintf($msg, $paths));
     }
 }
Пример #18
0
        echo '<a class="download" href="' . JRoute::_(JoomDOCRoute::download($this->access->relativePath, $this->access->alias)) . '" title="">';
    }
}
//display document title only if published for current user.
echo ($this->access->docid and $this->root->document->published == JOOMDOC_STATE_PUBLISHED) ? $this->root->document->title : $this->root->getFileName();
if ($this->access->canDownload) {
    echo '</a>';
}
echo '</h1>';
if ($this->access->canViewFileInfo && ($this->access->docid && $this->access->canShowFileDates || !$this->access->isFolder && $this->access->canShowFileInfo || $this->access->isFavorite)) {
    echo '<div class="info">';
    if ($this->access->canDisplayFavorite) {
        echo '<span class="favorite">' . JText::_('JOOMDOC_FAVORITE') . '</span>';
    }
    if ($config->showFilesize && !$this->access->isFolder) {
        echo '<span class="filesize">' . JText::sprintf('JOOMDOC_FILESIZE', JoomDOCFileSystem::getFileSize($this->root->getAbsolutePath())) . '</span>';
    }
    if ($this->access->docid) {
        if ($config->showCreated && !is_null($this->root->document->created)) {
            echo '<span class="created">' . JText::sprintf('JOOMDOC_CREATED', JHtml::date($this->root->document->created, JText::_('JOOMDOC_UPLOADED_DATE_J16'))) . '</span>';
        }
        if ($config->showModified && JoomDOCHelper::canViewModified($this->root->document->created, $this->root->document->modified)) {
            echo '<span class="modified">' . JText::sprintf('JOOMDOC_MODIFIED', JHtml::date($this->root->document->modified, JText::_('JOOMDOC_UPLOADED_DATE_J16'))) . '</span>';
        }
    }
    if ($config->showHits && !$this->access->isFolder) {
        echo '<span class="hits">' . JText::sprintf('JOOMDOC_HITS_INFO', JoomDOCHelper::number($this->root->document->hits)) . '</span>';
    }
    echo '<div class="clr"></div>';
    echo '</div>';
}
Пример #19
0
        //echo $i.' | '.$item->id.' | '.$item->version.' | '.$this->maxVersion;
        echo '<td>' . JHtml::_('grid.id', ++$i, $item->id, $item->version == $this->maxVersion) . '</td>';
    }
    echo '<td>' . $item->version . '</td>';
    if ($showDownload) {
        echo '<td>';
        if ($item->state == JOOMDOC_STATE_PUBLISHED) {
            echo '<a href="' . JRoute::_(JoomDOCRoute::download($item->path, null, $item->version)) . '" title="" target="_blank">';
            echo $download;
            echo '</a>';
        } elseif ($item->state == JOOMDOC_STATE_TRASHED) {
            echo $trashed;
        }
        echo '</td>';
    }
    echo '<td nowrap="nowrap">' . JoomDOCFileSystem::getFileSize(JoomDOCFileSystem::getFullPath($item->path)) . '</td>';
    echo '<td nowrap="nowrap">' . JoomDOCHelper::uploaded($item->upload, false) . '</td>';
    echo '<td nowrap="nowrap">' . $item->name . '</td>';
    echo '<td class="center" nowrap="nowrap">' . JoomDOCHelper::number($item->hits) . '</td>';
    echo '</tr>';
}
echo '</tbody>';
echo '<tfoot>';
echo '<tr>';
$pagination = new JPagination($this->filter->total, $this->filter->offset, $this->filter->limit);
echo '<td colspan="20">' . $pagination->getListFooter() . '</td>';
echo '</tr>';
echo '</tfoot>';
echo '</table>';
echo JHtml::_('form.token');
echo '<input type="hidden" name="task" value="" />';
Пример #20
0
 /**
  * Add page main toolbar.
  *
  * @return void
  */
 protected function addToolbar()
 {
     $bar = JToolBar::getInstance('toolbar');
     /* @var $bar JToolBar */
     JToolBarHelper::title(JText::_('JOOMDOC_DOCUMENTS'), 'documents');
     if ($this->access->canEditStates) {
         JToolBarHelper::publish(JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_PUBLISH));
         JToolBarHelper::unpublish(JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_UNPUBLISH));
         JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_CHECKIN), 'checkin', '', 'JTOOLBAR_CHECKIN', true);
     } else {
         $bar->appendButton('Standard', 'publish', 'JTOOLBAR_PUBLISH');
         $bar->appendButton('Standard', 'unpublish', 'JTOOLBAR_UNPUBLISH');
         $bar->appendButton('Standard', 'checkin', 'JTOOLBAR_CHECKIN');
     }
     JToolBarHelper::divider();
     if ($this->access->canCopyMove && !JoomDOCFileSystem::haveOperation()) {
         JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_COPY), 'copy', '', 'JTOOLBAR_COPY', true);
         JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_MOVE), 'move', '', 'JTOOLBAR_MOVE', true);
     } else {
         //$bar->appendButton('Standard', 'copy', 'JTOOLBAR_COPY');
         //$bar->appendButton('Standard', 'move', 'JTOOLBAR_MOVE');
     }
     if ($this->access->canCopyMove && JoomDOCFileSystem::haveOperation()) {
         JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_PASTE), 'save', '', 'JTOOLBAR_PASTE', false);
         JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_RESET), 'remove', '', 'JTOOLBAR_RESET', false);
     } else {
         //$bar->appendButton('Standard', 'save', 'JTOOLBAR_PASTE');
         //$bar->appendButton('Standard', 'remove', 'JTOOLBAR_RESET');
     }
     JToolBarHelper::divider();
     // Document delete
     //if ($this->access->canDeleteDocs)
     //$bar->appendButton('Confirm', 'JOOMDOC_ARE_YOU_SURE_DELETE_DOCUMETS', 'docs-delete', 'JOOMDOC_DELETE_DOCUMENT', JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_DELETE), true);
     //else
     //$bar->appendButton('Standard', 'docs-delete', 'JOOMDOC_DELETE_DOCUMENT');
     // Item delete
     if ($this->access->canDeleteFile) {
         JToolBarHelper::deleteList('JOOMDOC_ARE_YOU_SURE_DELETE_ITEMS', JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_DELETEFILE), 'JTOOLBAR_DELETE');
     } else {
         $bar->appendButton('Standard', 'delete', 'JOOMDOC_DELETE_ITEM');
     }
     if (JoomDOCHelper::trashedItemsCount() >= 1) {
         if ($this->access->canDeleteDocs && $this->access->canDeleteFile) {
             $bar->appendButton('Confirm', 'JOOMDOC_ARE_YOU_SURE_EMPTY_TRASH', 'trash', 'JTOOLBAR_EMPTY_TRASH', JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_TRASH), false);
         } else {
             $bar->appendButton('Standard', 'trash', 'JTOOLBAR_TRASH');
         }
     }
     if (JoomDOCAccessFileSystem::refresh()) {
         JToolBarHelper::divider();
         JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_REFRESH), 'refresh', '', 'JTOOLBAR_REFRESH', false);
         JHtml::_('joomdoc.tooltip', 'toolbar-refresh', 'JTOOLBAR_REFRESH', 'JOOMDOC_REFRESH_TIP');
         JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_DOCUMENTS, JOOMDOC_TASK_FLAT), 'reflat', '', 'JOOMDOC_REFLAT', false);
         JHtml::_('joomdoc.tooltip', 'toolbar-reflat', 'JOOMDOC_REFLAT', 'JOOMDOC_REFLAT_TIP');
     }
     if (JoomDOCAccess::admin()) {
         JToolBarHelper::divider();
         JToolBarHelper::preferences(JOOMDOC_OPTION, JOOMDOC_PARAMS_WINDOW_HEIGHT, JOOMDOC_PARAMS_WINDOW_WIDTH);
     }
 }
Пример #21
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;
 }
Пример #22
0
 /**
  * Reset operation from clipboard.
  */
 public function reset()
 {
     JoomDOCFileSystem::resetOperation();
     $this->setRedirect(JoomDOCRoute::viewDocuments(JoomDOCRequest::getPath(), false));
 }
Пример #23
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) : '';
 }
Пример #24
0
 /**
  * Reset operation from clipboard.
  */
 public function reset()
 {
     JoomDOCFileSystem::resetOperation();
     $this->setRedirect(JoomDOCRoute::viewDocuments());
 }
Пример #25
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);
 }
Пример #26
0
 * @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;
$mainframe = JFactory::getApplication();
/* @var $mainframe JApplication */
/* @var $this JoomDOCViewDocuments */
$listOrder = $this->escape($this->state->get(JOOMDOC_FILTER_ORDERING));
$listDirn = $this->escape($this->state->get(JOOMDOC_FILTER_DIRECTION));
$useLinkType = JRequest::getInt('useLinkType');
$linkType = JOOMDOC_LINK_TYPE_DETAIL;
$addSymLink = JRequest::getString('addSymLink');
$symLinkSource = JRequest::getString('symLinkSource');
$separator = JText::_('JOOMDOC_PATHWAY_SEPARATOR');
foreach (JoomDOCFileSystem::getPathBreadCrumbs($this->access->relativePath) as $i => $breadCrumb) {
    echo '<span>' . $separator . '<a href="' . JRoute::_(JoomDOCRoute::modalDocuments($breadCrumb->path, $useLinkType, $addSymLink, $symLinkSource)) . '" class="hasTip" title="' . $this->getTooltip($breadCrumb->path, 'JOOMDOC_DOCUMENTS_OPEN_FOLDER') . '">' . $breadCrumb->name . '</a></span>';
}
echo '<form action="' . JRoute::_(JoomDOCRoute::modalDocuments($this->access->relativePath, $useLinkType, $addSymLink, $symLinkSource)) . '" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">';
echo '<fieldset style="height: 65px;" class="filter-bar">';
echo '<div>';
echo '<label for="filter" class="hasTip filter-search-lbl" style="display:none" title="' . $this->getTooltip('JOOMDOC_DOCUMENTS_FILTER') . '">' . JText::_('JOOMDOC_DOCUMENTS_FILTER') . ':</label>';
echo '<div class="btn-group pull-left">';
echo '<input type="text" name="filter" id="filter" value="' . $this->escape($this->filter) . '" 
            		 title="' . JText::_('JOOMDOC_DOCUMENTS_FILTER') . '"  placeholder="' . JText::_('JOOMDOC_DOCUMENTS_FILTER') . '"/>';
echo '</div>';
echo '<div class="btn-group pull-left">';
echo '<button type="submit" class="btn">' . JText::_('JSEARCH_FILTER_SUBMIT') . '</button>';
echo '<button class="btn" type="button" onclick="var f=this.form;f.filter.value=\'\';f.submit();">' . JText::_('JSEARCH_FILTER_CLEAR') . '</button>';
echo '</div>';
if ($useLinkType) {
Пример #27
0
 public function run()
 {
     $db = JFactory::getDbo();
     /* @var $db JDatabase */
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     // selected source docman or joomdoc
     $component = JRequest::getString('component');
     // current database prefix
     $pr = $mainframe->getCfg('dbprefix');
     // all DocMAN or JoomDOC2 tables
     if ($component == 'docman') {
         $tables = array($pr . 'docman', $pr . 'docman_groups', $pr . 'docman_history', $pr . 'docman_licenses', $pr . 'docman_log');
     } else {
         $tables = array($pr . 'joomdoc2', $pr . 'joomdoc2_groups', $pr . 'joomdoc2_history', $pr . 'joomdoc2_licenses', $pr . 'joomdoc2_log');
     }
     // all tables in Joomla database
     $joomla = $db->getTableList();
     // check if all tables exists, are required
     if (array_intersect($tables, $joomla) != $tables) {
         return $this->setRedirect(JoomDOCRoute::viewJoomDOC(), JText::sprintf('JOOMDOC_MIGRATION_TABLES_UNAVAILABLE', implode(', ', $tables)), 'error');
     }
     // relative path folder where DocMAN or JoomDOC stored files, is required
     $docbase = JPath::clean(JPATH_ROOT . '/' . JRequest::getString('docbase'));
     if (!JFolder::exists($docbase)) {
         return $this->setRedirect(JoomDOCRoute::viewJoomDOC(), JText::sprintf('JOOMDOC_MIGRATION_DOCBASE_UNAVAILABLE', $docbase), 'error');
     }
     // statictis counters
     $newFolders = $newFiles = 0;
     /* copy DocMAN or JoomDOC2 licenses into JoomDOC3 */
     $license = JTable::getInstance(JOOMDOC_LICENSE, JOOMDOC_TABLE_PREFIX);
     /* @var $license JoomDOCTableLicense */
     $table = $component == 'docman' ? 'docman_licenses ' : 'joomdoc2_licenses ';
     // total of licenses in DocMAN or JoomDOC2
     $db->setQuery('SELECT COUNT(*) FROM #__' . $table);
     $total = $db->loadResult();
     // map Ids of licenses from DocMAN or JoomDOC2 into Ids of licenses in new JoomDOC3 structure
     $licensesMap = array();
     for ($i = 0; $i < $total; $i += 100) {
         // migrate licenses in batch process
         $db->setQuery('SELECT * FROM #__' . $table, $i, 100);
         $items = $db->loadObjectList();
         foreach ($items as $item) {
             // prepare new JoomDOC3 license
             $license->id = 0;
             $license->alias = null;
             $license->state = JOOMDOC_STATE_PUBLISHED;
             // copy data from DocMAN or JoomDOC2 license into JoomDOC3
             $license->title = $item->name;
             $license->text = $item->license;
             $license->store();
             // store licenses maping for using in new JoomDOC3 documents
             $licensesMap[$item->id] = $license->id;
         }
     }
     $document = JTable::getInstance(JOOMDOC_DOCUMENT, JOOMDOC_TABLE_PREFIX);
     /* @var $document JoomDOCTableDocument */
     // convert DocMAN or JoomDOC categories into JoomDOC3 folders
     $parents = array(0 => '');
     // root of categories tree
     // do for levels of categories tree
     // store map of Joomla categories and DocMAN/JoomDOC2 documents to JoomDOC3 paths
     $categoriesMap = $documentsMap = array();
     do {
         // name of Joomla category section - identify component
         $section = $db->quote($component == 'docman' ? 'com_docman' : 'com_joomdoc');
         $parentsIds = implode(', ', array_keys($parents));
         // load total of DocMAN or JoomDOC2 categories in one level of categories tree
         if ($component == 'docman' && in_array($pr . 'docman_categories', $joomla)) {
             // since DocMAN 1.5
             $db->setQuery('SELECT COUNT(*) FROM #__docman_categories WHERE parent_id IN (' . $parentsIds . ')');
         } else {
             $db->setQuery('SELECT COUNT(*) FROM #__categories WHERE section = ' . $section . ' AND parent_id IN (' . $parentsIds . ')');
         }
         try {
             $total = $db->loadResult();
         } catch (Exception $e) {
             // new format of table jos_categories without section column
             $c = $db->replacePrefix('#__categories');
             $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_MIGRATION_OLD_CATEGORIES', $c, $c, $c, $c), 'notice');
             return;
         }
         $nextLevel = isset($nextLevel) ? array() : array(0 => '');
         // in the first batch process uncategorized documents
         for ($i = 0; $i < $total; $i += 100) {
             // load DocMAN or JoomDOC2 categories tree level full node list in batch process
             if ($component == 'docman' && in_array($pr . 'docman_categories', $joomla)) {
                 // since DocMAN 1.5
                 $db->setQuery('SELECT id, title, parent_id, description, published, ordering, access FROM #__docman_categories WHERE parent_id IN (' . $parentsIds . ')', $i, 100);
             } else {
                 $db->setQuery('SELECT id, title, parent_id, description, published, ordering, access FROM #__categories WHERE section = ' . $section . ' AND parent_id IN (' . $parentsIds . ')', $i, 100);
             }
             $children = $db->loadObjectList('id');
             foreach ($children as $id => $kid) {
                 /* @var $kid JTableCategory */
                 // create folder name from category title
                 $folder = JFilterOutput::stringURLSafe($kid->title);
                 // create document for folder
                 $document->id = 0;
                 $document->parent_path = $parents[$kid->parent_id];
                 $document->path = ($document->parent_path ? $document->parent_path . DIRECTORY_SEPARATOR : '') . $folder;
                 // copy data form category into document
                 $document->title = $kid->title;
                 $document->alias = null;
                 $document->description = $kid->description;
                 $document->state = $kid->published == JOOMDOC_STATE_PUBLISHED ? JOOMDOC_STATE_PUBLISHED : JOOMDOC_STATE_UNPUBLISHED;
                 $document->ordering = $kid->ordering;
                 $document->access = $kid->access ? $kid->access : 1;
                 if (!JFolder::exists(JoomDOCFileSystem::getFullPath($document->path))) {
                     // create folder only if doesn't exists
                     JoomDOCFileSystem::newFolder($document->parent_path, $folder, false, false);
                 } else {
                     // folder exist, search last exists document
                     $db->setQuery('SELECT id FROM #__joomdoc WHERE path = ' . $db->Quote($document->path) . ' ORDER BY version DESC');
                     $document->id = $db->loadResult();
                 }
                 if (JFolder::exists(JoomDOCFileSystem::getFullPath($document->path))) {
                     if ($document->store(false, false)) {
                         $newFolders++;
                         // current kid will be in parents for next level of categories tree
                         $nextLevel[$id] = $document->path;
                         $categoriesMap[$kid->id] = $document->path;
                     }
                 }
             }
         }
         // next level parents
         $parents = $nextLevel;
         if (count($parents)) {
             /* Convert DocMAN or JoomDOC2 categories documents into JoomDOC3 files in folder */
             $table = $component == 'docman' ? 'docman' : 'joomdoc2';
             $parentsIds = implode(', ', array_keys($parents));
             // load total of DocMAN or JoomDOC2 documents for categories in current level
             $db->setQuery('SELECT COUNT(*) FROM #__' . $table . ' WHERE catid IN (' . $parentsIds . ')');
             $total = $db->loadResult();
             // DocMAN or JoomDOC2 documents from categories in current tree level - batch process
             for ($i = 0; $i < $total; $i += 100) {
                 $db->setQuery('SELECT * FROM #__' . $table . ' WHERE catid IN (' . $parentsIds . ')', $i, 100);
                 $items = $db->loadObjectList();
                 foreach ($items as $item) {
                     // create document for successfully uploaded file
                     $document->id = 0;
                     $document->parent_path = $parents[$item->catid];
                     $document->path = $document->parent_path . DIRECTORY_SEPARATOR . $item->dmfilename;
                     // copy data from DocMAN or JoomDOC2 document into JoomDOC3 document
                     $document->title = $item->dmname;
                     $document->alias = null;
                     $document->description = $item->dmdescription;
                     $document->publish_up = $item->dmdate_published;
                     $document->created_by = $item->dmsubmitedby;
                     $document->state = $item->published == JOOMDOC_STATE_PUBLISHED ? JOOMDOC_STATE_PUBLISHED : JOOMDOC_STATE_UNPUBLISHED;
                     $document->modified = $item->dmlastupdateon;
                     $document->modified_by = $item->dmlastupdateby;
                     $document->access = $item->access ? $item->access : 1;
                     $document->license = isset($licensesMap[$item->dmlicense_id]) ? $licensesMap[$item->dmlicense_id] : 0;
                     if (JFile::exists(JoomDOCFileSystem::getFullPath($document->path))) {
                         // if file exists search for last document
                         $db->setQuery('SELECT id FROM #__joomdoc WHERE path = ' . $db->quote($document->path) . ' ORDER BY version DESC');
                         $document->id = $db->loadResult();
                     }
                     if (JoomDOCFileSystem::uploadFile(JoomDOCFileSystem::getFullPath($parents[$item->catid]), $docbase . DIRECTORY_SEPARATOR . $item->dmfilename, $item->dmfilename, true, false)) {
                         // upload into JoomDOC3 tree structure
                         if ($document->store(false, false)) {
                             $newFiles++;
                             // copy document hits into JoomDOC3 file
                             $db->setQuery('UPDATE #__joomdoc_file SET hits = ' . $item->dmcounter . ' WHERE path = ' . $db->quote($document->path));
                             $db->query();
                             $documentsMap[$item->id] = $document->path;
                         }
                     }
                 }
             }
         }
     } while (count($parents));
     // reindex at the end
     JModelLegacy::getInstance(JOOMDOC_DOCUMENTS, JOOMDOC_MODEL_PREFIX)->flat();
     /* Migrate DocMAN/JoomDOC2 URLs to JoomDOC3 in JoomSEF and Joomla tables*/
     $entities = array(array('table' => 'menu', 'html' => false, 'columns' => array('link', 'params'), 'where' => ' WHERE client_id != 1 '), array('table' => 'content', 'html' => true, 'columns' => array('introtext', '`fulltext`')), array('table' => 'modules', 'html' => true, 'columns' => array('content')), array('table' => 'sefurls', 'html' => false, 'columns' => array('origurl')));
     foreach ($entities as $entity) {
         // check if table is available
         // backup table with name eq. jos_content_joomdoc3_migration_backup
         $backup = $pr . $entity['table'] . '_joomdoc3_migration_backup';
         // check if backup already exists
         $db->setQuery('SHOW TABLES LIKE ' . $db->quote($backup));
         if ($db->loadResult() === null) {
             // create clone of backuped table
             $db->setQuery('CREATE TABLE IF NOT EXISTS ' . $backup . ' LIKE #__' . $entity['table']);
             try {
                 $db->query();
             } catch (Exception $e) {
                 continue;
                 // JoomSEF not installed
             }
             // copy data of table into backup
             $db->setQuery('INSERT INTO ' . $backup . ' SELECT * FROM #__' . $entity['table']);
             $db->query();
             // inform user about backup available
             $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_MIGRATION_BACKUPED', $pr . $entity['table'], $backup));
         }
         // get total of rows
         $db->setQuery('SELECT COUNT(*) FROM #__' . $entity['table'] . (empty($entity['where']) ? '' : $entity['where']));
         $total = $db->loadResult();
         for ($i = 0; $i < $total; $i += 500) {
             // load URLs in batch process
             $db->setQuery('SELECT id, ' . implode(', ', $entity['columns']) . ' FROM #__' . $entity['table'] . (empty($entity['where']) ? '' : $entity['where']), $i, 500);
             // load as multidimensional array
             $items = $db->loadRowList();
             foreach ($items as $item) {
                 // information if any change was made
                 $affected = false;
                 $count = count($item);
                 // process columns without id
                 for ($j = 1; $j < $count; $j++) {
                     $urls = array();
                     if ($entity['html']) {
                         // content is HTML code from editor (article, module)
                         $matches = array();
                         if (preg_match_all('/href="([^"]*)"/', $item[$j], $matches)) {
                             $urls = $matches[1];
                         }
                     } else {
                         // URL is whole content (JoomSEF, menu)
                         $urls = array($item[$j]);
                     }
                     // analyse URLs
                     foreach ($urls as $url) {
                         $uri = JFactory::getURI($url);
                         /* @var $uri JURI Joomla support for working with URLs */
                         if ($uri->getVar('option') == 'com_joomdoc' || $uri->getVar('option') == 'com_docman') {
                             // JoomDOC3 option same as JoomDOC2
                             $uri->setVar('option', 'com_joomdoc');
                             // ID of DocMAN/JoomDOC2 category or document
                             $gid = $uri->getVar('gid');
                             // unused in new URL
                             $uri->delVar('gid');
                             // analyse DocMAN/JoomDOC task value to recognise typoe of URL
                             switch ($uri->getVar('task')) {
                                 case 'cat_view':
                                     /* display DocMAN/JoomDOC2 category */
                                     $uri->setVar('view', JOOMDOC_DOCUMENTS);
                                     $uri->delVar('task');
                                     // don't use task wit wire together
                                     break;
                                 case 'doc_details':
                                     /* display DocMAN/JoomDOC2 document */
                                 /* display DocMAN/JoomDOC2 document */
                                 case 'doc_view':
                                     $uri->setVar('view', JOOMDOC_DOCUMENTS);
                                     $uri->delVar('task');
                                     // don't use task with view together
                                     break;
                                 case 'doc_download':
                                     $uri->setVar('task', JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_DOWNLOAD));
                                     break;
                                 case 'doc_edit':
                                     $uri->setVar('task', JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_EDIT));
                                     break;
                                 case 'doc_delete':
                                     $uri->setVar('task', JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_DELETE));
                                     break;
                                 default:
                                     /* URLs not supported by JoomDOC3 redirect to root */
                                     $uri->setVar('view', JOOMDOC_DOCUMENTS);
                                     break;
                             }
                             if (isset($documentsMap[$gid])) {
                                 $uri->setVar('path', $documentsMap[$gid]);
                             }
                             // menu items to open documents list store for using in next entities
                             if ($entity['table'] == 'menu' && $uri->getVar('view') == JOOMDOC_DOCUMENTS) {
                                 $registry = new JRegistry($item[2]);
                                 // load menu item configuration
                                 $registry->set('virtual_folder', 0);
                                 // disable JoomDOC3 virtual folder
                                 $item[2] = $registry->toString();
                                 /* back to database format */
                             }
                             $new = $uri->toString();
                             // back to string
                             if ($entity['html']) {
                                 // safe for valid HTML code
                                 $new = str_replace('&', '&amp;', $new);
                             }
                             // remove encoding in path added with JURI - prevent for making duplicity with JoomSEF
                             $new = str_replace('%2F', '/', $new);
                             $item[$j] = str_replace($url, $new, $item[$j]);
                             // update in data
                             // row will be updated
                             $affected = true;
                         }
                     }
                 }
                 if ($affected) {
                     $cols = array();
                     for ($j = 1; $j < $count; $j++) {
                         $cols[] = $entity['columns'][$j - 1] . ' = ' . $db->quote($item[$j]);
                     }
                     $db->setQuery('UPDATE #__' . $entity['table'] . ' SET ' . implode(', ', $cols) . ' WHERE id = ' . $item[0]);
                     $db->query();
                 }
             }
         }
     }
     // final report
     $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_MIGRATION_REPORT', $newFolders, $newFiles));
     $this->setRedirect(JoomDOCRoute::viewMigration());
 }
Пример #28
0
 public static function frontend(&$path, $alias, &$itemID)
 {
     static $isSite;
     if (is_null($isSite)) {
         $isSite = JFactory::getApplication()->isSite();
     }
     if (!$isSite) {
         return $path;
     }
     // if alias is false on site search for document alias by path
     if ($alias === false) {
         static $model;
         /* @var $model JoomDOCModelDocument */
         if (is_null($model)) {
             $model = JModelLegacy::getInstance(JOOMDOC_DOCUMENT, JOOMDOC_MODEL_PREFIX);
         }
         $alias = $model->searchFullAliasByPath($path);
     }
     $itemID = JoomDOCMenu::getMenuItemID($path);
     $path = $alias ? $alias : $path;
     $path = JoomDOCFileSystem::getVirtualPath($path);
 }
Пример #29
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>';
Пример #30
0
JLoader::register('JoomDOCFolder', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/filesystem/folder.php');
JLoader::register('JoomDOCFile', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/filesystem/file.php');
JLoader::register('JoomDOCAccessHelper', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/access/helper.php');
JLoader::register('JoomDOCHelper', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/utilities/helper.php');
JLoader::register('JoomDOCAccessFileSystem', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/access/filesystem.php');
JLoader::register('JoomDOCAccess', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/access/joomdoc.php');
JLoader::register('JoomDOCAccessDocument', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/access/document.php');
JLoader::register('JHtmlJoomDOC', JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/html/joomdoc.php');
// Paths to load JoomDOC core classes (model, tables) sets.
JModelLegacy::addIncludePath(JOOMDOC_MODELS);
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 = JoomDOCModuleConfig::getInstance($params, $module->id);
$globalConfig = JoomDOCConfig::getInstance();
$modelDocuments = JModelLegacy::getInstance(JOOMDOC_DOCUMENTS, JOOMDOC_MODEL_SITE_PREFIX);
/* @var $modelDocuments JoomDOCSiteModelDocuments */
$listFields = $modelDocuments->getListFields();
// Only files are loaded.
$root = JoomDOCFileSystem::getFolderContent($moduleConfig->parent ? JoomDOCFileSystem::getFullPath($moduleConfig->parent) : $globalConfig->docroot, '', true, false, true);
// 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($moduleConfig->documentOrdering, $moduleConfig->fileOrdering, JOOMDOC_ORDER_DESC, 0, $moduleConfig->limit, $moduleConfig->limit);
// Active module template displayed.
require JModuleHelper::getLayoutPath('mod_joomdoc', $moduleConfig->layout);