You are here

function biblio_handler_field_contributor::pre_render in Bibliography Module 6.2

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

Overrides biblio_handler_field::pre_render

File

views/biblio_handler_field_contributor.inc, line 41
Views biblio contributor handler for Drupal biblio module.

Class

biblio_handler_field_contributor
@file Views biblio contributor handler for Drupal biblio module.

Code

function pre_render($values) {
  $vids = array();
  $this->items = array();
  foreach ($values as $result) {

    // Don't add empty results to the array.
    if (!empty($result->{$this->aliases['vid']})) {
      $vids[] = $result->{$this->aliases['vid']};
    }
  }
  if (count($vids)) {

    // Optimize query if $vids has only 1 item in the array, to use '=' instead of 'IN'.
    if (count($vids) > 1) {
      $vidstr = 'vid IN (' . implode(',', $vids) . ')';
    }
    else {
      $vidstr = 'vid = ' . $vids[0];
    }
    $result = db_query('SELECT * FROM {biblio_contributor} bc
                          INNER JOIN {biblio_contributor_data} bcd ON bc.cid = bcd.cid
                          WHERE ' . $vidstr . ' AND auth_category=' . $this->auth_category . ' ORDER BY bc.rank');
    while ($item = db_fetch_array($result)) {

      // Clean up the $item from vid.
      $vid = $item['vid'];
      unset($item['vid']);
      $this->items[$vid][] = $item;
    }
  }
}