Class HTMLPurifier_HTMLDefinition

InheritanceHTMLPurifier_HTMLDefinition » HTMLPurifier_Definition

Definition of the purified HTML that describes allowed children, attributes, and many other things.

Conventions:

All member variables that are prefixed with info (including the main $info array) are used by HTML Purifier internals and should not be directly edited when customizing the HTMLDefinition. They can usually be set via configuration directives or custom modules.

On the other hand, member variables without the info prefix are used internally by the HTMLDefinition and MUST NOT be used by other HTML Purifier internals. Many of them, however, are public, and may be edited by userspace code to tweak the behavior of HTMLDefinition.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$doctype Doctype object HTMLPurifier_HTMLDefinition
$info Associative array of element names to HTMLPurifier_ElementDef. HTMLPurifier_HTMLDefinition
$info_attr_transform_post Indexed list of HTMLPurifier_AttrTransform to be performed after validation. HTMLPurifier_HTMLDefinition
$info_attr_transform_pre Indexed list of HTMLPurifier_AttrTransform to be performed before validation. HTMLPurifier_HTMLDefinition
$info_block_wrapper String name of element used to wrap inline elements in block context. HTMLPurifier_HTMLDefinition
$info_content_sets Nested lookup array of content set name (Block, Inline) to element name to whether or not it belongs in that content set. HTMLPurifier_HTMLDefinition
$info_global_attr Associative array of global attribute name to attribute definition. HTMLPurifier_HTMLDefinition
$info_injector Indexed list of HTMLPurifier_Injector to be used. HTMLPurifier_HTMLDefinition
$info_parent String name of parent element HTML will be going into. HTMLPurifier_HTMLDefinition
$info_parent_def Definition for parent element, allows parent element to be a tag that's not allowed inside the HTML fragment. HTMLPurifier_HTMLDefinition
$info_tag_transform Associative array of deprecated tag name to HTMLPurifier_TagTransform. HTMLPurifier_HTMLDefinition
$manager HTMLPurifier_HTMLDefinition
$optimized If true, write out the final definition object to the cache after setup. This will be true only if all invocations to get a raw definition object are also optimized. This does not cause file system thrashing because on subsequent calls the cached object is used and any writes to the raw definition object are short circuited. See enduser-customize.html for the high-level picture. HTMLPurifier_Definition
$setup Has setup() been called yet? HTMLPurifier_Definition
$type HTMLPurifier_HTMLDefinition

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Performs low-cost, preliminary initialization. HTMLPurifier_HTMLDefinition
addAttribute() Adds a custom attribute to a pre-existing element HTMLPurifier_HTMLDefinition
addBlankElement() Adds a blank element to your HTML definition, for overriding existing behavior HTMLPurifier_HTMLDefinition
addElement() Adds a custom element to your HTML definition HTMLPurifier_HTMLDefinition
getAnonymousModule() Retrieves a reference to the anonymous module, so you can bust out advanced features without having to make your own module. HTMLPurifier_HTMLDefinition
parseTinyMCEAllowedList() Parses a TinyMCE-flavored Allowed Elements and Attributes list into separate lists for processing. Format is element[attr1|attr2],element2. HTMLPurifier_HTMLDefinition
setup() Setup function that aborts if already setup HTMLPurifier_Definition

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
doSetup() HTMLPurifier_HTMLDefinition
processModules() Extract out the information from the manager HTMLPurifier_HTMLDefinition
setupConfigStuff() Sets up stuff based on config. We need a better way of doing this. HTMLPurifier_HTMLDefinition

Property Details

$doctype public property
public $doctype null
$info public property
public $info = []
$info_attr_transform_post public property
$info_attr_transform_pre public property
$info_block_wrapper public property
public $info_block_wrapper 'p'
$info_content_sets public property
public $info_content_sets = []
$info_global_attr public property
public $info_global_attr = []
$info_injector public property
public $info_injector = []
$info_parent public property
public $info_parent 'div'
$info_parent_def public property
public $info_parent_def null
$info_tag_transform public property
public $info_tag_transform = []
$manager public property
public $manager null
$type public property
public $type 'HTML'

Method Details

__construct() public method

Performs low-cost, preliminary initialization.

public void __construct ( )
addAttribute() public method

Adds a custom attribute to a pre-existing element

public void addAttribute ( $element_name, $attr_name, $def )
$element_name string

Element name to add attribute to

$attr_name string

Name of attribute

$def mixed

Attribute definition, can be string or object, see

        HTMLPurifier_AttrTypes for details
addBlankElement() public method

Adds a blank element to your HTML definition, for overriding existing behavior

See also HTMLPurifier_HTMLModule::addBlankElement() for detailed parameter and return value descriptions.

public HTMLPurifier_ElementDef addBlankElement ( $element_name )
$element_name string
addElement() public method

Adds a custom element to your HTML definition

See also HTMLPurifier_HTMLModule::addElement() for detailed parameter and return value descriptions.

public void addElement ( $element_name, $type, $contents, $attr_collections, $attributes = [] )
$element_name
$type
$contents
$attr_collections
$attributes
doSetup() protected method

protected void doSetup ( $config )
$config HTMLPurifier_Config
getAnonymousModule() public method

Retrieves a reference to the anonymous module, so you can bust out advanced features without having to make your own module.

public HTMLPurifier_HTMLModule getAnonymousModule ( )
parseTinyMCEAllowedList() public method

Parses a TinyMCE-flavored Allowed Elements and Attributes list into separate lists for processing. Format is element[attr1|attr2],element2.

..

public array parseTinyMCEAllowedList ( $list )
$list array

String list to parse

processModules() protected method

Extract out the information from the manager

protected void processModules ( $config )
$config HTMLPurifier_Config
setupConfigStuff() protected method

Sets up stuff based on config. We need a better way of doing this.

protected void setupConfigStuff ( $config )
$config HTMLPurifier_Config