Esempio n. 1
0
 /**
  * Reset operation from clipboard.
  */
 public function reset()
 {
     JoomDOCFileSystem::resetOperation();
     $this->setRedirect(JoomDOCRoute::viewDocuments());
 }
Esempio n. 2
0
 public static function copyMove($move = false)
 {
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     $tableFile = JTable::getInstance(JOOMDOC_FILE, JOOMDOC_TABLE_PREFIX);
     /* @var $tableFile JoomDOCTableFile */
     // current folder copy into
     $folder = JoomDOCRequest::getPath();
     $folderAbsolutePath = JoomDOCFileSystem::getFullPath($folder);
     // current folder acces
     $folderCanCreateSubfolders = JoomDOCAccessFileSystem::newFolder(false, $folder);
     $folderCanUploadFiles = JoomDOCAccessFileSystem::uploadFile(false, $folder);
     // items to copy
     $paths = JoomDOCFileSystem::getOperationPaths();
     foreach ($paths as $path) {
         $absolutePath = JoomDOCFileSystem::getFullPath($path);
         $parent = JoomDOCFileSystem::getParentPath($absolutePath);
         $parentLength = JString::strlen($parent);
         $items = array($absolutePath);
         if (JFolder::exists($absolutePath)) {
             if (!$folderCanCreateSubfolders) {
                 // copied/moved item is folder and current folder aren't allowed to create subfolders
                 $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE_SUBFOLDERS', $folder, $path), 'notice');
                 continue;
             }
             // unable copy/move folder into own subfolder
             if (JoomDOCFileSystem::isSubFolder($folderAbsolutePath, $absolutePath)) {
                 $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE_INTO_SELF', $folder, $path), 'notice');
                 continue;
             }
             $items = array_merge($items, JFolder::folders($absolutePath, '', true, true, array('.svn', 'CVS', '.DS_Store', '__MACOSX', JOOMDOC_VERSION_DIR)));
             $items = array_merge($items, JFolder::files($absolutePath, '', true, true));
         } elseif (!JFile::exists($absolutePath)) {
             continue;
         }
         foreach ($items as $item) {
             $itemRelativePath = JoomDOCFileSystem::getRelativePath($item);
             if (!JoomDOCAccessFileSystem::copyMove(false, $itemRelativePath)) {
                 $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE', $itemRelativePath), 'notice');
                 continue;
             }
             // get relative path from copied path parent
             $relativePath = JString::substr($item, $parentLength);
             // destination is current folder + relative path
             $destination = $folderAbsolutePath . $relativePath;
             $destinationRelativePath = JoomDOCFileSystem::getRelativePath($destination);
             if (JFolder::exists($item)) {
                 // is folder only create
                 if (JFolder::exists($destination)) {
                     $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_FOLDER_EXISTS', $destinationRelativePath), 'notice');
                     continue;
                 }
                 JFolder::create($destination);
             }
             if (JFile::exists($item)) {
                 if (!$folderCanUploadFiles) {
                     // copied/moved item is file or contain files and current folder aren't allowed to upload files
                     $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_UNABLE_UPLOAD', $itemRelativePath, $folder), 'notice');
                     continue;
                 }
                 if (JFile::exists($destination)) {
                     $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_CPMV_FILE_EXISTS', $destinationRelativePath), 'notice');
                     continue;
                 }
                 JFile::copy($item, $destination);
                 // get file versions
             }
             // copy/move table rows
             $tableFile->copyMove($itemRelativePath, $destinationRelativePath, $move);
         }
         if ($move) {
             // move item delete source after copy
             JoomDOCFileSystem::deleteItem($absolutePath);
         }
     }
     JoomDOCFileSystem::resetOperation();
 }
Esempio n. 3
0
 /**
  * Reset operation from clipboard.
  */
 public function reset()
 {
     JoomDOCFileSystem::resetOperation();
     $this->setRedirect(JoomDOCRoute::viewDocuments(JoomDOCRequest::getPath(), false));
 }