function views_handler_relationship_translation::query
Called to implement a relationship in a query.
Overrides views_handler_relationship::query
File
-
modules/
translation/ views_handler_relationship_translation.inc, line 50
Class
- views_handler_relationship_translation
- Handles relationships for content translation sets and provides multiple options.
Code
public function query() {
// Figure out what base table this relationship brings to the party.
$table_data = views_fetch_data($this->definition['base']);
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
$this->ensure_my_table();
$def = $this->definition;
$def['table'] = $this->definition['base'];
$def['field'] = $base_field;
$def['left_table'] = $this->table_alias;
$def['left_field'] = $this->field;
if (!empty($this->options['required'])) {
$def['type'] = 'INNER';
}
$def['extra'] = array();
if ($this->options['language'] != 'all') {
switch ($this->options['language']) {
case 'current':
$def['extra'][] = array(
'field' => 'language',
'value' => '***CURRENT_LANGUAGE***',
);
break;
case 'default':
$def['extra'][] = array(
'field' => 'language',
'value' => '***DEFAULT_LANGUAGE***',
);
break;
// Other values will be the language codes.
default:
$def['extra'][] = array(
'field' => 'language',
'value' => $this->options['language'],
);
break;
}
}
if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
$join = new $def['join_handler']();
}
else {
$join = new views_join();
}
$join->definition = $def;
$join->extra = "(%alias.tnid != 0 OR ({$def['left_table']}.tnid = 0 AND %alias.nid = {$def['left_table']}.nid))";
$join->construct();
$join->adjusted = TRUE;
// Use a short alias for this.
$alias = $def['table'] . '_' . $this->table;
$this->alias = $this->query
->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
}