Class HTMLPurifier_Config

InheritanceHTMLPurifier_Config

Configuration object that triggers customizable behavior.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$autoFinalize Whether or not to automatically finalize the object if a read operation is done. HTMLPurifier_Config
$chatty Set to false if you do not want line and file numbers in errors. HTMLPurifier_Config
$def Reference HTMLPurifier_ConfigSchema for value checking. HTMLPurifier_Config
$version HTML Purifier's version HTMLPurifier_Config

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$definitions Indexed array of definitions. HTMLPurifier_Config
$finalized Whether or not config is finalized. HTMLPurifier_Config
$parser Parser for variables. HTMLPurifier_Config
$plist Property list containing configuration directives. HTMLPurifier_Config
$serial Serial for entire configuration object. HTMLPurifier_Config
$serials Namespace indexed array of serials for specific namespaces. HTMLPurifier_Config

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor HTMLPurifier_Config
autoFinalize() Finalizes configuration only if auto finalize is on and not already finalized HTMLPurifier_Config
create() Convenience constructor that creates a config object based on a mixed var HTMLPurifier_Config
createDefault() Convenience constructor that creates a default configuration object. HTMLPurifier_Config
finalize() Finalizes a configuration object, prohibiting further change HTMLPurifier_Config
get() Retrieves a value from the configuration. HTMLPurifier_Config
getAll() Retrieves all directives, organized by namespace HTMLPurifier_Config
getAllowedDirectivesForForm() 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. HTMLPurifier_Config
getBatch() Retrieves an array of directives to values from a given namespace HTMLPurifier_Config
getBatchSerial() Returns a SHA-1 signature of a segment of the configuration object that uniquely identifies that particular configuration HTMLPurifier_Config
getCSSDefinition() Retrieves object reference to the CSS definition HTMLPurifier_Config
getDefinition() Retrieves a definition HTMLPurifier_Config
getHTMLDefinition() Retrieves object reference to the HTML definition. HTMLPurifier_Config
getSerial() Returns a SHA-1 signature for the entire configuration object that uniquely identifies that particular configuration HTMLPurifier_Config
getURIDefinition() Retrieves object reference to the URI definition HTMLPurifier_Config
inherit() Creates a new config object that inherits from a previous one. HTMLPurifier_Config
isFinalized() Checks whether or not the configuration object is finalized. HTMLPurifier_Config
loadArray() Loads configuration values from an array with the following structure: Namespace.Directive => Value HTMLPurifier_Config
loadArrayFromForm() Loads configuration values from $_GET/$_POST that were posted via ConfigForm HTMLPurifier_Config
loadIni() Loads configuration values from an ini file HTMLPurifier_Config
maybeGetRawCSSDefinition() HTMLPurifier_Config
maybeGetRawDefinition() HTMLPurifier_Config
maybeGetRawHTMLDefinition() HTMLPurifier_Config
maybeGetRawURIDefinition() HTMLPurifier_Config
mergeArrayFromForm() Merges in configuration values from $_GET/$_POST to object. NOT STATIC. HTMLPurifier_Config
prepareArrayFromForm() Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config HTMLPurifier_Config
serialize() Returns a serialized form of the configuration object that can be reconstituted. HTMLPurifier_Config
set() Sets a value to configuration. HTMLPurifier_Config

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
triggerError() Produces a nicely formatted error message by supplying the stack frame information OUTSIDE of HTMLPurifier_Config. HTMLPurifier_Config

Property Details

$autoFinalize public property
public $autoFinalize true
$chatty public property

(useful when unit testing). This will also compress some errors and exceptions.

public $chatty true
$def public property
public $def null
$definitions protected property
protected $definitions null
$finalized protected property
protected $finalized false
$parser protected property
protected $parser null
$plist protected property
protected $plist null
$serial protected property
protected $serial null
$serials protected property

See also getSerial() for more info.

protected $serials = []
$version public property
public $version '4.6.0'

Method Details

__construct() public method

Constructor

public void __construct ( $definition, $parent null )
$definition HTMLPurifier_ConfigSchema

ConfigSchema that defines what directives are allowed.

$parent HTMLPurifier_PropertyList
autoFinalize() public method

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

public void autoFinalize ( )
create() public static method

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

public static HTMLPurifier_Config create ( $config, $schema null )
$config mixed

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.
$schema HTMLPurifier_ConfigSchema

Schema object

return HTMLPurifier_Config

Configured object

createDefault() public static method

Convenience constructor that creates a default configuration object.

public static HTMLPurifier_Config createDefault ( )
return HTMLPurifier_Config

Default object.

finalize() public method

Finalizes a configuration object, prohibiting further change

public void finalize ( )
get() public method

Retrieves a value from the configuration.

public mixed get ( $key, $a null )
$key string

String key

$a mixed
getAll() public method

Retrieves all directives, organized by namespace

public void getAll ( )
getAllowedDirectivesForForm() public static method

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.

public static array getAllowedDirectivesForForm ( $allowed, $schema null )
$allowed array

List of allowed namespaces/directives

$schema HTMLPurifier_ConfigSchema

Schema to use, if not global copy

getBatch() public method

Retrieves an array of directives to values from a given namespace

