4 * Abstract class of a tag token (start, end or empty), and its behavior.
6 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>.
14 public $is_tag = true;
17 * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
19 * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
20 * be lower-casing them, but these tokens cater to HTML tags, which are
26 * Associative array of the tag's attributes.
28 public $attr = array();
31 * Non-overloaded constructor, which lower-cases passed tag name.
33 * @param $name String name.
34 * @param $attr Associative array of attributes.
36 public function __construct($name, $attr = array(), $line = null, $col = null) {
37 $this->name
= ctype_lower($name) ?
$name : strtolower($name);
38 foreach ($attr as $key => $value) {
39 // normalization only necessary when key is not lowercase
40 if (!ctype_lower($key)) {
41 $new_key = strtolower($key);
42 if (!isset($attr[$new_key])) {
43 $attr[$new_key] = $attr[$key];
45 if ($new_key !== $key) {