Commit b3b99584 authored by David Lesieur's avatar David Lesieur

Use new functions from faceted_search.module.

parent 8d92a2a4
......@@ -34,26 +34,6 @@ function cck_facets_faceted_search_collect(&$facets, $domain, $env_id, $filter,
}
}
function _cck_facets_quoted_query_extract($keys, $option) {
// Based on search_query_extract, but matching a quoted value. Double-quotes
// are allowed into the value when escaped with the backslash character.
if (preg_match('/(^| )'. $option .':"((\\\.|[^"])*?)"( |$)/i', $keys, $matches)) {
return $matches[2];
}
}
function _cck_facets_quoted_query_insert($keys, $option, $value = '') {
// Based on search_query_extract, but matching a quoted value. Double-quotes
// are allowed into the value when escaped with the backslash character.
if (search_query_extract($keys, $option)) {
$keys = trim(preg_replace('/(^| )'. $option .':"((\\\.|[^"])*?)"( |$)/i', ' ', $keys));
}
if ($value != '') {
$keys .= ' '. $option .':'. $value;
}
return $keys;
}
/**
* Return database storage information for the specified field.
*
......
......@@ -21,16 +21,14 @@ function text_facets_cck_facets_collect(&$facets, $field, $domain, $env_id, $arg
case 'text':
// Scan the given search text for a '{field_name}:"{value}"'
// token, and create facets from it.
if ($found_text = _cck_facets_quoted_query_extract($arg, $field['field_name'])) {
// Unescape the value.
$found_text = strtr($found_text, array('\"' => '"', '\\\\' => '\\'));
if ($found_text = faceted_search_quoted_query_extract($arg, $field['field_name'])) {
if (!empty($found_text)) {
// Create an active facet with the value found in the search text.
$category = new cck_facet_category($field, $found_text);
$facets[] = new text_facet($field, array($category));
}
// Remove the parsed text
$arg = _cck_facets_quoted_query_insert($arg, $field['field_name']);
$arg = faceted_search_quoted_query_insert($arg, $field['field_name']);
}
break;
......
Markdown is supported
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