public function contextual_range_filter_handler_argument_list_range::query in Views Contextual Range Filter 7
Help build the query.
Overrides views_handler_argument_numeric::query
File
- views/
contextual_range_filter_handler_argument_list_range.inc, line 36 - Definition of contextual_filter_range_handler_argument_list_range.
Class
- contextual_range_filter_handler_argument_list_range
- Argument handler for arguments that are list ranges.
Code
public function query($group_by = FALSE) {
// From "Allow multple ranges" checkbox.
if (!empty($this->options['break_phrase'])) {
$this
->views_break_phrase_range($this->argument);
}
else {
$this->value = array(
$this->argument,
);
}
if ($this->value === FALSE) {
return;
}
$this
->ensure_my_table();
// From "Exclude:" tickbox.
$is_not = !empty($this->options['not']);
// All WHERE clauses are OR-ed or AND-ed together in the same group.
// Note: NOT (a OR b OR c) == (NOT a) AND (NOT b) AND (NOT c).
$group = $this->query
->set_where_group($is_not ? 'AND' : 'OR');
// E.g. field_datafield_price.field_price_value.
$field = "{$this->table_alias}.{$this->real_field}";
$operator = $is_not ? 'NOT IN' : 'IN';
$null_check = $is_not ? "OR {$field} IS NULL" : '';
foreach ($this->value as $range) {
$placeholder = $this
->placeholder();
$range_values = contextual_range_filter_explode_list_range($range, $this->allowed_values);
if ($range_values) {
$this->query
->add_where_expression($group, "{$field} {$operator} ({$placeholder}) {$null_check}", array(
$placeholder => $range_values,
));
}
}
}