You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.1KB

  1. <?php
  2. /**
  3. * Abstract base token class that all others inherit from.
  4. */
  5. abstract class HTMLPurifier_Token
  6. {
  7. /**
  8. * Line number node was on in source document. Null if unknown.
  9. * @type int
  10. */
  11. public $line;
  12. /**
  13. * Column of line node was on in source document. Null if unknown.
  14. * @type int
  15. */
  16. public $col;
  17. /**
  18. * Lookup array of processing that this token is exempt from.
  19. * Currently, valid values are "ValidateAttributes" and
  20. * "MakeWellFormed_TagClosedError"
  21. * @type array
  22. */
  23. public $armor = array();
  24. /**
  25. * Used during MakeWellFormed.
  26. * @type
  27. */
  28. public $skip;
  29. /**
  30. * @type
  31. */
  32. public $rewind;
  33. /**
  34. * @type
  35. */
  36. public $carryover;
  37. /**
  38. * @param string $n
  39. * @return null|string
  40. */
  41. public function __get($n)
  42. {
  43. if ($n === 'type') {
  44. trigger_error('Deprecated type property called; use instanceof', E_USER_NOTICE);
  45. switch (get_class($this)) {
  46. case 'HTMLPurifier_Token_Start':
  47. return 'start';
  48. case 'HTMLPurifier_Token_Empty':
  49. return 'empty';
  50. case 'HTMLPurifier_Token_End':
  51. return 'end';
  52. case 'HTMLPurifier_Token_Text':
  53. return 'text';
  54. case 'HTMLPurifier_Token_Comment':
  55. return 'comment';
  56. default:
  57. return null;
  58. }
  59. }
  60. }
  61. /**
  62. * Sets the position of the token in the source document.
  63. * @param int $l
  64. * @param int $c
  65. */
  66. public function position($l = null, $c = null)
  67. {
  68. $this->line = $l;
  69. $this->col = $c;
  70. }
  71. /**
  72. * Convenience function for DirectLex settings line/col position.
  73. * @param int $l
  74. * @param int $c
  75. */
  76. public function rawPosition($l, $c)
  77. {
  78. if ($c === -1) {
  79. $l++;
  80. }
  81. $this->line = $l;
  82. $this->col = $c;
  83. }
  84. /**
  85. * Converts a token into its corresponding node.
  86. */
  87. abstract public function toNode();
  88. }
  89. // vim: et sw=4 sts=4