diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index 071744be94281e8884fdc76d132bbef8f3da207c..2cdcde9298a0068422a78f53e1e6d96157df2c7e 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -4932,7 +4932,7 @@ parameters: - message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface\\:\\:getReadablePath\\(\\)\\.$#" - count: 2 + count: 3 path: ../../typo3/sysext/recordlist/Classes/Browser/FileBrowser.php - diff --git a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php index 30b14a5848687f31a95e7d0b23ef1cec1c7f478f..dd38d928ae2094ce843c2fe9dcb4bf44e767c51b 100644 --- a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php @@ -233,8 +233,33 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf $extensionList = !empty($extensionList) && $extensionList[0] === '*' ? [] : $extensionList; $files = $this->getFilesInFolder($folder, $extensionList); } - if (empty($files)) { - return $header . '<div class="shadow-sm bg-info bg-gradient p-3 mb-4 mt-4">' . sprintf(htmlspecialchars($lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang_browse_links.xlf:no_files')), $folder->getStorage()->getName() . ':' . $folder->getReadablePath()) . '</div>'; + + // Prepare search box, since the component should always be displayed, even if no files are available + $searchBox = GeneralUtility::makeInstance(RecordSearchBoxComponent::class) + ->setSearchWord($this->searchWord) + ->render($this->getScriptUrl() . HttpUtility::buildQueryString($this->getUrlParameters([]), '&')); + $searchBox = '<div class="mt-4 mb-4">' . $searchBox . '</div>'; + + if (!count($files)) { + // No files found. Either due to an active search or simply because the folder is empty. + if ($this->searchWord !== '') { + $message = sprintf( + $lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang_browse_links.xlf:no_files_search'), + $folder->getStorage()->getName() . ':' . $folder->getReadablePath(), + $this->searchWord + ); + } else { + $message = sprintf( + $lang->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang_browse_links.xlf:no_files'), + $folder->getStorage()->getName() . ':' . $folder->getReadablePath() + ); + } + + return $header + . '<div class="shadow-sm bg-info bg-gradient p-3 mb-4 mt-4">' . + htmlspecialchars($message) + . '</div>' . + $searchBox; } $lines = []; @@ -331,13 +356,8 @@ class FileBrowser extends AbstractElementBrowser implements ElementBrowserInterf </tr>'; } - $formUrl = $this->getScriptUrl() . HttpUtility::buildQueryString($this->getUrlParameters([]), '&'); - $searchBox = GeneralUtility::makeInstance(RecordSearchBoxComponent::class) - ->setSearchWord($this->searchWord) - ->render($formUrl); - $markup = []; - $markup[] = '<div class="mt-4 mb-4">' . $searchBox . '</div>'; + $markup[] = $searchBox; $markup[] = '<div id="filelist">'; $markup[] = ' <div class="row row-cols-auto justify-content-between gx-0 list-header multi-record-selection-actions-wrapper">'; $markup[] = ' <div class="col-auto">'; diff --git a/typo3/sysext/recordlist/Resources/Private/Language/locallang_browse_links.xlf b/typo3/sysext/recordlist/Resources/Private/Language/locallang_browse_links.xlf index d8dff4983c7b6878b82e04d34c480aee0df53a98..1d07fedb9148b80a11f00039466f0c9f5fc4f1a3 100644 --- a/typo3/sysext/recordlist/Resources/Private/Language/locallang_browse_links.xlf +++ b/typo3/sysext/recordlist/Resources/Private/Language/locallang_browse_links.xlf @@ -138,6 +138,9 @@ <trans-unit id="no_files" resname="no_files"> <source>No files found in %s</source> </trans-unit> + <trans-unit id="no_files_search" resname="no_files_search"> + <source>No files found in %s for "%s"</source> + </trans-unit> </body> </file> </xliff>