From dc7f86b09dcf7535c95d3938f0323ce5d740f62a Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 23 Jun 2016 15:27:44 -0400 Subject: [PATCH] Use custom GET parameter instead of hidden filter for tag search identification. - Avoids some nasty side effects of hidden filters (like broken autocomplete). --- .../VuFind/Controller/SearchController.php | 3 +- .../VuFind/src/VuFind/Search/Tags/Params.php | 30 +++++++++++++++++++ .../VuFind/src/VuFind/Search/Tags/Results.php | 3 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 2fd1fad0d1a..205d4c13738 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -510,8 +510,7 @@ class SearchController extends AbstractSearch // Because we're coming in from a search, we want to do a fuzzy // tag search, not an exact search like we would when linking to a // specific tag name. - $query = $this->getRequest()->getQuery() - ->set('hiddenFilters', ['fuzzy:true']); + $query = $this->getRequest()->getQuery()->set('fuzzy', 'true'); return $this->forwardTo('Tag', 'Home'); } diff --git a/module/VuFind/src/VuFind/Search/Tags/Params.php b/module/VuFind/src/VuFind/Search/Tags/Params.php index f1b9fafb1cb..8e8787989b3 100644 --- a/module/VuFind/src/VuFind/Search/Tags/Params.php +++ b/module/VuFind/src/VuFind/Search/Tags/Params.php @@ -38,4 +38,34 @@ namespace VuFind\Search\Tags; */ class Params extends \VuFind\Search\Base\Params { + /** + * Is this a fuzzy search? + * + * @var bool + */ + protected $fuzzy = false; + + /** + * Is this a fuzzy search? + * + * @var bool + */ + public function isFuzzyTagSearch() + { + return $this->fuzzy; + } + + /** + * Pull the search parameters + * + * @param \Zend\StdLib\Parameters $request Parameter object representing user + * request. + * + * @return void + */ + public function initFromRequest($request) + { + parent::initFromRequest($request); + $this->fuzzy = ('true' == $request->get('fuzzy', 'false')); + } } diff --git a/module/VuFind/src/VuFind/Search/Tags/Results.php b/module/VuFind/src/VuFind/Search/Tags/Results.php index 302fa5ac46f..e27e331df0d 100644 --- a/module/VuFind/src/VuFind/Search/Tags/Results.php +++ b/module/VuFind/src/VuFind/Search/Tags/Results.php @@ -123,8 +123,7 @@ class Results extends BaseResults // we are coming in from a search, in which case we want to do a fuzzy // search that supports wildcards, or else we are coming in from a tag // link, in which case we want to do an exact match. - $hf = $this->getParams()->getHiddenFilters(); - $rawResults = (isset($hf['fuzzy']) && in_array('true', $hf['fuzzy'])) + $rawResults = $this->getParams()->isFuzzyTagSearch() ? $this->performFuzzyTagSearch() : $this->performExactTagSearch(); -- GitLab