function views_extra_handlers_handler_field_query_alter::query in Extra Views Handlers 7
Called to add the field to a query.
Overrides views_handler_field::query
File
- views/
handlers/ views_extra_handlers_handler_field_query_alter.inc, line 10 - Views field handler for the views_system module.
Class
- views_extra_handlers_handler_field_query_alter
- @file Views field handler for the views_system module.
Code
function query() {
if (!empty($this->options['veh_join']['veh_table'])) {
$def = $this->definition;
$def['table'] = $this->options['veh_join']['veh_table'];
$def['field'] = $this->options['veh_join']['veh_column'];
$def['left_table'] = $this->options['veh_join']['veh_left_table'];
$def['left_field'] = $this->options['veh_join']['veh_left_column'];
$def['type'] = $this->options['veh_join']['veh_join_type'];
if (!empty($this->options['veh_join']['veh_join_condition'])) {
$def['left_query'] = $this->options['veh_join']['veh_join_condition'];
}
else {
$def['left_query'] = $this->options['veh_join']['veh_left_table'] . "." . $this->options['veh_join']['veh_left_column'];
}
if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
$join = new $def['join_handler']();
}
else {
$join = new views_join_subquery();
}
$join->definition = $def;
$join
->construct();
$join->adjusted = TRUE;
// use a short alias for this:
$alias = $this->options['veh_join']['veh_table_alias'];
// $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base']);
$this->alias = $this->query
->add_relationship($alias, $join, NULL);
}
if (!empty($this->options['veh_field']['veh_table'])) {
$this->field_alias = $this->query
->add_field($this->options['veh_field']['veh_table'], $this->options['veh_field']['veh_column'], '');
}
if (!empty($this->options['veh_where']['veh_table'])) {
$condition_type = db_condition($this->options['veh_where']['veh_where_type']);
//***CURRENT_ARG_1***
$where_field_value = $this->options['veh_where']['veh_value'];
if (veh_startsWith($where_field_value, "***CURRENT_ARG_") && veh_endsWith($where_field_value, "***")) {
$argument_pos = substr($where_field_value, 15, strlen($where_field_value) - 15 - 3);
$where_field_value = arg($argument_pos);
}
$condition = $condition_type
->condition($this->options['veh_where']['veh_table'] . '.' . $this->options['veh_where']['veh_column'], $where_field_value, $this->options['veh_where']['veh_where_operator']);
$this->query
->add_where(0, $condition);
}
}