You are here

public function csl_name::format in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 modules/CiteProc/CSL.inc \csl_name::format()
  2. 7.2 modules/CiteProc/CSL.inc \csl_name::format()

Overrides csl_format::format

1 call to csl_name::format()
csl_name::render in modules/CiteProc/CSL.inc

File

modules/CiteProc/CSL.inc, line 662
CiteProc-PHP.

Class

csl_name

Code

public function format($text, $part = 'base') {
  if (empty($text) || $this->no_op[$part]) {
    return $text;
  }
  if (isset($this->{$part}['text-case'])) {
    switch ($this->{$part}['text-case']) {
      case 'uppercase':
        $text = drupal_strtoupper($text);
        break;
      case 'lowercase':
        $text = drupal_strtolower($text);
        break;
      case 'capitalize-all':
        $text = mb_convert_case($text, MB_CASE_TITLE);
        break;
      case 'capitalize-first':
        $text = drupal_ucfirst($text);
        break;
    }
  }
  $open_quote = isset($this->{$part}['open-quote']) ? $this->{$part}['open-quote'] : '';
  $close_quote = isset($this->{$part}['close-quote']) ? $this->{$part}['close-quote'] : '';
  $prefix = isset($this->{$part}['prefix']) ? $this->{$part}['prefix'] : '';
  $suffix = isset($this->{$part}['suffix']) ? $this->{$part}['suffix'] : '';
  if ($text[strlen($text) - 1] == $suffix) {
    unset($suffix);
  }
  if (!empty($this->format[$part])) {
    $text = '<span style="' . $this->format[$part] . '">' . $text . '</span>';
  }
  return $prefix . $open_quote . $text . $close_quote . $suffix;
}