function _search_api_generate_range in Search API ranges 7
2 calls to _search_api_generate_range()
- search_api_ranges_generate_ranges_advanced in ./
search_api_ranges.module - search_api_ranges_generate_ranges_simple in ./
search_api_ranges.module - Generate the available ranges given the active facets
File
- ./
search_api_ranges.module, line 638 - Performs min/max queries through Search API and provides UI Slider display widget for Facet API
Code
function _search_api_generate_range($min, $max, $count, $variables, $params, $label = '') {
// Generate the new query.
$query = urlencode($variables['range_field']) . ":[{$min} TO {$max}]";
$active = FALSE;
// Add the new query or remove it if the range is already active.
if (empty($params['f'])) {
$params['f'] = array(
$query,
);
}
else {
$key = array_search($query, $params['f']);
if ($key !== FALSE) {
unset($params['f'][$key]);
$active = TRUE;
}
else {
$params['f'][] = $query;
}
}
if (empty($label)) {
$label = $variables['prefix'] . number_format($min, 0) . $variables['suffix'] . '–' . $variables['prefix'] . number_format($max, 0) . $variables['suffix'];
}
// Build up a render array.
return array(
'#markup' => $label,
'#path' => $variables['target'],
'#html' => FALSE,
'#indexed_value' => 'TODO: what to put here?',
'#count' => $count,
'#query' => $params,
'#active' => $active,
);
}