mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-10 15:48:42 +00:00
c2ec56b872
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@210 48356398-32a2-884e-a903-53898d9a118a
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
class HTMLPurifier_ConfigDef {
|
|
|
|
var $info = array();
|
|
|
|
function initialize() {
|
|
$this->defineNamespace('Core', 'Core features that are always available.');
|
|
$this->defineNamespace('Attr', 'Features regarding attribute validation.');
|
|
$this->defineNamespace('URI', 'Features regarding Uniform Resource Identifiers.');
|
|
}
|
|
|
|
function &instance($prototype = null) {
|
|
static $instance;
|
|
if ($prototype !== null) {
|
|
$instance = $prototype;
|
|
} elseif ($instance === null || $prototype === true) {
|
|
$instance = new HTMLPurifier_ConfigDef();
|
|
$instance->initialize();
|
|
}
|
|
return $instance;
|
|
}
|
|
|
|
function define($namespace, $name, $default, $description) {
|
|
$def =& HTMLPurifier_ConfigDef::instance();
|
|
if (!isset($def->info[$namespace])) {
|
|
trigger_error('Cannot define directive for undefined namespace',
|
|
E_USER_ERROR);
|
|
return;
|
|
}
|
|
if (isset($def->info[$namespace][$name])) {
|
|
// this behavior is at risk of change
|
|
trigger_error('Cannot redefine directive', E_USER_ERROR);
|
|
return;
|
|
}
|
|
$def->info[$namespace][$name] = $default;
|
|
}
|
|
|
|
function defineNamespace($namespace, $description) {
|
|
$def =& HTMLPurifier_ConfigDef::instance();
|
|
if (isset($def->info[$namespace])) {
|
|
trigger_error('Cannot redefine namespace', E_USER_ERROR);
|
|
return;
|
|
}
|
|
$def->info[$namespace] = array();
|
|
}
|
|
|
|
}
|
|
|
|
?>
|