Add conversion functions for our own tree format.
[htmlpurifier.git] / library / HTMLPurifier / Node / Element.php
blob6cbf56dadac0deec2d5b6322abda9e66f3b7ac0d
1 <?php
3 /**
4 * Concrete element node class.
5 */
6 class HTMLPurifier_Node_Element extends HTMLPurifier_Node
8 /**
9 * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
11 * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
12 * be lower-casing them, but these tokens cater to HTML tags, which are
13 * insensitive.
14 * @type string
16 public $name;
18 /**
19 * Associative array of the node's attributes.
20 * @type array
22 public $attr = array();
24 /**
25 * List of child elements.
26 * @type array
28 public $children = array();
30 /**
31 * Does this use the <a></a> form or the </a> form, i.e.
32 * is it a pair of start/end tokens or an empty token.
33 * @bool
35 public $empty = false;
37 public $endCol = null, $endLine = null, $endArmor = array();
39 public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) {
40 $this->name = $name;
41 $this->attr = $attr;
42 $this->line = $line;
43 $this->col = $col;
44 $this->armor = $armor;
47 public function toTokenPair() {
48 // XXX inefficiency here, normalization is not necessary
49 if ($this->empty) {
50 return array(new HTMLPurifier_Token_Empty($this->name, $this->attr, $this->line, $this->col, $this->armor), null);
51 } else {
52 $start = new HTMLPurifier_Token_Start($this->name, $this->attr, $this->line, $this->col, $this->armor);
53 $end = new HTMLPurifier_Token_End($this->name, array(), $this->endLine, $this->endCol, $this->endArmor);
54 //$end->start = $start;
55 return array($start, $end);