You are here

views_handler_relationship_fontyourface_tag.inc in @font-your-face 6.2

Same filename and directory in other branches
  1. 7 views/views_handler_relationship_fontyourface_tag.inc

Views handler.

File

views/views_handler_relationship_fontyourface_tag.inc
View source
<?php

/**
 * @file
 * Views handler.
 */
class views_handler_relationship_fontyourface_tag extends views_handler_relationship {

  /**
   * Called to implement a relationship in a query.
   */
  function query() {
    $this
      ->ensure_my_table();
    $def = $this->definition;
    $def['table'] = 'fontyourface_tag';
    if (!empty($this->options['required'])) {
      $tag_font = $this->query
        ->add_table('fontyourface_tag_font', $this->relationship);
      $def['left_table'] = $tag_font;
      $def['left_field'] = 'tid';
      $def['field'] = 'tid';
      if (!empty($this->options['required'])) {
        $def['type'] = 'INNER';
      }

      // if
    }
    else {

      // If the join is optional, join a subselect that will emulate fontyourface_tag_font table instead.
      $def['left_table'] = $this->table_alias;
      $def['left_field'] = 'fid';
      $def['field'] = 'font';
      $def['table formula'] = "(\n        SELECT t.*, tf.fid AS font\n        FROM {fontyourface_tag} t\n        INNER JOIN {fontyourface_tag_font} tf\n          ON t.tid = tf.tid\n      )";
    }

    // else
    $join = new views_join();
    $join->definition = $def;
    $join
      ->construct();
    $join->adjusted = TRUE;

    // use a short alias for this:
    $alias = $def['table'] . '_' . $this->table;
    $this->alias = $this->query
      ->add_relationship($alias, $join, 'fontyourface_tag', $this->relationship);
  }

}

// views_handler_relationship_fontyourface_tag_font

Classes

Namesort descending Description
views_handler_relationship_fontyourface_tag @file Views handler.