You are here

function _biblio_category_separator_bar in Bibliography Module 7

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

File

includes/biblio.pages.inc, line 729
Copyright (C) 2006-2011 Ron Jerome.

Code

function _biblio_category_separator_bar($node, $reset = FALSE) {
  $_text =& drupal_static(__FUNCTION__, '');
  if ($reset) {
    $_text =& drupal_static(__FUNCTION__, '', TRUE);
    return;
  }
  $content = '';
  if (isset($_GET['s'])) {
    $sort = $_GET['s'];
  }
  else {
    $sort = variable_get('biblio_sort', 'year');
  }
  switch ($sort) {
    case 'title':
      $title = $node->biblio_sort_title;
      $first = drupal_substr(drupal_ucfirst(ltrim($title)), 0, 1);
      if ($first != $_text) {
        if ($_text != '') {
          $content .= theme_biblio_end_category_section();
        }
        $_text = $first;
        $content .= theme_biblio_separator_bar($_text);
      }
      break;
    case 'author':
      if (isset($node->biblio_contributors[0]['lastname']) && drupal_substr(drupal_ucfirst(ltrim($node->biblio_contributors[0]['lastname'])), 0, 1) != $_text) {
        if ($_text != '') {
          $content .= theme_biblio_end_category_section();
        }
        $_text = drupal_substr(drupal_ucfirst(ltrim($node->biblio_contributors[0]['lastname'])), 0, 1);
        $content .= theme_biblio_separator_bar($_text);
      }
      break;
    case 'type':
      if ($node->biblio_type_name != $_text) {
        if ($_text != '') {
          $content .= theme_biblio_end_category_section();
        }
        $_text = $node->biblio_type_name;

        // $name = db_result(db_query("SELECT name FROM {biblio_types} as t where t.tid=%d", $node->biblio_type)) ;.
        $content .= theme_biblio_separator_bar(_biblio_localize_type($node->biblio_type, $_text));
      }
      break;

    // Added msh 08 aug 07.
    case 'keyword':

      // $kw = array_shift($node->biblio_keyword);.
      $tok = $node->biblio_keyword;
      if (empty($tok)) {
        $tok = t("No Keywords");
      }
      if ($tok != $_text) {
        if ($_text != '') {
          $content .= theme_biblio_end_category_section();
        }
        $_text = $tok;
        if ($_text != '') {
          $content .= theme_biblio_separator_bar($_text);
        }
      }
      break;
    case 'year':
    default:
      if ($node->biblio_year != $_text) {
        if ($_text != '') {
          $content .= theme_biblio_end_category_section();
        }
        $_text = $node->biblio_year;
        $content .= theme_biblio_separator_bar($_text);
      }
  }

  //end switch
  return $content;
}