diff --git a/languages/en.ini b/languages/en.ini index 9fc9f5b7d8c..fcd7dbe4adf 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -111,6 +111,7 @@ Available Functionality = "Available Functionality" Awards = "Awards" Back to Record = "Back to Record" Back to Search Results = "Back to Search Results" +back_to_browse_by = "Back to Browse %%field%%" Backtrace = "Backtrace" Bag = "Bag" Balance = "Balance" diff --git a/languages/fr.ini b/languages/fr.ini index bfb2875d497..166aad70dbe 100644 --- a/languages/fr.ini +++ b/languages/fr.ini @@ -111,6 +111,7 @@ Available Functionality = "Fonctions disponibles" Awards = "Récompenses" Back to Record = "Retourner à la notice" Back to Search Results = "Retourner aux résultats de recherche" +back_to_browse_by = "Retour à la recherche %%field%%" 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 9a74716244e..73f4b584e5a 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -506,6 +506,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/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index b473d395e73..a078ef927ea 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -37,6 +37,7 @@ use VuFind\Ratings\RatingsService; use VuFind\Record\ResourcePopulator; use VuFind\RecordDriver\AbstractBase as AbstractRecordDriver; +use VuFind\Search\SearchOrigin\SearchOriginFactory; use VuFind\Tags\TagsService; use VuFindSearch\ParamBag; @@ -955,9 +956,9 @@ protected function showTab($tab, $ajax = false) $view->defaultTab = strtolower($this->getDefaultTab()); $view->backgroundTabs = $this->getBackgroundTabs(); $view->tabsExtraScripts = $this->getTabsExtraScripts($view->tabs); - $view->loadInitialTabWithAjax - = isset($config->Site->loadInitialTabWithAjax) - ? (bool)$config->Site->loadInitialTabWithAjax : false; + $view->loadInitialTabWithAjax = (bool)($config->Site->loadInitialTabWithAjax ?? false); + $factory = $this->getService(SearchOriginFactory::class); + $this->layout()->setVariable('searchOrigin', $factory->createObject($this->params()->fromQuery())); // 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 8fbcde210a8..e3dd6a89ac0 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -37,7 +37,10 @@ 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\Search\SearchOrigin\AbstractSearchOrigin; +use VuFind\Search\SearchOrigin\SearchOriginFactory; use VuFind\Solr\Utils as SolrUtils; use function count; @@ -393,6 +396,8 @@ protected function getSearchResultsView($setupCallback = null) $queryParams['page'] = $lastPage; return $this->redirect()->toRoute('search-results', [], [ 'query' => $queryParams ]); } + $factory = $this->getService(SearchOriginFactory::class); + $searchOrigin = $factory->createObject($this->params()->fromQuery()); // 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 @@ -402,7 +407,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; } @@ -415,7 +420,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; } @@ -428,6 +433,8 @@ protected function getSearchResultsView($setupCallback = null) $this->flashMessenger()->addErrorMessage($error); } } + // For the header link + $this->layout()->setVariable('searchOrigin', $searchOrigin); // Special case: If we're in RSS view, we need to render differently: if (isset($view->params) && $view->params->getView() == 'rss') { @@ -444,11 +451,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 Search origin to propagate * * @return bool|HttpResponse */ - protected function processJumpTo($results) + protected function processJumpTo($results, ?AbstractSearchOrigin $searchOrigin = null) { // Missing/invalid parameter? Ignore it: $jumpto = $this->params()->fromQuery('jumpto'); @@ -457,18 +465,20 @@ protected function processJumpTo($results) } $recordList = $results->getResults(); + $queryParams = $searchOrigin?->getSearchUrlParamsArray() ?? []; return isset($recordList[$jumpto - 1]) - ? $this->getRedirectForRecord($recordList[$jumpto - 1]) : false; + ? $this->getRedirectForRecord($recordList[$jumpto - 1], $queryParams) : false; } /** * 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 Search origin to propagate * * @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. @@ -479,10 +489,9 @@ protected function processJumpToOnlyResult($results) && $results->getResultTotal() == 1 && $recordList = $results->getResults() ) { - return $this->getRedirectForRecord( - reset($recordList), - ['sid' => $results->getSearchId()] - ); + $queryParams = $searchOrigin?->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..541a9806f87 100644 --- a/module/VuFind/src/VuFind/Controller/AlphabrowseController.php +++ b/module/VuFind/src/VuFind/Controller/AlphabrowseController.php @@ -30,9 +30,11 @@ namespace VuFind\Controller; +use Exception; use Laminas\Config\Config; use Laminas\View\Model\ViewModel; use VuFind\Exception\BadRequest; +use VuFind\Search\SearchOrigin\AlphaBrowseSearchOrigin; use VuFindSearch\ParamBag; use function in_array; @@ -236,6 +238,16 @@ 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( + $this->getTypes($config)[$source] ?? null, + $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 +264,7 @@ public function homeAction(): ViewModel 'from' => $from, 'source' => $source, 'extras' => array_filter(explode(':', $extras[$source] ?? '')), + 'origin' => $origin, ] ); diff --git a/module/VuFind/src/VuFind/Controller/WebController.php b/module/VuFind/src/VuFind/Controller/WebController.php index 1b4f957f40f..464129ae267 100644 --- a/module/VuFind/src/VuFind/Controller/WebController.php +++ b/module/VuFind/src/VuFind/Controller/WebController.php @@ -30,6 +30,7 @@ namespace VuFind\Controller; use Laminas\ServiceManager\ServiceLocatorInterface; +use VuFind\Search\SearchOrigin\AbstractSearchOrigin; /** * Web Controller @@ -57,11 +58,12 @@ public function __construct(ServiceLocatorInterface $sm) * 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 \VuFind\Search\Base\Results $results Search results object. + * @param AbstractSearchOrigin|null $searchOrigin Search origin to propagate * * @return mixed */ - protected function processJumpTo($results) + protected function processJumpTo($results, ?AbstractSearchOrigin $searchOrigin = null) { // Missing/invalid parameter? Ignore it: $jumpto = $this->params()->fromQuery('jumpto'); 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..40f14ed5519 --- /dev/null +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/AbstractSearchOrigin.php @@ -0,0 +1,91 @@ + + * @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 Search + * @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; + + /** + * Get route name to generate the url + * + * @return string + */ + abstract public function getRouteName(): string; + + /** + * Get translation label + * + * @return string + */ + abstract public function getLinkTranslationKey(): string; + + /** + * Get translation label for breadcrumbs + * + * @return string + */ + abstract public function getBreadcrumbsTranslationKey(): string; +} 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..d2839ec3381 --- /dev/null +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/AlphaBrowseSearchOrigin.php @@ -0,0 +1,256 @@ + + * @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 Search + * @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'; + + /** + * Name of the route to get back to + * + * @var string + */ + protected const ROUTE_NAME = 'alphabrowse-home'; + + /** + * Config key for translation + * + * @var string + */ + protected const TRANSLATION_KEY = 'back_to_browse_by'; + + /** + * Config key for translation for the purpose of breadcrumbs + * + * @var string + */ + protected const BREADCRUMBS_TRANSLATION_KEY = 'Browse Alphabetically'; + + /** + * URL Parameter for "source to display" in search URL to be displayed (e.g., "call number" instead of "lcc") + * + * @var string + */ + public const SEARCH_SOURCE_DISPLAY_PARAM = 'AB-sd'; + + /** + * URL Parameter for "source" in search URL to be used in 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-f'; + + /** + * URL Parameter for "page" in search URL + * + * @var string + */ + public const SEARCH_PAGE_PARAM = 'AB-p'; + + /** + * 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 "sourceDisplay" + * + * @var string + */ + protected $sourceDisplay; + + /** + * 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 $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 $sourceDisplay, ?string $source, ?string $from, ?int $page = null) + { + if (isset($sourceDisplay, $source, $from) !== true) { + throw new Exception('Missing parameters'); + } + $this->sourceDisplay = $sourceDisplay; + $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 $this->sourceDisplay; + } + + /** + * Get array of parameters to put in the URL + * + * @return array + */ + 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, + ]; + 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; + } + + /** + * Get route name to generate the url + * + * @return string + */ + public function getRouteName(): string + { + return self::ROUTE_NAME; + } + + /** + * Get translation label + * + * @return string + */ + public function getLinkTranslationKey(): string + { + return self::TRANSLATION_KEY; + } + + /** + * Get translation label for breadcrumbs + * + * @return string + */ + public function getBreadcrumbsTranslationKey(): string + { + return self::BREADCRUMBS_TRANSLATION_KEY; + } +} 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..0155ab4bb0c --- /dev/null +++ b/module/VuFind/src/VuFind/Search/SearchOrigin/SearchOriginFactory.php @@ -0,0 +1,87 @@ + + * @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 Search + * @author Robby ROUDON + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ +class SearchOriginFactory implements \Laminas\Log\LoggerAwareInterface +{ + use \VuFind\Log\LoggerAwareTrait; + + /** + * From request parameters return an AbstractSearchOrigin object + * + * @param array $params URL GET parameters + * + * @return AbstractSearchOrigin|null + */ + public function createObject(array $params): ?AbstractSearchOrigin + { + if (empty($params[AbstractSearchOrigin::PARAM_NAME])) { + return null; + } + try { + return self::createObjectByName($params); + } catch (Exception $e) { + $this->logWarning('Error while trying to build search origin object : ' . $e->getMessage()); + return null; + } + } + + /** + * From (request) parameters return an AbstractSearchOrigin object by name + * + * @param array $params Parameters + * + * @return AlphaBrowseSearchOrigin|null + * @throws Exception + */ + public static function createObjectByName(array $params): ?AlphaBrowseSearchOrigin + { + return match ($params[AbstractSearchOrigin::PARAM_NAME]) { + 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 + ), + default => 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..6ca9baf87fa 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowse.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AlphaBrowse.php @@ -30,6 +30,7 @@ namespace VuFind\View\Helper\Root; use Laminas\View\Helper\Url; +use VuFind\Search\SearchOrigin\AbstractSearchOrigin; /** * AlphaBrowse view helper @@ -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,8 @@ public function getUrl($source, $item) if ($item['count'] == 1) { $query['jumpto'] = 1; } + $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..011120db1be 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']) && 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 98bf220428e..29f3f9d7450 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); $largeImage = $this->record($this->driver)->getThumbnail('large'); $linkAttributes = $largeImage ? ['href' => $largeImage, 'data-lightbox-image' => 'true'] : []; @@ -23,7 +24,7 @@

