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

Smarter display of range filters.

- Resolves VUFIND-922.
parent fdf8c579
No related merge requests found
...@@ -492,4 +492,28 @@ class Params extends \VuFind\Search\Base\Params ...@@ -492,4 +492,28 @@ class Params extends \VuFind\Search\Base\Params
return $backendParams; return $backendParams;
} }
/**
* Format a single filter for use in getFilterList().
*
* @param string $field Field name
* @param string $value Field value
* @param string $operator Operator (AND/OR/NOT)
* @param bool $translate Should we translate the label?
*
* @return array
*/
protected function formatFilterListEntry($field, $value, $operator, $translate)
{
$filter = parent::formatFilterListEntry(
$field, $value, $operator, $translate
);
// Convert range queries to a language-non-specific format:
if (preg_match('/^\[(.*) TO (.*)\]$/', $value, $matches)) {
$filter['displayText'] = $matches[1] . '-' . $matches[2];
}
return $filter;
}
} }
\ No newline at end of file
...@@ -260,4 +260,28 @@ class Params extends \VuFind\Search\Base\Params ...@@ -260,4 +260,28 @@ class Params extends \VuFind\Search\Base\Params
} }
} }
} }
/**
* Format a single filter for use in getFilterList().
*
* @param string $field Field name
* @param string $value Field value
* @param string $operator Operator (AND/OR/NOT)
* @param bool $translate Should we translate the label?
*
* @return array
*/
protected function formatFilterListEntry($field, $value, $operator, $translate)
{
$filter = parent::formatFilterListEntry(
$field, $value, $operator, $translate
);
// Convert range queries to a language-non-specific format:
if (preg_match('/^\[(.*) TO (.*)\]$/', $value, $matches)) {
$filter['displayText'] = $matches[1] . '-' . $matches[2];
}
return $filter;
}
} }
\ No newline at end of file
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