[TASK] Make search levels in live search and list search consistent 71/44171/12
authorMarcus Schwemer <ms@schwemer.de>
Mon, 19 Oct 2015 23:25:42 +0000 (01:25 +0200)
committerBenni Mack <benni@typo3.org>
Fri, 4 Mar 2016 20:30:28 +0000 (21:30 +0100)
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>
typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Documentation/Changelog/master/Important-70849-MakeSearchLevelsConsistent.rst [new file with mode: 0644]
typo3/sysext/lang/locallang_core.xlf
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php

index 67212c4..b6ca661 100644 (file)
@@ -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();
index 57ba8b6..8f65d06 100644 (file)
@@ -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 (file)
index 0000000..aebec6f
--- /dev/null
@@ -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.
+
index e5c7791..bbf0a40 100644 (file)
                        <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>
index a5076b4..05b71fc 100644 (file)
@@ -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>';