From c2eb96d8f8caf3051125ca4c52fb9aca457aab7d Mon Sep 17 00:00:00 2001 From: Marcus Schwemer <ms@schwemer.de> Date: Tue, 20 Oct 2015 01:25:42 +0200 Subject: [PATCH] [TASK] Make search levels in live search and list search consistent Live search searches through the whole system, while list search is limited to four levels. Solution: * Add default pageTS for search levels * Live search "Show all" now uses "-1" for infinite search Resolves: #70849 Releases: master Change-Id: Ibf8b043da26e58bbe0df18fb2013934da5ec64f3 Reviewed-on: https://review.typo3.org/44171 Reviewed-by: Daniel Maier <dani-maier@gmx.de> Tested-by: Daniel Maier <dani-maier@gmx.de> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> --- .../Resources/Public/JavaScript/LiveSearch.js | 2 +- .../Configuration/DefaultConfiguration.php | 8 +++++++ ...rtant-70849-MakeSearchLevelsConsistent.rst | 22 +++++++++++++++++++ typo3/sysext/lang/locallang_core.xlf | 18 +++++++++++++++ .../RecordList/AbstractDatabaseRecordList.php | 19 ++++++++++++++-- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Important-70849-MakeSearchLevelsConsistent.rst diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js index 67212c4f6d77..b6ca661c7162 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js @@ -91,7 +91,7 @@ define(['jquery', 'jquery/autocomplete', 'TYPO3/CMS/Backend/jquery.clearable'], // set up the events $(containerSelector).on('click', '.t3js-live-search-show-all', function(evt) { evt.preventDefault(); - TYPO3.ModuleMenu.App.showModule('web_list', 'id=0&search_levels=4&search_field=' + encodeURIComponent($(searchFieldSelector).val())); + TYPO3.ModuleMenu.App.showModule('web_list', 'id=0&search_levels=-1&search_field=' + encodeURIComponent($(searchFieldSelector).val())); }); $(containerSelector).on('click', '.dropdown-list-link', function(evt) { evt.preventDefault(); diff --git a/typo3/sysext/core/Configuration/DefaultConfiguration.php b/typo3/sysext/core/Configuration/DefaultConfiguration.php index 57ba8b6e3c25..8f65d06d77ec 100644 --- a/typo3/sysext/core/Configuration/DefaultConfiguration.php +++ b/typo3/sysext/core/Configuration/DefaultConfiguration.php @@ -1022,6 +1022,14 @@ return array( tt_content.after = pages,backend_layout,sys_template sys_category.after = tt_content } + mod.web_list.searchLevel.items { + -1 = EXT:lang/locallang_core.xlf:labels.searchLevel.infinite + 0 = EXT:lang/locallang_core.xlf:labels.searchLevel.0 + 1 = EXT:lang/locallang_core.xlf:labels.searchLevel.1 + 2 = EXT:lang/locallang_core.xlf:labels.searchLevel.2 + 3 = EXT:lang/locallang_core.xlf:labels.searchLevel.3 + 4 = EXT:lang/locallang_core.xlf:labels.searchLevel.4 + } mod.wizards.newRecord.pages.show.pageInside=1 mod.wizards.newRecord.pages.show.pageAfter=1 mod.wizards.newRecord.pages.show.pageSelectPosition=1 diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-70849-MakeSearchLevelsConsistent.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-70849-MakeSearchLevelsConsistent.rst new file mode 100644 index 000000000000..aebec6f6c125 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Important-70849-MakeSearchLevelsConsistent.rst @@ -0,0 +1,22 @@ +================================================================================ +Important: #70849 - Make search levels in live search and list search consistent +================================================================================ + +Description +=========== + +In order to make the searchlevel handling consistent between live and list search a new PageTS option has been added. + +.. code-block:: typoscript + + mod.web_list.searchLevel.items { + -1 = EXT:lang/locallang_core.xlf:labels.searchLevel.infinite + 0 = EXT:lang/locallang_core.xlf:labels.searchLevel.0 + 1 = EXT:lang/locallang_core.xlf:labels.searchLevel.1 + 2 = EXT:lang/locallang_core.xlf:labels.searchLevel.2 + 3 = EXT:lang/locallang_core.xlf:labels.searchLevel.3 + 4 = EXT:lang/locallang_core.xlf:labels.searchLevel.4 + } + +This makes it possible to add custom search level entries. + diff --git a/typo3/sysext/lang/locallang_core.xlf b/typo3/sysext/lang/locallang_core.xlf index e5c7791fbc2d..bbf0a4027db7 100644 --- a/typo3/sysext/lang/locallang_core.xlf +++ b/typo3/sysext/lang/locallang_core.xlf @@ -66,6 +66,24 @@ <trans-unit id="labels.enterSearchLevels"> <source>This page|1 level down|2 levels down|3 levels down|4 levels down</source> </trans-unit> + <trans-unit id="labels.searchLevel.0"> + <source>This page</source> + </trans-unit> + <trans-unit id="labels.searchLevel.1"> + <source>1 level down</source> + </trans-unit> + <trans-unit id="labels.searchLevel.2"> + <source>2 levels down</source> + </trans-unit> + <trans-unit id="labels.searchLevel.3"> + <source>3 levels down</source> + </trans-unit> + <trans-unit id="labels.searchLevel.4"> + <source>4 levels down</source> + </trans-unit> + <trans-unit id="labels.searchLevel.infinite"> + <source>Infinite levels</source> + </trans-unit> <trans-unit id="labels.noEditPermission"> <source>Sorry, you didn't have proper permissions to perform this change.</source> </trans-unit> diff --git a/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php index a5076b4db062..05b71fc857b1 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php @@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\HttpUtility; use TYPO3\CMS\Core\Utility\MathUtility; +use TYPO3\CMS\Core\Utility\ArrayUtility; /** * Child class for rendering of Web > List (not the final class) @@ -549,8 +550,22 @@ class AbstractDatabaseRecordList extends AbstractRecordList } // Make level selector: $opt = array(); - $parts = explode('|', $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.enterSearchLevels')); - foreach ($parts as $kv => $label) { + + // "New" generation of search levels ... based on TS config + $config = BackendUtility::getPagesTSconfig($this->id); + $searchLevelsFromTSconfig = $config['mod.']['web_list.']['searchLevel.']['items.']; + $searchLevelItems = array(); + + // get translated labels for search levels from pagets + foreach ($searchLevelsFromTSconfig as $keySearchLevel => $labelConfigured ) { + $label = $lang->sL('LLL:' . $labelConfigured, false); + if ($label === '') { + $label = $labelConfigured; + } + $searchLevelItems[$keySearchLevel] = $label; + } + + foreach ($searchLevelItems as $kv => $label) { $opt[] = '<option value="' . $kv . '"' . ($kv === $this->searchLevels ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>'; } $lMenu = '<select class="form-control" name="search_levels" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.search_levels', true) . '" id="search_levels">' . implode('', $opt) . '</select>'; -- GitLab