From 33566571d1fa74327fb3bb1a0a3bd9592668feee Mon Sep 17 00:00:00 2001 From: Robby Date: Mon, 15 Jul 2024 10:26:19 -0400 Subject: [PATCH 01/33] Back to browse results feature --- languages/en.ini | 6 + languages/fr.ini | 6 + .../src/VuFind/Controller/AbstractRecord.php | 9 +- .../src/VuFind/Controller/AbstractSearch.php | 14 +- .../Controller/AlphabrowseController.php | 8 + .../VuFind/src/VuFind/Search/Base/Params.php | 35 ++++ .../Search/Factory/UrlQueryHelperFactory.php | 3 + module/VuFind/src/VuFind/Search/Minified.php | 8 + .../SearchOrigin/AbstractSearchOrigin.php | 70 +++++++ .../SearchOrigin/AlphaBrowseSearchOrigin.php | 188 ++++++++++++++++++ .../SearchOrigin/SearchOriginFactory.php | 71 +++++++ .../VuFind/View/Helper/Root/AlphaBrowse.php | 11 +- .../VuFind/View/Helper/Root/RecordLinker.php | 15 +- themes/bootstrap3/scss/components/record.scss | 7 + themes/bootstrap3/scss/components/search.scss | 13 +- .../DefaultRecord/result-list.phtml | 1 + .../templates/alphabrowse/home.phtml | 3 +- themes/bootstrap3/templates/header.phtml | 9 +- themes/root/templates/search/backtoorigin.php | 10 + 19 files changed, 467 insertions(+), 20 deletions(-) create mode 100644 module/VuFind/src/VuFind/Search/SearchOrigin/AbstractSearchOrigin.php create mode 100644 module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php create mode 100644 module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php create mode 100644 themes/root/templates/search/backtoorigin.php diff --git a/languages/en.ini b/languages/en.ini index 7a208b5d8d7..77b0fb02418 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -109,6 +109,12 @@ Availability = "Availability" Available = "Available" Available Functionality = "Available Functionality" Awards = "Awards" +; For back to search origin +Back to Subject Browse = "Back to Subject Browse" +Back to Author Browse = "Back to Author Browse" +Back to Title Browse = "Back to Title Browse" +Back to Call Number Browse = "Back to Call number Browse" +Back to Series Browse = "Back to Series Browse" Back to Record = "Back to Record" Back to Search Results = "Back to Search Results" Backtrace = "Backtrace" diff --git a/languages/fr.ini b/languages/fr.ini index 90ecf5f93a2..2a0eafce267 100644 --- a/languages/fr.ini +++ b/languages/fr.ini @@ -109,6 +109,12 @@ Availability = "Disponibilité" Available = "Disponible" Available Functionality = "Fonctions disponibles" Awards = "Récompenses" +; For back to search origin +Back to Subject Browse = "Retourner à la recherche par Sujet" +Back to Author Browse = "Retourner à la recherche par Auteur" +Back to Title Browse = "Retourner à la recherche par Titre" +Back to Call Number Browse = "Retourner à la recherche par Cote" +Back to Series Browse = "Retourner à la recherche par Collection" Back to Record = "Retourner à la notice" Back to Search Results = "Retourner aux résultats de recherche" Backtrace = "Historique" diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index 2c78c89efd3..7271198100c 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -29,6 +29,8 @@ namespace VuFind\Controller; +use VuFind\Search\SearchOrigin\SearchOriginFactory; +use Exception; use VuFind\Db\Service\UserListServiceInterface; use VuFind\Db\Service\UserResourceServiceInterface; use VuFind\Exception\BadRequest as BadRequestException; @@ -953,8 +955,11 @@ protected function showTab($tab, $ajax = false) $view->backgroundTabs = $this->getBackgroundTabs(); $view->tabsExtraScripts = $this->getTabsExtraScripts($view->tabs); $view->loadInitialTabWithAjax - = isset($config->Site->loadInitialTabWithAjax) - ? (bool)$config->Site->loadInitialTabWithAjax : false; + = isset($config->Site->loadInitialTabWithAjax) && (bool) $config->Site->loadInitialTabWithAjax; + try { + $this->layout()->setVariable('searchOrigin', SearchOriginFactory::createObject($this->params()->fromQuery())); + } catch (Exception) { + } // Set up next/previous record links (if appropriate) if ($this->resultScrollerActive()) { diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index 12afa219ffe..3f9c2ba11cd 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -37,6 +37,7 @@ use Laminas\View\Model\ViewModel; use VuFind\Db\Entity\SearchEntityInterface; use VuFind\Db\Service\SearchServiceInterface; +use VuFind\Search\Base\Results; use VuFind\Search\RecommendListener; use VuFind\Solr\Utils as SolrUtils; @@ -372,6 +373,7 @@ protected function getSearchResultsView($setupCallback = null) $lastView = $this->getSearchMemory() ->retrieveLastSetting($this->searchClassId, 'view'); try { + /** @var Results $results */ $view->results = $results = $runner->run( $request, $this->searchClassId, @@ -428,6 +430,8 @@ protected function getSearchResultsView($setupCallback = null) $this->flashMessenger()->addErrorMessage($error); } } + // For the header link + $this->layout()->setVariable('searchOrigin', $results->getParams()->getSearchOrigin()); // Special case: If we're in RSS view, we need to render differently: if (isset($view->params) && $view->params->getView() == 'rss') { @@ -457,8 +461,9 @@ protected function processJumpTo($results) } $recordList = $results->getResults(); + $queryParams = $results->getParams()->getSearchOrigin()->getSearchUrlParamsArray() ?? []; return isset($recordList[$jumpto - 1]) - ? $this->getRedirectForRecord($recordList[$jumpto - 1]) : false; + ? $this->getRedirectForRecord($recordList[$jumpto - 1], $queryParams) : false; } /** @@ -479,10 +484,9 @@ protected function processJumpToOnlyResult($results) && $results->getResultTotal() == 1 && $recordList = $results->getResults() ) { - return $this->getRedirectForRecord( - reset($recordList), - ['sid' => $results->getSearchId()] - ); + $queryParams = $results->getParams()->getSearchOrigin()->getSearchUrlParamsArray() ?? []; + $queryParams['sid'] = $results->getSearchId(); + return $this->getRedirectForRecord(reset($recordList), $queryParams); } return false; diff --git a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php index b7fa1b7995c..e753a006198 100644 --- a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php +++ b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php @@ -30,6 +30,8 @@ namespace VuFind\Controller; +use VuFind\Search\SearchOrigin\AlphaBrowseSearchOrigin; +use Exception; use Laminas\Config\Config; use Laminas\View\Model\ViewModel; use VuFind\Exception\BadRequest; @@ -236,6 +238,11 @@ public function homeAction(): ViewModel $source = $this->params()->fromQuery('source', false); $from = $this->params()->fromQuery('from', false); $page = intval($this->params()->fromQuery('page', 0)); + try { + $origin = new AlphaBrowseSearchOrigin($source, $from, $page ?: null); + } catch (Exception) { + $origin = null; + } // Load highlighting configuration while accounting for special case: // highlighting is pointless if there's no user input: @@ -252,6 +259,7 @@ public function homeAction(): ViewModel 'from' => $from, 'source' => $source, 'extras' => array_filter(explode(':', $extras[$source] ?? '')), + 'origin' => $origin, ] ); diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 7c85a7c1e03..92aa2ff6aa4 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -31,6 +31,8 @@ namespace VuFind\Search\Base; +use VuFind\Search\SearchOrigin\AbstractSearchOrigin; +use VuFind\Search\SearchOrigin\SearchOriginFactory; use VuFind\I18n\TranslatableString; use VuFind\Search\Minified; use VuFind\Search\QueryAdapter; @@ -110,6 +112,13 @@ class Params */ protected $searchType = 'basic'; + /** + * Page the search originate from + * + * @var AbstractSearchOrigin|null + */ + protected $searchOrigin; + /** * Shards * @@ -371,6 +380,20 @@ public function initFromRequest($request) $this->initSort($request); $this->initFilters($request); $this->initHiddenFilters($request); + $this->initOrigin($request); + } + + /** + * Pull origin parameters (ie: alphabrowse) from the request + * + * @param \Laminas\Stdlib\Parameters $request Parameter object representing user + * request. + * + * @return void + */ + protected function initOrigin($request) + { + $this->searchOrigin = SearchOriginFactory::createObject($request->toArray()); } /** @@ -1862,6 +1885,7 @@ public function minify(Minified &$minified): void { $minified->ty = $this->getSearchType(); $minified->cl = $this->getSearchClassId(); + $minified->o = $this->getSearchOrigin(); // Search terms, we'll shorten keys $query = $this->getQuery(); @@ -1892,6 +1916,7 @@ public function deminify($minified) $this->hiddenFilters = $minified->hf; $this->searchType = $minified->ty; $this->searchContextParameters = $minified->scp; + $this->searchOrigin = $minified->o; // Deminified searches will always have defaults already applied; // we don't want to accidentally manipulate them further. @@ -1944,6 +1969,16 @@ public function getQueryIDLimit() return -1; } + /** + * Get origin (the page originating the search). + * + * @return null|AbstractSearchOrigin + */ + public function getSearchOrigin(): ?AbstractSearchOrigin + { + return $this->searchOrigin; + } + /** * Get an array of the names of all selected shards. These should correspond * with keys in the array returned by the option class's getShards() method. diff --git a/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php b/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php index 54333cd32d7..d82ecb74427 100644 --- a/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php @@ -130,6 +130,9 @@ protected function getUrlParams(Params $params, array $config) if ($hiddenFilters = $params->getHiddenFiltersAsQueryParams()) { $urlParams['hiddenFilters'] = $hiddenFilters; } + if ($origin = $params->getSearchOrigin()) { + $urlParams += $origin->getSearchUrlParamsArray(); + } $shards = $params->getSelectedShards(); if (!empty($shards)) { sort($shards); diff --git a/module/VuFind/src/VuFind/Search/Minified.php b/module/VuFind/src/VuFind/Search/Minified.php index c74cedd6bb1..4ec1fa17b91 100644 --- a/module/VuFind/src/VuFind/Search/Minified.php +++ b/module/VuFind/src/VuFind/Search/Minified.php @@ -30,6 +30,7 @@ namespace VuFind\Search; +use VuFind\Search\SearchOrigin\AbstractSearchOrigin; use VuFind\Search\Base\Results; /** @@ -142,6 +143,13 @@ class Minified */ public $scp = []; + /** + * Search origin + * + * @var AbstractSearchOrigin|null + */ + public $o; + /** * Constructor. * diff --git a/module/VuFind/src/VuFind/Search/SearchOrigin/AbstractSearchOrigin.php b/module/VuFind/src/VuFind/Search/SearchOrigin/AbstractSearchOrigin.php new file mode 100644 index 00000000000..2fcc14011a0 --- /dev/null +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/AbstractSearchOrigin.php @@ -0,0 +1,70 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ + +namespace VuFind\Search\SearchOrigin; + +/** + * Abstract object for any search origin + * + * @category VuFind + * @package TODO? + * @author Robby ROUDON + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ +abstract class AbstractSearchOrigin +{ + /** + * Name of the URL parameter containing the value of the search origin + * + * @var string + */ + public const PARAM_NAME = 'origin'; + + /** + * Get origin name + * + * @return string + */ + abstract public static function getName(): string; + + /** + * Get array of parameters to put in the search URL + * + * @return array + */ + abstract public function getSearchUrlParamsArray(): array; + + /** + * Get array of parameters to recreate the origin in the URL + * + * @return array + */ + abstract public function getOriginUrlParamsArray(): array; +} diff --git a/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php b/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php new file mode 100644 index 00000000000..a84dc8f2948 --- /dev/null +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php @@ -0,0 +1,188 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ + +namespace VuFind\Search\SearchOrigin; + +use Exception; + +/** + * Object for search originating from AlphaBrowse + * + * @category VuFind + * @package TODO? + * @author Robby ROUDON + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ +class AlphaBrowseSearchOrigin extends AbstractSearchOrigin +{ + /** + * Name of the origin of the search + * + * @var string + */ + protected const NAME = 'AB'; + + /** + * URL Parameter for "source" in search URL + * + * @var string + */ + public const SEARCH_SOURCE_PARAM = 'AB-source'; + + /** + * URL Parameter for "from" in search URL + * + * @var string + */ + public const SEARCH_FROM_PARAM = 'AB-from'; + + /** + * URL Parameter for "page" in search URL + * + * @var string + */ + public const SEARCH_PAGE_PARAM = 'AB-page'; + + /** + * URL Parameter for "source" in origin URL + * + * @var string + */ + public const ORIGIN_SOURCE_PARAM = 'source'; + + /** + * URL Parameter for "from" in origin URL + * + * @var string + */ + public const ORIGIN_FROM_PARAM = 'from'; + + /** + * URL Parameter for "page" in origin URL + * + * @var string + */ + public const ORIGIN_PAGE_PARAM = 'page'; + + /** + * Value of the parameter for "source" + * + * @var string + */ + protected $source; + + /** + * Value of the parameter for "from" + * + * @var string + */ + protected $from; + + /** + * Value of the parameter for "page" + * + * @var int + */ + protected $page; + + /** + * Constructor + * + * @param string|null $source source parameter for alpha browse search + * @param string|null $from from parameter for alpha browse search + * @param int|null $page page parameter for alpha browse search + * + * @throws Exception + */ + public function __construct(?string $source, ?string $from, ?int $page = null) + { + if (isset($source, $from) !== true) { + throw new Exception('Missing parameters'); + } + $this->source = $source; + $this->from = $from; + $this->page = $page; + } + + /** + * Get origin name + * + * @return string + */ + public static function getName(): string + { + return self::NAME; + } + + /** + * Get name to display (ie. back to author browse)) + * + * @return string + */ + public function getDisplayName(): string + { + return ucwords($this->source) . ' Browse'; + } + + /** + * Get array of parameters to put in the URL + * + * @return array + */ + public function getSearchUrlParamsArray(): array + { + $return = [ + self::PARAM_NAME => self::getName(), + self::SEARCH_SOURCE_PARAM => $this->source, + self::SEARCH_FROM_PARAM => $this->from, + ]; + if (isset($this->page)) { + $return[self::SEARCH_PAGE_PARAM] = $this->page; + } + return $return; + } + + /** + * Get array of parameters to recreate the origin in the URL + * + * @return array + */ + public function getOriginUrlParamsArray(): array + { + $return = [ + self::ORIGIN_SOURCE_PARAM => $this->source, + self::ORIGIN_FROM_PARAM => $this->from, + ]; + if (isset($this->page)) { + $return[self::ORIGIN_PAGE_PARAM] = $this->page; + } + return $return; + } +} diff --git a/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php b/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php new file mode 100644 index 00000000000..68848bfec34 --- /dev/null +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php @@ -0,0 +1,71 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ + +namespace VuFind\Search\SearchOrigin; + +use Exception; + +/** + * Factory for search origin objects + * + * @category VuFind + * @package TODO? + * @author Robby ROUDON + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ +class SearchOriginFactory +{ + /** + * From a request return an AbstractSearchOrigin object + * + * @param array $params URL GET parameters + * + * @return AbstractSearchOrigin|null + */ + public static function createObject(array $params): ?AbstractSearchOrigin + { + $nameParam = AbstractSearchOrigin::PARAM_NAME; + if (empty($params[$nameParam])) { + return null; + } + try { + return match ($params[$nameParam]) { + AlphaBrowseSearchOrigin::getName() => new AlphaBrowseSearchOrigin( + $params[AlphaBrowseSearchOrigin::SEARCH_SOURCE_PARAM] ?? null, + $params[AlphaBrowseSearchOrigin::SEARCH_FROM_PARAM] ?? null, + $params[AlphaBrowseSearchOrigin::SEARCH_PAGE_PARAM] ?? null + ), + default => null, + }; + } catch (Exception) { + return null; + } + } +} diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowse.php b/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowse.php index ca241e0b8b4..b405663d982 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowse.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowse.php @@ -29,6 +29,7 @@ namespace VuFind\View\Helper\Root; +use VuFind\Search\SearchOrigin\AbstractSearchOrigin; use Laminas\View\Helper\Url; /** @@ -71,12 +72,13 @@ public function __construct(Url $helper, array $options = []) /** * Get link to browse results (or null if no valid URL available) * - * @param string $source AlphaBrowse index currently being used - * @param array $item Item to link to + * @param string $source AlphaBrowse index currently being used + * @param array $item Item to link to + * @param AbstractSearchOrigin|null $origin Current page to provide the origin of the search * * @return string */ - public function getUrl($source, $item) + public function getUrl($source, $item, ?AbstractSearchOrigin $origin = null) { if ($item['count'] <= 0) { return null; @@ -92,6 +94,9 @@ public function getUrl($source, $item) if ($item['count'] == 1) { $query['jumpto'] = 1; } + if (isset($origin)) { + $query += $origin->getSearchUrlParamsArray(); + } return ($this->url)('search-results', [], ['query' => $query]); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php b/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php index af612fee5ea..4db88f97fe7 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php @@ -344,11 +344,16 @@ protected function getVersionsActionForSource($source) */ protected function getRecordUrlParams(array $options = []): array { - if (!empty($options['excludeSearchId'])) { - return []; + $params = []; + if ( + empty($options['excludeSearchId']) + && $sid = $this->results?->getSearchId() ?? $this->getView()->plugin('searchMemory')->getLastSearchId() + ) { + $params['sid'] = $sid; } - $sid = ($this->results ? $this->results->getSearchId() : null) - ?? $this->getView()->plugin('searchMemory')->getLastSearchId(); - return $sid ? compact('sid') : []; + if (empty($options['excludeSearchOrigin']) && $this->results?->getParams()?->getSearchOrigin()) { + $params += $this->results->getParams()->getSearchOrigin()->getSearchUrlParamsArray(); + } + return $params; } } diff --git a/themes/bootstrap3/scss/components/record.scss b/themes/bootstrap3/scss/components/record.scss index 72ff41813da..5723d371d55 100644 --- a/themes/bootstrap3/scss/components/record.scss +++ b/themes/bootstrap3/scss/components/record.scss @@ -353,3 +353,10 @@ align-items: center; justify-content: center; } + +.backtoorigin>p>a { + text-decoration: none; + &::before { + content:"← "; + } +} diff --git a/themes/bootstrap3/scss/components/search.scss b/themes/bootstrap3/scss/components/search.scss index 3badb30d9ac..7ed132c3f6b 100644 --- a/themes/bootstrap3/scss/components/search.scss +++ b/themes/bootstrap3/scss/components/search.scss @@ -523,7 +523,7 @@ body.rtl { .wikipedia img { margin-right: 1rem; } .geoItem { font-size: .9em; - margin: 0px 0px 10px; + margin: 0 0 10px; } .title-in-heading { font-size: inherit; @@ -594,10 +594,10 @@ body.rtl { .checkbox label { display: inline-block; - padding: 10px 0px; + padding: 10px 0; @media (max-width: $screen-sm-min) { float: right; - padding: 0px; + padding: 0; } } .filters-term { @@ -864,3 +864,10 @@ table.search-history-table { } } } + +.backtoorigin>p>a { + text-decoration: none; + &::before { + content:"← "; + } +} diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml index 0a0da4b8a63..ff1a80ab46b 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml @@ -1,4 +1,5 @@ recordLinker($this->results); $coverDetails = $this->record($this->driver)->getCoverDetails('result-list', 'medium', $recordLinker->getUrl($this->driver)); $cover = $coverDetails['html']; diff --git a/themes/bootstrap3/templates/alphabrowse/home.phtml b/themes/bootstrap3/templates/alphabrowse/home.phtml index 30f97d231ce..c52acba917c 100644 --- a/themes/bootstrap3/templates/alphabrowse/home.phtml +++ b/themes/bootstrap3/templates/alphabrowse/home.phtml @@ -1,4 +1,5 @@ headTitle($this->translate('Browse the Collection Alphabetically')); $this->layout()->breadcrumbs = '
  • ' . $this->transEsc('Browse Alphabetically') . '
  • '; $baseQuery = ['source' => $this->source, 'from' => $this->from]; @@ -105,7 +106,7 @@ - alphabrowse()->getUrl($this->source, $item)): ?> + alphabrowse()->getUrl($this->source, $item, $this->origin)): ?> escapeHtml($item['heading'])?> escapeHtml($item['heading'])?> diff --git a/themes/bootstrap3/templates/header.phtml b/themes/bootstrap3/templates/header.phtml index 3a9d7b20cb0..d9090ce6ea3 100644 --- a/themes/bootstrap3/templates/header.phtml +++ b/themes/bootstrap3/templates/header.phtml @@ -1,4 +1,9 @@ -auth()->getManager(); ?> +auth()->getManager(); +/** @var \VuFind\Search\SearchOrigin\AbstractSearchOrigin|null $searchOrigin */ +$searchOrigin = $this->get('searchOrigin'); +?> + + render('search/backtoorigin.phtml', ['searchOrigin' => $searchOrigin]); ?> diff --git a/themes/root/templates/search/backtoorigin.php b/themes/root/templates/search/backtoorigin.php new file mode 100644 index 00000000000..1aa492f806a --- /dev/null +++ b/themes/root/templates/search/backtoorigin.php @@ -0,0 +1,10 @@ +url('alphabrowse-home') . '?' . http_build_query($searchOrigin->getOriginUrlParamsArray()); + echo + ''; +} From e476f3e1e6315b5b76ad2adde362d6de9421f94f Mon Sep 17 00:00:00 2001 From: Robby Date: Mon, 15 Jul 2024 10:46:05 -0400 Subject: [PATCH 02/33] Back to browse results feature --- languages/en.ini | 6 +++--- languages/fr.ini | 6 +++--- themes/bootstrap3/scss/components/search.scss | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/languages/en.ini b/languages/en.ini index 77b0fb02418..bfd396228f8 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -110,13 +110,13 @@ Available = "Available" Available Functionality = "Available Functionality" Awards = "Awards" ; For back to search origin -Back to Subject Browse = "Back to Subject Browse" Back to Author Browse = "Back to Author Browse" -Back to Title Browse = "Back to Title Browse" Back to Call Number Browse = "Back to Call number Browse" -Back to Series Browse = "Back to Series Browse" Back to Record = "Back to Record" +Back to Series Browse = "Back to Series Browse" Back to Search Results = "Back to Search Results" +Back to Subject Browse = "Back to Subject Browse" +Back to Title Browse = "Back to Title Browse" Backtrace = "Backtrace" Bag = "Bag" Balance = "Balance" diff --git a/languages/fr.ini b/languages/fr.ini index 2a0eafce267..bc735a39eb1 100644 --- a/languages/fr.ini +++ b/languages/fr.ini @@ -110,12 +110,12 @@ Available = "Disponible" Available Functionality = "Fonctions disponibles" Awards = "Récompenses" ; For back to search origin -Back to Subject Browse = "Retourner à la recherche par Sujet" Back to Author Browse = "Retourner à la recherche par Auteur" -Back to Title Browse = "Retourner à la recherche par Titre" Back to Call Number Browse = "Retourner à la recherche par Cote" -Back to Series Browse = "Retourner à la recherche par Collection" Back to Record = "Retourner à la notice" +Back to Series Browse = "Retourner à la recherche par Collection" +Back to Subject Browse = "Retourner à la recherche par Sujet" +Back to Title Browse = "Retourner à la recherche par Titre" Back to Search Results = "Retourner aux résultats de recherche" Backtrace = "Historique" Bag = "Panier" diff --git a/themes/bootstrap3/scss/components/search.scss b/themes/bootstrap3/scss/components/search.scss index 7ed132c3f6b..8645ee1773b 100644 --- a/themes/bootstrap3/scss/components/search.scss +++ b/themes/bootstrap3/scss/components/search.scss @@ -523,7 +523,7 @@ body.rtl { .wikipedia img { margin-right: 1rem; } .geoItem { font-size: .9em; - margin: 0 0 10px; + margin: 0px 0px 10px; } .title-in-heading { font-size: inherit; @@ -594,10 +594,10 @@ body.rtl { .checkbox label { display: inline-block; - padding: 10px 0; + padding: 10px 0px; @media (max-width: $screen-sm-min) { float: right; - padding: 0; + padding: 0px; } } .filters-term { From a3568bd773ec58ec5081b1289697268bed80aaab Mon Sep 17 00:00:00 2001 From: Robby Date: Mon, 15 Jul 2024 10:48:16 -0400 Subject: [PATCH 03/33] Back to browse results feature --- languages/en.ini | 2 +- languages/fr.ini | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/languages/en.ini b/languages/en.ini index bfd396228f8..65180b98a9d 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -113,8 +113,8 @@ Awards = "Awards" Back to Author Browse = "Back to Author Browse" Back to Call Number Browse = "Back to Call number Browse" Back to Record = "Back to Record" -Back to Series Browse = "Back to Series Browse" Back to Search Results = "Back to Search Results" +Back to Series Browse = "Back to Series Browse" Back to Subject Browse = "Back to Subject Browse" Back to Title Browse = "Back to Title Browse" Backtrace = "Backtrace" diff --git a/languages/fr.ini b/languages/fr.ini index bc735a39eb1..69d43129b56 100644 --- a/languages/fr.ini +++ b/languages/fr.ini @@ -109,14 +109,13 @@ Availability = "Disponibilité" Available = "Disponible" Available Functionality = "Fonctions disponibles" Awards = "Récompenses" -; For back to search origin Back to Author Browse = "Retourner à la recherche par Auteur" Back to Call Number Browse = "Retourner à la recherche par Cote" Back to Record = "Retourner à la notice" +Back to Search Results = "Retourner aux résultats de recherche" Back to Series Browse = "Retourner à la recherche par Collection" Back to Subject Browse = "Retourner à la recherche par Sujet" Back to Title Browse = "Retourner à la recherche par Titre" -Back to Search Results = "Retourner aux résultats de recherche" Backtrace = "Historique" Bag = "Panier" Balance = "Solde du compte" From 3a3580772bc34b28796424a2c06d3e2818b2ae2e Mon Sep 17 00:00:00 2001 From: Robby Date: Mon, 15 Jul 2024 10:51:48 -0400 Subject: [PATCH 04/33] Back to browse results feature --- languages/en.ini | 1 - themes/bootstrap3/scss/components/search.scss | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/languages/en.ini b/languages/en.ini index 65180b98a9d..eb040430713 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -109,7 +109,6 @@ Availability = "Availability" Available = "Available" Available Functionality = "Available Functionality" Awards = "Awards" -; For back to search origin Back to Author Browse = "Back to Author Browse" Back to Call Number Browse = "Back to Call number Browse" Back to Record = "Back to Record" diff --git a/themes/bootstrap3/scss/components/search.scss b/themes/bootstrap3/scss/components/search.scss index 8645ee1773b..ea88f32e2c9 100644 --- a/themes/bootstrap3/scss/components/search.scss +++ b/themes/bootstrap3/scss/components/search.scss @@ -865,7 +865,7 @@ table.search-history-table { } } -.backtoorigin>p>a { +.backtoorigin > p > a { text-decoration: none; &::before { content:"← "; From 16bc5cde4eeff657bdf74c76faf79d7d9d3bc5be Mon Sep 17 00:00:00 2001 From: Robby Date: Thu, 25 Jul 2024 10:33:35 -0400 Subject: [PATCH 05/33] Back to browse results feature - Discussion changes --- languages/en.ini | 6 +- languages/fr.ini | 6 +- module/VuFind/config/module.config.php | 1 + .../src/VuFind/Controller/AbstractBase.php | 14 ++ .../src/VuFind/Controller/AbstractRecord.php | 3 +- .../src/VuFind/Controller/AbstractSearch.php | 35 ++- .../Controller/AlphabrowseController.php | 2 +- .../VuFind/src/VuFind/Search/Base/Params.php | 35 --- .../Search/Factory/UrlQueryHelperFactory.php | 3 - .../SearchOrigin/AlphaBrowseSearchOrigin.php | 35 ++- .../SearchOrigin/SearchOriginFactory.php | 3 +- .../VuFind/View/Helper/Root/RecordLinker.php | 4 +- .../DefaultRecord/result-list.phtml | 2 +- themes/bootstrap3/templates/header.phtml | 215 +++++++++-------- themes/bootstrap5/templates/header.phtml | 218 +++++++++--------- .../{backtoorigin.php => backtoorigin.phtml} | 0 16 files changed, 294 insertions(+), 288 deletions(-) rename themes/root/templates/search/{backtoorigin.php => backtoorigin.phtml} (100%) diff --git a/languages/en.ini b/languages/en.ini index eb040430713..ab687766c92 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -109,13 +109,9 @@ Availability = "Availability" Available = "Available" Available Functionality = "Available Functionality" Awards = "Awards" -Back to Author Browse = "Back to Author Browse" -Back to Call Number Browse = "Back to Call number Browse" +back_to_browse_by = "Back to Browse %%field%%" Back to Record = "Back to Record" Back to Search Results = "Back to Search Results" -Back to Series Browse = "Back to Series Browse" -Back to Subject Browse = "Back to Subject Browse" -Back to Title Browse = "Back to Title Browse" Backtrace = "Backtrace" Bag = "Bag" Balance = "Balance" diff --git a/languages/fr.ini b/languages/fr.ini index 69d43129b56..d7ad952c07a 100644 --- a/languages/fr.ini +++ b/languages/fr.ini @@ -109,13 +109,9 @@ Availability = "Disponibilité" Available = "Disponible" Available Functionality = "Fonctions disponibles" Awards = "Récompenses" -Back to Author Browse = "Retourner à la recherche par Auteur" -Back to Call Number Browse = "Retourner à la recherche par Cote" +back_to_browse_by = "Retour à la recherche %%field%%" Back to Record = "Retourner à la notice" Back to Search Results = "Retourner aux résultats de recherche" -Back to Series Browse = "Retourner à la recherche par Collection" -Back to Subject Browse = "Retourner à la recherche par Sujet" -Back to Title Browse = "Retourner à la recherche par Titre" Backtrace = "Historique" Bag = "Panier" Balance = "Solde du compte" diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 3f56b221b2f..78e014bed87 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -493,6 +493,7 @@ 'VuFind\Search\Params\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\Search\Results\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory', 'VuFind\Search\SearchNormalizer' => 'VuFind\Search\SearchNormalizerFactory', + \VuFind\Search\SearchOrigin\SearchOriginFactory::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, 'VuFind\Search\SearchRunner' => 'VuFind\Search\SearchRunnerFactory', 'VuFind\Search\SearchTabsHelper' => 'VuFind\Search\SearchTabsHelperFactory', 'VuFind\Search\Solr\HierarchicalFacetHelper' => 'VuFind\Search\Solr\HierarchicalFacetHelperFactory', diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index 9d6958961d9..935e2855a86 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -889,4 +889,18 @@ protected function isLocalUrl(string $url): bool $baseUrlNorm = $this->normalizeUrlForComparison($this->getServerUrl('home')); return str_starts_with($this->normalizeUrlForComparison($url), $baseUrlNorm); } + + /** + * Retrieve a service + * + * @param class-string $name Name of service to retrieve + * + * @template T + * + * @return T + */ + public function getService(string $name) + { + return $this->serviceLocator->get($name); + } } diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index 7271198100c..8cd8adbb926 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -957,7 +957,8 @@ protected function showTab($tab, $ajax = false) $view->loadInitialTabWithAjax = isset($config->Site->loadInitialTabWithAjax) && (bool) $config->Site->loadInitialTabWithAjax; try { - $this->layout()->setVariable('searchOrigin', SearchOriginFactory::createObject($this->params()->fromQuery())); + $factory = $this->getService(SearchOriginFactory::class); + $this->layout()->setVariable('searchOrigin', $factory->createObject($this->params()->fromQuery())); } catch (Exception) { } diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index 3f9c2ba11cd..7065738c9a0 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -39,6 +39,8 @@ use VuFind\Db\Service\SearchServiceInterface; use VuFind\Search\Base\Results; use VuFind\Search\RecommendListener; +use VuFind\Search\SearchOrigin\AbstractSearchOrigin; +use VuFind\Search\SearchOrigin\SearchOriginFactory; use VuFind\Solr\Utils as SolrUtils; use function count; @@ -183,8 +185,8 @@ protected function rememberSearch($results) // Only save search URL if the property tells us to... if ($this->rememberSearch) { $searchUrl = $this->url()->fromRoute( - $results->getOptions()->getSearchAction() - ) . $results->getUrlQuery()->getParams(false); + $results->getOptions()->getSearchAction() + ) . $results->getUrlQuery()->getParams(false); $this->getSearchMemory() ->rememberSearch($searchUrl, $results->getSearchId()); } @@ -373,7 +375,6 @@ protected function getSearchResultsView($setupCallback = null) $lastView = $this->getSearchMemory() ->retrieveLastSetting($this->searchClassId, 'view'); try { - /** @var Results $results */ $view->results = $results = $runner->run( $request, $this->searchClassId, @@ -395,6 +396,12 @@ protected function getSearchResultsView($setupCallback = null) $queryParams['page'] = $lastPage; return $this->redirect()->toRoute('search-results', [], [ 'query' => $queryParams ]); } + try { + $factory = $this->getService(SearchOriginFactory::class); + $searchOrigin = $factory->createObject($this->params()->fromQuery()); + } catch (Exception) { + $searchOrigin = null; + } // If we received an EmptySet back, that indicates that the real search // failed due to some kind of syntax error, and we should display a @@ -404,7 +411,7 @@ protected function getSearchResultsView($setupCallback = null) $view->parseError = true; } else { // If a "jumpto" parameter is set, deal with that now: - if ($jump = $this->processJumpTo($results)) { + if ($jump = $this->processJumpTo($results, $searchOrigin)) { return $jump; } @@ -417,7 +424,7 @@ protected function getSearchResultsView($setupCallback = null) } // Jump to only result, if configured: - if ($jump = $this->processJumpToOnlyResult($results)) { + if ($jump = $this->processJumpToOnlyResult($results, $searchOrigin)) { return $jump; } @@ -431,7 +438,9 @@ protected function getSearchResultsView($setupCallback = null) } } // For the header link - $this->layout()->setVariable('searchOrigin', $results->getParams()->getSearchOrigin()); + $this->layout()->setVariable('searchOrigin', $searchOrigin); + // For the records URL + $view->setVariable('searchOrigin', $searchOrigin); // Special case: If we're in RSS view, we need to render differently: if (isset($view->params) && $view->params->getView() == 'rss') { @@ -448,11 +457,12 @@ protected function getSearchResultsView($setupCallback = null) * Process the jumpto parameter -- either redirect to a specific record and * return view model, or ignore the parameter and return false. * - * @param \VuFind\Search\Base\Results $results Search results object. + * @param Results $results Search results object. + * @param AbstractSearchOrigin|null $searchOrigin * * @return bool|HttpResponse */ - protected function processJumpTo($results) + protected function processJumpTo($results, ?AbstractSearchOrigin $searchOrigin = null) { // Missing/invalid parameter? Ignore it: $jumpto = $this->params()->fromQuery('jumpto'); @@ -461,7 +471,7 @@ protected function processJumpTo($results) } $recordList = $results->getResults(); - $queryParams = $results->getParams()->getSearchOrigin()->getSearchUrlParamsArray() ?? []; + $queryParams = $searchOrigin?->getSearchUrlParamsArray() ?? []; return isset($recordList[$jumpto - 1]) ? $this->getRedirectForRecord($recordList[$jumpto - 1], $queryParams) : false; } @@ -469,11 +479,12 @@ protected function processJumpTo($results) /** * Process jump to record if there is only one result. * - * @param \VuFind\Search\Base\Results $results Search results object. + * @param Results $results Search results object. + * @param AbstractSearchOrigin|null $searchOrigin * * @return bool|HttpResponse */ - protected function processJumpToOnlyResult($results) + protected function processJumpToOnlyResult($results, ?AbstractSearchOrigin $searchOrigin = null) { // If jumpto is explicitly disabled (set to false, e.g. by combined search), // we should NEVER jump to a result regardless of other factors. @@ -484,7 +495,7 @@ protected function processJumpToOnlyResult($results) && $results->getResultTotal() == 1 && $recordList = $results->getResults() ) { - $queryParams = $results->getParams()->getSearchOrigin()->getSearchUrlParamsArray() ?? []; + $queryParams = $searchOrigin?->getSearchUrlParamsArray() ?? []; $queryParams['sid'] = $results->getSearchId(); return $this->getRedirectForRecord(reset($recordList), $queryParams); } diff --git a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php index e753a006198..78dc91bf28c 100644 --- a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php +++ b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php @@ -239,7 +239,7 @@ public function homeAction(): ViewModel $from = $this->params()->fromQuery('from', false); $page = intval($this->params()->fromQuery('page', 0)); try { - $origin = new AlphaBrowseSearchOrigin($source, $from, $page ?: null); + $origin = new AlphaBrowseSearchOrigin($this->defaultTypes[$source], $source, $from, $page ?: null); } catch (Exception) { $origin = null; } diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 92aa2ff6aa4..7c85a7c1e03 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -31,8 +31,6 @@ namespace VuFind\Search\Base; -use VuFind\Search\SearchOrigin\AbstractSearchOrigin; -use VuFind\Search\SearchOrigin\SearchOriginFactory; use VuFind\I18n\TranslatableString; use VuFind\Search\Minified; use VuFind\Search\QueryAdapter; @@ -112,13 +110,6 @@ class Params */ protected $searchType = 'basic'; - /** - * Page the search originate from - * - * @var AbstractSearchOrigin|null - */ - protected $searchOrigin; - /** * Shards * @@ -380,20 +371,6 @@ public function initFromRequest($request) $this->initSort($request); $this->initFilters($request); $this->initHiddenFilters($request); - $this->initOrigin($request); - } - - /** - * Pull origin parameters (ie: alphabrowse) from the request - * - * @param \Laminas\Stdlib\Parameters $request Parameter object representing user - * request. - * - * @return void - */ - protected function initOrigin($request) - { - $this->searchOrigin = SearchOriginFactory::createObject($request->toArray()); } /** @@ -1885,7 +1862,6 @@ public function minify(Minified &$minified): void { $minified->ty = $this->getSearchType(); $minified->cl = $this->getSearchClassId(); - $minified->o = $this->getSearchOrigin(); // Search terms, we'll shorten keys $query = $this->getQuery(); @@ -1916,7 +1892,6 @@ public function deminify($minified) $this->hiddenFilters = $minified->hf; $this->searchType = $minified->ty; $this->searchContextParameters = $minified->scp; - $this->searchOrigin = $minified->o; // Deminified searches will always have defaults already applied; // we don't want to accidentally manipulate them further. @@ -1969,16 +1944,6 @@ public function getQueryIDLimit() return -1; } - /** - * Get origin (the page originating the search). - * - * @return null|AbstractSearchOrigin - */ - public function getSearchOrigin(): ?AbstractSearchOrigin - { - return $this->searchOrigin; - } - /** * Get an array of the names of all selected shards. These should correspond * with keys in the array returned by the option class's getShards() method. diff --git a/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php b/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php index d82ecb74427..54333cd32d7 100644 --- a/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/UrlQueryHelperFactory.php @@ -130,9 +130,6 @@ protected function getUrlParams(Params $params, array $config) if ($hiddenFilters = $params->getHiddenFiltersAsQueryParams()) { $urlParams['hiddenFilters'] = $hiddenFilters; } - if ($origin = $params->getSearchOrigin()) { - $urlParams += $origin->getSearchUrlParamsArray(); - } $shards = $params->getSelectedShards(); if (!empty($shards)) { sort($shards); diff --git a/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php b/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php index a84dc8f2948..0b3c0b362c7 100644 --- a/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php @@ -54,21 +54,28 @@ class AlphaBrowseSearchOrigin extends AbstractSearchOrigin * * @var string */ - public const SEARCH_SOURCE_PARAM = 'AB-source'; + public const SEARCH_SOURCE_DISPLAY_PARAM = 'AB-sd'; + + /** + * URL Parameter for "source" in search URL + * + * @var string + */ + public const SEARCH_SOURCE_PARAM = 'AB-s'; /** * URL Parameter for "from" in search URL * * @var string */ - public const SEARCH_FROM_PARAM = 'AB-from'; + public const SEARCH_FROM_PARAM = 'AB-f'; /** * URL Parameter for "page" in search URL * * @var string */ - public const SEARCH_PAGE_PARAM = 'AB-page'; + public const SEARCH_PAGE_PARAM = 'AB-p'; /** * URL Parameter for "source" in origin URL @@ -91,6 +98,13 @@ class AlphaBrowseSearchOrigin extends AbstractSearchOrigin */ public const ORIGIN_PAGE_PARAM = 'page'; + /** + * Value of the parameter for "sourceDisplay" + * + * @var string + */ + protected $sourceDisplay; + /** * Value of the parameter for "source" * @@ -115,17 +129,19 @@ class AlphaBrowseSearchOrigin extends AbstractSearchOrigin /** * Constructor * - * @param string|null $source source parameter for alpha browse search - * @param string|null $from from parameter for alpha browse search - * @param int|null $page page parameter for alpha browse search + * @param string|null $sourceDisplay Display source parameter for alpha browse search + * @param string|null $source source parameter for alpha browse search + * @param string|null $from from parameter for alpha browse search + * @param int|null $page page parameter for alpha browse search * * @throws Exception */ - public function __construct(?string $source, ?string $from, ?int $page = null) + public function __construct(?string $sourceDisplay, ?string $source, ?string $from, ?int $page = null) { - if (isset($source, $from) !== true) { + if (isset($sourceDisplay, $source, $from) !== true) { throw new Exception('Missing parameters'); } + $this->sourceDisplay = $sourceDisplay; $this->source = $source; $this->from = $from; $this->page = $page; @@ -148,7 +164,7 @@ public static function getName(): string */ public function getDisplayName(): string { - return ucwords($this->source) . ' Browse'; + return $this->sourceDisplay; } /** @@ -160,6 +176,7 @@ public function getSearchUrlParamsArray(): array { $return = [ self::PARAM_NAME => self::getName(), + self::SEARCH_SOURCE_DISPLAY_PARAM => $this->sourceDisplay, self::SEARCH_SOURCE_PARAM => $this->source, self::SEARCH_FROM_PARAM => $this->from, ]; diff --git a/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php b/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php index 68848bfec34..b3126b878b4 100644 --- a/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php @@ -49,7 +49,7 @@ class SearchOriginFactory * * @return AbstractSearchOrigin|null */ - public static function createObject(array $params): ?AbstractSearchOrigin + public function createObject(array $params): ?AbstractSearchOrigin { $nameParam = AbstractSearchOrigin::PARAM_NAME; if (empty($params[$nameParam])) { @@ -58,6 +58,7 @@ public static function createObject(array $params): ?AbstractSearchOrigin try { return match ($params[$nameParam]) { AlphaBrowseSearchOrigin::getName() => new AlphaBrowseSearchOrigin( + $params[AlphaBrowseSearchOrigin::SEARCH_SOURCE_DISPLAY_PARAM] ?? null, $params[AlphaBrowseSearchOrigin::SEARCH_SOURCE_PARAM] ?? null, $params[AlphaBrowseSearchOrigin::SEARCH_FROM_PARAM] ?? null, $params[AlphaBrowseSearchOrigin::SEARCH_PAGE_PARAM] ?? null diff --git a/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php b/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php index 4db88f97fe7..011120db1be 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/RecordLinker.php @@ -351,8 +351,8 @@ protected function getRecordUrlParams(array $options = []): array ) { $params['sid'] = $sid; } - if (empty($options['excludeSearchOrigin']) && $this->results?->getParams()?->getSearchOrigin()) { - $params += $this->results->getParams()->getSearchOrigin()->getSearchUrlParamsArray(); + if (empty($options['excludeSearchOrigin']) && isset($options['searchOrigin'])) { + $params += $options['searchOrigin']->getSearchUrlParamsArray(); } return $params; } diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml index ff1a80ab46b..a7a995cad10 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/result-list.phtml @@ -22,7 +22,7 @@

    - + record($this->driver)->getTitleHtml()?> driver->tryMethod('getTitlesAltScript', [], []) as $altTitle): ?> diff --git a/themes/bootstrap3/templates/header.phtml b/themes/bootstrap3/templates/header.phtml index d9090ce6ea3..d29b37ff17d 100644 --- a/themes/bootstrap3/templates/header.phtml +++ b/themes/bootstrap3/templates/header.phtml @@ -5,122 +5,121 @@ $account = $this->auth()->getManager(); $searchOrigin = $this->get('searchOrigin'); ?> layout()->searchbox !== false): ?> -