1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

[3.1.0] De-crudify the ConfigSchema space; we're starting over again

- Optimize ConfigSchema by removing non-essential runtime data. We can probably optimize even more by collapsing object structures to arrays.
- Removed validation data from ConfigSchema; this will be reimplemented on Interchange
- Implement a sane Interchange composite hierarchy that doesn't use arrays
- Implement StringHash -> Interchange -> ConfigSchema, and rewrite maintenance file to account for this

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1615 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-22 03:55:59 +00:00
parent 93babf0a88
commit ec59062a9d
42 changed files with 440 additions and 1528 deletions

View File

@@ -21,69 +21,15 @@ class HTMLPurifier_ConfigSchema_Interchange
/**
* Adds a namespace array to $namespaces
*/
public function addNamespace($arr) {
$this->namespaces[$arr['ID']] = $arr;
public function addNamespace($namespace) {
$this->namespaces[$namespace->namespace] = $namespace;
}
/**
* Adds a directive array to $directives
*/
public function addDirective($arr) {
$this->directives[$arr['ID']] = $arr;
}
/**
* Retrieves a version of this object wrapped in the validator adapter
* to be used for data-input.
*/
public function getValidatorAdapter() {
$validator = new HTMLPurifier_ConfigSchema_InterchangeValidator($this);
// Validators should be defined in the order they are to be called.
$namespace = $validator->namespace;
$directive = $validator->directive;
// ID tests
$validator->addValidator($this->make('Exists', 'ID'));
$validator->addValidator($this->make('Unique'));
// ID: Namespace test
$namespace->addValidator($this->make('Alnum', 'ID'));
// ID: Common tests
$validator->addValidator($this->make('ParseId'));
$validator->addValidator($this->make('Exists', '_NAMESPACE'));
$validator->addValidator($this->make('Alnum', '_NAMESPACE'));
// ID: Directive tests
$directive->addValidator($this->make('Exists', '_DIRECTIVE'));
$directive->addValidator($this->make('Alnum', '_DIRECTIVE'));
$directive->addValidator($this->make('NamespaceExists'));
// Directive: Type and Default tests
$directive->addValidator($this->make('Exists', 'TYPE'));
$directive->addValidator($this->make('ParseType'));
$directive->addValidator($this->make('Exists', '_TYPE'));
$directive->addValidator($this->make('Exists', '_NULL'));
$directive->addValidator($this->make('Exists', 'DEFAULT'));
$directive->addValidator($this->make('ParseDefault'));
// Common tests
$validator->addValidator($this->make('Exists', 'DESCRIPTION'));
return $validator;
}
/**
* Creates a validator.
* @warning
* Only *one* argument is supported; multiple args shouldn't use
* this function.
*/
protected function make($name, $arg = null) {
$class = "HTMLPurifier_ConfigSchema_Validator_$name";
if ($arg === null) return new $class();
else return new $class($arg);
public function addDirective($directive) {
$this->directives[(string) $directive->id] = $directive;
}
}