diff --git a/config/vufind/Summon.ini b/config/vufind/Summon.ini index b3cd8a2565e41883c406c0b94abfa595ae4bbd85..91312983d8580a3d95f282e3ca12681006dbe67b 100644 --- a/config/vufind/Summon.ini +++ b/config/vufind/Summon.ini @@ -162,13 +162,20 @@ facet_limit = 100 ; how many values should we show for each facet? ; Some facet types don't lend themselves to this format, and they can be turned on ; by inclusion in the comma-separated list below, or turned off by being excluded. ; Supported values: +; checkboxes - displays a list of checkbox facets as specified in the +; [CheckboxFacets] section above. You can specify the config file/section +; with colon-separated parameters following the checkboxes setting; e.g. +; checkboxes:facets:myCustomCheckboxes will load from the myCustomCheckboxes +; section of facets.ini. You can prefix the section name with a tilde (~) +; to reverse processing of the section to label => filter format (useful if your +; filters contain values that are illegal in configuration keys -- e.g. []). ; daterange - for the range controls specified by the dateRange setting under ; [Special_Facets] above; if multiple fields are specified above but you ; only want certain ones on the advanced screen, you can filter with a ; colon separated list; e.g. "daterange:field1:field2:field3" ; genericrange - just like daterange above, but for genericRange[] fields. ; numericrange - just like daterange above, but for numericRange[] fields. -special_facets = daterange +special_facets = "daterange,checkboxes:Summon" ; Should we OR together facets rather than ANDing them? Set to * for ; all facets, use a comma-separated list to apply to some of the facets, set ; to false or omit to disable ORed facets. diff --git a/module/VuFind/src/VuFind/Config/Upgrade.php b/module/VuFind/src/VuFind/Config/Upgrade.php index 282ff5bcecf87d3628cf879ab997374cbe664e4e..c97adc07b756fbaf501b2d99b2b7519cbec79bd4 100644 --- a/module/VuFind/src/VuFind/Config/Upgrade.php +++ b/module/VuFind/src/VuFind/Config/Upgrade.php @@ -744,6 +744,17 @@ class Upgrade ); $this->applyOldSettings('Summon.ini', $groups); + // Turn on advanced checkbox facets if we're upgrading from a version + // prior to 2.3. + if ((float)$this->from < 2.3) { + $cfg = & $this->newConfigs['Summon.ini']['Advanced_Facet_Settings']; + if (!isset($cfg['special_facets']) || empty($cfg['special_facets'])) { + $cfg['special_facets'] = 'checkboxes:Summon'; + } else if (false === strpos('checkboxes', $cfg['special_facets'])) { + $cfg['special_facets'] .= ',checkboxes:Summon'; + } + } + // save the file $this->saveModifiedConfig('Summon.ini'); } diff --git a/module/VuFind/src/VuFind/Controller/SummonController.php b/module/VuFind/src/VuFind/Controller/SummonController.php index 888d33113bf5fb1b6726feab37570a8b84c12170..0097f11a5e9e052ee3cad6ba9807f3dc4b28e060 100644 --- a/module/VuFind/src/VuFind/Controller/SummonController.php +++ b/module/VuFind/src/VuFind/Controller/SummonController.php @@ -101,6 +101,11 @@ class SummonController extends AbstractSearch $specialFacets = $this->parseSpecialFacetsSetting( $view->options->getSpecialAdvancedFacets() ); + if (isset($specialFacets['checkboxes'])) { + $view->checkboxFacets = $this->processAdvancedCheckboxes( + $specialFacets['checkboxes'], $view->saved + ); + } $view->ranges = $this ->getAllRangeSettings($specialFacets, $view->saved, 'Summon'); diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php index 2158a0de2ce46dd979a78a1031e0570cccaaa4c8..83bb5029a33af732454c705374f66cfae51621a0 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php @@ -109,6 +109,13 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase $this->assertEquals(0, count($warnings)); } + // Summon should always have the checkboxes setting turned on after + // upgrade: + $this->assertEquals( + 'daterange,checkboxes:Summon', + $results['Summon.ini']['Advanced_Facet_Settings']['special_facets'] + ); + // Make sure the obsolete Index/local setting is removed: $this->assertFalse(isset($results['config.ini']['Index']['local'])); diff --git a/themes/blueprint/templates/search/advanced/summon.phtml b/themes/blueprint/templates/search/advanced/summon.phtml index 7ba27ada0a79fd4c5d4f262a89a1c796e25a08a9..9f15eda79237f85dc0900dcf0901ad0a2bfb23e0 100644 --- a/themes/blueprint/templates/search/advanced/summon.phtml +++ b/themes/blueprint/templates/search/advanced/summon.phtml @@ -1,5 +1,12 @@ -<? if (!empty($this->facetList)): ?> +<? if (!empty($this->facetList) || !empty($this->checkboxFacets)): ?> <h3><?=$this->transEsc('Limit To')?></h3> +<? endif; ?> + +<? if (!empty($this->checkboxFacets)): ?> + <?=$this->render('search/advanced/checkbox-filters.phtml')?> +<? endif; ?> + +<? if (!empty($this->facetList)): ?> <? foreach ($this->facetList as $field => $list): ?> <div class="span-5"> <label class="displayBlock" for="limit_<?=$this->escapeHtml(str_replace(' ', '', $field))?>"><?=$this->transEsc($list['label'])?>:</label>