public array getBatch ( $namespace )
$namespace string

String namespace

getBatchSerial() public method

Returns a SHA-1 signature of a segment of the configuration object that uniquely identifies that particular configuration

public string getBatchSerial ( $namespace )
$namespace string

Namespace to get serial for

getCSSDefinition() public method

Retrieves object reference to the CSS definition

public HTMLPurifier_CSSDefinition getCSSDefinition ( $raw false, $optimized false )
$raw bool

Return a copy that has not been setup yet. Must be

        called before it's been setup, otherwise won't work.
$optimized bool

If true, this method may return null, to

        indicate that a cached version of the modified
        definition object is available and no further edits
        are necessary.  Consider using
        maybeGetRawCSSDefinition, which is more explicitly
        named, instead.
getDefinition() public method

Retrieves a definition

public HTMLPurifier_Definition getDefinition ( $type, $raw false, $optimized false )
$type string

Type of definition: HTML, CSS, etc

$raw bool

Whether or not definition should be returned raw

$optimized bool

Only has an effect when $raw is true. Whether

   or not to return null if the result is already present in
   the cache.  This is off by default for backwards
   compatibility reasons, but you need to do things this
   way in order to ensure that caching is done properly.
   Check out enduser-customize.html for more details.
   We probably won't ever change this default, as much as the
   maybe semantics is the "right thing to do."
throws HTMLPurifier_Exception
getHTMLDefinition() public method

Retrieves object reference to the HTML definition.

public HTMLPurifier_HTMLDefinition getHTMLDefinition ( $raw false, $optimized false )
$raw bool

Return a copy that has not been setup yet. Must be

        called before it's been setup, otherwise won't work.
$optimized bool

If true, this method may return null, to

        indicate that a cached version of the modified
        definition object is available and no further edits
        are necessary.  Consider using
        maybeGetRawHTMLDefinition, which is more explicitly
        named, instead.
getSerial() public method

Returns a SHA-1 signature for the entire configuration object that uniquely identifies that particular configuration

public string getSerial ( )
getURIDefinition() public method

Retrieves object reference to the URI definition

public HTMLPurifier_URIDefinition getURIDefinition ( $raw false, $optimized false )
$raw bool

Return a copy that has not been setup yet. Must be

        called before it's been setup, otherwise won't work.
$optimized bool

If true, this method may return null, to

        indicate that a cached version of the modified
        definition object is available and no further edits
        are necessary.  Consider using
        maybeGetRawURIDefinition, which is more explicitly
        named, instead.
inherit() public static method

Creates a new config object that inherits from a previous one.

public static HTMLPurifier_Config inherit ( HTMLPurifier_Config $config )
$config HTMLPurifier_Config

Configuration object to inherit from.

return HTMLPurifier_Config

Object with $config as its parent.

isFinalized() public method

Checks whether or not the configuration object is finalized.

public bool isFinalized ( $error false )
$error string|bool

String error message, or false for no error

loadArray() public method

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

public void loadArray ( $config_array )
$config_array array

Configuration associative array

loadArrayFromForm() public static method

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

public static mixed loadArrayFromForm ( $array, $index false, $allowed true, $mq_fix true, $schema null )
$array array

$_GET or $_POST array to import

$index string|bool

Index/name that the config variables are in

$allowed array|bool

List of allowed namespaces/directives

$mq_fix bool

Boolean whether or not to enable magic quotes fix

$schema HTMLPurifier_ConfigSchema

Schema to use, if not global copy

loadIni() public method

Loads configuration values from an ini file

public void loadIni ( $filename )
$filename string

Name of ini file

maybeGetRawCSSDefinition() public method

public void maybeGetRawCSSDefinition ( )
maybeGetRawDefinition() public method

public void maybeGetRawDefinition ( $name )
$name
maybeGetRawHTMLDefinition() public method

public void maybeGetRawHTMLDefinition ( )
maybeGetRawURIDefinition() public method

public void maybeGetRawURIDefinition ( )
mergeArrayFromForm() public method

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

public void mergeArrayFromForm ( $array, $index false, $allowed true, $mq_fix true )
$array array

$_GET or $_POST array to import

$index string|bool

Index/name that the config variables are in

$allowed array|bool

List of allowed namespaces/directives

$mq_fix bool

Boolean whether or not to enable magic quotes fix

prepareArrayFromForm() public static method

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

public static array prepareArrayFromForm ( $array, $index false, $allowed true, $mq_fix true, $schema null )
$array array

$_GET or $_POST array to import

$index string|bool

Index/name that the config variables are in

$allowed array|bool

List of allowed namespaces/directives

$mq_fix bool

Boolean whether or not to enable magic quotes fix

$schema HTMLPurifier_ConfigSchema

Schema to use, if not global copy

serialize() public method

Returns a serialized form of the configuration object that can be reconstituted.

public string serialize ( )
set() public method

Sets a value to configuration.

public void set ( $key, $value, $a null )
$key string

Key

$value mixed

Value

$a mixed
triggerError() protected method

Produces a nicely formatted error message by supplying the stack frame information OUTSIDE of HTMLPurifier_Config.

protected void triggerError ( $msg, $no )
$msg string

An error message

$no int

An error number