1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-07 14:46:48 +02:00

[3.1.0] Make StringHash system-agnostic.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1621 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-22 19:30:37 +00:00
parent ec59062a9d
commit 56cfcba5d1
11 changed files with 12 additions and 63 deletions

View File

@@ -1,46 +0,0 @@
<?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);
}
}

View File

@@ -8,7 +8,7 @@
* of PHP 5, you must not use the $hash[$key] syntax; if you do
* our version of offsetGet is never called.
*/
class HTMLPurifier_ConfigSchema_StringHash extends ArrayObject
class HTMLPurifier_StringHash extends ArrayObject
{
protected $accessed = array();

View File

@@ -20,19 +20,15 @@
* )
*
* We use this as an easy to use file-format for configuration schema
* files.
*
* @todo
* Put this in its own class hierarchy or something; this class
* is usage agnostic.
* files, but the class itself is usage agnostic.
*/
class HTMLPurifier_ConfigSchema_StringHashParser
class HTMLPurifier_StringHashParser
{
public $default = 'ID';
public function parseFile($file) {
if (!file_exists($file)) throw new HTMLPurifier_ConfigSchema_Exception('File ' . $file . ' does not exist');
if (!file_exists($file)) return false;
$fh = fopen($file, 'r');
$state = false;
$single = false;