function _get_biblio_filters in Bibliography Module 7
Same name and namespace in other branches
- 5 biblio.module \_get_biblio_filters()
- 6.2 includes/biblio.pages.inc \_get_biblio_filters()
- 6 biblio.pages.inc \_get_biblio_filters()
- 7.2 includes/biblio.pages.inc \_get_biblio_filters()
2 calls to _get_biblio_filters()
- biblio_form_filter in includes/
biblio.pages.inc - biblio_form_filter_submit in includes/
biblio.pages.inc - _state
File
- includes/
biblio.pages.inc, line 1018 - Copyright (C) 2006-2011 Ron Jerome.
Code
function _get_biblio_filters() {
$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 {taxonomy_index} as ti on n.nid = ti.nid",
"left join {taxonomy_term_data} as td on ti.tid = td.tid",
"left join {taxonomy_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 DISTINCT firstname, initials, lastname, bcd.cid\n FROM {biblio_contributor_data} as bcd\n INNER JOIN {biblio_contributor} as bc on bc.cid = bcd.cid\n 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}");
$pub_years['any'] = t('any');
$pub_type['any'] = t('any');
$pub_authors['any'] = t('any');
$pub_keywords['any'] = t('any');
$pub_taxo['any'] = t('any');
foreach ($result as $option) {
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);
}
foreach ($authors as $auth) {
$pub_authors[$auth->cid] = $auth->lastname . (!empty($auth->firstname) || !empty($auth->initials) ? ', ' . $auth->firstname . ' ' . $auth->initials : '');
}
foreach ($keywords as $keyword) {
$pub_keywords[$keyword->kid] = $keyword->word;
}
foreach ($taxoresult as $tax) {
$pub_taxo["{$tax->taxid}"] = "{$tax->vocab_name} - {$tax->termname}";
}
$author_select = isset($pub_authors) ? array(
'title' => t('Author'),
'options' => $pub_authors,
) : NULL;
$years_select = isset($pub_years) ? array(
'title' => t('Year'),
'options' => array_unique($pub_years),
) : NULL;
$type_select = isset($pub_type) ? array(
'title' => t('Type'),
'options' => array_unique($pub_type),
) : NULL;
$tax_select = isset($pub_taxo) ? array(
'title' => t('Term'),
'options' => array_unique($pub_taxo),
) : NULL;
$keyword_select = isset($pub_keywords) ? 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;
}