You are here

function biblio_category_section in Bibliography Module 7

Same name and namespace in other branches
  1. 7.2 includes/biblio.pages.inc \biblio_category_section()
1 call to biblio_category_section()
biblio_page_content in includes/biblio.pages.inc

File

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

Code

function biblio_category_section($node, $reset = FALSE) {
  $_text =& drupal_static(__FUNCTION__, '');
  if ($reset) {
    $_text =& drupal_static(__FUNCTION__, '', TRUE);
    return;
  }
  $section = array();
  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) {
        $_text = $first;
        $section['bar'] = biblio_section_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) {
        $_text = drupal_substr(drupal_ucfirst(ltrim($node->biblio_contributors[0]['lastname'])), 0, 1);
        $section['bar'] = biblio_section_bar($_text);
      }
      break;
    case 'type':
      if ($node->biblio_type_name != $_text) {
        $_text = $node->biblio_type_name;

        // $name = db_result(db_query("SELECT name FROM {biblio_types} as t where t.tid=%d", $node->biblio_type)) ;.
        $section['bar'] = biblio_section_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) {
        $_text = $tok;
        if ($_text != '') {
          $section['bar'] = biblio_section_bar($_text);
        }
      }
      break;
    case 'year':
    default:
      if ($node->biblio_year != $_text) {
        $_text = $node->biblio_year;
        $section['bar'] = biblio_section_bar($_text);
      }
  }

  //end switch
  if (!empty($section)) {
    $section += array(
      '#prefix' => '<div class="biblio-category-section">',
      '#suffix' => '</div>',
    );
  }
  return $section;
}