Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

60 lines
1.7KB

  1. <?php
  2. /**
  3. * Concrete element node class.
  4. */
  5. class HTMLPurifier_Node_Element extends HTMLPurifier_Node
  6. {
  7. /**
  8. * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
  9. *
  10. * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
  11. * be lower-casing them, but these tokens cater to HTML tags, which are
  12. * insensitive.
  13. * @type string
  14. */
  15. public $name;
  16. /**
  17. * Associative array of the node's attributes.
  18. * @type array
  19. */
  20. public $attr = array();
  21. /**
  22. * List of child elements.
  23. * @type array
  24. */
  25. public $children = array();
  26. /**
  27. * Does this use the <a></a> form or the </a> form, i.e.
  28. * is it a pair of start/end tokens or an empty token.
  29. * @bool
  30. */
  31. public $empty = false;
  32. public $endCol = null, $endLine = null, $endArmor = array();
  33. public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) {
  34. $this->name = $name;
  35. $this->attr = $attr;
  36. $this->line = $line;
  37. $this->col = $col;
  38. $this->armor = $armor;
  39. }
  40. public function toTokenPair() {
  41. // XXX inefficiency here, normalization is not necessary
  42. if ($this->empty) {
  43. return array(new HTMLPurifier_Token_Empty($this->name, $this->attr, $this->line, $this->col, $this->armor), null);
  44. } else {
  45. $start = new HTMLPurifier_Token_Start($this->name, $this->attr, $this->line, $this->col, $this->armor);
  46. $end = new HTMLPurifier_Token_End($this->name, array(), $this->endLine, $this->endCol, $this->endArmor);
  47. //$end->start = $start;
  48. return array($start, $end);
  49. }
  50. }
  51. }