function _biblio_filter_info_line in Bibliography Module 7
Same name and namespace in other branches
- 6.2 includes/biblio.pages.inc \_biblio_filter_info_line()
- 6 biblio.pages.inc \_biblio_filter_info_line()
- 7.2 includes/biblio.pages.inc \_biblio_filter_info_line()
1 call to _biblio_filter_info_line()
- biblio_page_header in includes/
biblio.pages.inc
File
- includes/
biblio.pages.inc, line 617 - Copyright (C) 2006-2011 Ron Jerome.
Code
function _biblio_filter_info_line($args = array()) {
$content = '';
$filtercontent = '';
$search_content = FALSE;
$profile_content = FALSE;
$base = variable_get('biblio_base', 'biblio');
$session = !empty($_SESSION['biblio_filter']) ? $_SESSION['biblio_filter'] : array();
// If there are any filters in place, print them at the top of the list.
$uri = drupal_parse_url(request_uri());
$uri['path'] = variable_get('biblio_base', 'biblio');
$filters = isset($uri['query']['f']) ? $uri['query']['f'] : (isset($args['f']) ? $args['f'] : array());
if (count($filters)) {
$i = 0;
foreach ($filters as $type => $value) {
// Will $value be run through check_plain()?
$check_plain = TRUE;
if ($type == 'search') {
$search_content = $value;
continue;
}
if ($type == 'profile') {
$profile_content = $value;
continue;
}
if ($type == 'term_id') {
$term = taxonomy_term_load($value);
$value = $term->name;
$type = t("Taxonomy term");
}
if ($type == 'keyword') {
module_load_include('inc', 'biblio', 'includes/biblio.keywords');
$type = t("Keyword");
if (is_numeric($value)) {
$term = biblio_get_keyword_by_id($value);
if (isset($term->word)) {
$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)) {
module_load_include('inc', 'biblio', 'includes/biblio.contributors');
$author = biblio_get_contributor($value);
$check_plain = FALSE;
$value = isset($author->name) ? check_plain($author->name) : t('Unknown Author');
// Link to edit page for author.
if (drupal_valid_path(variable_get('biblio_base', 'biblio') . '/authors/%/edit')) {
$value .= _biblio_author_edit_links($author);
}
$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_query('SELECT t.* FROM {biblio_types} as t WHERE t.tid=:tid', array(
':tid' => $value,
))
->fetchObject()) {
$value = drupal_ucfirst(_biblio_localize_type($pub_type->tid, $pub_type->name));
$type = t("Type");
}
}
$params = array(
'%a' => check_plain(ucwords($type)),
'!b' => $check_plain ? check_plain($value) : $value,
);
$filtercontent .= $i++ ? t(' <strong>and</strong> %a is <em class="placeholder">!b</em>', $params) : t('%a is <em class="placeholder">!b</em>', $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['s'])) {
$link_options['query']['s'] = $_GET['s'];
}
if (isset($_GET['o'])) {
$link_options['query']['o'] = $_GET['o'];
}
unset($uri['query']['f']);
if ($search_content) {
$content .= ' ' . l('[' . t('Reset Search') . ']', "{$base}/filter/clear", $link_options);
}
elseif (!$search_content && !$profile_content) {
$content .= ' ' . l('[' . t('Clear All Filters') . ']', "{$base}/filter/clear", $uri);
}
$content .= '</div>';
}
return $content;
}