Exemple #1
0
 /**
  * @return void
  */
 public function processChangesInStorages()
 {
     // get all file-identifiers from the storage
     $availableFiles = $this->storage->getFileIdentifiersInFolder($this->storage->getRootLevelFolder()->getIdentifier(), TRUE, TRUE);
     $this->detectChangedFilesInStorage($availableFiles);
     $this->processChangedAndNewFiles();
     $this->detectMissingFiles();
 }
Exemple #2
0
 /**
  * Returns the full path of this folder, from the root.
  *
  * @param string $rootId ID of the root folder, NULL to auto-detect
  *
  * @return string
  */
 public function getReadablePath($rootId = null)
 {
     if ($rootId === null) {
         // Find first matching filemount and use that as root
         foreach ($this->storage->getFileMounts() as $fileMount) {
             if ($this->storage->isWithinFolder($fileMount['folder'], $this)) {
                 $rootId = $fileMount['folder']->getIdentifier();
                 break;
             }
         }
         if ($rootId === null) {
             $rootId = $this->storage->getRootLevelFolder()->getIdentifier();
         }
     }
     $readablePath = '/';
     if ($this->identifier !== $rootId) {
         try {
             $readablePath = $this->getParentFolder()->getReadablePath($rootId);
         } catch (Exception\InsufficientFolderAccessPermissionsException $e) {
             // May no access to parent folder (e.g. because of mount point)
             $readablePath = '/';
         }
     }
     return $readablePath . ($this->name ? $this->name . '/' : '');
 }
Exemple #3
0
	/**
	 * Returns the full path of this folder, from the root.
	 *
	 * @param string $rootId ID of the root folder, NULL to auto-detect
	 *
	 * @return string
	 */
	public function getReadablePath($rootId = NULL) {
		$oldPermissionFlag = $this->getStorage()->getEvaluatePermissions();
		$this->getStorage()->setEvaluatePermissions(FALSE);
		if ($rootId === NULL) {
			$rootId = $this->storage->getRootLevelFolder(FALSE)->getIdentifier();
		}
		$readablePath = '';
		if ($this->identifier !== $rootId) {
			$readablePath = $this->getParentFolder()->getReadablePath($rootId);
		}
		$this->getStorage()->setEvaluatePermissions($oldPermissionFlag);
		return $readablePath . $this->name . '/';
	}
Exemple #4
0
 /**
  * Returns the full path of this folder, from the root.
  *
  * @param string $rootId ID of the root folder, NULL to auto-detect
  *
  * @return string
  */
 public function getReadablePath($rootId = null)
 {
     if ($rootId === null) {
         $rootId = $this->storage->getRootLevelFolder()->getIdentifier();
     }
     $readablePath = '/';
     if ($this->identifier !== $rootId) {
         try {
             $readablePath = $this->getParentFolder()->getReadablePath($rootId);
         } catch (Exception\InsufficientFolderAccessPermissionsException $e) {
             // May no access to parent folder (e.g. because of mount point)
             $readablePath = '/';
         }
     }
     return $readablePath . ($this->name ? $this->name . '/' : '');
 }
 /**
  * Ensures a new folder "fileadmin/content_upload/" is available.
  *
  * @return void
  */
 protected function checkPrerequisites()
 {
     if (!$this->storage->hasFolder(self::FOLDER_ContentUploads)) {
         $this->storage->createFolder(self::FOLDER_ContentUploads, $this->storage->getRootLevelFolder());
     }
 }
