4 * Abstract class of a tag token (start, end or empty), and its behavior.
6 abstract class HTMLPurifier_Token_Tag
extends HTMLPurifier_Token
9 * Static bool marker that indicates the class is a tag.
11 * This allows us to check objects with <tt>!empty($obj->is_tag)</tt>
12 * without having to use a function call <tt>is_a()</tt>.
15 public $is_tag = true;
18 * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
20 * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
21 * be lower-casing them, but these tokens cater to HTML tags, which are
28 * Associative array of the tag's attributes.
31 public $attr = array();
34 * Non-overloaded constructor, which lower-cases passed tag name.
36 * @param string $name String name.
37 * @param array $attr Associative array of attributes.
42 public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array())
44 $this->name
= ctype_lower($name) ?
$name : strtolower($name);
45 foreach ($attr as $key => $value) {
46 // normalization only necessary when key is not lowercase
47 if (!ctype_lower($key)) {
48 $new_key = strtolower($key);
49 if (!isset($attr[$new_key])) {
50 $attr[$new_key] = $attr[$key];
52 if ($new_key !== $key) {
60 $this->armor
= $armor;
63 public function toNode() {
64 return new HTMLPurifier_Node_Element($this->name
, $this->attr
, $this->line
, $this->col
, $this->armor
);