diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index bfc25aa1c8fa69198fec688b18bee86f43d9dfac..e8bdeb640e1dafeb15a31948f97ea9139caafd8a 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -112,6 +112,17 @@ class AbstractSearch extends AbstractBase $view->saved = $this->restoreAdvancedSearch($searchId); } + // If we have default filters, set them up as a fake "saved" search + // to properly populate special controls on the advanced screen. + if (!$view->saved && count($view->options->getDefaultFilters()) > 0) { + $view->saved = $this->getServiceLocator() + ->get('VuFind\SearchResultsPluginManager') + ->get($this->searchClassId); + $view->saved->getParams()->initFromRequest( + new \Zend\StdLib\Parameters(array()) + ); + } + return $view; } diff --git a/themes/blueprint/templates/search/advanced/layout.phtml b/themes/blueprint/templates/search/advanced/layout.phtml index 8915c9b015cf31123135c7df140c6caf81244fd8..d7ad979a7579fd5e06599a5fff26a279c4a91078 100644 --- a/themes/blueprint/templates/search/advanced/layout.phtml +++ b/themes/blueprint/templates/search/advanced/layout.phtml @@ -11,7 +11,12 @@ // Set up saved search details: if (isset($this->saved) && is_object($this->saved)) { $searchDetails = $this->saved->getParams()->getQuery(); - $groups = $searchDetails->getQueries(); + if ($searchDetails instanceof \VuFindSearch\Query\Query) { + // Not an advanced query -- ignore it. + $searchDetails = $groups = false; + } else { + $groups = $searchDetails->getQueries(); + } $hasDefaultsApplied = $this->saved->getParams()->hasDefaultsApplied(); $searchFilters = $this->saved->getParams()->getFilterList(); } else { diff --git a/themes/bootstrap/templates/search/advanced/layout.phtml b/themes/bootstrap/templates/search/advanced/layout.phtml index fa9ae6d508f8d55571021e7b7e4f43c60de28dc2..9b224c58ee53629d4b7022e116751bd7a2a067a6 100644 --- a/themes/bootstrap/templates/search/advanced/layout.phtml +++ b/themes/bootstrap/templates/search/advanced/layout.phtml @@ -12,7 +12,12 @@ // Set up saved search details: if (isset($this->saved) && is_object($this->saved)) { $searchDetails = $this->saved->getParams()->getQuery(); - $groups = $searchDetails->getQueries(); + if ($searchDetails instanceof \VuFindSearch\Query\Query) { + // Not an advanced query -- ignore it. + $searchDetails = $groups = false; + } else { + $groups = $searchDetails->getQueries(); + } $hasDefaultsApplied = $this->saved->getParams()->hasDefaultsApplied(); $searchFilters = $this->saved->getParams()->getFilterList(); } else {