]> git.wh0rd.org - tt-rss.git/blob - lib/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php
c05668a7060398c870e25b19debe75325de84323
[tt-rss.git] / lib / htmlpurifier / library / HTMLPurifier / ConfigSchema / Builder / ConfigSchema.php
1 <?php
2
3 /**
4 * Converts HTMLPurifier_ConfigSchema_Interchange to our runtime
5 * representation used to perform checks on user configuration.
6 */
7 class HTMLPurifier_ConfigSchema_Builder_ConfigSchema
8 {
9
10 public function build($interchange) {
11 $schema = new HTMLPurifier_ConfigSchema();
12 foreach ($interchange->directives as $d) {
13 $schema->add(
14 $d->id->key,
15 $d->default,
16 $d->type,
17 $d->typeAllowsNull
18 );
19 if ($d->allowed !== null) {
20 $schema->addAllowedValues(
21 $d->id->key,
22 $d->allowed
23 );
24 }
25 foreach ($d->aliases as $alias) {
26 $schema->addAlias(
27 $alias->key,
28 $d->id->key
29 );
30 }
31 if ($d->valueAliases !== null) {
32 $schema->addValueAliases(
33 $d->id->key,
34 $d->valueAliases
35 );
36 }
37 }
38 $schema->postProcess();
39 return $schema;
40 }
41
42 }
43
44 // vim: et sw=4 sts=4