You are here

function nodereferrer_view_handler_relationship::ensure_my_table in NodeReferrer 7

Same name and namespace in other branches
  1. 6 views/nodereferrer_view_handler_relationship.inc \nodereferrer_view_handler_relationship::ensure_my_table()

Ensure the main table for this handler is in the query. This is used a lot.

Overrides views_handler::ensure_my_table

1 call to nodereferrer_view_handler_relationship::ensure_my_table()
nodereferrer_view_handler_relationship::query in views/nodereferrer_view_handler_relationship.inc
Called to implement a relationship in a query.

File

views/nodereferrer_view_handler_relationship.inc, line 50
nodereferrer.module Views integration

Class

nodereferrer_view_handler_relationship
@file nodereferrer.module Views integration

Code

function ensure_my_table() {
  if (!isset($this->table_alias)) {
    $fieldname = $this->options['referrer_field'];
    $field = content_fields($fieldname);
    $db_info = content_database_info($field);
    $join = new views_join();
    $join
      ->construct($db_info['table'], 'node', 'nid', $db_info['columns']['nid']['column']);

    // Add delta condition.
    if (!isset($join->extra)) {
      $join->extra = array();
    }
    $delta = isset($this->options['referrer_delta']) ? $this->options['referrer_delta'] : -1;
    if ($delta != -1) {
      $join->extra[] = array(
        'field' => 'delta',
        'value' => $delta,
        'numeric' => TRUE,
      );
    }
    $this->table_alias = $this->query
      ->add_table($this->table, $this->relationship, $join);
  }
  return $this->table_alias;
}