Exemple #6
0
 /**
  * Get a tree for one storage
  *
  * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
  * @return void
  */
 public function getBrowseableTreeForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject)
 {
     // If there are filemounts, show each, otherwise just the rootlevel folder
     $fileMounts = $storageObject->getFileMounts();
     $rootLevelFolders = array();
     if (count($fileMounts)) {
         foreach ($fileMounts as $fileMountInfo) {
             $rootLevelFolders[] = array('folder' => $fileMountInfo['folder'], 'name' => $fileMountInfo['title']);
         }
     } elseif ($this->BE_USER->isAdmin()) {
         $rootLevelFolders[] = array('folder' => $storageObject->getRootLevelFolder(), 'name' => $storageObject->getName());
     }
     // Clean the tree
     $this->reset();
     // Go through all "root level folders" of this tree (can be the rootlevel folder or any file mount points)
     foreach ($rootLevelFolders as $rootLevelFolderInfo) {
         /** @var $rootLevelFolder \TYPO3\CMS\Core\Resource\Folder */
         $rootLevelFolder = $rootLevelFolderInfo['folder'];
         $rootLevelFolderName = $rootLevelFolderInfo['name'];
         $folderHashSpecUID = GeneralUtility::md5int($rootLevelFolder->getCombinedIdentifier());
         $this->specUIDmap[$folderHashSpecUID] = $rootLevelFolder->getCombinedIdentifier();
         // Hash key
         $storageHashNumber = $this->getShortHashNumberForStorage($storageObject, $rootLevelFolder);
         // Set first:
         $this->bank = $storageHashNumber;
         $isOpen = $this->stored[$storageHashNumber][$folderHashSpecUID] || $this->expandFirst;
         // Set PM icon:
         $cmd = $this->generateExpandCollapseParameter($this->bank, !$isOpen, $rootLevelFolder);
         if (!$storageObject->isBrowsable() || $this->getNumberOfSubfolders($rootLevelFolder) === 0) {
             $rootIcon = 'blank';
         } elseif (!$isOpen) {
             $rootIcon = 'plusonly';
         } else {
             $rootIcon = 'minusonly';
         }
         $icon = '<img' . IconUtility::skinImg($this->backPath, 'gfx/ol/' . $rootIcon . '.gif') . ' alt="" />';
         // Only link icon if storage is browseable
         if (in_array($rootIcon, array('minusonly', 'plusonly'))) {
             $firstHtml = $this->PM_ATagWrap($icon, $cmd);
         } else {
             $firstHtml = $icon;
         }
         // Mark a storage which is not online, as offline
         // maybe someday there will be a special icon for this
         if ($storageObject->isOnline() === FALSE) {
             $rootLevelFolderName .= ' (' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file.xlf:sys_file_storage.isOffline') . ')';
         }
         // Preparing rootRec for the mount
         $firstHtml .= $this->wrapIcon(IconUtility::getSpriteIconForResource($rootLevelFolder, array('mount-root' => TRUE)), $rootLevelFolder);
         $row = array('uid' => $folderHashSpecUID, 'title' => $rootLevelFolderName, 'path' => $rootLevelFolder->getCombinedIdentifier(), 'folder' => $rootLevelFolder);
         // Add the storage root to ->tree
         $this->tree[] = array('HTML' => $firstHtml, 'row' => $row, 'bank' => $this->bank, 'hasSub' => $isOpen && $storageObject->isBrowsable());
         // If the mount is expanded, go down:
         if ($isOpen && $storageObject->isBrowsable()) {
             // Set depth:
             $this->getFolderTree($rootLevelFolder, 999);
         }
     }
 }
