You are here

class csl_element in Bibliography Module 7

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

Hierarchy

Expanded class hierarchy of csl_element

File

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

View source
class csl_element extends csl_collection {
  protected $attributes = array();
  protected $citeproc;

  /**
   *
   */
  public function __construct($dom_node = NULL, $citeproc = NULL) {
    $this->citeproc =& $citeproc;
    $this
      ->set_attributes($dom_node);
    $this
      ->init($dom_node, $citeproc);
  }

  /**
   *
   */
  public function init($dom_node, $citeproc) {
    if (!$dom_node) {
      return;
    }
    foreach ($dom_node->childNodes as $node) {
      if ($node->nodeType == 1) {
        $this
          ->add_element(csl_factory::create($node, $citeproc));
      }
    }
  }

  /**
   *
   */
  public function __set($name, $value) {
    $this->attributes[$name] = $value;
  }

  /**
   *
   */
  public function __isset($name) {
    return isset($this->attributes[$name]);
  }

  /**
   *
   */
  public function __unset($name) {
    unset($this->attributes[$name]);
  }

  /**
   *
   */
  public function &__get($name = NULL) {
    $null = NULL;
    if (array_key_exists($name, $this->attributes)) {
      return $this->attributes[$name];
    }
    if (isset($this->{$name})) {
      return $this->{$name};
    }
    return $null;
  }

  /**
   *
   */
  public function set_attributes($dom_node) {
    $att = array();
    $element_name = $dom_node->nodeName;
    if (isset($dom_node->attributes->length)) {
      for ($i = 0; $i < $dom_node->attributes->length; $i++) {
        $value = $dom_node->attributes
          ->item($i)->value;
        $name = str_replace(' ', '_', $dom_node->attributes
          ->item($i)->name);
        if ($name == 'type') {
          $value = $this->citeproc
            ->map_type($value);
        }
        if (($name == 'variable' || $name == 'is-numeric') && $element_name != 'label') {
          $value = $this->citeproc
            ->map_field($value);
        }
        $this->{$name} = $value;
      }
    }
  }

  /**
   *
   */
  public function get_attributes() {
    return $this->attributes;
  }

  /**
   *
   */
  public function get_hier_attributes() {
    $hier_attr = array();
    $hier_names = array(
      'and',
      'delimiter-precedes-last',
      'et-al-min',
      'et-al-use-first',
      'et-al-subsequent-min',
      'et-al-subsequent-use-first',
      'initialize-with',
      'name-as-sort-order',
      'sort-separator',
      'name-form',
      'name-delimiter',
      'names-delimiter',
    );
    foreach ($hier_names as $name) {
      if (isset($this->attributes[$name])) {
        $hier_attr[$name] = $this->attributes[$name];
      }
    }
    return $hier_attr;
  }

  /**
   *
   */
  public function name($name = NULL) {
    if ($name) {
      $this->name = $name;
    }
    else {
      return str_replace(' ', '_', $this->name);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
csl_collection::$elements protected property
csl_collection::add_element public function
csl_collection::format public function 1
csl_collection::render public function 2
csl_element::$attributes protected property
csl_element::$citeproc protected property
csl_element::get_attributes public function
csl_element::get_hier_attributes public function
csl_element::init public function 5
csl_element::name public function
csl_element::set_attributes public function
csl_element::__construct public function 2
csl_element::__get public function
csl_element::__isset public function
csl_element::__set public function
csl_element::__unset public function