diff --git a/typo3/sysext/filelist/Classes/Controller/FileListController.php b/typo3/sysext/filelist/Classes/Controller/FileListController.php index dd708d82410f987abb477929adb54edc56348bb3..2e67c0279b704ed8bc01d2a91f429dbfa15da5d2 100644 --- a/typo3/sysext/filelist/Classes/Controller/FileListController.php +++ b/typo3/sysext/filelist/Classes/Controller/FileListController.php @@ -51,7 +51,7 @@ class FileListController { /* @var \TYPO3\CMS\Core\Resource\Folder $folderObject */ protected $folderObject; - /* @var t3lib_FlashMessage $errorMessage */ + /* @var \TYPO3\CMS\Core\Messaging\FlashMessage $errorMessage */ protected $errorMessage; // Pointer to listing @@ -99,32 +99,45 @@ class FileListController { $this->overwriteExistingFiles = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('overwriteExistingFiles'); // Setting module name: $this->MCONF = $GLOBALS['MCONF']; - // Create the folder object - try { - if ($combinedIdentifier) { - $fileFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory'); - $this->folderObject = $fileFactory->getFolderObjectFromCombinedIdentifier($combinedIdentifier); - // Disallow the rendering of the processing folder (e.g. could be called manually) - // and all folders without any defined storage - if ($this->folderObject && ($this->folderObject->getStorage()->getUid() == 0 || trim($this->folderObject->getStorage()->getProcessingFolder()->getIdentifier(), '/') == trim($this->folderObject->getIdentifier(), '/'))) { - $this->folderObject = NULL; - } - } else { - // Take the first object of the first storage - $fileStorages = $GLOBALS['BE_USER']->getFileStorages(); - $fileStorage = reset($fileStorages); - if ($fileStorage) { - // Validating the input "id" (the path, directory!) and - // checking it against the mounts of the user. - now done in the controller - $this->folderObject = $fileStorage->getRootLevelFolder(); + // Create the folder object, even try parent folders + while ($this->folderObject === NULL && count(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('/', $combinedIdentifier, TRUE)) > 1) { + try { + if ($combinedIdentifier) { + $fileFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory'); + $this->folderObject = $fileFactory->getFolderObjectFromCombinedIdentifier($combinedIdentifier); + // Disallow the rendering of the processing folder (e.g. could be called manually) + // and all folders without any defined storage + if ($this->folderObject && ($this->folderObject->getStorage()->getUid() == 0 || trim($this->folderObject->getStorage()->getProcessingFolder()->getIdentifier(), '/') == trim($this->folderObject->getIdentifier(), '/'))) { + $this->folderObject = NULL; + } } else { - $this->folderObject = NULL; + // Take the first object of the first storage + $fileStorages = $GLOBALS['BE_USER']->getFileStorages(); + $fileStorage = reset($fileStorages); + if ($fileStorage) { + // Validating the input "id" (the path, directory!) and + // checking it against the mounts of the user. - now done in the controller + $this->folderObject = $fileStorage->getRootLevelFolder(); + } else { + $this->folderObject = NULL; + } } + } catch (\TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException $fileException) { + // Set folder object to null and throw a message later on + $this->folderObject = NULL; + if ($this->id == $combinedIdentifier) { + $this->errorMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', + sprintf($GLOBALS['LANG']->getLL('folderNotFoundMessage', TRUE), + htmlspecialchars($this->id) + ), + $GLOBALS['LANG']->getLL('folderNotFoundTitle', TRUE), + \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE); + } + + $combinedIdentifierParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('/', $combinedIdentifier, TRUE); + array_pop($combinedIdentifierParts); + $combinedIdentifier = implode('/', $combinedIdentifierParts) . '/'; } - } catch (\TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException $fileException) { - // Set folder object to null and throw a message later on - $this->folderObject = NULL; - $this->errorMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('folderNotFoundMessage', TRUE), htmlspecialchars($this->id)), $GLOBALS['LANG']->getLL('folderNotFoundTitle', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc. $this->menuConfig(); @@ -354,7 +367,7 @@ class FileListController { $markerArray = array( 'CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), - 'CONTENT' => $pageContent + 'CONTENT' => ($this->errorMessage ? $this->errorMessage->render() : '') . $pageContent ); $this->content = $this->doc->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers)); // Renders the module page @@ -362,6 +375,7 @@ class FileListController { } else { $content = ''; if ($this->errorMessage) { + $this->errorMessage->setSeverity(\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); $content = $this->doc->moduleBody(array(), array_merge(array('LEVEL_UP' => '', 'REFRESH' => ''), $this->getButtons()), array('CSH' => '', 'TITLE' => '', 'FOLDER_INFO' => '', 'PAGE_ICON' => '', 'FUNC_MENU' => '', 'CONTENT' => $this->errorMessage->render())); } // Create output - no access (no warning though) @@ -412,4 +426,4 @@ class FileListController { } -?> \ No newline at end of file +?> diff --git a/typo3/sysext/lang/locallang_mod_file_list.xlf b/typo3/sysext/lang/locallang_mod_file_list.xlf index 02c2bf4af739ca30f2729e7455bcb98d2f2f6c8f..6e247083dd72d5b7e3ce48e0bcb4d8dbe3acf4f9 100644 --- a/typo3/sysext/lang/locallang_mod_file_list.xlf +++ b/typo3/sysext/lang/locallang_mod_file_list.xlf @@ -97,10 +97,10 @@ <source>You are trying to access a folder in a storage that is not browsable.</source> </trans-unit> <trans-unit id="folderNotFoundTitle" xml:space="preserve"> - <source>Folder access denied.</source> + <source>Folder not found.</source> </trans-unit> <trans-unit id="folderNotFoundMessage" xml:space="preserve"> - <source>The folder "%s" cannot be accessed.</source> + <source>The folder "%s" cannot be accessed. Trying to use parent folder(s).</source> </trans-unit> </body> </file>