PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/system/vendor/htmlpurifier/HTMLPurifier/Token/Tag.php

https://github.com/Toushi/flow
PHP | 53 lines | 23 code | 4 blank | 26 comment | 3 complexity | 7e6d9aa29c72510582fad1187ecba831 MD5 | raw file
  1. <?php
  2. /**
  3. * Abstract class of a tag token (start, end or empty), and its behavior.
  4. */
  5. class HTMLPurifier_Token_Tag extends HTMLPurifier_Token
  6. {
  7. /**
  8. * Static bool marker that indicates the class is a tag.
  9. *
  10. * This allows us to check objects with <tt>!empty($obj->is_tag)</tt>
  11. * without having to use a function call <tt>is_a()</tt>.
  12. */
  13. public $is_tag = true;
  14. /**
  15. * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
  16. *
  17. * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
  18. * be lower-casing them, but these tokens cater to HTML tags, which are
  19. * insensitive.
  20. */
  21. public $name;
  22. /**
  23. * Associative array of the tag's attributes.
  24. */
  25. public $attr = array();
  26. /**
  27. * Non-overloaded constructor, which lower-cases passed tag name.
  28. *
  29. * @param $name String name.
  30. * @param $attr Associative array of attributes.
  31. */
  32. public function __construct($name, $attr = array(), $line = null) {
  33. $this->name = ctype_lower($name) ? $name : strtolower($name);
  34. foreach ($attr as $key => $value) {
  35. // normalization only necessary when key is not lowercase
  36. if (!ctype_lower($key)) {
  37. $new_key = strtolower($key);
  38. if (!isset($attr[$new_key])) {
  39. $attr[$new_key] = $attr[$key];
  40. }
  41. if ($new_key !== $key) {
  42. unset($attr[$key]);
  43. }
  44. }
  45. }
  46. $this->attr = $attr;
  47. $this->line = $line;
  48. }
  49. }