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