2008-03-22 03:55:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts HTMLPurifier_ConfigSchema_Interchange to our runtime
|
|
|
|
* representation used to perform checks on user configuration.
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_ConfigSchema_Builder_ConfigSchema
|
|
|
|
{
|
|
|
|
|
|
|
|
public function build($interchange) {
|
|
|
|
$schema = new HTMLPurifier_ConfigSchema();
|
2008-03-30 21:44:16 +00:00
|
|
|
foreach ($interchange->namespaces as $n) {
|
2008-03-22 03:55:59 +00:00
|
|
|
$schema->addNamespace($n->namespace);
|
|
|
|
}
|
2008-03-30 21:44:16 +00:00
|
|
|
foreach ($interchange->directives as $d) {
|
2008-03-22 03:55:59 +00:00
|
|
|
$schema->add(
|
|
|
|
$d->id->namespace,
|
|
|
|
$d->id->directive,
|
|
|
|
$d->default,
|
|
|
|
$d->type,
|
|
|
|
$d->typeAllowsNull
|
|
|
|
);
|
|
|
|
if ($d->allowed !== null) {
|
|
|
|
$schema->addAllowedValues(
|
|
|
|
$d->id->namespace,
|
|
|
|
$d->id->directive,
|
|
|
|
$d->allowed
|
|
|
|
);
|
|
|
|
}
|
|
|
|
foreach ($d->aliases as $alias) {
|
|
|
|
$schema->addAlias(
|
2008-03-30 21:44:16 +00:00
|
|
|
$alias->namespace,
|
|
|
|
$alias->directive,
|
2008-03-22 03:55:59 +00:00
|
|
|
$d->id->namespace,
|
|
|
|
$d->id->directive
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ($d->valueAliases !== null) {
|
|
|
|
$schema->addValueAliases(
|
|
|
|
$d->id->namespace,
|
|
|
|
$d->id->directive,
|
|
|
|
$d->valueAliases
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2008-03-30 21:44:16 +00:00
|
|
|
return $schema;
|
2008-03-22 03:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|