Beispiel #1
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;
 }
Beispiel #2
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);
     }
 }