Add vim modelines to all files.
[htmlpurifier.git] / library / HTMLPurifier / Token / Tag.php
blob798be028ee6394ab904f9e67b2ba1e8f8a70ae24
1 <?php
3 /**
4 * Abstract class of a tag token (start, end or empty), and its behavior.
5 */
6 class HTMLPurifier_Token_Tag extends HTMLPurifier_Token
8 /**
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;
16 /**
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
21 * insensitive.
23 public $name;
25 /**
26 * Associative array of the tag's attributes.
28 public $attr = array();
30 /**
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) {
46 unset($attr[$key]);
50 $this->attr = $attr;
51 $this->line = $line;
52 $this->col = $col;
56 // vim: et sw=4 sts=4