diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php index 071ac7404507fbaaf9fb1d39f32e9a1900c17320..b945bc619ec498c11f619442818e6bc854d6df5c 100644 --- a/module/VuFind/src/VuFind/Search/Base/Params.php +++ b/module/VuFind/src/VuFind/Search/Base/Params.php @@ -1428,4 +1428,33 @@ class Params implements ServiceLocatorAwareInterface } return $this->query; } + + /** + * Initialize facet settings for the specified configuration sections. + * + * @param string $facetList Config section containing fields to activate + * @param string $facetSettings Config section containing related settings + * @param string $cfgFile Name of configuration to load + * + * @return bool True if facets set, false if no settings found + */ + protected function initFacetList($facetList, $facetSettings, $cfgFile = 'facets') + { + $config = $this->getServiceLocator()->get('VuFind\Config')->get($cfgFile); + if (!isset($config->$facetList)) { + return false; + } + if (isset($config->$facetSettings->orFacets)) { + $orFields + = array_map('trim', explode(',', $config->$facetSettings->orFacets)); + } else { + $orFields = array(); + } + foreach ($config->$facetList as $key => $value) { + $useOr = (isset($orFields[0]) && $orFields[0] == '*') + || in_array($key, $orFields); + $this->addFacet($key, $value, $useOr); + } + return true; + } } \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php index 4454b808943a2cf19527d6d2ea4934775986965d..e6c44bd852613b071877bbae2f6cc1b09e051546 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Params.php +++ b/module/VuFind/src/VuFind/Search/Solr/Params.php @@ -234,32 +234,19 @@ class Params extends \VuFind\Search\Base\Params * * @param string $facetList Config section containing fields to activate * @param string $facetSettings Config section containing related settings + * @param string $cfgFile Name of configuration to load * * @return bool True if facets set, false if no settings found */ - protected function initFacetList($facetList, $facetSettings) + protected function initFacetList($facetList, $facetSettings, $cfgFile = 'facets') { $config = $this->getServiceLocator()->get('VuFind\Config')->get('facets'); - if (!isset($config->$facetList)) { - return false; - } - if (isset($config->$facetSettings->orFacets)) { - $orFields - = array_map('trim', explode(',', $config->$facetSettings->orFacets)); - } else { - $orFields = array(); - } - foreach ($config->$facetList as $key => $value) { - $useOr = (isset($orFields[0]) && $orFields[0] == '*') - || in_array($key, $orFields); - $this->addFacet($key, $value, $useOr); - } if (isset($config->$facetSettings->facet_limit) && is_numeric($config->$facetSettings->facet_limit) ) { $this->setFacetLimit($config->$facetSettings->facet_limit); } - return true; + return parent::initFacetList($facetList, $facetSettings, $cfgFile); } /** diff --git a/module/VuFind/src/VuFind/Search/Summon/Params.php b/module/VuFind/src/VuFind/Search/Summon/Params.php index 04c56fef9d8eaec5f18434f42dc6f208d344b961..9cde5cc1bcbbb078bb777e412fc9d082ccd06efe 100644 --- a/module/VuFind/src/VuFind/Search/Summon/Params.php +++ b/module/VuFind/src/VuFind/Search/Summon/Params.php @@ -296,4 +296,21 @@ class Params extends \VuFind\Search\Base\Params return $filter; } + + /** + * Load all available facet settings. This is mainly useful for showing + * appropriate labels when an existing search has multiple filters associated + * with it. + * + * @param string $preferredSection Section to favor when loading settings; if + * multiple sections contain the same facet, this section's description will + * be favored. + * + * @return void + */ + public function activateAllFacets($preferredSection = false) + { + $this->initFacetList('Facets', 'Results_Settings', 'Summon'); + $this->initFacetList('Advanced_Facets', 'Advanced_Facet_Settings', 'Summon'); + } } \ No newline at end of file