Skip to content

Commit

Permalink
Add specialized search flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jan 17, 2025
1 parent f92ba8c commit b861b76
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions module/VuFind/src/VuFind/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ public function newitemresultsAction()
$this->getRequest()->getQuery()->set('hiddenFilters', $hiddenFilters);
}

// Flag this as a specialized search to avoid bleeding defaults into the
// standard search box:
$this->getRequest()->getQuery()->set('specializedSearch', true);

// Don't save to history or memory -- history page doesn't handle correctly
// and we don't want hidden filters bleeding to weird places:
$this->saveToHistory = false;
Expand Down
20 changes: 20 additions & 0 deletions module/VuFind/src/VuFind/Search/Base/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ class Params
*/
protected $queryAdapterClass = QueryAdapter::class;

/**
* Is this a specialized search (i.e. a customized scenario like new items,
* rather than a "normal" backend search)?
*
* @var bool
*/
protected $isSpecializedSearch = false;

/**
* Constructor
*
Expand Down Expand Up @@ -369,6 +377,7 @@ public function initFromRequest($request)
$this->initSort($request);
$this->initFilters($request);
$this->initHiddenFilters($request);
$this->isSpecializedSearch = $request->get('specializedSearch', false);
}

/**
Expand Down Expand Up @@ -2102,4 +2111,15 @@ public function supportsFacetFiltering($facet)
$translatedFacets = $this->getOptions()->getTranslatedFacets();
return method_exists($this, 'setFacetContains') && !in_array($facet, $translatedFacets);
}

/**
* Is this a specialized search (i.e. a customized scenario like new items,
* rather than a "normal" backend search)?
*
* @var bool
*/
public function isSpecializedSearch(): bool
{
return $this->isSpecializedSearch;
}
}
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/search/searchbox.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?? 'Solr';
}
// Initialize from current search if eligible, defaults otherwise:
if (isset($params) && $this->searchClassId === $params->getSearchClassId()) {
if (isset($params) && $this->searchClassId === $params->getSearchClassId() && !$params->isSpecializedSearch()) {
$hiddenFilters = $params->getHiddenFilters();
$lastSort = $params->getSort();
$lastLimit = $params->getLimit();
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/templates/search/searchbox.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?? 'Solr';
}
// Initialize from current search if eligible, defaults otherwise:
if (isset($params) && $this->searchClassId === $params->getSearchClassId()) {
if (isset($params) && $this->searchClassId === $params->getSearchClassId() && !$params->isSpecializedSearch()) {
$hiddenFilters = $params->getHiddenFilters();
$lastSort = $params->getSort();
$lastLimit = $params->getLimit();
Expand Down

0 comments on commit b861b76

Please sign in to comment.