Commit 34b6304e authored by David Lesieur's avatar David Lesieur

Getting ready for more specialization by other modules - part 2.

parent 298b7a65
......@@ -39,12 +39,8 @@ function cck_facets_faceted_search_collect(&$facets, $domain, $env_id, $filter,
$field_name = $matches[2][$index];
$value = strtr($matches[3][$index], '""', '"');
if (isset($field_name) && isset($value) && isset($fields[$field_name]) && (!isset($filter) || isset($filter['cck'][$field_name]))) {
// Validate the value.
$db_info = _cck_facets_db_info($fields[$field_name]);
$column = reset($db_info['columns']); // Get the first database column. Other columns are ignored.
if (is_numeric($value) || !in_array($column['type'], array('int', 'mediumint', 'tinyint', 'bigint', 'float'))) {
// Create an active facet with the value found in the search text.
$active_path = cck_facets_create_category($fields[$field_name], $value, 'user');
// Create an active facet with the value found in the search text.
if ($active_path = cck_facets_create_category($fields[$field_name], $value, 'user')) {
$facets[] = cck_facets_create_facet($fields[$field_name], $active_path);
}
}
......@@ -151,6 +147,14 @@ function cck_facets_create_category($field, $value, $source, $count = NULL, $ful
* @see cck_facets_create_category
*/
function cck_facets_create_category_default($field, $value, $source, $count, $full_active_path) {
if ($source == 'user') {
// Basic validation.
$db_info = _cck_facets_db_info($field);
$column = reset($db_info['columns']); // Get the first database column. Other columns are ignored.
if (!is_numeric($value) && in_array($column['type'], array('int', 'mediumint', 'tinyint', 'bigint', 'float'))) {
return FALSE;
}
}
$category = new cck_facet_category($field, $value, $count);
return $full_active_path ? array($category) : $category;
}
......
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