You are here

class csl_label in Bibliography Module 7.2

Same name and namespace in other branches
  1. 6.2 modules/CiteProc/CSL.inc \csl_label
  2. 7 modules/CiteProc/CSL.inc \csl_label

Hierarchy

Expanded class hierarchy of csl_label

1 string reference to 'csl_label'
csl_names::render in modules/CiteProc/CSL.inc

File

modules/CiteProc/CSL.inc, line 1150

View source
class csl_label extends csl_format {
  private $plural;
  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:
        if (count($data) == 1) {
          $plural = 'single';
        }
        elseif (count($data) > 1) {
          $plural = 'multiple';
        }
    }
    if (is_array($data) && isset($data['variable'])) {
      $text = $this->citeproc
        ->get_locale('term', $data['variable'], $form, $plural);
    }
    if (empty($text)) {
      foreach ($variables as $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);
  }

}

Members