You are here

function _biblio_sort_tabs in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 includes/biblio.pages.inc \_biblio_sort_tabs()
  2. 7.2 includes/biblio.pages.inc \_biblio_sort_tabs()
1 call to _biblio_sort_tabs()
biblio_show_results in ./biblio.pages.inc
biblio_show_results takes the query results from biblio_db_search and adds some controls to the page then loops through the results applying the selected style to each entry

File

./biblio.pages.inc, line 545

Code

function _biblio_sort_tabs($attrib, $options = NULL) {
  global $base_path;
  $content = '';
  $sort_links = array();
  $tabs = variable_get('biblio_sort_tabs_style', 0);
  $order = $attrib['order'] == "desc" || $attrib['order'] == "DESC" ? "asc" : "desc";
  $cur_order = $attrib['order'] == "desc" || $attrib['order'] == "DESC" ? "desc" : "asc";
  $path = drupal_get_path('module', 'biblio');
  $order_arrow = $order == 'asc' ? ' <img src ="' . $base_path . $path . '/arrow-asc.png" alt =" (Desc)" />' : ' <img src ="' . $base_path . $path . '/arrow-desc.png" alt = " (Asc)" />';
  $sort_links = variable_get('biblio_sort_tabs', array(
    'author' => 'author',
    'title' => 'title',
    'type' => 'type',
    'year' => 'year',
    'keyword' => 'keyword',
  ));
  ksort($sort_links);
  $content .= $tabs ? '<ul class="tabs secondary ">' : '';
  foreach ($sort_links as $key => $title) {
    $tab['path'] = $_GET['q'];
    $tab['attributes'] = array(
      "title" => t("Click a second time to reverse the sort order"),
    );
    $tab['html'] = TRUE;
    $tab['text'] = t(ucfirst($title));
    if ($key === $title && $title == $attrib['sort']) {
      $tab['query'] = array(
        'sort' => $title,
        'order' => $order,
      );
      $tab['attributes'] += array(
        'class' => "active",
      );
      $tab['active'] = TRUE;
      $tab['pfx'] = ' [ ';
      $tab['sfx'] = '] ';
      $tab['arrow'] = $order_arrow;
      $content .= _biblio_sort_tab($tab, $tabs);
    }
    elseif ($key === $title) {
      $tab['query'] = array(
        'sort' => $title,
        'order' => $order,
      );
      $tab['active'] = FALSE;
      $tab['pfx'] = ' ';
      $tab['sfx'] = ' ';
      $tab['arrow'] = '';
      $content .= _biblio_sort_tab($tab, $tabs);
    }
  }
  if (!$tabs) {
    $content = t('Sort by') . ': ' . $content;
  }
  $content .= $tabs ? '</ul>' : '';
  return $content;
}