You are here

function biblio_category_section in Bibliography Module 7.2

Same name and namespace in other branches
  1. 7 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 792

Code

function biblio_category_section($biblio, $reset = FALSE) {
  $wrapper = biblio_wrapper($biblio);
  $_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 = $wrapper->biblio_sort_title
        ->value();
      $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($biblio->biblio_contributors[0]['lastname']) && drupal_substr(drupal_ucfirst(ltrim($biblio->biblio_contributors[0]['lastname'])), 0, 1) != $_text) {
        $_text = drupal_substr(drupal_ucfirst(ltrim($biblio->biblio_contributors[0]['lastname'])), 0, 1);
        $section['bar'] = biblio_section_bar($_text);
      }
      break;
    case 'type':
      if ($biblio->biblio_type_name != $_text) {
        $_text = $biblio->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($biblio->biblio_type, $_text));
      }
      break;
    case 'keyword':

      // added msh 08 aug 07
      // $kw = array_shift($node->biblio_keyword);
      $tok = $biblio->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 ($wrapper->biblio_year
        ->value() != $_text) {
        $_text = $wrapper->biblio_year
          ->value();
        $section['bar'] = biblio_section_bar($_text);
      }
  }

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