From 33afdb3919fa222af91e5c95cf61b361d0ff96c7 Mon Sep 17 00:00:00 2001 From: Jochen Lienhard <lienhard@ub.uni-freiburg.de> Date: Wed, 1 Jul 2015 09:14:34 -0400 Subject: [PATCH] Modified SolrWeb to read more configs from website.ini. --- config/vufind/website.ini | 14 ++++++++++ .../Search/Factory/SolrWebBackendFactory.php | 27 ++++++++++++++++++- .../VuFind/src/VuFind/Search/Solr/Params.php | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/config/vufind/website.ini b/config/vufind/website.ini index e1c03870516..5f2082be557 100644 --- a/config/vufind/website.ini +++ b/config/vufind/website.ini @@ -24,3 +24,17 @@ title = sort_title category = "Category" linktype = "Link Type" subject = "Subject" + +[Results_Settings] +facet_limit = 30 ; how many values should we show for each facet? +; Should we show "exclude" links for some or all of the facets? Set to * for +; all facets, use a comma-separated list to show for some of the facets, set +; to false or omit to disable "exclude" links +;exclude = * + +; This section defines the location of the website Solr index; if it is omitted, +; a default_core of "website" will be used, and the url will be inherited from +; the [Index] section of config.ini. +;[Index] +;url = http://localhost:8080/solr +;default_core = website diff --git a/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php index 32e8169325e..60caa4bfedd 100644 --- a/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php @@ -47,12 +47,37 @@ class SolrWebBackendFactory extends AbstractSolrBackendFactory public function __construct() { parent::__construct(); - $this->solrCore = 'website'; $this->searchConfig = 'website'; $this->searchYaml = 'websearchspecs.yaml'; $this->facetConfig = 'website'; } + /** + * Get the Solr core. + * + * @return string + */ + protected function getSolrCore() + { + $config = $this->config->get($this->searchConfig); + return isset($config->Index->default_core) + ? $config->Index->default_core : 'website'; + } + + /** + * Get the Solr URL. + * + * @return string + */ + protected function getSolrUrl() + { + // Allow the searchConfig to override the default config if set. + $webconfig = $this->config->get($this->searchConfig); + return isset($webconfig->Index->url) + ? $webconfig->Index->url . '/' . $this->getSolrCore() + : parent::getSolrUrl(); + } + /** * Create the SOLR backend. * diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php index 16fb111dc22..08bff9dab5c 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Params.php +++ b/module/VuFind/src/VuFind/Search/Solr/Params.php @@ -91,7 +91,7 @@ class Params extends \VuFind\Search\Base\Params { parent::__construct($options, $configLoader); // Use basic facet limit by default, if set: - $config = $configLoader->get('facets'); + $config = $configLoader->get($options->getFacetsIni()); if (isset($config->Results_Settings->facet_limit) && is_numeric($config->Results_Settings->facet_limit) ) { -- GitLab