Exemplo n.º 1
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'));
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 /**
  * Do copy/move into current folder.
  */
 public function paste()
 {
     JoomDOCFileSystem::doOperation();
     //display "added X files/folders" only if not 0
     $this->setRedirect(JoomDOCRoute::viewDocuments(), ($refreshed = JoomDOCFileSystem::refresh()) > 1 ? JText::sprintf('JOOMDOC_REFRESHED', $refreshed) : null);
 }