コード例 #1
0
ファイル: filesystem.php プロジェクト: abdullah929/bulletin
 /**
  * Get one level folder list exploded to the some folder.
  *
  * @param string $absolutePath absolute folder path
  * @param string $filter filter folder/file name
  * @param boolean $recurse use recursive folder scaning (in subfolders), default false (ignore subitems)
  * @param string $exploded exploded node in tree
  * @return array folder absolute path list
  */
 public static function getExplodedFolders($absolutePath, $filter, $recurse, $exploded)
 {
     $folders = JFolder::folders($absolutePath, $filter . '.', $recurse, true);
     // default folder level
     $crumbs = JoomDOCFileSystem::getPathBreadCrumbs($exploded, true);
     // crumbs to the exploded folder
     while (!empty($crumbs)) {
         // add all crumbs are in the folder list
         foreach ($folders as $l => $folder) {
             if (JString::strpos($folder, JOOMDOC_VERSION_DIR) === false) {
                 if (in_array($folder, $crumbs)) {
                     // expand to the depth
                     $children = JFolder::folders($folder, $filter . '.', $recurse, true);
                     if (!empty($children)) {
                         // append next level after crumb
                         $head = array_slice($folders, 0, $l + 1);
                         $tail = array_slice($folders, $l + 1);
                         $folders = array_merge($head, $children, $tail);
                     }
                     unset($crumbs[array_search($folder, $crumbs)]);
                     // crumb satisfied
                 }
             }
         }
     }
     $folders = array_unique($folders);
     return $folders;
 }
コード例 #2
0
ファイル: joomdoc.php プロジェクト: abdullah929/bulletin
    /**
     * 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;
    }
コード例 #3
0
ファイル: default.php プロジェクト: abdullah929/bulletin
}
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) {
コード例 #4
0
ファイル: modal.php プロジェクト: abdullah929/bulletin
 * @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) {