Skip to content
Snippets Groups Projects
Commit 54085f46 authored by Demian Katz's avatar Demian Katz
Browse files

Summon advanced checkbox facet support.

- On by default, with upgrade support + test
parent f6e53b48
Branches
Tags
No related merge requests found
...@@ -162,13 +162,20 @@ facet_limit = 100 ; how many values should we show for each facet? ...@@ -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 ; 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. ; by inclusion in the comma-separated list below, or turned off by being excluded.
; Supported values: ; 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 ; daterange - for the range controls specified by the dateRange setting under
; [Special_Facets] above; if multiple fields are specified above but you ; [Special_Facets] above; if multiple fields are specified above but you
; only want certain ones on the advanced screen, you can filter with a ; only want certain ones on the advanced screen, you can filter with a
; colon separated list; e.g. "daterange:field1:field2:field3" ; colon separated list; e.g. "daterange:field1:field2:field3"
; genericrange - just like daterange above, but for genericRange[] fields. ; genericrange - just like daterange above, but for genericRange[] fields.
; numericrange - just like daterange above, but for numericRange[] 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 ; 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 ; all facets, use a comma-separated list to apply to some of the facets, set
; to false or omit to disable ORed facets. ; to false or omit to disable ORed facets.
......
...@@ -744,6 +744,17 @@ class Upgrade ...@@ -744,6 +744,17 @@ class Upgrade
); );
$this->applyOldSettings('Summon.ini', $groups); $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 // save the file
$this->saveModifiedConfig('Summon.ini'); $this->saveModifiedConfig('Summon.ini');
} }
......
...@@ -101,6 +101,11 @@ class SummonController extends AbstractSearch ...@@ -101,6 +101,11 @@ class SummonController extends AbstractSearch
$specialFacets = $this->parseSpecialFacetsSetting( $specialFacets = $this->parseSpecialFacetsSetting(
$view->options->getSpecialAdvancedFacets() $view->options->getSpecialAdvancedFacets()
); );
if (isset($specialFacets['checkboxes'])) {
$view->checkboxFacets = $this->processAdvancedCheckboxes(
$specialFacets['checkboxes'], $view->saved
);
}
$view->ranges = $this $view->ranges = $this
->getAllRangeSettings($specialFacets, $view->saved, 'Summon'); ->getAllRangeSettings($specialFacets, $view->saved, 'Summon');
......
...@@ -109,6 +109,13 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase ...@@ -109,6 +109,13 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase
$this->assertEquals(0, count($warnings)); $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: // Make sure the obsolete Index/local setting is removed:
$this->assertFalse(isset($results['config.ini']['Index']['local'])); $this->assertFalse(isset($results['config.ini']['Index']['local']));
......
<? if (!empty($this->facetList)): ?> <? if (!empty($this->facetList) || !empty($this->checkboxFacets)): ?>
<h3><?=$this->transEsc('Limit To')?></h3> <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): ?> <? foreach ($this->facetList as $field => $list): ?>
<div class="span-5"> <div class="span-5">
<label class="displayBlock" for="limit_<?=$this->escapeHtml(str_replace(' ', '', $field))?>"><?=$this->transEsc($list['label'])?>:</label> <label class="displayBlock" for="limit_<?=$this->escapeHtml(str_replace(' ', '', $field))?>"><?=$this->transEsc($list['label'])?>:</label>
......
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