Skip to content
Snippets Groups Projects
Commit ae118f98 authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Merge branch 'master' of https://github.com/vufind-org/vufind

parents af2a4881 e71ce5a3
No related merge requests found
...@@ -128,25 +128,31 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper ...@@ -128,25 +128,31 @@ class SearchBox extends \Zend\View\Helper\AbstractHelper
public function getFilterDetails($filterList, $checkboxFilters) public function getFilterDetails($filterList, $checkboxFilters)
{ {
$results = array(); $results = array();
$i = 0;
foreach ($filterList as $field => $data) { foreach ($filterList as $field => $data) {
foreach ($data as $value) { foreach ($data as $value) {
$results[] = array( $results[] = "$field:\"$value\"";
'id' => 'applied_filter_' . ++$i,
'value' => "$field:\"$value\""
);
} }
} }
$i = 0;
foreach ($checkboxFilters as $current) { foreach ($checkboxFilters as $current) {
if ($current['selected']) { // Check a normalized version of the checkbox facet against the existing
$results[] = array( // filter list to avoid unnecessary duplication. Note that we don't
'id' => 'applied_checkbox_filter_' . ++$i, // actually use this normalized version for anything beyond dupe-checking
'value' => $current['filter'] // in case it breaks advanced syntax.
); $regex = '/^([^:]*):([^"].*[^"]|[^"]{1,2})$/';
$normalized
= preg_match($regex, $current['filter'], $match)
? "{$match[1]}:\"{$match[2]}\"" : $current['filter'];
if ($current['selected'] && !in_array($normalized, $results)
&& !in_array($current['filter'], $results)
) {
$results[] = $current['filter'];
} }
} }
return $results; $final = array();
foreach ($results as $i => $val) {
$final[] = array('id' => 'applied_filter_' . ($i + 1), 'value' => $val);
}
return $final;
} }
/** /**
......
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