function _get_biblio_filters in Bibliography Module 5
Same name and namespace in other branches
- 6.2 includes/biblio.pages.inc \_get_biblio_filters()
- 6 biblio.pages.inc \_get_biblio_filters()
- 7 includes/biblio.pages.inc \_get_biblio_filters()
- 7.2 includes/biblio.pages.inc \_get_biblio_filters()
2 calls to _get_biblio_filters()
File
- ./
biblio.module, line 1383
Code
function _get_biblio_filters() {
$fields = " b.biblio_year, b.biblio_authors, 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.nid = tn.nid",
"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}");
$taxoresult = db_query("SELECT {$taxo_fields} FROM {$table} {$taxo_joins} ORDER BY {$taxo_order}");
while ($option = db_fetch_object($result)) {
if ($option->biblio_year == 9998) {
$option->biblio_year = t("In Press");
}
if ($option->biblio_year == 9999) {
$option->biblio_year = t("Submitted");
}
$pub_years["{$option->biblio_year}"] = $option->biblio_year;
$pub_type["{$option->tid}"] = $option->name;
$author_array = explode(";", $option->biblio_authors);
foreach ($author_array as $auth) {
if (strstr($auth, ",")) {
$parts = split(",", $auth);
$lastname = trim($parts[0]);
}
else {
$parts = split(" ", $auth);
$lastname = trim(end($parts));
}
if ($lastname) {
$pub_authors["{$lastname}"] = $lastname;
}
}
}
while ($tax = db_fetch_object($taxoresult)) {
$pub_taxo["{$tax->taxid}"] = "{$tax->vocab_name} - {$tax->termname}";
}
$pub_years = array_unique($pub_years);
$pub_type = array_unique($pub_type);
if (!empty($pub_taxo)) {
$pub_taxo = array_unique($pub_taxo);
}
if (!empty($pub_taxo)) {
$tax_select = array(
'title' => t('Term'),
'options' => $pub_taxo,
);
}
else {
$tax_select = null;
}
ksort($pub_authors);
$filters = array(
'author' => array(
'title' => t('Author'),
'options' => $pub_authors,
),
'type' => array(
'title' => t('Type'),
'options' => $pub_type,
),
'term_id' => $tax_select,
'year' => array(
'title' => t('Year'),
'options' => $pub_years,
),
);
return $filters;
}