diff --git a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DocumentHeader.ts b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DocumentHeader.ts index a6c27605f925..52456427654d 100644 --- a/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DocumentHeader.ts +++ b/Build/Sources/TypeScript/backend/Resources/Public/TypeScript/DocumentHeader.ts @@ -42,11 +42,6 @@ class DocumentHeader { return; } - const documentHeaderSearchBar = document.querySelector(this.settings.selectors.moduleSearchBar); - if (documentHeaderSearchBar !== null) { - this.documentHeader.appendChild(documentHeaderSearchBar); - } - const moduleElement = this.documentHeader.parentElement; new ThrottleEvent('scroll', this.scroll, 100).bindTo(moduleElement); }); diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php index 8e7fc1ce521e..3f1be5862ce9 100644 --- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php +++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php @@ -45,7 +45,6 @@ use TYPO3\CMS\Core\Versioning\VersionState; use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper; -use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; /** * Script Class for Web > Layout module @@ -592,7 +591,6 @@ function deleteRecord(table,id,url) { // // All other listings $content .= $this->renderContent(); $content .= ''; - $content .= $this->searchContent; // Setting up the buttons for the docheader $this->makeButtons($request); @@ -694,17 +692,7 @@ protected function renderContent(): string $content .= GeneralUtility::callUserFunction($hook, $params, $this); } $content .= $tableOutput; - // Making search form: - $this->searchContent = $this->getSearchBox(); - if ($this->searchContent) { - $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox'); - $toggleSearchFormButton = $this->buttonBar->makeLinkButton() - ->setClasses('t3js-toggle-search-toolbox') - ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.searchIcon')) - ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL)) - ->setHref('#'); - $this->buttonBar->addButton($toggleSearchFormButton, ButtonBar::BUTTON_POSITION_LEFT, 4); - } + // Additional footer content foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook'] ?? [] as $hook) { $params = []; @@ -1036,24 +1024,6 @@ protected function getTargetPageIfVisible(array $targetPage): array return !(bool)($targetPage['hidden'] ?? false) ? $targetPage : []; } - /** - * Creates the search box - * - * @return string HTML for the search box - */ - protected function getSearchBox(): string - { - if (!$this->getBackendUser()->check('modules', 'web_list')) { - return ''; - } - - $dbList = GeneralUtility::makeInstance(DatabaseRecordList::class); - $dbList->start($this->id, '', ''); - $formUrl = $this->uriBuilder->buildUriFromRoute('web_list', ['id' => $this->id]); - - return ''; - } - /** * Returns the shortcut title for the current page * diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/DocumentHeader.js b/typo3/sysext/backend/Resources/Public/JavaScript/DocumentHeader.js index cf3e2056f10e..7604e9c0e7f2 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/DocumentHeader.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/DocumentHeader.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require","exports","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Core/Event/ThrottleEvent"],(function(t,e,i,o){"use strict";return new class{constructor(){this.documentHeader=null,this.direction="down",this.reactionRange=300,this.lastPosition=0,this.currentPosition=0,this.changedPosition=0,this.settings={margin:24,offset:100,selectors:{moduleDocumentHeader:".t3js-module-docheader",moduleSearchBar:".t3js-module-docheader-bar-search"}},this.scroll=t=>{this.currentPosition=t.target.scrollTop,this.currentPosition>this.lastPosition?"down"!==this.direction&&(this.direction="down",this.changedPosition=this.currentPosition):this.currentPosition{if(this.documentHeader=document.querySelector(this.settings.selectors.moduleDocumentHeader),null===this.documentHeader)return;const t=document.querySelector(this.settings.selectors.moduleSearchBar);null!==t&&this.documentHeader.appendChild(t);const e=this.documentHeader.parentElement;new o("scroll",this.scroll,100).bindTo(e)})}}})); \ No newline at end of file +define(["require","exports","TYPO3/CMS/Core/DocumentService","TYPO3/CMS/Core/Event/ThrottleEvent"],(function(t,e,i,o){"use strict";return new class{constructor(){this.documentHeader=null,this.direction="down",this.reactionRange=300,this.lastPosition=0,this.currentPosition=0,this.changedPosition=0,this.settings={margin:24,offset:100,selectors:{moduleDocumentHeader:".t3js-module-docheader",moduleSearchBar:".t3js-module-docheader-bar-search"}},this.scroll=t=>{this.currentPosition=t.target.scrollTop,this.currentPosition>this.lastPosition?"down"!==this.direction&&(this.direction="down",this.changedPosition=this.currentPosition):this.currentPosition{if(this.documentHeader=document.querySelector(this.settings.selectors.moduleDocumentHeader),null===this.documentHeader)return;const t=this.documentHeader.parentElement;new o("scroll",this.scroll,100).bindTo(t)})}}})); \ No newline at end of file diff --git a/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php b/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php index 3ba348e430b8..9668e16d9c87 100644 --- a/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/DatabaseBrowser.php @@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView; use TYPO3\CMS\Recordlist\Tree\View\LinkParameterProviderInterface; +use TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent; /** * Showing a page tree and allows you to browse for records @@ -38,6 +39,7 @@ class DatabaseBrowser extends AbstractElementBrowser implements ElementBrowserIn * @var int|null */ protected $expandPage; + protected array $modTSconfig = []; protected function initialize() { @@ -75,6 +77,7 @@ public function processSessionData($data) public function render() { $userTsConfig = $this->getBackendUser()->getTSConfig(); + $this->modTSconfig = BackendUtility::getPagesTSconfig((int)$this->expandPage)['mod.']['web_list.'] ?? []; $this->setTemporaryDbMounts(); [, , , $allowedTables] = explode('|', $this->bparams); @@ -217,18 +220,21 @@ protected function renderTableRecords($tables) $dbList->setRelatingTableAndField($relatingTableName, $relatingFieldName); } + $selectedTable = GeneralUtility::_GP('table'); + $searchWord = (string)GeneralUtility::_GP('search_field'); + $searchLevels = (int)GeneralUtility::_GP('search_levels'); $dbList->start( $this->expandPage, - GeneralUtility::_GP('table'), + $selectedTable, MathUtility::forceIntegerInRange(GeneralUtility::_GP('pointer'), 0, 100000), - GeneralUtility::_GP('search_field'), - GeneralUtility::_GP('search_levels') + $searchWord, + $searchLevels ); $dbList->setDispFields(); $tableList = $dbList->generateList(); - $out .= '
' . $dbList->getSearchBox() . '
'; + $out .= $this->renderSearchBox($dbList, $searchWord, $searchLevels); // Add the HTML for the record list to output variable: $out .= $tableList; @@ -242,6 +248,16 @@ protected function renderTableRecords($tables) return $out; } + protected function renderSearchBox(ElementBrowserRecordList $dblist, string $searchWord, int $searchLevels): string + { + $searchBox = GeneralUtility::makeInstance(RecordSearchBoxComponent::class) + ->setAllowedSearchLevels((array)($this->modTSconfig['searchLevel.']['items.'] ?? [])) + ->setSearchWord($searchWord) + ->setSearchLevel($searchLevels) + ->render($dblist->listURL('', '-1', 'pointer,search_field')); + return '
' . $searchBox . '
'; + } + /** * @return string[] Array of body-tag attributes */ diff --git a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php index c50d62141a65..823c4bc15b12 100644 --- a/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php +++ b/typo3/sysext/recordlist/Classes/Browser/FileBrowser.php @@ -32,6 +32,7 @@ use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Recordlist\Tree\View\LinkParameterProviderInterface; use TYPO3\CMS\Recordlist\View\FolderUtilityRenderer; +use TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent; /** * Browser for files @@ -95,7 +96,7 @@ protected function initVariables() { parent::initVariables(); $this->expandFolder = $this->getRequest()->getParsedBody()['expandFolder'] ?? $this->getRequest()->getQueryParams()['expandFolder'] ?? null; - $this->searchWord = $this->getRequest()->getParsedBody()['searchWord'] ?? $this->getRequest()->getQueryParams()['searchWord'] ?? ''; + $this->searchWord = $this->getRequest()->getParsedBody()['search_field'] ?? $this->getRequest()->getQueryParams()['search_field'] ?? ''; } /** @@ -320,8 +321,13 @@ public function renderFilesInFolder(Folder $folder, array $extensionList = [], $ } } + $formUrl = $this->getScriptUrl() . HttpUtility::buildQueryString($this->getUrlParameters([]), '&'); + $searchBox = GeneralUtility::makeInstance(RecordSearchBoxComponent::class) + ->setSearchWord($this->searchWord) + ->render($formUrl); + $markup = []; - $markup[] = GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this)->getFileSearchField($this->searchWord); + $markup[] = '
' . $searchBox . '
'; $markup[] = '
'; $markup[] = ' ' . $this->getBulkSelector(); $markup[] = ' '; diff --git a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php index d9935ddf74da..307aa314ed27 100644 --- a/typo3/sysext/recordlist/Classes/Controller/RecordListController.php +++ b/typo3/sysext/recordlist/Classes/Controller/RecordListController.php @@ -45,6 +45,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Recordlist\Event\RenderAdditionalContentToRecordListEvent; use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList; +use TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent; /** * Script Class for the Web > List module; rendering the listing of records on a page @@ -260,11 +261,12 @@ function editRecords(table,idList,addParams,CBflag) { $body .= $additionalRecordListEvent->getAdditionalContentAbove(); $this->moduleTemplate->setTitle($title); + $beforeOutput = ''; $output = ''; // Show the selector to add page translations and the list of translations of the current page // but only when in "default" mode if ($this->id && !$dblist->csvOutput && !$search_field && !$cmd && !$table) { - $output .= $this->languageSelector($request->getAttribute('normalizedParams')->getRequestUri()); + $beforeOutput .= $this->languageSelector($request->getAttribute('normalizedParams')->getRequestUri()); $pageTranslationsDatabaseRecordList = clone $dblist; $pageTranslationsDatabaseRecordList->listOnlyInSingleTableMode = false; $pageTranslationsDatabaseRecordList->disableSingleTableView = true; @@ -275,6 +277,11 @@ function editRecords(table,idList,addParams,CBflag) { $output .= $pageTranslationsDatabaseRecordList->getTable('pages', $this->id); } + // search box toolbar + if (!($this->modTSconfig['disableSearchBox'] ?? false) && ($tableOutput || !empty($search_field))) { + $beforeOutput .= $this->renderSearchBox($dblist, $search_field, $search_levels); + } + if (!empty($tableOutput)) { $output .= $tableOutput; } else { @@ -301,6 +308,9 @@ function editRecords(table,idList,addParams,CBflag) { $defaultFlashMessageQueue->enqueue($flashMessage); } + if ($beforeOutput) { + $body .= '
' . $beforeOutput . '
'; + } $body .= ''; $body .= $output; $body .= ''; @@ -357,34 +367,12 @@ function editRecords(table,idList,addParams,CBflag) { $dblist->listURL(), $MOD_SETTINGS ); - // search box toolbar - $content = ''; - if (!($this->modTSconfig['disableSearchBox'] ?? false) && ($tableOutput || !empty($dblist->searchString))) { - $searchBoxVisible = !empty($dblist->searchString); - $searchBox = $dblist->getSearchBox(); - $content .= ''; - $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox'); - - $searchButton = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->makeLinkButton(); - $searchButton - ->setHref('#') - ->setClasses('t3js-toggle-search-toolbox') - ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.searchIcon')) - ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL)); - $this->moduleTemplate->getDocHeaderComponent()->getButtonBar()->addButton( - $searchButton, - ButtonBar::BUTTON_POSITION_LEFT, - 90 - ); - } if ($pageinfo) { $this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($pageinfo); } - // Build the for the module - $content .= $body; - $this->moduleTemplate->setContent($content); + $this->moduleTemplate->setContent($body); return new HtmlResponse($this->moduleTemplate->renderContent()); } @@ -424,6 +412,31 @@ protected function initializeClipboard(ServerRequestInterface $request, bool $is return $clipboard; } + protected function renderSearchBox(DatabaseRecordList $dblist, string $searchWord, int $searchLevels): string + { + $searchBoxVisible = !empty($dblist->searchString); + $searchBox = GeneralUtility::makeInstance(RecordSearchBoxComponent::class) + ->setAllowedSearchLevels((array)($this->modTSconfig['searchLevel.']['items.'] ?? [])) + ->setSearchWord($searchWord) + ->setSearchLevel($searchLevels) + ->render($dblist->listURL('', '-1', 'pointer,search_field')); + + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox'); + $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); + $searchButton = $buttonBar->makeLinkButton(); + $searchButton + ->setHref('#') + ->setClasses('t3js-toggle-search-toolbox') + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.searchIcon')) + ->setIcon($this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL)); + $buttonBar->addButton( + $searchButton, + ButtonBar::BUTTON_POSITION_LEFT, + 90 + ); + return '
' . $searchBox . '
'; + } + /** * Create the panel of buttons for submitting the form or otherwise perform * operations. @@ -641,11 +654,10 @@ protected function languageSelector(string $requestUri): string $output .= ''; } - return '
' - . '
' + return '
' . '
'; + . '
'; } return ''; } diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php index d674b158991c..a9ba7950d3a9 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php @@ -2380,23 +2380,6 @@ protected function getTablesToRender(): array return array_keys($orderedTableNames); } - /** - * Creates the search box - * - * @return string HTML for the search box - */ - public function getSearchBox(string $formUrl = null): string - { - return $this->getFluidTemplateObject('Search.html') - ->assignMultiple([ - 'formUrl' => $formUrl ?? $this->listURL('', '-1', 'pointer,search_field'), - 'searchLevelsFromTSconfig' => (array)(BackendUtility::getPagesTSconfig($this->id)['mod.']['web_list.']['searchLevel.']['items.'] ?? []), - 'selectedSearchLevel' => $this->searchLevels, - 'searchString' => $this->searchString - ]) - ->render(); - } - /** * Setting the field names to display in extended list. * Sets the internal variable $this->setFields diff --git a/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php b/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php index deda733cb433..4bfbee9cb3e1 100644 --- a/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php +++ b/typo3/sysext/recordlist/Classes/View/FolderUtilityRenderer.php @@ -17,8 +17,6 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -use TYPO3\CMS\Core\Imaging\Icon; -use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Resource\Folder; use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry; @@ -38,7 +36,6 @@ class FolderUtilityRenderer */ protected $parameterProvider; protected UriBuilder $uriBuilder; - protected IconFactory $iconFactory; /** * @param LinkParameterProviderInterface $parameterProvider @@ -47,7 +44,6 @@ public function __construct(LinkParameterProviderInterface $parameterProvider) { $this->parameterProvider = $parameterProvider; $this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); - $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); } /** @@ -227,31 +223,6 @@ public function uploadForm(Folder $folderObject, array $allowedExtensions) return $code; } - /** - * Get the HTML data required for the file search field of the TYPO3 Element Browser. - * - * @param string $searchWord - * @return string HTML data required for the search field in the file list of the Element Browser - */ - public function getFileSearchField(string $searchWord): string - { - $action = $this->parameterProvider->getScriptUrl() - . HttpUtility::buildQueryString($this->parameterProvider->getUrlParameters([]), '&'); - - $markup = []; - $markup[] = ''; - $markup[] = '
'; - $markup[] = ' '; - $markup[] = $this->iconFactory->getIcon('actions-search', Icon::SIZE_SMALL)->render(); - $markup[] = ' '; - $markup[] = ' '; - $markup[] = '
'; - $markup[] = ''; - return implode(LF, $markup); - } - protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; diff --git a/typo3/sysext/recordlist/Classes/View/RecordSearchBoxComponent.php b/typo3/sysext/recordlist/Classes/View/RecordSearchBoxComponent.php new file mode 100644 index 000000000000..f705c4d44274 --- /dev/null +++ b/typo3/sysext/recordlist/Classes/View/RecordSearchBoxComponent.php @@ -0,0 +1,78 @@ +view = $view ?? $this->getView('Search.html'); + } + + public function setSearchWord(string $searchWord): self + { + $this->searchWord = $searchWord; + return $this; + } + + public function setSearchLevel(int $searchLevel): self + { + $this->searchLevel = $searchLevel; + return $this; + } + + public function setAllowedSearchLevels(array $allowedSearchLevels): self + { + $this->allowedSearchLevels = $allowedSearchLevels; + return $this; + } + + public function render(string $formUrl = ''): string + { + return $this->view + ->assignMultiple([ + 'formUrl' => $formUrl, + 'availableSearchLevels' => $this->allowedSearchLevels, + 'selectedSearchLevel' => $this->searchLevel, + 'searchString' => $this->searchWord + ]) + ->render(); + } + + protected function getView(string $filename): StandaloneView + { + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplateRootPaths(['EXT:recordlist/Resources/Private/Templates']); + $view->setTemplate($filename); + return $view; + } +} diff --git a/typo3/sysext/recordlist/Resources/Private/Templates/Search.html b/typo3/sysext/recordlist/Resources/Private/Templates/Search.html index e10749245c05..388aa1740896 100644 --- a/typo3/sysext/recordlist/Resources/Private/Templates/Search.html +++ b/typo3/sysext/recordlist/Resources/Private/Templates/Search.html @@ -1,29 +1,34 @@ - -
-
-
- - + +
+ + + + + + -
- - -
-
- - -
-
+