]> git.wh0rd.org - tt-rss.git/blame - lib/htmlpurifier/library/HTMLPurifier/Token/Tag.php
remove Archived articles from Uncategorized view
[tt-rss.git] / lib / htmlpurifier / library / HTMLPurifier / Token / Tag.php
CommitLineData
f45a286b
AD
1<?php
2
3/**
4 * Abstract class of a tag token (start, end or empty), and its behavior.
5 */
6class HTMLPurifier_Token_Tag extends HTMLPurifier_Token
7{
8 /**
9 * Static bool marker that indicates the class is a tag.
10 *
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>.
13 */
14 public $is_tag = true;
15
16 /**
17 * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
18 *
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.
22 */
23 public $name;
24
25 /**
26 * Associative array of the tag's attributes.
27 */
28 public $attr = array();
29
30 /**
31 * Non-overloaded constructor, which lower-cases passed tag name.
32 *
33 * @param $name String name.
34 * @param $attr Associative array of attributes.
35 */
f4f0f80d 36 public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) {
f45a286b
AD
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];
44 }
45 if ($new_key !== $key) {
46 unset($attr[$key]);
47 }
48 }
49 }
50 $this->attr = $attr;
51 $this->line = $line;
52 $this->col = $col;
f4f0f80d 53 $this->armor = $armor;
f45a286b
AD
54 }
55}
56
57// vim: et sw=4 sts=4