Exemple #7
0
 /**
  * Get a tree for one storage
  *
  * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
  * @return void
  */
 public function getBrowseableTreeForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject)
 {
     // If there are filemounts, show each, otherwise just the rootlevel folder
     $fileMounts = $storageObject->getFileMounts();
     $rootLevelFolders = array();
     if (!empty($fileMounts)) {
         foreach ($fileMounts as $fileMountInfo) {
             $rootLevelFolders[] = array('folder' => $fileMountInfo['folder'], 'name' => $fileMountInfo['title']);
         }
     } elseif ($this->BE_USER->isAdmin()) {
         $rootLevelFolders[] = array('folder' => $storageObject->getRootLevelFolder(), 'name' => $storageObject->getName());
     }
     // Clean the tree
     $this->reset();
     // Go through all "root level folders" of this tree (can be the rootlevel folder or any file mount points)
     foreach ($rootLevelFolders as $rootLevelFolderInfo) {
         /** @var $rootLevelFolder \TYPO3\CMS\Core\Resource\Folder */
         $rootLevelFolder = $rootLevelFolderInfo['folder'];
         $rootLevelFolderName = $rootLevelFolderInfo['name'];
         $folderHashSpecUID = GeneralUtility::md5int($rootLevelFolder->getCombinedIdentifier());
         $this->specUIDmap[$folderHashSpecUID] = $rootLevelFolder->getCombinedIdentifier();
         // Hash key
         $storageHashNumber = $this->getShortHashNumberForStorage($storageObject, $rootLevelFolder);
         // Set first:
         $this->bank = $storageHashNumber;
         $isOpen = $this->stored[$storageHashNumber][$folderHashSpecUID] || $this->expandFirst;
         // Set PM icon:
         $cmd = $this->generateExpandCollapseParameter($this->bank, !$isOpen, $rootLevelFolder);
         // Only show and link icon if storage is browseable
         if (!$storageObject->isBrowsable() || $this->getNumberOfSubfolders($rootLevelFolder) === 0) {
             $firstHtml = '';
         } else {
             $firstHtml = $this->renderPMIconAndLink($cmd, $isOpen);
         }
         // Mark a storage which is not online, as offline
         // maybe someday there will be a special icon for this
         if ($storageObject->isOnline() === false) {
             $rootLevelFolderName .= ' (' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file.xlf:sys_file_storage.isOffline') . ')';
         }
         // Preparing rootRec for the mount
         $icon = $this->iconFactory->getIconForResource($rootLevelFolder, Icon::SIZE_SMALL, null, array('mount-root' => true));
         $firstHtml .= $this->wrapIcon($icon, $rootLevelFolder);
         $row = array('uid' => $folderHashSpecUID, 'title' => $rootLevelFolderName, 'path' => $rootLevelFolder->getCombinedIdentifier(), 'folder' => $rootLevelFolder);
         // Add the storage root to ->tree
         $this->tree[] = array('HTML' => $firstHtml, 'row' => $row, 'bank' => $this->bank, 'hasSub' => $isOpen && $storageObject->isBrowsable(), 'invertedDepth' => 1000);
         // If the mount is expanded, go down:
         if ($isOpen && $storageObject->isBrowsable()) {
             // Set depth:
             $this->getFolderTree($rootLevelFolder, 999);
         }
     }
 }
 /**
  * Get a tree for one storage
  *
  * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
  * @return void
  */
 public function getBrowseableTreeForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject)
 {
     // If there are filemounts, show each, otherwise just the rootlevel folder
     $fileMounts = $storageObject->getFileMounts();
     $rootLevelFolders = array();
     if (!empty($fileMounts)) {
         foreach ($fileMounts as $fileMountInfo) {
             $rootLevelFolders[] = array('folder' => $fileMountInfo['folder'], 'name' => $fileMountInfo['title']);
         }
     } elseif ($this->BE_USER->isAdmin()) {
         $rootLevelFolders[] = array('folder' => $storageObject->getRootLevelFolder(), 'name' => $storageObject->getName());
     }
     // Clean the tree
     $this->reset();
     // Go through all "root level folders" of this tree (can be the rootlevel folder or any file mount points)
     foreach ($rootLevelFolders as $rootLevelFolderInfo) {
         /** @var $rootLevelFolder \TYPO3\CMS\Core\Resource\Folder */
         $rootLevelFolder = $rootLevelFolderInfo['folder'];
         $rootLevelFolderName = $rootLevelFolderInfo['name'];
         $folderHashSpecUID = GeneralUtility::md5int($rootLevelFolder->getCombinedIdentifier());
         $this->specUIDmap[$folderHashSpecUID] = $rootLevelFolder->getCombinedIdentifier();
         // Hash key
         $storageHashNumber = $this->getShortHashNumberForStorage($storageObject, $rootLevelFolder);
         // Set first:
         $this->bank = $storageHashNumber;
         $isOpen = $this->stored[$storageHashNumber][$folderHashSpecUID] || $this->expandFirst;
         // Set PM icon:
         $cmd = $this->generateExpandCollapseParameter($this->bank, !$isOpen, $rootLevelFolder);
         if (!$storageObject->isBrowsable() || $this->getNumberOfSubfolders($rootLevelFolder) === 0) {
             $firstHtml = '';
         } else {
             // Only show and link icon if storage is browseable
             $link = '';
             if ($this->thisScript) {
                 $link = ' href="' . htmlspecialchars($this->getThisScript() . 'PM=' . $cmd) . '"';
             }
             $firstHtml = '<a class="list-tree-control list-tree-control-' . ($isOpen ? 'open' : 'closed') . '"' . $link . '><i class="fa"></i></a>';
         }
         // Mark a storage which is not online, as offline
         // maybe someday there will be a special icon for this
         if ($storageObject->isOnline() === FALSE) {
             $rootLevelFolderName .= ' (' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_file.xlf:sys_file_storage.isOffline') . ')';
         }
         // Preparing rootRec for the mount
         $firstHtml .= $this->wrapIcon(IconUtility::getSpriteIconForResource($rootLevelFolder, array('mount-root' => TRUE)), $rootLevelFolder);
         $row = array('uid' => $folderHashSpecUID, 'title' => $rootLevelFolderName, 'path' => $rootLevelFolder->getCombinedIdentifier(), 'folder' => $rootLevelFolder);
         // Add the storage root to ->tree
         $this->tree[] = array('HTML' => $firstHtml, 'row' => $row, 'bank' => $this->bank, 'hasSub' => $isOpen && $storageObject->isBrowsable());
         // If the mount is expanded, go down:
         if ($isOpen && $storageObject->isBrowsable()) {
             // Set depth:
             $this->getFolderTree($rootLevelFolder, 999);
         }
     }
 }
 /**
  * Ensures a new folder "fileadmin/content_upload/" is available.
  *
  * @return void
  */
 protected function checkPrerequisites()
 {
     if (!$this->storage->hasFolder(self::FILE_MIGRATION_FOLDER)) {
         $this->storage->createFolder(self::FILE_MIGRATION_FOLDER, $this->storage->getRootLevelFolder());
     }
 }
