You are here

function biblio_load in Bibliography Module 7

Same name and namespace in other branches
  1. 5 biblio.module \biblio_load()
  2. 6.2 biblio.module \biblio_load()
  3. 6 biblio.module \biblio_load()
  4. 7.3 biblio.module \biblio_load()
  5. 7.2 biblio.module \biblio_load()

Implements hook_load().

This hook is called every time a node is loaded, and allows us to do some loading of our own.

File

./biblio.module, line 1840
Bibliography Module for Drupal.

Code

function biblio_load($nodes) {
  module_load_include('inc', 'biblio', 'includes/biblio.util');
  module_load_include('inc', 'biblio', 'includes/biblio.contributors');
  module_load_include('inc', 'biblio', 'includes/biblio.keywords');
  $vids = array();
  foreach ($nodes as $nid => $node) {
    $vids[] = $node->vid;
  }
  $result = db_query('SELECT b.*, bt.name as biblio_type_name
                      FROM {biblio} b
                      LEFT JOIN {biblio_types} bt on b.biblio_type = bt.tid
                      WHERE b.vid IN (:vids)', array(
    ':vids' => $vids,
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  $contributors = biblio_load_contributors_multiple($vids);
  $keywords = biblio_load_keywords_multiple($vids);
  foreach ($result as $record) {
    if ((isset($record['biblio_url']) || isset($record['biblio_accession_number'])) && variable_get('biblio_fix_isi_links', 0)) {
      biblio_fix_isi_links($record);
    }
    foreach ($record as $key => $value) {
      $nodes[$record['nid']]->{$key} = $value;
    }
    $nodes[$record['nid']]->biblio_year = _biblio_text_year($record['biblio_year']);
    $nodes[$record['nid']]->biblio_contributors = isset($contributors[$record['vid']]) ? $contributors[$record['vid']] : array();
    $nodes[$record['nid']]->biblio_keywords = isset($keywords[$record['vid']]) ? $keywords[$record['vid']] : array();
    if (empty($record['biblio_coins'])) {
      $nodes[$record['nid']]->biblio_coins = biblio_coins($nodes[$record['nid']]);
    }
    if ($record['biblio_formats'] != NULL) {
      $nodes[$record['nid']]->biblio_formats = unserialize($record['biblio_formats']);
    }
    else {
      $nodes[$record['nid']]->biblio_formats = array();
    }
  }
}