You are here

function biblio_load_keywords_multiple in Bibliography Module 7

Same name and namespace in other branches
  1. 7.2 includes/biblio.keywords.inc \biblio_load_keywords_multiple()

Load keywords for multiple nodes.

Parameters

array $vids:

Return value

multitype

3 calls to biblio_load_keywords_multiple()
biblio_handler_field_keyword::post_execute in views/biblio_handler_field_keyword.inc
Run after the view is executed, before the result is cached.
biblio_load in ./biblio.module
Implements hook_load().
biblio_load_keywords in includes/biblio.keywords.inc
Load keywords for a single node.

File

includes/biblio.keywords.inc, line 81
Contains all keyword related functions.

Code

function biblio_load_keywords_multiple($vids = array()) {
  $keywords = array();
  if (empty($vids)) {
    return $keywords;
  }
  $query = db_select('biblio_keyword', 'bk');
  $query
    ->innerJoin('biblio_keyword_data', 'bkd', 'bk.kid = bkd.kid');
  $query
    ->addField('bk', 'vid');
  $query
    ->fields('bkd', array(
    'kid',
    'word',
  ));
  $query
    ->orderby('bk.vid');
  $query
    ->orderby('bkd.word');
  if (count($vids) == 1) {
    $query
      ->condition('bk.vid', $vids[0]);
  }
  else {
    $query
      ->condition('bk.vid', $vids, 'IN');
  }
  $query
    ->addMetaData('base_table', 'biblio_keyword');
  $query
    ->addTag('node_access');
  $result = $query
    ->execute();
  foreach ($result as $keyword) {
    $keywords[$keyword->vid][$keyword->kid] = $keyword->word;
  }
  return $keywords;
}