You are here

class csl_text in Bibliography Module 7.2

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

Hierarchy

Expanded class hierarchy of csl_text

File

modules/CiteProc/CSL.inc, line 1080

View source
class csl_text extends csl_format {
  public $source;
  protected $var;
  function init($dom_node, $citeproc) {
    foreach (array(
      'variable',
      'macro',
      'term',
      'value',
    ) as $attr) {
      if ($dom_node
        ->hasAttribute($attr)) {
        $this->source = $attr;
        if ($this->source == 'macro') {
          $this->var = str_replace(' ', '_', $dom_node
            ->getAttribute($attr));
        }
        else {
          $this->var = $dom_node
            ->getAttribute($attr);
        }
      }
    }
  }
  function init_formatting() {
    if ($this->variable == 'title') {
      $this->span_class = 'biblio-title';
    }
    parent::init_formatting();
  }
  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;
  }

}

Members