[BUGFIX] Keep state of extendedSearch 46/54646/4
authorPeter Niederlag <peter.niederlag@datenbetrieb.de>
Wed, 15 Nov 2017 09:53:54 +0000 (10:53 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 13 May 2018 22:25:19 +0000 (00:25 +0200)
formAction has set a bunch of variables that are required by
the frontend for the extendedSearch

Inside searchAction this parameters were not set resulting in
the extendedSearch section being empty in frontend after searching.

With this change the processing of the variables is extracted
into a method and called from formAction and searchAction.

Releases: master, 8.7
Resolves: #82064
Change-Id: Ia21c445ef0aa72e8e084e9bd021bc5caa7a1e74b
Reviewed-on: https://review.typo3.org/54646
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/indexed_search/Classes/Controller/SearchController.php

index 57bad61..1b68c3a 100644 (file)
@@ -259,6 +259,11 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
             // index configuration is disabled
             $freeIndexUid = -1;
         }
+
+        if (!empty($searchData['extendedSearch'])) {
+            $this->view->assignMultiple($this->processExtendedSearchParameters());
+        }
+
         $indexCfgs = GeneralUtility::intExplode(',', $freeIndexUid);
         $resultsets = [];
         foreach ($indexCfgs as $freeIndexUid) {
@@ -961,38 +966,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
         $this->view->assign('sword', $this->getSword());
         // Extended search
         if (!empty($searchData['extendedSearch'])) {
-            // "Search for"
-            $allSearchTypes = $this->getAllAvailableSearchTypeOptions();
-            $this->view->assign('allSearchTypes', $allSearchTypes);
-            $allDefaultOperands = $this->getAllAvailableOperandsOptions();
-            $this->view->assign('allDefaultOperands', $allDefaultOperands);
-            $showTypeSearch = !empty($allSearchTypes) || !empty($allDefaultOperands);
-            $this->view->assign('showTypeSearch', $showTypeSearch);
-            // "Search in"
-            $allMediaTypes = $this->getAllAvailableMediaTypesOptions();
-            $this->view->assign('allMediaTypes', $allMediaTypes);
-            $allLanguageUids = $this->getAllAvailableLanguageOptions();
-            $this->view->assign('allLanguageUids', $allLanguageUids);
-            $showMediaAndLanguageSearch = !empty($allMediaTypes) || !empty($allLanguageUids);
-            $this->view->assign('showMediaAndLanguageSearch', $showMediaAndLanguageSearch);
-            // Sections
-            $allSections = $this->getAllAvailableSectionsOptions();
-            $this->view->assign('allSections', $allSections);
-            // Free Indexing Configurations
-            $allIndexConfigurations = $this->getAllAvailableIndexConfigurationsOptions();
-            $this->view->assign('allIndexConfigurations', $allIndexConfigurations);
-            // Sorting
-            $allSortOrders = $this->getAllAvailableSortOrderOptions();
-            $this->view->assign('allSortOrders', $allSortOrders);
-            $allSortDescendings = $this->getAllAvailableSortDescendingOptions();
-            $this->view->assign('allSortDescendings', $allSortDescendings);
-            $showSortOrders = !empty($allSortOrders) || !empty($allSortDescendings);
-            $this->view->assign('showSortOrders', $showSortOrders);
-            // Limits
-            $allNumberOfResults = $this->getAllAvailableNumberOfResultsOptions();
-            $this->view->assign('allNumberOfResults', $allNumberOfResults);
-            $allGroups = $this->getAllAvailableGroupOptions();
-            $this->view->assign('allGroups', $allGroups);
+            $this->view->assignMultiple($this->processExtendedSearchParameters());
         }
         $this->view->assign('searchParams', $searchData);
     }
@@ -1519,6 +1493,43 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
     }
 
     /**
+     * Process variables related to indexed_search extendedSearch needed by frontend view.
+     * Populate select boxes and setting some flags.
+     * The returned data should be passed into the view by assignMultiple()
+     *
+     * @return array Variables to pass into the view so they can be used in fluid template
+     */
+    protected function processExtendedSearchParameters()
+    {
+        // "Search for"
+        $extendedSearchParameters['allSearchTypes'] = $this->getAllAvailableSearchTypeOptions();
+        $extendedSearchParameters['allDefaultOperands'] = $this->getAllAvailableOperandsOptions();
+        $extendedSearchParameters['showTypeSearch'] = !empty($allSearchTypes) || !empty($allDefaultOperands);
+
+        // "Search in"
+        $extendedSearchParameters['allMediaTypes'] = $this->getAllAvailableMediaTypesOptions();
+        $extendedSearchParameters['allLanguageUids'] = $this->getAllAvailableLanguageOptions();
+        $extendedSearchParameters['showMediaAndLanguageSearch'] = !empty($allMediaTypes) || !empty($allLanguageUids);
+
+        // Sections
+        $extendedSearchParameters['allSections'] = $this->getAllAvailableSectionsOptions();
+
+        // Free Indexing Configurations
+        $extendedSearchParameters['allIndexConfigurations'] = $this->getAllAvailableIndexConfigurationsOptions();
+
+        // Sorting
+        $extendedSearchParameters['allSortOrders'] = $this->getAllAvailableSortOrderOptions();
+        $extendedSearchParameters['allSortDescendings'] = $this->getAllAvailableSortDescendingOptions();
+        $extendedSearchParameters['showSortOrders'] = !empty($allSortOrders) || !empty($allSortDescendings);
+
+        // Limits
+        $extendedSearchParameters['allNumberOfResults'] = $this->getAllAvailableNumberOfResultsOptions();
+        $extendedSearchParameters['allGroups'] = $this->getAllAvailableGroupOptions();
+
+        return $extendedSearchParameters;
+    }
+
+    /**
      * Load settings and apply stdWrap to them
      */
     protected function loadSettings()