- + record($this->driver)->getTitleHtml()?> driver->tryMethod('getTitlesAltScript', [], []) as $altTitle): ?> 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/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml index 3235bc478d3..5184778ee37 100644 --- a/themes/bootstrap3/templates/layout/layout.phtml +++ b/themes/bootstrap3/templates/layout/layout.phtml @@ -11,6 +11,8 @@ if (!isset($this->layout()->searchbox)) { $this->layout()->searchbox = $this->context($this)->renderInContext('search/searchbox.phtml', []); } + /** @var \VuFind\Search\SearchOrigin\AbstractSearchOrigin|null $searchOrigin */ + $searchOrigin = $this->layout()->searchOrigin; ?> layout()->rtl): ?> dir="rtl"> @@ -145,12 +147,25 @@ transEsc('Skip to content') ?> render('header.phtml')?> - layout()->showBreadcrumbs ?? true) && $this->layout()->breadcrumbs !== false): ?> + layout()->showBreadcrumbs ?? true) && $this->layout()->breadcrumbs !== false): + if (isset($searchOrigin)) { + $link = $this->url($searchOrigin->getRouteName()) . '?' . http_build_query($searchOrigin->getOriginUrlParamsArray()); + $fieldValue = $this->translate($searchOrigin->getDisplayName()); + $searchOriginBreadcrumb = '
  • ' . + $this->transEsc($searchOrigin->getBreadcrumbsTranslationKey()) . + '
  • '; + } else { + $searchOriginBreadcrumb = ''; + } + ?> + + render('search/back-to-origin.phtml', ['searchOrigin' => $searchOrigin]); ?>
    diff --git a/themes/bootstrap3/templates/search/back-to-origin.phtml b/themes/bootstrap3/templates/search/back-to-origin.phtml new file mode 100644 index 00000000000..76c2e4cb9f5 --- /dev/null +++ b/themes/bootstrap3/templates/search/back-to-origin.phtml @@ -0,0 +1,16 @@ +url($searchOrigin->getRouteName()) . '?' . http_build_query($searchOrigin->getOriginUrlParamsArray()); + $fieldValue = $this->translate($searchOrigin->getDisplayName()); + ?> + + diff --git a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/result-list.phtml b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/result-list.phtml index 98bf220428e..29f3f9d7450 100644 --- a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/result-list.phtml +++ b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/result-list.phtml @@ -1,4 +1,5 @@ recordLinker($this->results); $largeImage = $this->record($this->driver)->getThumbnail('large'); $linkAttributes = $largeImage ? ['href' => $largeImage, 'data-lightbox-image' => 'true'] : []; @@ -23,7 +24,7 @@

    - + record($this->driver)->getTitleHtml()?> driver->tryMethod('getTitlesAltScript', [], []) as $altTitle): ?> diff --git a/themes/bootstrap5/templates/alphabrowse/home.phtml b/themes/bootstrap5/templates/alphabrowse/home.phtml index 30f97d231ce..c52acba917c 100644 --- a/themes/bootstrap5/templates/alphabrowse/home.phtml +++ b/themes/bootstrap5/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/bootstrap5/templates/layout/layout.phtml b/themes/bootstrap5/templates/layout/layout.phtml index 46e73bb82ff..b15a6ccb591 100644 --- a/themes/bootstrap5/templates/layout/layout.phtml +++ b/themes/bootstrap5/templates/layout/layout.phtml @@ -11,6 +11,8 @@ if (!isset($this->layout()->searchbox)) { $this->layout()->searchbox = $this->context($this)->renderInContext('search/searchbox.phtml', []); } + /** @var \VuFind\Search\SearchOrigin\AbstractSearchOrigin|null $searchOrigin */ + $searchOrigin = $this->layout()->searchOrigin; ?> layout()->rtl): ?> dir="rtl"> @@ -145,12 +147,25 @@ transEsc('Skip to content') ?> render('header.phtml')?> - layout()->showBreadcrumbs ?? true) && $this->layout()->breadcrumbs !== false): ?> + layout()->showBreadcrumbs ?? true) && $this->layout()->breadcrumbs !== false): + if (isset($searchOrigin)) { + $link = $this->url($searchOrigin->getRouteName()) . '?' . http_build_query($searchOrigin->getOriginUrlParamsArray()); + $fieldValue = $this->translate($searchOrigin->getDisplayName()); + $searchOriginBreadcrumb = '
  • ' . + $this->transEsc($searchOrigin->getBreadcrumbsTranslationKey()) . + '
  • '; + } else { + $searchOriginBreadcrumb = ''; + } + ?> + + render('search/back-to-origin.phtml', ['searchOrigin' => $searchOrigin]); ?>
    diff --git a/themes/bootstrap5/templates/search/back-to-origin.phtml b/themes/bootstrap5/templates/search/back-to-origin.phtml new file mode 100644 index 00000000000..76c2e4cb9f5 --- /dev/null +++ b/themes/bootstrap5/templates/search/back-to-origin.phtml @@ -0,0 +1,16 @@ +url($searchOrigin->getRouteName()) . '?' . http_build_query($searchOrigin->getOriginUrlParamsArray()); + $fieldValue = $this->translate($searchOrigin->getDisplayName()); + ?> + +