Skip to content
Snippets Groups Projects
Commit caa0accf authored by Demian Katz's avatar Demian Katz
Browse files

Load AlphaBrowse options in more appropriate context.

parent 57fe66ce
No related merge requests found
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment