1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-30 19:00:10 +02:00

[3.1.0] Implement ConfigSchema interchange

- Implement exception hierarchy

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1582 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-03-01 17:06:23 +00:00
parent c521e3a534
commit 240b565513
9 changed files with 133 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
<?php
/**
* Exceptions related to configuration schema
*/
class HTMLPurifier_ConfigSchema_Exception extends HTMLPurifier_Exception
{
}

View File

@@ -0,0 +1,54 @@
<?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.
*/
public $types = array(
'string' => 'String',
'istring' => 'Case-insensitive string',
'text' => 'Text',
'itext' => 'Case-insensitive text',
'int' => 'Integer',
'float' => 'Float',
'bool' => 'Boolean',
'lookup' => 'Lookup array',
'list' => 'Array list',
'hash' => 'Associative array',
'mixed' => 'Mixed'
);
/**
* Array of Namespace ID => array(namespace info)
*/
public $namespaces;
/**
* Array of Directive ID => array(directive info)
*/
public $directives;
/**
* Adds a namespace array to $namespaces
*/
public function addNamespace($arr) {
if (!isset($arr['ID'])) throw new HTMLPurifier_ConfigSchema_Exception('Namespace must have ID');
$this->namespaces[$arr['ID']] = $arr;
}
/**
* Adds a directive array to $directives
*/
public function addDirective($arr) {
if (!isset($arr['ID'])) throw new HTMLPurifier_ConfigSchema_Exception('Directive must have ID');
$this->directives[$arr['ID']] = $arr;
}
}

View File

@@ -32,7 +32,7 @@ class HTMLPurifier_ConfigSchema_StringHashParser
public $default = 'ID';
public function parseFile($file) {
if (!file_exists($file)) throw new Exception('File does not exist');
if (!file_exists($file)) throw new HTMLPurifier_ConfigSchema_Exception('File ' . $file . ' does not exist');
$fh = fopen($file, 'r');
$state = false;
$single = false;

View File

@@ -0,0 +1,11 @@
<?php
/**
* Global exception class for HTML Purifier; any exceptions we throw
* are from here.
*/
class HTMLPurifier_Exception extends Exception
{
}