File indexing completed on 2024-05-12 06:02:06

0001 <?php
0002 
0003 /**
0004  * Concrete element node class.
0005  */
0006 class HTMLPurifier_Node_Element extends HTMLPurifier_Node
0007 {
0008     /**
0009      * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
0010      *
0011      * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
0012      * be lower-casing them, but these tokens cater to HTML tags, which are
0013      * insensitive.
0014      * @type string
0015      */
0016     public $name;
0017 
0018     /**
0019      * Associative array of the node's attributes.
0020      * @type array
0021      */
0022     public $attr = array();
0023 
0024     /**
0025      * List of child elements.
0026      * @type array
0027      */
0028     public $children = array();
0029 
0030     /**
0031      * Does this use the <a></a> form or the </a> form, i.e.
0032      * is it a pair of start/end tokens or an empty token.
0033      * @bool
0034      */
0035     public $empty = false;
0036 
0037     public $endCol = null, $endLine = null, $endArmor = array();
0038 
0039     public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) {
0040         $this->name = $name;
0041         $this->attr = $attr;
0042         $this->line = $line;
0043         $this->col = $col;
0044         $this->armor = $armor;
0045     }
0046 
0047     public function toTokenPair() {
0048         // XXX inefficiency here, normalization is not necessary
0049         if ($this->empty) {
0050             return array(new HTMLPurifier_Token_Empty($this->name, $this->attr, $this->line, $this->col, $this->armor), null);
0051         } else {
0052             $start = new HTMLPurifier_Token_Start($this->name, $this->attr, $this->line, $this->col, $this->armor);
0053             $end = new HTMLPurifier_Token_End($this->name, array(), $this->endLine, $this->endCol, $this->endArmor);
0054             //$end->start = $start;
0055             return array($start, $end);
0056         }
0057     }
0058 }
0059