From 7a43fc48f706823a2e754ad4b2213e2a2ec68461 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 24 Jan 2013 11:42:39 -0500 Subject: [PATCH] Progress on VUFIND-505: created mechanism to allow more complex checkbox filters. --- config/vufind/searches.ini | 3 +++ module/VuFind/src/VuFind/Recommend/SideFacets.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/config/vufind/searches.ini b/config/vufind/searches.ini index 3ed96c12103..ba223f0b9ba 100644 --- a/config/vufind/searches.ini +++ b/config/vufind/searches.ini @@ -192,6 +192,9 @@ CallNumber = callnumber ; standard facet settings (defaults to "Results" if not specified), ; and [checkbox facet section] is the name of a section of the ini file ; containing checkbox facet settings (leave blank for no checkbox facets). +; Checkbox facets are normally in filter => label format; prefix the section +; name with ~ to reverse this and use label => filter format (useful if your +; filters contain values that are illegal in configuration keys -- e.g. []). ; SummonDatabases:[GET parameter] ; Display Summon-generated database recommendations matching the terms found ; in the specified GET parameter. NOTE: If you are using this module with a diff --git a/module/VuFind/src/VuFind/Recommend/SideFacets.php b/module/VuFind/src/VuFind/Recommend/SideFacets.php index 5c274c81285..181902b7339 100644 --- a/module/VuFind/src/VuFind/Recommend/SideFacets.php +++ b/module/VuFind/src/VuFind/Recommend/SideFacets.php @@ -77,9 +77,16 @@ class SideFacets implements RecommendInterface } // Checkbox facets: + if (substr($checkboxSection, 0, 1) == '~') { + $checkboxSection = substr($checkboxSection, 1); + $flipCheckboxes = true; + } $this->checkboxFacets = ($checkboxSection && isset($config->$checkboxSection)) ? $config->$checkboxSection->toArray() : array(); + if ($flipCheckboxes) { + $this->checkboxFacets = array_flip($this->checkboxFacets); + } } /** -- GitLab