Beispiel #1
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 . '/' : '');
 }
 /**
  * @test
  * @group integration
  */
 public function storageUsesInjectedFilemountsToCheckForMountBoundaries()
 {
     $mockedFile = $this->getSimpleFileMock('/mountFolder/file');
     $this->addToMount(array('mountFolder' => array('file' => 'asdfg')));
     $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), NULL, NULL);
     $this->initializeVfs();
     $this->prepareFixture(array(), NULL, $mockedDriver);
     $this->fixture->injectFileMount('/mountFolder');
     $this->assertEquals(1, count($this->fixture->getFileMounts()));
     $this->fixture->isWithinFileMountBoundaries($mockedFile);
 }
 /**
  * @test
  * @group integration
  * @TODO: Rewrite or move to functional suite
  */
 public function storageUsesInjectedFilemountsToCheckForMountBoundaries()
 {
     $this->markTestSkipped('This test does way to much and is mocked incomplete. Skipped for now.');
     $mockedFile = $this->getSimpleFileMock('/mountFolder/file');
     $this->addToMount(array('mountFolder' => array('file' => 'asdfg')));
     $mockedDriver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), null, null);
     $this->initializeVfs();
     $this->prepareSubject(array(), null, $mockedDriver);
     $this->subject->addFileMount('/mountFolder');
     $this->assertEquals(1, count($this->subject->getFileMounts()));
     $this->subject->isWithinFileMountBoundaries($mockedFile);
 }
Beispiel #4
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);
         }
     }
 }
Beispiel #5
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);
         }
     }
 }
Beispiel #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 (!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);
         }
     }
 }