Tripal v1.0 (6.x-1.0)
views_handler_field_node_optional Class Reference

List of all members.

Public Member Functions

 construct ()
 query ()
 render_link ($data, $values)

Detailed Description

Definition at line 10 of file views_handler_field_node_optional.inc.


Member Function Documentation

views_handler_field_node_optional::construct ( )

Definition at line 12 of file views_handler_field_node_optional.inc.

                       {
    parent::construct();
    $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');
    if (module_exists('translation')) {
      $this->additional_fields['language'] = array('table' => 'node', 'field' => 'language');
    }
  }
views_handler_field_node_optional::query ( )

Add chado_* and *_node alias'd left joins to the table

Definition at line 23 of file views_handler_field_node_optional.inc.

                   {

    // Check what we have (ie: current table? node table? )
    $chado_table = 'chado_' . $this->table;
    foreach ($this->query->table_queue as $table_def) {
      //check is $this->table
      if ($table_def['table'] == $this->table) {
        $this_table_alias = $table_def['alias'];
      }

      // check is node joined to #this->table
      if ($table_def['table'] == $chado_table) {
        $node_table_alias = $table_def['alias'];
      }
    }

    // First: Add the main field-----------------------------------------------
    if (!$this_table_alias) {
      $this_table_alias = $this->ensure_my_table();
    }
    $field_alias = $this->query->add_field($this_table_alias, $this->real_field);
    $this->aliases[ $this->real_field ] = $field_alias;
    $this->field_alias = $field_alias;

    // Second: Add nid field and Joins if necessary----------------------------
    // Add node join if needed
    if (!$node_table_alias) {
      $def['table'] = $chado_table;
      $def['field'] = $this->table . '_id';
      $def['left_table'] = $this_table_alias;
      $def['left_field'] = $this->table . '_id';

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

      $node_table_alias = $this->query->add_relationship($def['table'], $join, $def['table']);
    }

    // Finally Add Field
    $field_alias = $this->query->add_field($node_table_alias, 'nid');
    $this->aliases['nid'] = $field_alias;

  }
views_handler_field_node_optional::render_link ( data,
values 
)

Render whatever the data is as a link to the node.

Data should be made XSS safe prior to calling this function.

Definition at line 74 of file views_handler_field_node_optional.inc.

                                       {
    if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') {
      if (!empty($values->{$this->aliases['nid']})) {
        $this->options['alter']['make_link'] = TRUE;
        $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']};
        if (isset($this->aliases['language'])) {
          $languages = language_list();
          if (isset($languages[$values->{$this->aliases['language']}])) {
            $this->options['alter']['language'] = $languages[$values->{$this->aliases['language']}];
          }
          else {
            unset($this->options['alter']['language']);
          }
        }
      }
      else {
        $this->options['alter']['make_link'] = FALSE;
        $this->options['alter']['path'] = "";
      }
    }

    return $data;
  }

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables