Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[BUGFIX] Keep state of extendedSearch
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/55547
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
pniederlag authored and lolli42 committed May 13, 2018
1 parent 1c2866e commit 8e6aa67
Showing 1 changed file with 43 additions and 32 deletions.
75 changes: 43 additions & 32 deletions typo3/sysext/indexed_search/Classes/Controller/SearchController.php
Expand Up @@ -261,6 +261,11 @@ public function searchAction($search = [])
// index configuration is disabled
$freeIndexUid = -1;
}

if (!empty($searchData['extendedSearch'])) {
$this->view->assignMultiple($this->processExtendedSearchParameters());
}

$indexCfgs = GeneralUtility::intExplode(',', $freeIndexUid);
$resultsets = [];
foreach ($indexCfgs as $freeIndexUid) {
Expand Down Expand Up @@ -992,38 +997,7 @@ public function formAction($search = [])
$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);
}
Expand Down Expand Up @@ -1537,6 +1511,43 @@ protected function multiplePagesType($item_type)
return is_object($this->externalParsers[$item_type]) && $this->externalParsers[$item_type]->isMultiplePageExtension($item_type);
}

/**
* 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
*/
Expand Down

0 comments on commit 8e6aa67

Please sign in to comment.