Overview

Namespaces

  • academicpuma
    • citeproc

Classes

  • Bibliography
  • Choose
  • Citation
  • CiteProc
  • Collection
  • CSLUtils
  • Date
  • DatePart
  • Element
  • EtAl
  • Factory
  • Format
  • Group
  • Info
  • Label
  • Layout
  • Locale
  • Macro
  • Macros
  • Mapper
  • Name
  • Names
  • Number
  • Option
  • Options
  • PElse
  • PElseIf
  • PIf
  • RenderingElement
  • Sort
  • Style
  • Substitute
  • Terms
  • Text
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: /*
 4:  * To change this license header, choose License Headers in Project Properties.
 5:  * To change this template file, choose Tools | Templates
 6:  * and open the template in the editor.
 7:  */
 8: 
 9: namespace academicpuma\citeproc;
10: 
11: /**
12:  * Description of csl_text
13:  *
14:  * @author sebastian
15:  */
16: 
17: class Text extends Format {
18: 
19:     public $source;
20:     protected $var;
21: 
22:     function init($dom_node, $citeproc) {
23:         foreach (array('variable', 'macro', 'term', 'value') as $attr) {
24:             if ($dom_node->hasAttribute($attr)) {
25:                 $this->source = $attr;
26:                 if ($this->source == 'macro') {
27:                     $this->var = str_replace(' ', '_', $dom_node->getAttribute($attr));
28:                 } else {
29:                     $this->var = $dom_node->getAttribute($attr);
30:                 }
31:             }
32:         }
33:     }
34: 
35:     function init_formatting() {
36: //    if ($this->variable == 'title') {
37: //      $this->span_class = 'title';
38: //    }
39:         parent::init_formatting();
40:     }
41: 
42:     function render($data = NULL, $mode = NULL) {
43:         $text = '';
44:         if (in_array($this->var, $this->citeproc->quash))
45:             return;
46: 
47:         switch ($this->source) {
48:             case 'variable':
49:                 if (!isset($data->{$this->variable}) || empty($data->{$this->variable}))
50:                     return;
51:                 $text = $data->{$this->variable}; //$this->data[$this->var];  // include the contents of a variable
52:                 break;
53:             case 'macro':
54:                 $macro = $this->var;
55:                 $text = $this->citeproc->render_macro($macro, $data, $mode); //trigger the macro process
56:                 break;
57:             case 'term':
58:                 $form = (($form = $this->form)) ? $form : '';
59:                 $text = $this->citeproc->get_locale('term', $this->var, $form);
60:                 break;
61:             case 'value':
62:                 $text = $this->var; //$this->var;  // dump the text verbatim
63:                 break;
64:         }
65: 
66:         if (empty($text))
67:             return;
68:         return $this->format($text);
69:     }
70:     
71:     public function getVar() {
72:         return $this->var;
73:     }
74: 
75: }
76: 
API documentation generated by ApiGen