You are here

function csl_text::render in Bibliography Module 7.2

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

Overrides csl_rendering_element::render

File

modules/CiteProc/CSL.inc, line 1105

Class

csl_text

Code

function render($data = NULL, $mode = NULL) {
  $text = '';
  switch ($this->source) {
    case 'variable':
      if (!isset($data->{$this->variable}) || empty($data->{$this->variable})) {
        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;
      $text = $this->citeproc
        ->render_macro($macro, $data, $mode);

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

      //$this->var;  // dump the text verbatim
      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;
}