2008-03-01 17:06:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic schema interchange format that can be converted to a runtime
|
|
|
|
* representation (HTMLPurifier_ConfigSchema) or HTML documentation. Members
|
|
|
|
* are completely validated.
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_ConfigSchema_Interchange
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hash table of allowed types.
|
|
|
|
*/
|
2008-03-02 04:00:43 +00:00
|
|
|
public $types = array(
|
2008-03-01 17:06:23 +00:00
|
|
|
'string' => 'String',
|
|
|
|
'istring' => 'Case-insensitive string',
|
|
|
|
'text' => 'Text',
|
2008-03-02 01:55:14 +00:00
|
|
|
'itext' => 'Case-insensitive text',
|
2008-03-01 17:06:23 +00:00
|
|
|
'int' => 'Integer',
|
|
|
|
'float' => 'Float',
|
|
|
|
'bool' => 'Boolean',
|
|
|
|
'lookup' => 'Lookup array',
|
|
|
|
'list' => 'Array list',
|
|
|
|
'hash' => 'Associative array',
|
|
|
|
'mixed' => 'Mixed'
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of Namespace ID => array(namespace info)
|
|
|
|
*/
|
2008-03-02 04:00:43 +00:00
|
|
|
public $namespaces;
|
2008-03-01 17:06:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of Directive ID => array(directive info)
|
|
|
|
*/
|
2008-03-02 04:00:43 +00:00
|
|
|
public $directives;
|
2008-03-01 17:06:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a namespace array to $namespaces
|
|
|
|
*/
|
|
|
|
public function addNamespace($arr) {
|
|
|
|
$this->namespaces[$arr['ID']] = $arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a directive array to $directives
|
|
|
|
*/
|
|
|
|
public function addDirective($arr) {
|
|
|
|
$this->directives[$arr['ID']] = $arr;
|
|
|
|
}
|
|
|
|
|
2008-03-02 01:55:14 +00:00
|
|
|
/**
|
|
|
|
* Retrieves a version of this object wrapped in the validator adapter
|
|
|
|
* to be used for data-input.
|
|
|
|
*/
|
|
|
|
public function getValidatorAdapter() {
|
2008-03-02 04:00:43 +00:00
|
|
|
$validator = new HTMLPurifier_ConfigSchema_InterchangeValidator($this);
|
2008-03-04 04:13:07 +00:00
|
|
|
|
|
|
|
// Validators should be defined in the order they are to be called.
|
|
|
|
|
2008-03-02 04:39:14 +00:00
|
|
|
// Common validators
|
|
|
|
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Exists('ID'));
|
2008-03-04 04:20:55 +00:00
|
|
|
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Unique());
|
2008-03-02 04:39:14 +00:00
|
|
|
$validator->addValidator(new HTMLPurifier_ConfigSchema_Validator_Exists('DESCRIPTION'));
|
2008-03-04 04:13:07 +00:00
|
|
|
|
2008-03-02 04:39:14 +00:00
|
|
|
// Namespace validators
|
|
|
|
|
|
|
|
// Directive validators
|
|
|
|
|
2008-03-02 04:00:43 +00:00
|
|
|
return $validator;
|
2008-03-02 01:55:14 +00:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:06:23 +00:00
|
|
|
}
|