You are here

public function csl_text::render in Bibliography Module 7

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

Overrides csl_rendering_element::render

File

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

Class

csl_text

Code

public function render($data = NULL, $mode = NULL) {
  $text = '';
  if (in_array($this->var, $this->citeproc->quash)) {
    return;
  }
  switch ($this->source) {
    case 'variable':
      if (!isset($data->{$this->variable}) || empty($data->{$this->variable}) || trim($data->{$this->variable}) == FALSE) {
        return;
      }
      if ($this->variable == 'biblio_url') {
        $text = l($data->{$this->variable}, $data->{$this->variable});
      }
      else {
        $text = $data->{$this->variable};

        //$this->data[$this->var];  // include the contents of a variable
      }
      break;
    case 'macro':
      $macro = $this->var;

      // Trigger the macro process.
      $text = $this->citeproc
        ->render_macro($macro, $data, $mode);
      break;
    case 'term':
      $form = ($form = $this->form) ? $form : '';
      $text = $this->citeproc
        ->get_locale('term', $this->var, $form);
      break;
    case 'value':

      // $this->var;  // dump the text verbatim.
      $text = $this->var;
      break;
  }
  if (empty($text)) {
    return;
  }
  $text = $this
    ->format($text);
  if ($this->variable == 'title') {
    $url = biblio_get_title_url_info($data);
    $text = l($text, $url['link'], $url['options']);
  }
  return $text;
}