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.

75 satır
1.8KB

  1. <?php
  2. /**
  3. * Records errors for particular segments of an HTML document such as tokens,
  4. * attributes or CSS properties. They can contain error structs (which apply
  5. * to components of what they represent), but their main purpose is to hold
  6. * errors applying to whatever struct is being used.
  7. */
  8. class HTMLPurifier_ErrorStruct
  9. {
  10. /**
  11. * Possible values for $children first-key. Note that top-level structures
  12. * are automatically token-level.
  13. */
  14. const TOKEN = 0;
  15. const ATTR = 1;
  16. const CSSPROP = 2;
  17. /**
  18. * Type of this struct.
  19. * @type string
  20. */
  21. public $type;
  22. /**
  23. * Value of the struct we are recording errors for. There are various
  24. * values for this:
  25. * - TOKEN: Instance of HTMLPurifier_Token
  26. * - ATTR: array('attr-name', 'value')
  27. * - CSSPROP: array('prop-name', 'value')
  28. * @type mixed
  29. */
  30. public $value;
  31. /**
  32. * Errors registered for this structure.
  33. * @type array
  34. */
  35. public $errors = array();
  36. /**
  37. * Child ErrorStructs that are from this structure. For example, a TOKEN
  38. * ErrorStruct would contain ATTR ErrorStructs. This is a multi-dimensional
  39. * array in structure: [TYPE]['identifier']
  40. * @type array
  41. */
  42. public $children = array();
  43. /**
  44. * @param string $type
  45. * @param string $id
  46. * @return mixed
  47. */
  48. public function getChild($type, $id)
  49. {
  50. if (!isset($this->children[$type][$id])) {
  51. $this->children[$type][$id] = new HTMLPurifier_ErrorStruct();
  52. $this->children[$type][$id]->type = $type;
  53. }
  54. return $this->children[$type][$id];
  55. }
  56. /**
  57. * @param int $severity
  58. * @param string $message
  59. */
  60. public function addError($severity, $message)
  61. {
  62. $this->errors[] = array($severity, $message);
  63. }
  64. }
  65. // vim: et sw=4 sts=4