HumHub Documentation (unofficial)

HTMLPurifier_Config
in package

Configuration object that triggers customizable behavior.

Tags
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

Table of Contents

Properties

$autoFinalize  : mixed
Whether or not to automatically finalize the object if a read operation is done.
$chatty  : mixed
Set to false if you do not want line and file numbers in errors.
$def  : mixed
Reference HTMLPurifier_ConfigSchema for value checking.
$version  : mixed
HTML Purifier's version
$definitions  : mixed
Indexed array of definitions.
$finalized  : mixed
Whether or not config is finalized.
$parser  : mixed
Parser for variables.
$plist  : mixed
Property list containing configuration directives.
$serial  : mixed
Serial for entire configuration object.
$serials  : mixed
Namespace indexed array of serials for specific namespaces.
$aliasMode  : mixed
Whether or not a set is taking place due to an alias lookup.
$lock  : mixed
Current lock; only gets to this namespace are allowed.

Methods

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

Properties

$autoFinalize

Whether or not to automatically finalize the object if a read operation is done.

public mixed $autoFinalize = \true
Tags
type

bool

$chatty

Set to false if you do not want line and file numbers in errors.

public mixed $chatty = \true

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

Tags
type

bool

$def

Reference HTMLPurifier_ConfigSchema for value checking.

public mixed $def
Tags
type

HTMLPurifier_ConfigSchema

note

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

$version

HTML Purifier's version

public mixed $version = '4.17.0'
Tags
type

string

$definitions

Indexed array of definitions.

protected mixed $definitions
Tags
type

HTMLPurifier_Definition[]

$finalized

Whether or not config is finalized.

protected mixed $finalized = \false
Tags
type

bool

$parser

Parser for variables.

protected mixed $parser = \null
Tags
type

HTMLPurifier_VarParser_Flexible

$plist

Property list containing configuration directives.

protected mixed $plist
Tags
type

array

$serial

Serial for entire configuration object.

protected mixed $serial
Tags
type

string

$serials

Namespace indexed array of serials for specific namespaces.

protected mixed $serials = array()
Tags
see
getSerial()

for more info.

type

string[]

$aliasMode

Whether or not a set is taking place due to an alias lookup.

private mixed $aliasMode
Tags
type

bool

$lock

Current lock; only gets to this namespace are allowed.

private mixed $lock
Tags
type

string

Methods

autoFinalize()

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

public autoFinalize() : mixed

create()

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

public static create(mixed $config[, HTMLPurifier_ConfigSchema $schema = null ]) : HTMLPurifier_Config
Parameters
$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 = null

Schema object

Return values
HTMLPurifier_Config

Configured object

finalize()

Finalizes a configuration object, prohibiting further change

public finalize() : mixed

get()

Retrieves a value from the configuration.

public get(string $key[, mixed $a = null ]) : mixed
Parameters
$key : string

String key

$a : mixed = null

getAll()

Retrieves all directives, organized by namespace

public getAll() : mixed
Tags
warning

This is a pretty inefficient function, avoid if you can

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.

public static getAllowedDirectivesForForm(array<string|int, mixed> $allowed[, HTMLPurifier_ConfigSchema $schema = null ]) : array<string|int, mixed>
Parameters
$allowed : array<string|int, mixed>

List of allowed namespaces/directives

$schema : HTMLPurifier_ConfigSchema = null

Schema to use, if not global copy

Return values
array<string|int, mixed>

getBatch()

Retrieves an array of directives to values from a given namespace

public getBatch(string $namespace) : array<string|int, mixed>
Parameters
$namespace : string

String namespace

Return values
array<string|int, mixed>

getBatchSerial()

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

public getBatchSerial(string $namespace) : string
Parameters
$namespace : string

Namespace to get serial for

Tags
note

Revision is handled specially and is removed from the batch before processing!

Return values
string

getCSSDefinition()

Retrieves object reference to the CSS definition

public getCSSDefinition([bool $raw = false ][, bool $optimized = false ]) : HTMLPurifier_CSSDefinition|null
Parameters
$raw : bool = false

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

$optimized : bool = false

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.

Return values
HTMLPurifier_CSSDefinition|null

