Skip to content
Snippets Groups Projects
Commit d790f665 authored by Leila Gonzales's avatar Leila Gonzales Committed by Demian Katz
Browse files

Add mechanism to specify labels for rarely-used facet fields. (#823)

- Used this to label the location_geo field utilized by geographic search.
parent 4b13f52f
Branches
Tags
No related merge requests found
...@@ -23,6 +23,12 @@ publishDate = "adv_search_year" ; share year string w/advanced search pa ...@@ -23,6 +23,12 @@ publishDate = "adv_search_year" ; share year string w/advanced search pa
[ResultsTop] [ResultsTop]
topic_facet = "Suggested Topics" 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 ; This section is used to identify facets for special treatment by the SideFacets
; recommendations module. ; recommendations module.
[SpecialFacets] [SpecialFacets]
......
...@@ -126,6 +126,13 @@ class Params implements ServiceLocatorAwareInterface ...@@ -126,6 +126,13 @@ class Params implements ServiceLocatorAwareInterface
*/ */
protected $facetConfig = []; protected $facetConfig = [];
/**
* Extra facet labels
*
* @var array
*/
protected $extraFacetLabels = [];
/** /**
* Checkbox facet configuration * Checkbox facet configuration
* *
...@@ -928,12 +935,16 @@ class Params implements ServiceLocatorAwareInterface ...@@ -928,12 +935,16 @@ class Params implements ServiceLocatorAwareInterface
public function getFacetLabel($field, $value = null) public function getFacetLabel($field, $value = null)
{ {
if (!isset($this->facetConfig[$field]) if (!isset($this->facetConfig[$field])
&& !isset($this->extraFacetLabels[$field])
&& isset($this->facetAliases[$field]) && isset($this->facetAliases[$field])
) { ) {
$field = $this->facetAliases[$field]; $field = $this->facetAliases[$field];
} }
return isset($this->facetConfig[$field]) if (isset($this->facetConfig[$field])) {
? $this->facetConfig[$field] : 'unrecognized_facet_label'; return $this->facetConfig[$field];
}
return isset($this->extraFacetLabels[$field])
? $this->extraFacetLabels[$field] : 'unrecognized_facet_label';
} }
/** /**
......
...@@ -107,6 +107,9 @@ class Params extends \VuFind\Search\Base\Params ...@@ -107,6 +107,9 @@ class Params extends \VuFind\Search\Base\Params
if (isset($config->LegacyFields)) { if (isset($config->LegacyFields)) {
$this->facetAliases = $config->LegacyFields->toArray(); $this->facetAliases = $config->LegacyFields->toArray();
} }
if (isset($config->ExtraFacetLabels)) {
$this->extraFacetLabels = $config->ExtraFacetLabels->toArray();
}
if (isset($config->Results_Settings->facet_limit_by_field)) { if (isset($config->Results_Settings->facet_limit_by_field)) {
foreach ($config->Results_Settings->facet_limit_by_field as $k => $v) { foreach ($config->Results_Settings->facet_limit_by_field as $k => $v) {
$this->facetLimitByField[$k] = $v; $this->facetLimitByField[$k] = $v;
......
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