mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-10 07:38:41 +00:00
e4ab6d584e
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1606 48356398-32a2-884e-a903-53898d9a118a
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Decorator for interchange that performs validations
|
|
*/
|
|
class HTMLPurifier_ConfigSchema_InterchangeValidator
|
|
{
|
|
protected $interchange;
|
|
public $namespace;
|
|
public $directive;
|
|
|
|
/**
|
|
* @param $interchange Instance of HTMLPurifier_ConfigSchema_Interchange
|
|
* to save changes to.
|
|
*/
|
|
public function __construct($interchange) {
|
|
$this->interchange = $interchange;
|
|
$this->namespace = new HTMLPurifier_ConfigSchema_Validator_Composite();
|
|
$this->directive = new HTMLPurifier_ConfigSchema_Validator_Composite();
|
|
}
|
|
|
|
/**
|
|
* Registers a HTMLPurifier_ConfigSchema_Validator for both
|
|
* directive and namespace
|
|
*/
|
|
public function addValidator($validator) {
|
|
$this->directive->addValidator($validator);
|
|
$this->namespace->addValidator($validator);
|
|
}
|
|
|
|
/**
|
|
* Validates and adds a namespace hash
|
|
*/
|
|
public function addNamespace($hash) {
|
|
$this->namespace->validate($hash, $this->interchange);
|
|
$this->interchange->addNamespace($hash);
|
|
}
|
|
|
|
/**
|
|
* Validates and adds a directive hash
|
|
*/
|
|
public function addDirective($hash) {
|
|
$this->directive->validate($hash, $this->interchange);
|
|
$this->interchange->addDirective($hash);
|
|
}
|
|
}
|