getDefinition()

Retrieves a definition

public getDefinition(string $type[, bool $raw = false ][, bool $optimized = false ]) : HTMLPurifier_Definition|null
Parameters
$type : string

Type of definition: HTML, CSS, etc

$raw : bool = false

Whether or not definition should be returned raw

$optimized : bool = false

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."

Tags
throws
HTMLPurifier_Exception
Return values
HTMLPurifier_Definition|null

getHTMLDefinition()

Retrieves object reference to the HTML definition.

public getHTMLDefinition([bool $raw = false ][, bool $optimized = false ]) : HTMLPurifier_HTMLDefinition|null
Parameters
$raw : bool = false

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

$optimized : bool = false

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.

Return values
HTMLPurifier_HTMLDefinition|null

getSerial()

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

public getSerial() : string
Return values
string

getURIDefinition()

Retrieves object reference to the URI definition

public getURIDefinition([bool $raw = false ][, bool $optimized = false ]) : HTMLPurifier_URIDefinition|null
Parameters
$raw : bool = false

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

$optimized : bool = false

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.

Return values
HTMLPurifier_URIDefinition|null

isFinalized()

Checks whether or not the configuration object is finalized.

public isFinalized([string|bool $error = false ]) : bool
Parameters
$error : string|bool = false

String error message, or false for no error

Return values
bool

loadArray()

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

public loadArray(array<string|int, mixed> $config_array) : mixed
Parameters
$config_array : array<string|int, mixed>

Configuration associative array

loadArrayFromForm()

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

public static loadArrayFromForm(array<string|int, mixed> $array[, string|bool $index = false ][, array<string|int, mixed>|bool $allowed = true ][, bool $mq_fix = true ][, HTMLPurifier_ConfigSchema $schema = null ]) : mixed
Parameters
$array : array<string|int, mixed>

$_GET or $_POST array to import

$index : string|bool = false

Index/name that the config variables are in

$allowed : array<string|int, mixed>|bool = true

List of allowed namespaces/directives

$mq_fix : bool = true

Boolean whether or not to enable magic quotes fix

$schema : HTMLPurifier_ConfigSchema = null

Schema to use, if not global copy

loadIni()

Loads configuration values from an ini file

public loadIni(string $filename) : mixed
Parameters
$filename : string

Name of ini file

maybeGetRawDefinition()

public maybeGetRawDefinition(mixed $name) : mixed
Parameters
$name : mixed

mergeArrayFromForm()

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

public mergeArrayFromForm(array<string|int, mixed> $array[, string|bool $index = false ][, array<string|int, mixed>|bool $allowed = true ][, bool $mq_fix = true ]) : mixed
Parameters
$array : array<string|int, mixed>

$_GET or $_POST array to import

$index : string|bool = false

Index/name that the config variables are in

$allowed : array<string|int, mixed>|bool = true

List of allowed namespaces/directives

$mq_fix : bool = true

Boolean whether or not to enable magic quotes fix

prepareArrayFromForm()

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

public static prepareArrayFromForm(array<string|int, mixed> $array[, string|bool $index = false ][, array<string|int, mixed>|bool $allowed = true ][, bool $mq_fix = true ][, HTMLPurifier_ConfigSchema $schema = null ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>

$_GET or $_POST array to import

$index : string|bool = false

Index/name that the config variables are in

$allowed : array<string|int, mixed>|bool = true

List of allowed namespaces/directives

$mq_fix : bool = true

Boolean whether or not to enable magic quotes fix

$schema : HTMLPurifier_ConfigSchema = null

Schema to use, if not global copy

Return values
array<string|int, mixed>

serialize()

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

public serialize() : string
Return values
string

set()

Sets a value to configuration.

public set(string $key, mixed $value[, mixed $a = null ]) : mixed
Parameters
$key : string

key

$value : mixed

value

$a : mixed = null

triggerError()

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

protected triggerError(string $msg, int $no) : mixed
Parameters
$msg : string

An error message

$no : int

An error number

_listify()

Convenience function for error reporting

private _listify(array<string|int, mixed> $lookup) : string
Parameters
$lookup : array<string|int, mixed>
Return values
string

        
On this page

Search results