PHP Class HTMLPurifier_Config, yii

Exibir arquivo Open project: yiisoft/yii Class Usage Examples

Public Properties

Property Type Description
$autoFinalize Whether or not to automatically finalize the object if a read operation is done.
$chatty (useful when unit testing). This will also compress some errors and exceptions.
$def Reference HTMLPurifier_ConfigSchema for value checking.
$version HTML Purifier's version

Protected Properties

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

Public Methods

Method Description
__construct ( HTMLPurifier_ConfigSchema $definition, HTMLPurifier_PropertyList $parent = null ) Constructor
autoFinalize ( ) Finalizes configuration only if auto finalize is on and not already finalized
create ( mixed $config, HTMLPurifier_ConfigSchema $schema = null ) : 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 ( ) Finalizes a configuration object, prohibiting further change
get ( string $key, mixed $a = null ) : mixed Retrieves a value from the configuration.
getAll ( ) Retrieves all directives, organized by namespace
getAllowedDirectivesForForm ( array $allowed, HTMLPurifier_ConfigSchema $schema = null ) : array 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 ( string $namespace ) : array Retrieves an array of directives to values from a given namespace
getBatchSerial ( string $namespace ) : string Returns a SHA-1 signature of a segment of the configuration object that uniquely identifies that particular configuration
getCSSDefinition ( boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_CSSDefinition Retrieves object reference to the CSS definition
getDefinition ( string $type, boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_Definition Retrieves a definition
getHTMLDefinition ( boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_HTMLDefinition 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 ( boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_URIDefinition Retrieves object reference to the URI definition
inherit ( HTMLPurifier_Config $config ) : HTMLPurifier_Config Creates a new config object that inherits from a previous one.
isFinalized ( string | boolean $error = false ) : boolean Checks whether or not the configuration object is finalized.
loadArray ( array $config_array ) Loads configuration values from an array with the following structure: Namespace.Directive => Value
loadArrayFromForm ( array $array, string | boolean $index = false, array | boolean $allowed = true, boolean $mq_fix = true, HTMLPurifier_ConfigSchema $schema = null ) : mixed Loads configuration values from $_GET/$_POST that were posted via ConfigForm
loadIni ( string $filename ) Loads configuration values from an ini file
maybeGetRawCSSDefinition ( ) : HTMLPurifier_CSSDefinition
maybeGetRawDefinition ( $name )
maybeGetRawHTMLDefinition ( ) : HTMLPurifier_HTMLDefinition
maybeGetRawURIDefinition ( ) : HTMLPurifier_URIDefinition
mergeArrayFromForm ( array $array, string | boolean $index = false, array | boolean $allowed = true, boolean $mq_fix = true ) Merges in configuration values from $_GET/$_POST to object. NOT STATIC.
prepareArrayFromForm ( array $array, string | boolean $index = false, array | boolean $allowed = true, boolean $mq_fix = true, HTMLPurifier_ConfigSchema $schema = null ) : array 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 ( string $key, mixed $value, mixed $a = null ) Sets a value to configuration.

Protected Methods

Method Description
triggerError ( string $msg, integer $no ) Produces a nicely formatted error message by supplying the stack frame information OUTSIDE of HTMLPurifier_Config.

Private Methods

Method Description
_listify ( array $lookup ) : string Convenience function for error reporting
initDefinition ( string $type ) : HTMLPurifier_CSSDefinition | HTMLPurifier_HTMLDefinition | HTMLPurifier_URIDefinition Initialise definition

Method Details

__construct() public method

Constructor
public __construct ( HTMLPurifier_ConfigSchema $definition, HTMLPurifier_PropertyList $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 autoFinalize ( )

create() public static method

Convenience constructor that creates a config object based on a mixed var
public static create ( mixed $config, HTMLPurifier_ConfigSchema $schema = null ) : HTMLPurifier_Config
$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 createDefault ( ) : HTMLPurifier_Config
return HTMLPurifier_Config default object.

finalize() public method

Finalizes a configuration object, prohibiting further change
public finalize ( )

get() public method

Retrieves a value from the configuration.
public get ( string $key, mixed $a = null ) : mixed
$key string String key
$a mixed
return mixed

getAll() public method

Retrieves all directives, organized by namespace
public 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 getAllowedDirectivesForForm ( array $allowed, HTMLPurifier_ConfigSchema $schema = null ) : array
$allowed array List of allowed namespaces/directives
$schema HTMLPurifier_ConfigSchema Schema to use, if not global copy
return array

getBatch() public method

Retrieves an array of directives to values from a given namespace
public getBatch ( string $namespace ) : array
$namespace string String namespace
return array

getBatchSerial() public method

Returns a SHA-1 signature of a segment of the configuration object that uniquely identifies that particular configuration
public getBatchSerial ( string $namespace ) : string
$namespace string Namespace to get serial for
return string

getCSSDefinition() public method

Retrieves object reference to the CSS definition
public getCSSDefinition ( boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_CSSDefinition
$raw boolean Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work.
$optimized boolean 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 HTMLPurifier_CSSDefinition

getDefinition() public method

Retrieves a definition
public getDefinition ( string $type, boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_Definition
$type string Type of definition: HTML, CSS, etc
$raw boolean Whether or not definition should be returned raw
$optimized boolean 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."
return HTMLPurifier_Definition

getHTMLDefinition() public method

Retrieves object reference to the HTML definition.
public getHTMLDefinition ( boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_HTMLDefinition
$raw boolean Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work.
$optimized boolean 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 HTMLPurifier_HTMLDefinition

getSerial() public method

Returns a SHA-1 signature for the entire configuration object that uniquely identifies that particular configuration
public getSerial ( ) : string
return string

getURIDefinition() public method

Retrieves object reference to the URI definition
public getURIDefinition ( boolean $raw = false, boolean $optimized = false ) : HTMLPurifier_URIDefinition
$raw boolean Return a copy that has not been setup yet. Must be called before it's been setup, otherwise won't work.
$optimized boolean 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 HTMLPurifier_URIDefinition

inherit() public static method

Creates a new config object that inherits from a previous one.
public static inherit ( HTMLPurifier_Config $config ) : HTMLPurifier_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 isFinalized ( string | boolean $error = false ) : boolean
$error string | boolean String error message, or false for no error
return boolean

loadArray() public method

Loads configuration values from an array with the following structure: Namespace.Directive => Value
public loadArray ( array $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 loadArrayFromForm ( array $array, string | boolean $index = false, array | boolean $allowed = true, boolean $mq_fix = true, HTMLPurifier_ConfigSchema $schema = null ) : mixed
$array array $_GET or $_POST array to import
$index string | boolean Index/name that the config variables are in
$allowed array | boolean List of allowed namespaces/directives
$mq_fix boolean Boolean whether or not to enable magic quotes fix
$schema HTMLPurifier_ConfigSchema Schema to use, if not global copy
return mixed

loadIni() public method

Loads configuration values from an ini file
public loadIni ( string $filename )
$filename string Name of ini file

maybeGetRawCSSDefinition() public method

public maybeGetRawCSSDefinition ( ) : HTMLPurifier_CSSDefinition
return HTMLPurifier_CSSDefinition

maybeGetRawDefinition() public method

public maybeGetRawDefinition ( $name )

maybeGetRawHTMLDefinition() public method

public maybeGetRawHTMLDefinition ( ) : HTMLPurifier_HTMLDefinition
return HTMLPurifier_HTMLDefinition

maybeGetRawURIDefinition() public method

public maybeGetRawURIDefinition ( ) : HTMLPurifier_URIDefinition
return HTMLPurifier_URIDefinition

mergeArrayFromForm() public method

Merges in configuration values from $_GET/$_POST to object. NOT STATIC.
public mergeArrayFromForm ( array $array, string | boolean $index = false, array | boolean $allowed = true, boolean $mq_fix = true )
$array array $_GET or $_POST array to import
$index string | boolean Index/name that the config variables are in
$allowed array | boolean List of allowed namespaces/directives
$mq_fix boolean 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 prepareArrayFromForm ( array $array, string | boolean $index = false, array | boolean $allowed = true, boolean $mq_fix = true, HTMLPurifier_ConfigSchema $schema = null ) : array
$array array $_GET or $_POST array to import
$index string | boolean Index/name that the config variables are in
$allowed array | boolean List of allowed namespaces/directives
$mq_fix boolean Boolean whether or not to enable magic quotes fix
$schema HTMLPurifier_ConfigSchema Schema to use, if not global copy
return array

serialize() public method

Returns a serialized form of the configuration object that can be reconstituted.
public serialize ( ) : string
return string

set() public method

Sets a value to configuration.
public set ( string $key, mixed $value, mixed $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 triggerError ( string $msg, integer $no )
$msg string An error message
$no integer An error number

Property Details

$autoFinalize public_oe property

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

$chatty public_oe property

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

$def public_oe property

Reference HTMLPurifier_ConfigSchema for value checking.
public $def

$definitions protected_oe property

Indexed array of definitions.
protected $definitions

$finalized protected_oe property

Whether or not config is finalized.
protected $finalized

$parser protected_oe property

Parser for variables.
protected $parser

$plist protected_oe property

Property list containing configuration directives.
protected $plist

$serial protected_oe property

Serial for entire configuration object.
protected $serial

$serials protected_oe property

Namespace indexed array of serials for specific namespaces.
See also: getSerial() for more info.
protected $serials

$version public_oe property

HTML Purifier's version
public $version