menu_node_views_relationship_double.inc in Menu Node Views 7.2
File
includes/menu_node_views_relationship_double.inc
View source
<?php
class menu_node_views_relationship_double extends views_handler_relationship {
function init(&$view, &$options) {
parent::init($view, $options);
if (isset($this->definition['relationship table'])) {
$this->table = $this->definition['relationship table'];
}
if (isset($this->definition['relationship field'])) {
$this->real_field = $this->field = $this->definition['relationship field'];
}
}
function label() {
if (!isset($this->options['label'])) {
return $this
->ui_name();
}
return $this->options['label'];
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Identifier'),
'#default_value' => isset($this->options['label']) ? $this->options['label'] : '',
'#description' => t('Edit the administrative label displayed when referencing this relationship from filters, etc.'),
'#required' => TRUE,
);
$form['required'] = array(
'#type' => 'checkbox',
'#title' => t('Require this relationship'),
'#description' => t('Enable to hide items that do not contain this relationship'),
'#default_value' => !empty($this->options['required']),
);
}
function query() {
$this
->ensure_my_table();
$middle_table = $this->query
->add_table($this->definition['middle_table'], $this->relationship);
$def['table'] = $this->definition['right_table'];
$def['left_table'] = $middle_table;
$def['left_field'] = $this->definition['middle_field_2'];
$def['field'] = $this->definition['right_field_2'];
$def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
$join = new views_join();
$join->definition = $def;
$join
->construct();
$join->adjusted = TRUE;
$alias = $def['table'] . '_' . $this->table;
$this->alias = $this->query
->add_relationship($alias, $join, $this->definition['right_table'], $this->relationship);
}
function use_group_by() {
return FALSE;
}
}