~andy-freeborough/sahana-agasti/krakatoa

« back to all changes in this revision

Viewing changes to sahana-phase2/3rd/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php

  • Committer: Greg Miernicki
  • Date: 2011-01-13 18:39:51 UTC
  • Revision ID: g@miernicki.com-20110113183951-7o6e8mpjgkw7bj2w
new htmlpurifier added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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