You are here

function _get_biblio_filters in Bibliography Module 6.2

Same name and namespace in other branches
  1. 5 biblio.module \_get_biblio_filters()
  2. 6 biblio.pages.inc \_get_biblio_filters()
  3. 7 includes/biblio.pages.inc \_get_biblio_filters()
  4. 7.2 includes/biblio.pages.inc \_get_biblio_filters()

Populates the various selection filters with biblio data.

Return value

array An associative array with the following keys:

  • author:
  • type:
  • term_id:
  • year:
  • keyword:
2 calls to _get_biblio_filters()
biblio_form_filter in includes/biblio.pages.inc
Form constructor for a biblio content filter.
biblio_form_filter_submit in includes/biblio.pages.inc
Form submission handler for biblio_form_filter().

File

includes/biblio.pages.inc, line 1012
Functions in the biblio module related to filtering and page generation.

Code

function _get_biblio_filters() {
  $pub_authors[0] = '';
  $pub_years[-1] = '';
  $pub_type[0] = '';
  $pub_taxo[0] = '';
  $pub_keywords[0] = '';
  $fields = " b.biblio_year, t.name , t.tid ";
  $order = " b.biblio_year DESC";
  $taxo_fields = "td.name as termname,td.tid as taxid, v.name as vocab_name";
  $taxo_order = "vocab_name ASC, termname ASC";
  $table = "{node} as n  inner join {biblio} as b on n.vid=b.vid ";
  $join = "left join {biblio_types} as t on b.biblio_type = t.tid";
  $taxo_join = array(
    "inner join {term_node} as tn on n.vid = tn.vid",
    "left join  {term_data} as td on tn.tid= td.tid",
    "left join  {vocabulary} as v on v.vid= td.vid",
  );
  $taxo_joins = implode(' ', $taxo_join);
  $result = db_query("SELECT {$fields} FROM {$table} {$join} ORDER BY {$order}");
  $authors = db_query("SELECT firstname, initials, lastname, cid FROM {biblio_contributor_data} ORDER BY lastname ASC");
  $keywords = db_query("SELECT word, kid FROM {biblio_keyword_data} ORDER BY word ASC");
  $taxoresult = db_query("SELECT {$taxo_fields} FROM {$table} {$taxo_joins} ORDER BY {$taxo_order}");
  while ($option = db_fetch_object($result)) {
    if (isset($option->biblio_year)) {
      $option->biblio_year = _biblio_text_year($option->biblio_year);
    }
    $pub_years["{$option->biblio_year}"] = $option->biblio_year;
    $pub_type["{$option->tid}"] = _biblio_localize_type($option->tid, $option->name);
  }
  while ($auth = db_fetch_object($authors)) {
    $pub_authors[$auth->cid] = $auth->lastname . (!empty($auth->firstname) || !empty($auth->initials) ? ', ' . $auth->firstname . ' ' . $auth->initials : '');
  }
  while ($keyword = db_fetch_object($keywords)) {
    $pub_keywords[$keyword->kid] = $keyword->word;
  }
  while ($tax = db_fetch_object($taxoresult)) {
    $pub_taxo["{$tax->taxid}"] = "{$tax->vocab_name} - {$tax->termname}";
  }
  $author_select = count($pub_authors) > 1 ? array(
    'title' => t('Author'),
    'options' => $pub_authors,
  ) : NULL;
  $years_select = count($pub_years) > 1 ? array(
    'title' => t('Year'),
    'options' => array_unique($pub_years),
  ) : NULL;
  $type_select = count($pub_type) > 1 ? array(
    'title' => t('Type'),
    'options' => array_unique($pub_type),
  ) : NULL;
  $tax_select = count($pub_taxo) > 1 ? array(
    'title' => t('Term'),
    'options' => array_unique($pub_taxo),
  ) : NULL;
  $keyword_select = count($pub_keywords) > 1 ? array(
    'title' => t('Keyword'),
    'options' => $pub_keywords,
  ) : NULL;
  $filters = array(
    'author' => $author_select,
    'type' => $type_select,
    'term_id' => $tax_select,
    'year' => $years_select,
    'keyword' => $keyword_select,
  );
  return $filters;
}