You are here

function csl_label::render in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 modules/CiteProc/CSL.inc \csl_label::render()
  2. 7.2 modules/CiteProc/CSL.inc \csl_label::render()

Overrides csl_rendering_element::render

File

modules/CiteProc/CSL.inc, line 1202

Class

csl_label

Code

function render($data, $mode = NULL) {
  $text = '';
  $variables = explode(' ', $this->variable);
  $form = ($form = $this->form) ? $form : 'long';
  switch ($this->plural) {
    case 'never':
      $plural = 'single';
      break;
    case 'always':
      $plural = 'multiple';
      break;
    case 'contextual':
    default:
  }
  foreach ($variables as $variable) {
    $field = $this->citeproc
      ->map_field($variable);
    if (isset($data->{$field}) && !empty($data->{$field})) {
      if (!isset($this->plural) && empty($plural) && is_array($data->{$field})) {
        $count = count($data->{$field});
        if ($count == 1) {
          $plural = 'single';
        }
        elseif ($count > 1) {
          $plural = 'multiple';
        }
      }
      else {
        $plural = $this
          ->evaluateStringPluralism($data, $variable);
      }
      if ($term = $this->citeproc
        ->get_locale('term', $variable, $form, $plural)) {
        $text = $term;
        break;
      }
    }
  }
  if (empty($text)) {
    return;
  }
  if ($this->{'strip-periods'}) {
    $text = str_replace('.', '', $text);
  }
  return $this
    ->format($text);
}