diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php index aac4f035995c2410bf495ca23504a49045a2bfa2..87f8bcb5d8b90565fd2ddf1408681d44deb5ea92 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php @@ -284,6 +284,33 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper return $this->cachedConfigs[$activeSearchClass]; } + /** + * Support method for getCombinedHandlers(): get alphabrowse options. + * + * @param string $activeHandler Current active search handler + * @param bool $indent Should we indent these options? + * + * @return array + */ + protected function getAlphabrowseHandlers($activeHandler, $indent = true) + { + $alphaBrowseBase = $this->getView()->plugin('url') + ->__invoke('alphabrowse-home'); + $labelPrefix = $this->getView()->translate('Browse Alphabetically') . ': '; + $handlers = []; + foreach ($this->alphabrowseConfig as $source => $label) { + $alphaBrowseUrl = $alphaBrowseBase . '?source=' . urlencode($source) + . '&from='; + $handlers[] = [ + 'value' => 'External:' . $alphaBrowseUrl, + 'label' => $labelPrefix . $this->getView()->translate($label), + 'indent' => $indent, + 'selected' => $activeHandler == 'AlphaBrowse:' . $source + ]; + } + return $handlers; + } + /** * Support method for getHandlers() -- load combined settings. * @@ -298,6 +325,7 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper $handlers = []; $selectedFound = false; $backupSelectedIndex = false; + $addedBrowseHandlers = false; $settings = $this->getCombinedHandlerConfig($activeSearchClass); $typeCount = count($settings['type']); for ($i = 0; $i < $typeCount; $i++) { @@ -330,6 +358,14 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper 'selected' => $selected ]; } + + // Should we add alphabrowse links? + if ($target === 'Solr' && $this->alphaBrowseOptionsEnabled()) { + $addedBrowseHandlers = true; + $handlers = array_merge( + $handlers, $this->getAlphaBrowseHandlers($activeHandler) + ); + } } elseif ($type == 'External') { $handlers[] = [ 'value' => $type . ':' . $target, 'label' => $label, @@ -338,22 +374,12 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper } } - // Should we add alphabrowse links? - if ($this->alphaBrowseOptionsEnabled()) { - $alphaBrowseBase = $this->getView()->plugin('url') - ->__invoke('alphabrowse-home'); - $labelPrefix = $this->getView()->translate('Browse Alphabetically') - . ': '; - foreach ($this->alphabrowseConfig as $source => $label) { - $alphaBrowseUrl = $alphaBrowseBase . '?source=' . urlencode($source) - . '&from='; - $handlers[] = [ - 'value' => 'External:' . $alphaBrowseUrl, - 'label' => $labelPrefix . $this->getView()->translate($label), - 'indent' => false, - 'selected' => $activeHandler == 'AlphaBrowse:' . $source - ]; - } + // If we didn't add alphabrowse links above as part of the Solr section + // but we are configured to include them, we should add them now: + if (!$addedBrowseHandlers && $this->alphaBrowseOptionsEnabled()) { + $handlers = array_merge( + $handlers, $this->getAlphaBrowseHandlers($activeHandler, false) + ); } // If we didn't find an exact match for a selected index, use a fuzzy