function _biblio_filter_info_line in Bibliography Module 6
Same name and namespace in other branches
- 6.2 includes/biblio.pages.inc \_biblio_filter_info_line()
- 7 includes/biblio.pages.inc \_biblio_filter_info_line()
- 7.2 includes/biblio.pages.inc \_biblio_filter_info_line()
1 call to _biblio_filter_info_line()
File
- ./
biblio.pages.inc, line 602
Code
function _biblio_filter_info_line($args) {
module_load_include('inc', 'biblio', 'biblio.contributors');
$content = '';
$filtercontent = '';
$search_content = '';
$base = variable_get('biblio_base', 'biblio');
$session =& $_SESSION['biblio_filter'];
// if there are any filters in place, print them at the top of the list
if (count($args)) {
$i = 0;
while ($args) {
$type = $args[0];
array_shift($args);
$value = db_escape_string($args[0]);
if ($type == 'search') {
$search_content = array_shift($args);
continue;
}
if ($type == 'term_id') {
$term = taxonomy_get_term($value);
$value = $term->name;
$type = t("Taxonomy term");
}
if ($type == 'keyword') {
require_once drupal_get_path('module', 'biblio') . '/biblio.keywords.inc';
$type = t("Keyword");
if (is_numeric($value)) {
$term = biblio_get_keyword_by_id($value);
$value = $term->word;
}
elseif (is_string($value) && strlen($value) == 1) {
$type = t("First letter of keyword ");
}
}
if ($type == 'uid') {
$user = user_load($value);
$value = $user->name;
$type = t("Drupal user");
}
if ($type == 'aid' || $type == 'author' && is_numeric($value)) {
$author = biblio_get_contributor($value);
$value = $author->name;
$type = t("Author");
}
if ($type == 'ag') {
//return;
$type = t("First letter of last name");
}
if ($type == 'tg') {
//return;
$type = t("First letter of title");
}
if ($type == 'type' && $value > 0) {
if ($pub_type = db_fetch_object(db_query('SELECT t.* FROM {biblio_types} as t WHERE t.tid=%d', $value))) {
$value = drupal_ucfirst(_biblio_localize_type($pub_type->tid, $pub_type->name));
$type = t("Type");
}
}
array_shift($args);
$params = array(
'%a' => check_plain(ucwords($type)),
'%b' => check_plain($value),
);
$filtercontent .= $i++ ? t('<em> and</em> <strong>%a</strong> is <strong>%b</strong>', $params) : t('<strong>%a</strong> is <strong>%b</strong>', $params);
}
if ($search_content) {
$content .= '<div class="biblio-current-filters"><b>' . t('Search results for ') . '</b>';
$content .= '<em>' . check_plain($search_content) . '</em>';
if ($filtercontent) {
$content .= '<br><b>' . t('Filters') . ': </b>';
}
}
else {
$content .= '<div class="biblio-current-filters"><b>' . t('Filters') . ': </b>';
}
$content .= $filtercontent;
$link_options = array();
if (isset($_GET['sort'])) {
$link_options['query'] .= "sort=" . $_GET['sort'];
}
if (isset($_GET['order'])) {
$link_options['query'] .= $link_options['query'] ? "&" : "";
$link_options['query'] .= "order=" . $_GET['order'];
}
if ($search_content) {
$content .= ' ' . l('[' . t('Reset Search') . ']', "{$base}/filter/clear", $link_options);
}
else {
$content .= ' ' . l('[' . t('Clear All Filters') . ']', "{$base}/filter/clear", $link_options);
}
$content .= '</div>';
}
return $content;
}