|
Revision 21, 1.5 kB
(checked in by admin, 18 years ago)
|
|
|
| Line | |
|---|
| 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->namespaces as $n) { |
|---|
| 13 | $schema->addNamespace($n->namespace); |
|---|
| 14 | } |
|---|
| 15 | foreach ($interchange->directives as $d) { |
|---|
| 16 | $schema->add( |
|---|
| 17 | $d->id->namespace, |
|---|
| 18 | $d->id->directive, |
|---|
| 19 | $d->default, |
|---|
| 20 | $d->type, |
|---|
| 21 | $d->typeAllowsNull |
|---|
| 22 | ); |
|---|
| 23 | if ($d->allowed !== null) { |
|---|
| 24 | $schema->addAllowedValues( |
|---|
| 25 | $d->id->namespace, |
|---|
| 26 | $d->id->directive, |
|---|
| 27 | $d->allowed |
|---|
| 28 | ); |
|---|
| 29 | } |
|---|
| 30 | foreach ($d->aliases as $alias) { |
|---|
| 31 | $schema->addAlias( |
|---|
| 32 | $alias->namespace, |
|---|
| 33 | $alias->directive, |
|---|
| 34 | $d->id->namespace, |
|---|
| 35 | $d->id->directive |
|---|
| 36 | ); |
|---|
| 37 | } |
|---|
| 38 | if ($d->valueAliases !== null) { |
|---|
| 39 | $schema->addValueAliases( |
|---|
| 40 | $d->id->namespace, |
|---|
| 41 | $d->id->directive, |
|---|
| 42 | $d->valueAliases |
|---|
| 43 | ); |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | return $schema; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | } |
|---|