HTMLPurifier_Config Class Reference

Configuration object that triggers customizable behavior. More...

List of all members.

Public Member Functions

 __construct ($definition)
 
Parameters:
$definition HTMLPurifier_ConfigSchema that defines what directives are allowed.

 get ($namespace, $key)
 Retreives a value from the configuration.
 getBatch ($namespace)
 Retreives an array of directives to values from a given namespace.
 getBatchSerial ($namespace)
 Returns a md5 signature of a segment of the configuration object that uniquely identifies that particular configuration.
 getSerial ()
 Returns a md5 signature for the entire configuration object that uniquely identifies that particular configuration.
 getAll ()
 Retrieves all directives, organized by namespace.
 set ($namespace, $key, $value, $from_alias=false)
 Sets a value to configuration.
 getHTMLDefinition ($raw=false)
 Retrieves object reference to the HTML definition.
 getCSSDefinition ($raw=false)
 Retrieves object reference to the CSS definition.
 getDefinition ($type, $raw=false)
 Retrieves a definition.
 loadArray ($config_array)
 Loads configuration values from an array with the following structure: Namespace.Directive => Value.
 mergeArrayFromForm ($array, $index=false, $allowed=true, $mq_fix=true)
 Merges in configuration values from $_GET/$_POST to object.
 loadIni ($filename)
 Loads configuration values from an ini file.
 isFinalized ($error=false)
 Checks whether or not the configuration object is finalized.
 autoFinalize ()
 Finalizes configuration only if auto finalize is on and not already finalized.
 finalize ()
 Finalizes a configuration object, prohibiting further change.
 __construct ($definition)
 
Parameters:
$definition HTMLPurifier_ConfigSchema that defines what directives are allowed.

 get ($namespace, $key)
 Retreives a value from the configuration.
 getBatch ($namespace)
 Retreives an array of directives to values from a given namespace.
 getBatchSerial ($namespace)
 Returns a md5 signature of a segment of the configuration object that uniquely identifies that particular configuration.
 getSerial ()
 Returns a md5 signature for the entire configuration object that uniquely identifies that particular configuration.
 getAll ()
 Retrieves all directives, organized by namespace.
 set ($namespace, $key, $value, $from_alias=false)
 Sets a value to configuration.
 getHTMLDefinition ($raw=false)
 Retrieves object reference to the HTML definition.
 getCSSDefinition ($raw=false)
 Retrieves object reference to the CSS definition.
 getDefinition ($type, $raw=false)
 Retrieves a definition.
 loadArray ($config_array)
 Loads configuration values from an array with the following structure: Namespace.Directive => Value.
 mergeArrayFromForm ($array, $index=false, $allowed=true, $mq_fix=true)
 Merges in configuration values from $_GET/$_POST to object.
 loadIni ($filename)
 Loads configuration values from an ini file.
 isFinalized ($error=false)
 Checks whether or not the configuration object is finalized.
 autoFinalize ()
 Finalizes configuration only if auto finalize is on and not already finalized.
 finalize ()
 Finalizes a configuration object, prohibiting further change.

Static Public Member Functions

static create ($config, $schema=null)
 Convenience constructor that creates a config object based on a mixed var.
static createDefault ()
 Convenience constructor that creates a default configuration object.
static getAllowedDirectivesForForm ($allowed, $schema=null)
 Returns a list of array(namespace, directive) for all directives that are allowed in a web-form context as per an allowed namespaces/directives list.
static loadArrayFromForm ($array, $index=false, $allowed=true, $mq_fix=true, $schema=null)
 Loads configuration values from $_GET/$_POST that were posted via ConfigForm.
static prepareArrayFromForm ($array, $index=false, $allowed=true, $mq_fix=true, $schema=null)
 Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config.
static create ($config, $schema=null)
 Convenience constructor that creates a config object based on a mixed var.
static createDefault ()
 Convenience constructor that creates a default configuration object.
static getAllowedDirectivesForForm ($allowed, $schema=null)
 Returns a list of array(namespace, directive) for all directives that are allowed in a web-form context as per an allowed namespaces/directives list.
