You are here

public function views_handler_field_term_node_tid::init in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 modules/taxonomy/views_handler_field_term_node_tid.inc \views_handler_field_term_node_tid::init()
  2. 6.2 modules/taxonomy/views_handler_field_term_node_tid.inc \views_handler_field_term_node_tid::init()

Init the handler with necessary data.

Parameters

view $view: The $view object this handler is attached to.

array $options: The item from the database; the actual contents of this will vary based upon the type of handler.

Overrides views_handler_field::init

File

modules/taxonomy/views_handler_field_term_node_tid.inc, line 18
Definition of views_handler_field_term_node_tid.

Class

views_handler_field_term_node_tid
Field handler to display all taxonomy terms of a node.

Code

public function init(&$view, &$options) {
  parent::init($view, $options);

  // @todo Wouldn't it be possible to use $this->base_table and no if here?
  if ($view->base_table == 'node_revision') {
    $this->additional_fields['nid'] = array(
      'table' => 'node_revision',
      'field' => 'nid',
    );
  }
  else {
    $this->additional_fields['nid'] = array(
      'table' => 'node',
      'field' => 'nid',
    );
  }

  // Convert legacy vids option to machine name vocabularies.
  if (!empty($this->options['vids'])) {
    $vocabularies = taxonomy_get_vocabularies();
    foreach ($this->options['vids'] as $vid) {
      if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
        $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
      }
    }
  }
}