public function location_handler_filter_location_country::query in Location 7.3
Same name and namespace in other branches
- 6.3 handlers/location_handler_filter_location_country.inc \location_handler_filter_location_country::query()
- 7.5 handlers/location_handler_filter_location_country.inc \location_handler_filter_location_country::query()
- 7.4 handlers/location_handler_filter_location_country.inc \location_handler_filter_location_country::query()
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides views_handler_filter_in_operator::query
File
- handlers/
location_handler_filter_location_country.inc, line 178 - Filter on country.
Class
Code
public function query() {
if (empty($this->value)) {
return;
}
$this
->ensure_my_table();
$field = "{$this->table_alias}.{$this->real_field}";
// Normalize values.
$value = $this->value;
if (is_array($value)) {
if (count($value) == 1) {
// If multiple is allowed but only one was chosen, use a string instead.
$value = reset($value);
}
}
if (is_array($value)) {
// Multiple values.
$operator = $this->operator == 'in' ? 'IN' : 'NOT IN';
$this->query
->add_where($this->options['group'], $field, $value, $operator);
}
else {
// Single value.
$operator = $this->operator == 'in' ? '=' : '!=';
$this->query
->add_where($this->options['group'], $field, $value, $operator);
}
}