You are here

function views_handler_field_fontyourface_tag_font_tid::pre_render in @font-your-face 7

Same name and namespace in other branches
  1. 6.2 views/views_handler_field_fontyourface_tag_font_tid.inc \views_handler_field_fontyourface_tag_font_tid::pre_render()
  2. 7.2 modules/fontyourface_ui/views/views_handler_field_fontyourface_tag_font_tid.inc \views_handler_field_fontyourface_tag_font_tid::pre_render()

Run before any fields are rendered.

This gives the handlers some time to set up before any handler has been rendered.

Parameters

array $values: An array of all objects returned from the query.

Overrides views_handler_field::pre_render

File

views/views_handler_field_fontyourface_tag_font_tid.inc, line 55
Views handler.

Class

views_handler_field_fontyourface_tag_font_tid
Field handler for tags. Largely copied from views_handler_field_term_node_tid.inc

Code

function pre_render(&$values) {
  $this->field_alias = $this->aliases['fid'];
  $fids = array();
  foreach ($values as $result) {
    if (!empty($result->{$this->aliases['fid']})) {
      $fids[] = $result->{$this->aliases['fid']};
    }

    // if
  }

  // foreach
  if ($fids) {
    $query = db_select('fontyourface_tag', 't');
    $tag_font_alias = $query
      ->join('fontyourface_tag_font', 'tf', 't.tid = tf.tid');
    $query
      ->condition($tag_font_alias . '.fid', $fids, 'IN')
      ->fields('t')
      ->orderBy('t.name');
    $font_fid_field = $query
      ->addField($tag_font_alias, 'fid', 'font_fid');
    $result = $query
      ->execute();
    foreach ($result as $tag) {
      $this->items[$tag->font_fid][$tag->tid]['name'] = check_plain($tag->name);
      $this->items[$tag->font_fid][$tag->tid]['tid'] = $tag->tid;
      if (isset($tag->fid)) {
        $this->items[$tag->font_fid][$tag->tid]['fid'] = $tag->fid;
      }

      // if
      if (!empty($this->options['link_to_tag'])) {
        $this->items[$tag->font_fid][$tag->tid]['make_link'] = TRUE;
        $this->items[$tag->font_fid][$tag->tid]['path'] = 'admin/appearance/fontyourface/add?tid[]=' . $tag->tid;
      }

      // if
    }

    // foreach
  }

  // if
}