Exemple #10
0
 /**
  * Return a new target folder when moving file from one storage to another.
  *
  * @param ResourceStorage $storage
  * @param File $file
  * @return \TYPO3\CMS\Core\Resource\Folder
  */
 public function getDefaultFolderInStorage(ResourceStorage $storage, File $file)
 {
     // default is the root level
     $folder = $storage->getRootLevelFolder();
     // Retrieve storage record and a possible configured mount point.
     $storageRecord = $storage->getStorageRecord();
     $mountPointIdentifier = $storageRecord['mount_point_file_type_' . $file->getType()];
     if ($mountPointIdentifier > 0) {
         // We don't have a Mount Point repository in FAL, so query the database directly.
         $record = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('path', 'sys_filemounts', 'deleted = 0 AND uid = ' . $mountPointIdentifier);
         if (!empty($record['path'])) {
             $folder = $storage->getFolder($record['path']);
         }
     }
     return $folder;
 }
 /**
  * Ensures a new folder "fileadmin/content_upload/" is available.
  *
  * @return void
  */
 protected function checkPrerequisites()
 {
     if (!$this->storage->hasFolder(\TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads)) {
         $this->storage->createFolder(\TYPO3\CMS\Install\Updates\TtContentUploadsUpdateWizard::FOLDER_ContentUploads, $this->storage->getRootLevelFolder());
     }
 }