static loadArrayFromForm ($array, $index=false, $allowed=true, $mq_fix=true, $schema=null)
 Loads configuration values from $_GET/$_POST that were posted via ConfigForm.
static prepareArrayFromForm ($array, $index=false, $allowed=true, $mq_fix=true, $schema=null)
 Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config.

Public Attributes

 $version = '3.1.1'
 HTML Purifier's version.
 $autoFinalize = true
 Bool indicator whether or not to automatically finalize the object if a read operation is done.
 $def
 Reference HTMLPurifier_ConfigSchema for value checking.

Protected Attributes

 $serials = array()
 Namespace indexed array of serials for specific namespaces (see getSerial() for more info).
 $serial
 Serial for entire configuration object.
 $conf
 Two-level associative array of configuration directives.
 $parser
 Parser for variables.
 $definitions
 Indexed array of definitions.
 $finalized = false
 Bool indicator whether or not config is finalized.

Private Member Functions

 _listify ($lookup)
 Convenience function for error reporting.
 _listify ($lookup)
 Convenience function for error reporting.


Detailed Description

Configuration object that triggers customizable behavior.

Warning:
This class is strongly defined: that means that the class will fail if an undefined directive is retrieved or set.
Note:
Many classes that could (although many times don't) use the configuration object make it a mandatory parameter. This is because a configuration object should always be forwarded, otherwise, you run the risk of missing a parameter and then being stumped when a configuration directive doesn't work.
Todo:
Reconsider some of the public member variables
Warning:
This class is strongly defined: that means that the class will fail if an undefined directive is retrieved or set.
Note:
Many classes that could (although many times don't) use the configuration object make it a mandatory parameter. This is because a configuration object should always be forwarded, otherwise, you run the risk of missing a parameter and then being stumped when a configuration directive doesn't work.
Todo:
Reconsider some of the public member variables

Definition at line 17 of file Config.php.


Constructor & Destructor Documentation

HTMLPurifier_Config::__construct ( definition  ) 

Parameters:
$definition HTMLPurifier_ConfigSchema that defines what directives are allowed.

Definition at line 75 of file Config.php.

HTMLPurifier_Config::__construct ( definition  ) 

Parameters:
$definition HTMLPurifier_ConfigSchema that defines what directives are allowed.

Definition at line 1294 of file HTMLPurifier.standalone.php.


Member Function Documentation

static HTMLPurifier_Config::create ( config,
schema = null 
) [static]

Convenience constructor that creates a config object based on a mixed var.

Parameters:
mixed $config Variable that defines the state of the config object. Can be: a HTMLPurifier_Config() object, an array of directives based on loadArray(), or a string filename of an ini file.
HTMLPurifier_ConfigSchema Schema object
Returns:
Configured HTMLPurifier_Config object

Definition at line 90 of file Config.php.

References createDefault().

Referenced by HTMLPurifier::__construct(), loadArrayFromForm(), phorum_htmlpurifier_get_config(), and HTMLPurifier::purify().

static HTMLPurifier_Config::createDefault (  )  [static]

Convenience constructor that creates a default configuration object.

Returns:
Default HTMLPurifier_Config object.

Definition at line 109 of file Config.php.

References HTMLPurifier_ConfigSchema::instance().

Referenced by create(), HTMLPurifier_URISchemeRegistry::getScheme(), kses(), and phorum_htmlpurifier_get_config().

HTMLPurifier_Config::get ( namespace,
key 
)

Retreives a value from the configuration.

Parameters:
$namespace String namespace
$key String key

Definition at line 120 of file Config.php.

References autoFinalize(), and finalize().

HTMLPurifier_Config::getBatch ( namespace  ) 

Retreives an array of directives to values from a given namespace.

Parameters:
$namespace String namespace

Definition at line 141 of file Config.php.

References autoFinalize(), and finalize().

Referenced by getBatchSerial().

HTMLPurifier_Config::getBatchSerial ( namespace  ) 

Returns a md5 signature of a segment of the configuration object that uniquely identifies that particular configuration.

Note:
Revision is handled specially and is removed from the batch before processing!
Parameters:
$namespace Namespace to get serial for

Definition at line 158 of file Config.php.

References getBatch().

HTMLPurifier_Config::getSerial (  ) 

Returns a md5 signature for the entire configuration object that uniquely identifies that particular configuration.

Definition at line 171 of file Config.php.

References getAll().

HTMLPurifier_Config::getAll (  ) 

Retrieves all directives, organized by namespace.

Definition at line 181 of file Config.php.

References autoFinalize(), and finalize().

Referenced by getSerial().

HTMLPurifier_Config::set ( namespace,
key,
value,
from_alias = false 
)

Sets a value to configuration.

Parameters:
$namespace String namespace
$key String key
$value Mixed value

Definition at line 192 of file Config.php.

References $def, _listify(), HTMLPurifier_VarParser::getTypeName(), and isFinalized().

HTMLPurifier_Config::_listify ( lookup  )  [private]

Convenience function for error reporting.

Definition at line 258 of file Config.php.

Referenced by set().

HTMLPurifier_Config::getHTMLDefinition ( raw = false  ) 

Retrieves object reference to the HTML definition.

Parameters:
$raw Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work.

Definition at line 269 of file Config.php.

References getDefinition().

HTMLPurifier_Config::getCSSDefinition ( raw = false  ) 

Retrieves object reference to the CSS definition.

Parameters:
$raw Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work.

Definition at line 278 of file Config.php.

References getDefinition().

HTMLPurifier_Config::getDefinition ( type,
raw = false 
)

Retrieves a definition.

Parameters:
$type Type of definition: HTML, CSS, etc
$raw Whether or not definition should be returned raw

Definition at line 287 of file Config.php.

References autoFinalize(), finalize(), and HTMLPurifier_DefinitionCacheFactory::instance().

Referenced by getCSSDefinition(), and getHTMLDefinition().

HTMLPurifier_Config::loadArray ( config_array  ) 

Loads configuration values from an array with the following structure: Namespace.Directive => Value.

Parameters:
$config_array Configuration associative array

Definition at line 343 of file Config.php.

References isFinalized().

Referenced by loadIni(), and mergeArrayFromForm().

static HTMLPurifier_Config::getAllowedDirectivesForForm ( allowed,
schema = null 
) [static]

Returns a list of array(namespace, directive) for all directives that are allowed in a web-form context as per an allowed namespaces/directives list.

Parameters:
$allowed List of allowed namespaces/directives

Definition at line 367 of file Config.php.

References $def, and HTMLPurifier_ConfigSchema::instance().

Referenced by prepareArrayFromForm(), and HTMLPurifier_Printer_ConfigForm::render().

static HTMLPurifier_Config::loadArrayFromForm ( array,
index = false,
allowed = true,
mq_fix = true,
schema = null 
) [static]

Loads configuration values from $_GET/$_POST that were posted via ConfigForm.

Parameters:
$array $_GET or $_POST array to import
$index Index/name that the config variables are in
$allowed List of allowed namespaces/directives
$mq_fix Boolean whether or not to enable magic quotes fix
$schema Instance of HTMLPurifier_ConfigSchema to use, if not global copy

Definition at line 414 of file Config.php.

References create(), and prepareArrayFromForm().

HTMLPurifier_Config::mergeArrayFromForm ( array,
index = false,
allowed = true,
mq_fix = true 
)

Merges in configuration values from $_GET/$_POST to object.

NOT STATIC.

Note:
Same parameters as loadArrayFromForm

Definition at line 424 of file Config.php.

References loadArray(), and prepareArrayFromForm().

static HTMLPurifier_Config::prepareArrayFromForm ( array,
index = false,
allowed = true,
mq_fix = true,
schema = null 
) [static]

Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config.

Definition at line 433 of file Config.php.

References getAllowedDirectivesForForm().

Referenced by loadArrayFromForm(), and mergeArrayFromForm().

HTMLPurifier_Config::loadIni ( filename  ) 

Loads configuration values from an ini file.

Parameters:
$filename Name of ini file

Definition at line 457 of file Config.php.

References isFinalized(), and loadArray().

HTMLPurifier_Config::isFinalized ( error = false  ) 

Checks whether or not the configuration object is finalized.

Parameters:
$error String error message, or false for no error

Definition at line 467 of file Config.php.

Referenced by loadArray(), loadIni(), and set().

HTMLPurifier_Config::autoFinalize (  ) 

Finalizes configuration only if auto finalize is on and not already finalized.

Definition at line 478 of file Config.php.

References finalize().

Referenced by autoFinalize(), get(), getAll(), getBatch(), and getDefinition().

HTMLPurifier_Config::finalize (  ) 

Finalizes a configuration object, prohibiting further change.

Definition at line 485 of file Config.php.

Referenced by autoFinalize(), get(), getAll(), getBatch(), and getDefinition().

static HTMLPurifier_Config::create ( config,
schema = null 
) [static]

Convenience constructor that creates a config object based on a mixed var.

Parameters:
mixed $config Variable that defines the state of the config object. Can be: a HTMLPurifier_Config() object, an array of directives based on loadArray(), or a string filename of an ini file.
HTMLPurifier_ConfigSchema Schema object
Returns:
Configured HTMLPurifier_Config object

Definition at line 1309 of file HTMLPurifier.standalone.php.

References createDefault().

static HTMLPurifier_Config::createDefault (  )  [static]

Convenience constructor that creates a default configuration object.

Returns:
Default HTMLPurifier_Config object.

Definition at line 1328 of file HTMLPurifier.standalone.php.

References HTMLPurifier_ConfigSchema::instance().

HTMLPurifier_Config::get ( namespace,
key 
)

Retreives a value from the configuration.

Parameters:
$namespace String namespace
$key String key

Definition at line 1339 of file HTMLPurifier.standalone.php.

References autoFinalize(), and finalize().

HTMLPurifier_Config::getBatch ( namespace  ) 

Retreives an array of directives to values from a given namespace.

Parameters:
$namespace String namespace

Definition at line 1360 of file HTMLPurifier.standalone.php.

References autoFinalize(), and finalize().

HTMLPurifier_Config::getBatchSerial ( namespace  ) 

Returns a md5 signature of a segment of the configuration object that uniquely identifies that particular configuration.

Note:
Revision is handled specially and is removed from the batch before processing!
Parameters:
$namespace Namespace to get serial for

Definition at line 1377 of file HTMLPurifier.standalone.php.

References getBatch().

HTMLPurifier_Config::getSerial (  ) 

Returns a md5 signature for the entire configuration object that uniquely identifies that particular configuration.

Definition at line 1390 of file HTMLPurifier.standalone.php.

References getAll().

HTMLPurifier_Config::getAll (  ) 

Retrieves all directives, organized by namespace.

Definition at line 1400 of file HTMLPurifier.standalone.php.

References autoFinalize(), and finalize().

HTMLPurifier_Config::set ( namespace,
key,
value,
from_alias = false 
)

Sets a value to configuration.

Parameters:
$namespace String namespace
$key String key
$value Mixed value

Definition at line 1411 of file HTMLPurifier.standalone.php.

References $def, _listify(), HTMLPurifier_VarParser::getTypeName(), and isFinalized().

HTMLPurifier_Config::_listify ( lookup  )  [private]

Convenience function for error reporting.

Definition at line 1477 of file HTMLPurifier.standalone.php.

HTMLPurifier_Config::getHTMLDefinition ( raw = false  ) 

Retrieves object reference to the HTML definition.

Parameters:
$raw Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work.

Definition at line 1488 of file HTMLPurifier.standalone.php.

References getDefinition().

HTMLPurifier_Config::getCSSDefinition ( raw = false  ) 

Retrieves object reference to the CSS definition.

Parameters:
$raw Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work.

Definition at line 1497 of file HTMLPurifier.standalone.php.

References getDefinition().

HTMLPurifier_Config::getDefinition ( type,
raw = false 
)

Retrieves a definition.

Parameters:
$type Type of definition: HTML, CSS, etc
$raw Whether or not definition should be returned raw

Definition at line 1506 of file HTMLPurifier.standalone.php.

References autoFinalize(), finalize(), and HTMLPurifier_DefinitionCacheFactory::instance().

HTMLPurifier_Config::loadArray ( config_array  ) 

Loads configuration values from an array with the following structure: Namespace.Directive => Value.

Parameters:
$config_array Configuration associative array

Definition at line 1562 of file HTMLPurifier.standalone.php.

References isFinalized().

static HTMLPurifier_Config::getAllowedDirectivesForForm ( allowed,
schema = null 
) [static]

Returns a list of array(namespace, directive) for all directives that are allowed in a web-form context as per an allowed namespaces/directives list.

Parameters:
$allowed List of allowed namespaces/directives

Definition at line 1586 of file HTMLPurifier.standalone.php.

References $def, and HTMLPurifier_ConfigSchema::instance().

static HTMLPurifier_Config::loadArrayFromForm ( array,
index = false,
allowed = true,
mq_fix = true,
schema = null 
) [static]

Loads configuration values from $_GET/$_POST that were posted via ConfigForm.

Parameters:
$array $_GET or $_POST array to import
$index Index/name that the config variables are in
$allowed List of allowed namespaces/directives
$mq_fix Boolean whether or not to enable magic quotes fix
$schema Instance of HTMLPurifier_ConfigSchema to use, if not global copy

Definition at line 1633 of file HTMLPurifier.standalone.php.

References create(), and prepareArrayFromForm().

HTMLPurifier_Config::mergeArrayFromForm ( array,
index = false,
allowed = true,
mq_fix = true 
)

Merges in configuration values from $_GET/$_POST to object.

NOT STATIC.

Note:
Same parameters as loadArrayFromForm

Definition at line 1643 of file HTMLPurifier.standalone.php.

References loadArray(), and prepareArrayFromForm().

static HTMLPurifier_Config::prepareArrayFromForm ( array,
index = false,
allowed = true,
mq_fix = true,
schema = null 
) [static]

Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config.

Definition at line 1652 of file HTMLPurifier.standalone.php.

References getAllowedDirectivesForForm().

HTMLPurifier_Config::loadIni ( filename  ) 

Loads configuration values from an ini file.

Parameters:
$filename Name of ini file

Definition at line 1676 of file HTMLPurifier.standalone.php.

References isFinalized(), and loadArray().

HTMLPurifier_Config::isFinalized ( error = false  ) 

Checks whether or not the configuration object is finalized.

Parameters:
$error String error message, or false for no error

Definition at line 1686 of file HTMLPurifier.standalone.php.

HTMLPurifier_Config::autoFinalize (  ) 

Finalizes configuration only if auto finalize is on and not already finalized.

Definition at line 1697 of file HTMLPurifier.standalone.php.

References autoFinalize(), and finalize().

HTMLPurifier_Config::finalize (  ) 

Finalizes a configuration object, prohibiting further change.

Definition at line 1704 of file HTMLPurifier.standalone.php.


Member Data Documentation

HTMLPurifier_Config::$version = '3.1.1'

HTML Purifier's version.

Definition at line 23 of file Config.php.

HTMLPurifier_Config::$autoFinalize = true

Bool indicator whether or not to automatically finalize the object if a read operation is done.

Definition at line 29 of file Config.php.

HTMLPurifier_Config::$serials = array() [protected]

Namespace indexed array of serials for specific namespaces (see getSerial() for more info).

Definition at line 37 of file Config.php.

HTMLPurifier_Config::$serial [protected]

Serial for entire configuration object.

Definition at line 42 of file Config.php.

HTMLPurifier_Config::$conf [protected]

Two-level associative array of configuration directives.

Definition at line 47 of file Config.php.

HTMLPurifier_Config::$parser [protected]

Parser for variables.

Definition at line 52 of file Config.php.

HTMLPurifier_Config::$def

Reference HTMLPurifier_ConfigSchema for value checking.

Note:
This is public for introspective purposes. Please don't abuse!

Definition at line 59 of file Config.php.

Referenced by getAllowedDirectivesForForm(), and set().

HTMLPurifier_Config::$definitions [protected]

Indexed array of definitions.

Definition at line 64 of file Config.php.

HTMLPurifier_Config::$finalized = false [protected]

Bool indicator whether or not config is finalized.

Definition at line 69 of file Config.php.


The documentation for this class was generated from the following files:
Generated on Thu Jun 19 18:47:29 2008 for HTMLPurifier by  doxygen 1.5.3