]>
Commit | Line | Data |
---|---|---|
d4949327 NL |
1 | <?php\r |
2 | \r | |
3 | /**\r | |
4 | * Generic schema interchange format that can be converted to a runtime\r | |
5 | * representation (HTMLPurifier_ConfigSchema) or HTML documentation. Members\r | |
6 | * are completely validated.\r | |
7 | */\r | |
8 | class HTMLPurifier_ConfigSchema_Interchange\r | |
9 | {\r | |
10 | \r | |
11 | /**\r | |
12 | * Name of the application this schema is describing.\r | |
13 | * @type string\r | |
14 | */\r | |
15 | public $name;\r | |
16 | \r | |
17 | /**\r | |
18 | * Array of Directive ID => array(directive info)\r | |
19 | * @type HTMLPurifier_ConfigSchema_Interchange_Directive[]\r | |
20 | */\r | |
21 | public $directives = array();\r | |
22 | \r | |
23 | /**\r | |
24 | * Adds a directive array to $directives\r | |
25 | * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive\r | |
26 | * @throws HTMLPurifier_ConfigSchema_Exception\r | |
27 | */\r | |
28 | public function addDirective($directive)\r | |
29 | {\r | |
30 | if (isset($this->directives[$i = $directive->id->toString()])) {\r | |
31 | throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'");\r | |
32 | }\r | |
33 | $this->directives[$i] = $directive;\r | |
34 | }\r | |
35 | \r | |
36 | /**\r | |
37 | * Convenience function to perform standard validation. Throws exception\r | |
38 | * on failed validation.\r | |
39 | */\r | |
40 | public function validate()\r | |
41 | {\r | |
42 | $validator = new HTMLPurifier_ConfigSchema_Validator();\r | |
43 | return $validator->validate($this);\r | |
44 | }\r | |
45 | }\r | |
46 | \r | |
47 | // vim: et sw=4 sts=4\r |