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_element
 13:  *
 14:  * @author sebastian
 15:  */
 16: 
 17: class Element extends Collection {
 18: 
 19:     protected $attributes = array();
 20:     protected $citeproc;
 21:     protected $dom_node;
 22: 
 23:     function __construct($dom_node = NULL, $citeproc = NULL) {
 24:         $this->dom_node = $dom_node;
 25:         $this->citeproc = &$citeproc;
 26:         $this->set_attributes($dom_node);
 27:         $this->init($dom_node, $citeproc);
 28:     }
 29: 
 30:     function init($dom_node, $citeproc) {
 31:         if (!$dom_node)
 32:             return;
 33: 
 34:         foreach ($dom_node->childNodes as $node) {
 35:             if ($node->nodeType == 1) {
 36:                 $this->addElement(Factory::create($node, $citeproc));
 37:             }
 38:         }
 39:     }
 40: 
 41:     function __set($name, $value) {
 42:         $this->attributes[$name] = $value;
 43:     }
 44: 
 45:     function __isset($name) {
 46:         return isset($this->attributes[$name]);
 47:     }
 48: 
 49:     function __unset($name) {
 50:         unset($this->attributes[$name]);
 51:     }
 52: 
 53:     function &__get($name = NULL) {
 54:         $null = NULL;
 55:         if (array_key_exists($name, $this->attributes)) {
 56:             return $this->attributes[$name];
 57:         }
 58:         if (isset($this->{$name})) {
 59:             return $this->{$name};
 60:         }
 61:         return $null;
 62:     }
 63: 
 64:     function set_attributes($dom_node) {
 65:         $att = array();
 66:         $element_name = $dom_node->nodeName;
 67:         if (isset($dom_node->attributes->length)) {
 68:             for ($i = 0; $i < $dom_node->attributes->length; $i++) {
 69:                 $value = $dom_node->attributes->item($i)->value;
 70:                 $name = str_replace(' ', '_', $dom_node->attributes->item($i)->name);
 71:                 if ($name == 'type') {
 72:                     $value = $this->citeproc->map_type($value);
 73:                 }
 74: 
 75:                 if (($name == 'variable' || $name == 'is-numeric') && $element_name != 'label') {
 76:                     $value = $this->citeproc->map_field($value);
 77:                 }
 78:                 $this->{$name} = $value;
 79:             }
 80:         }
 81:     }
 82: 
 83:     function get_attributes() {
 84:         return $this->attributes;
 85:     }
 86: 
 87:     function get_hier_attributes() {
 88:         $hier_attr = array();
 89:         $hier_names = array('and', 'delimiter-precedes-last', 'et-al-min', 'et-al-use-first',
 90:             'et-al-subsequent-min', 'et-al-subsequent-use-first', 'initialize-with',
 91:             'name-as-sort-order', 'sort-separator', 'name-form', 'name-delimiter',
 92:             'names-delimiter');
 93:         foreach ($hier_names as $name) {
 94:             if (isset($this->attributes[$name])) {
 95:                 $hier_attr[$name] = $this->attributes[$name];
 96:             }
 97:         }
 98:         return $hier_attr;
 99:     }
100: 
101:     function name($name = NULL) {
102:         if ($name) {
103:             $this->name = $name;
104:         } else {
105:             return str_replace(' ', '_', $this->name);
106:         }
107:     }
108: 
109:     function getDomNode() {
110:         return $this->dom_node;
111:     }
112: 
113: }
114: 
API documentation generated by ApiGen