From d790f66569a4a55c5fff29725c6bd5f8556b3264 Mon Sep 17 00:00:00 2001
From: Leila Gonzales <lmg@agiweb.org>
Date: Fri, 14 Oct 2016 13:39:36 -0400
Subject: [PATCH] Add mechanism to specify labels for rarely-used facet fields.
 (#823)

- Used this to label the location_geo field utilized by geographic search.
---
 config/vufind/facets.ini                        |  6 ++++++
 module/VuFind/src/VuFind/Search/Base/Params.php | 15 +++++++++++++--
 module/VuFind/src/VuFind/Search/Solr/Params.php |  3 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/config/vufind/facets.ini b/config/vufind/facets.ini
index 5d7096df24f..a8eb0380da2 100644
--- a/config/vufind/facets.ini
+++ b/config/vufind/facets.ini
@@ -23,6 +23,12 @@ publishDate        = "adv_search_year"  ; share year string w/advanced search pa
 [ResultsTop]
 topic_facet        = "Suggested Topics"
 
+; This section is used to specify labels for facets that may be applied by parts
+; of VuFind other than the facet lists defined in this file (for example, the
+; hierarchical browse of the BrowseController, or the Geographic Search).
+[ExtraFacetLabels]
+location_geo = "Geographic Search" 
+
 ; This section is used to identify facets for special treatment by the SideFacets
 ; recommendations module.
 [SpecialFacets]
diff --git a/module/VuFind/src/VuFind/Search/Base/Params.php b/module/VuFind/src/VuFind/Search/Base/Params.php
index 35b5e6954f9..a14c0ef0af5 100644
--- a/module/VuFind/src/VuFind/Search/Base/Params.php
+++ b/module/VuFind/src/VuFind/Search/Base/Params.php
@@ -126,6 +126,13 @@ class Params implements ServiceLocatorAwareInterface
      */
     protected $facetConfig = [];
 
+    /**
+     * Extra facet labels
+     *
+     * @var array
+     */
+    protected $extraFacetLabels = [];
+
     /**
      * Checkbox facet configuration
      *
@@ -928,12 +935,16 @@ class Params implements ServiceLocatorAwareInterface
     public function getFacetLabel($field, $value = null)
     {
         if (!isset($this->facetConfig[$field])
+            && !isset($this->extraFacetLabels[$field])
             && isset($this->facetAliases[$field])
         ) {
             $field = $this->facetAliases[$field];
         }
-        return isset($this->facetConfig[$field])
-            ? $this->facetConfig[$field] : 'unrecognized_facet_label';
+        if (isset($this->facetConfig[$field])) {
+            return $this->facetConfig[$field];
+        }
+        return isset($this->extraFacetLabels[$field])
+            ? $this->extraFacetLabels[$field] : 'unrecognized_facet_label';
     }
 
     /**
diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php
index 9689a2d893b..98f921c9c19 100644
--- a/module/VuFind/src/VuFind/Search/Solr/Params.php
+++ b/module/VuFind/src/VuFind/Search/Solr/Params.php
@@ -107,6 +107,9 @@ class Params extends \VuFind\Search\Base\Params
         if (isset($config->LegacyFields)) {
             $this->facetAliases = $config->LegacyFields->toArray();
         }
+        if (isset($config->ExtraFacetLabels)) {
+            $this->extraFacetLabels = $config->ExtraFacetLabels->toArray();
+        }
         if (isset($config->Results_Settings->facet_limit_by_field)) {
             foreach ($config->Results_Settings->facet_limit_by_field as $k => $v) {
                 $this->facetLimitByField[$k] = $v;
-- 
GitLab