diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 5062e9579f58a9074f5bbb359c5ee6f1b8d1b2c1..f1df82a0cf77310e98612a0cf9de6a2c36d47a9b 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -909,7 +909,7 @@ class Params implements ServiceLocatorAwareInterface // Extract the facet field name from the filter, then add the // relevant information to the array. list($fieldName) = explode(':', $filter); - $this->checkboxFacets[$fieldName] + $this->checkboxFacets[$fieldName][] = ['desc' => $desc, 'filter' => $filter]; } @@ -1072,12 +1072,14 @@ class Params implements ServiceLocatorAwareInterface protected function getCheckboxFacetValues() { $list = []; - foreach ($this->checkboxFacets as $current) { - list($field, $value) = $this->parseFilter($current['filter']); - if (!isset($list[$field])) { - $list[$field] = []; + foreach ($this->checkboxFacets as $facets) { + foreach ($facets as $current) { + list($field, $value) = $this->parseFilter($current['filter']); + if (!isset($list[$field])) { + $list[$field] = []; + } + $list[$field][] = $value; } - $list[$field][] = $value; } return $list; } @@ -1091,20 +1093,18 @@ class Params implements ServiceLocatorAwareInterface { // Build up an array of checkbox facets with status booleans and // toggle URLs. - $facets = []; - foreach ($this->checkboxFacets as $field => $details) { - $facets[$field] = $details; - if ($this->hasFilter($details['filter'])) { - $facets[$field]['selected'] = true; - } else { - $facets[$field]['selected'] = false; + $result = []; + foreach ($this->checkboxFacets as $field => $facets) { + foreach ($facets as $facet) { + $facet['selected'] = $this->hasFilter($facet['filter']); + // Is this checkbox always visible, even if non-selected on the + // "no results" screen? By default, no (may be overridden by + // child classes). + $facet['alwaysVisible'] = false; + $result[] = $facet; } - // Is this checkbox always visible, even if non-selected on the - // "no results" screen? By default, no (may be overridden by - // child classes). - $facets[$field]['alwaysVisible'] = false; } - return $facets; + return $result; } /** @@ -1770,4 +1770,24 @@ class Params implements ServiceLocatorAwareInterface { return $this->defaultsApplied; } + + /** + * Initialize checkbox facet settings for the specified configuration sections. + * + * @param string $facetList Config section containing fields to activate + * @param string $cfgFile Name of configuration to load + * + * @return bool True if facets set, false if no settings found + */ + protected function initCheckboxFacets($facetList = 'CheckboxFacets', + $cfgFile = 'facets' + ) { + $config = $this->getServiceLocator()->get('VuFind\Config')->get($cfgFile); + if (empty($config->$facetList)) { + return false; + } + foreach ($config->$facetList as $key => $value) { + $this->addCheckboxFacet($key, $value); + } + } } diff --git a/module/VuFind/src/VuFind/Search/Primo/Params.php b/module/VuFind/src/VuFind/Search/Primo/Params.php index cb371c78f8ac473eaef7f175f743ee02670707aa..8de1045b1de1693dc4d9b29f64da6a5cb2285019 100644 --- a/module/VuFind/src/VuFind/Search/Primo/Params.php +++ b/module/VuFind/src/VuFind/Search/Primo/Params.php @@ -114,5 +114,6 @@ class Params extends \VuFind\Search\Base\Params { $this->initFacetList('Facets', 'Results_Settings', 'Primo'); $this->initFacetList('Advanced_Facets', 'Advanced_Facet_Settings', 'Primo'); + $this->initCheckboxFacets('CheckboxFacets', 'Primo'); } } diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php index 30661c1b2400bddc88cb9261cc46dd2f8278a0e8..06df69db698501987534ab3b0732dbbfecc82eb5 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Params.php +++ b/module/VuFind/src/VuFind/Search/Solr/Params.php @@ -363,6 +363,7 @@ class Params extends \VuFind\Search\Base\Params $this->initAdvancedFacets(); $this->initBasicFacets(); } + $this->initCheckboxFacets(); } /** diff --git a/module/VuFind/src/VuFind/Search/Summon/Params.php b/module/VuFind/src/VuFind/Search/Summon/Params.php index 217fa24235a06d5d4fc5327f5b9c6dd582088f62..17b911c0c65ffc9dfe0cf1e433d559386448defe 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Params.php +++ b/module/VuFind/src/VuFind/Search/Summon/Params.php @@ -339,5 +339,6 @@ class Params extends \VuFind\Search\Base\Params { $this->initFacetList('Facets', 'Results_Settings', 'Summon'); $this->initFacetList('Advanced_Facets', 'Advanced_Facet_Settings', 'Summon'); + $this->initCheckboxFacets('CheckboxFacets', 'Summon'); } } diff --git a/themes/bootstrap3/templates/search/history-table.phtml b/themes/bootstrap3/templates/search/history-table.phtml index 9daf184a3e2e8ae507d709d41cd5a6cb75077df2..27126e25d9bc515c0411f387f6f79b1f3d17dace 100644 --- a/themes/bootstrap3/templates/search/history-table.phtml +++ b/themes/bootstrap3/templates/search/history-table.phtml @@ -18,12 +18,17 @@ ?></a> </td> <td> - <? $info->getParams()->activateAllFacets(); foreach ($info->getParams()->getFilterList() as $field => $filters): ?> + <? $info->getParams()->activateAllFacets(); foreach ($info->getParams()->getFilterList(true) as $field => $filters): ?> <? foreach ($filters as $i => $filter): ?> <? if ($filter['operator'] == 'NOT') echo $this->transEsc('NOT') . ' '; if ($filter['operator'] == 'OR' && $i > 0) echo $this->transEsc('OR') . ' '; ?> <strong><?=$this->transEsc($field)?></strong>: <?=$this->escapeHtml($filter['displayText'])?><br/> <? endforeach; ?> <? endforeach; ?> + <? foreach($info->getParams()->getCheckboxFacets() as $facet): ?> + <? if ($facet['selected']): ?> + <strong><?=$this->transEsc($facet['desc'])?></strong><br/> + <? endif; ?> + <? endforeach; ?> </td> <td><?=$this->escapeHtml($this->localizedNumber($info->getResultTotal()))?></td> <? if ($saveSupported): ?> diff --git a/themes/jquerymobile/templates/search/history-table.phtml b/themes/jquerymobile/templates/search/history-table.phtml index c43cabf5643df5824d5ef8f76311318a7e319e56..480d6d22f14953df79e1c0bcebf2e83b177a2e4a 100644 --- a/themes/jquerymobile/templates/search/history-table.phtml +++ b/themes/jquerymobile/templates/search/history-table.phtml @@ -10,11 +10,16 @@ ?></h3> <span class="ui-li-count"><?=$this->escapeHtml($this->localizedNumber($info->getResultTotal()))?></span> <p><strong><?=$this->transEsc("history_time")?></strong>: <?=$this->escapeHtml($this->dateTime()->convertToDisplayDateAndTime("U", $info->getStartTime()))?></p> - <? $info->getParams()->activateAllFacets(); foreach ($info->getParams()->getFilterList() as $field => $filters): ?> + <? $info->getParams()->activateAllFacets(); foreach ($info->getParams()->getFilterList(true) as $field => $filters): ?> <? foreach ($filters as $i => $filter): ?> <p><? if ($filter['operator'] == 'NOT') echo $this->transEsc('NOT') . ' '; if ($filter['operator'] == 'OR' && $i > 0) echo $this->transEsc('OR') . ' '; ?><strong><?=$this->transEsc($field)?></strong>: <?=$this->escapeHtml($filter['displayText'])?></p> <? endforeach; ?> <? endforeach; ?> + <? foreach($info->getParams()->getCheckboxFacets() as $facet): ?> + <? if ($facet['selected']): ?> + <p><strong><?=$this->transEsc($facet['desc'])?></strong></p> + <? endif; ?> + <? endforeach; ?> </div> </a> <? if ($saveSupported): ?>