You are here

function _biblio_sort_tabs in Bibliography Module 6.2

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

Parameters

$attrib:

array $options: (optional) An associative array with following possible keys:

Return value

string $content An HTML formatted string?

1 call to _biblio_sort_tabs()
biblio_show_results in includes/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

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

Code

function _biblio_sort_tabs($attrib, $options = NULL) {
  global $base_path;
  $content = '';
  $sort_links = array();
  $tabs = variable_get('biblio_sort_tabs_style', 0);

  // What is the default for $order in event $attrib['order'] not defined?
  $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 . '/misc/arrow-asc.png" alt =" (Desc)" />' : ' <img src ="' . $base_path . $path . '/misc/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;
}