You are here

function _biblio_filter_info_line in Bibliography Module 6.2

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

Parameters

$args:

Return value

string

1 call to _biblio_filter_info_line()
biblio_db_search in includes/biblio.pages.inc
Page callback: Displays a listing of biblio type of content.

File

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

Code

function _biblio_filter_info_line($args) {
  module_load_include('inc', 'biblio', 'includes/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') {
        module_load_include('inc', 'biblio', 'includes/biblio.keywords');
        $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') {
        $type = t("First letter of last name");
      }
      if ($type == 'tg') {
        $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();
    $link_options['query'] = '';
    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 .= '&nbsp;&nbsp;' . l('[' . t('Reset Search') . ']', "{$base}/filter/clear", $link_options);
    }
    else {
      $content .= '&nbsp;&nbsp;' . l('[' . t('Clear All Filters') . ']', "{$base}/filter/clear", $link_options);
    }
    $content .= '</div>';
  }
  return $content;
}