Example #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);
 }
Example #2
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'));
     }
 }
Example #3
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":""}');
     }
 }
Example #4
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);
 }
Example #5
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;
    }
Example #6
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;
 }
Example #7
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 JoomDOCViewFile */
jimport('joomla.html.pagination');
JHtml::_('behavior.modal');
$config = JoomDOCConfig::getInstance();
$showDownload = JoomDOCAccessFileSystem::download($this->document ? $this->document->id : null, $this->filter->path);
// texts translations
$download = JText::_('JOOMDOC_DOWNLOAD_FILE');
$content = JText::_('JOOMDOC_FILE_CONTENT');
$trashed = JText::_('JTRASHED');
//var_dump($this->filter->state);
echo '<form name="adminForm" id="adminForm" action="' . JURI::getInstance()->toString() . '" method="post">';
//Joomla 3.0 display sidemenu manually
if (JOOMDOC_ISJ3) {
    $options = array();
    $options[0] = JText::_('JOOMDOC_FILE_PUBLISHED_TRASHED');
    $options[JOOMDOC_STATE_PUBLISHED] = JText::_('JOOMDOC_FILE_PUBLISHED');
    $options[JOOMDOC_STATE_TRASHED] = JText::_('JOOMDOC_FILE_TRASHED');
    JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'state', JHtml::_('select.options', $options, 'value', 'text', $this->filter->state, true));
    echo '<div id="j-sidebar-nav" class="span2">';
    //render sidebar
Example #8
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);
     }
 }
Example #9
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);
 }