HumHub Documentation (unofficial)

HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
in package

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.

Tags
note

This class is inspected by Printer_HTMLDefinition; please update that class if things here change.

warning

Directives that change this object's structure must be in the HTML or Attr namespace!

Table of Contents

Properties

$doctype  : mixed
Doctype object
$info  : mixed
Associative array of element names to HTMLPurifier_ElementDef.
$info_attr_transform_post  : mixed
Indexed list of HTMLPurifier_AttrTransform to be performed after validation.
$info_attr_transform_pre  : mixed
Indexed list of HTMLPurifier_AttrTransform to be performed before validation.
$info_block_wrapper  : mixed
String name of element used to wrap inline elements in block context.
$info_content_sets  : mixed
Nested lookup array of content set name (Block, Inline) to element name to whether or not it belongs in that content set.
$info_global_attr  : mixed
Associative array of global attribute name to attribute definition.
$info_injector  : mixed
Indexed list of HTMLPurifier_Injector to be used.
$info_parent  : mixed
String name of parent element HTML will be going into.
$info_parent_def  : mixed
Definition for parent element, allows parent element to be a tag that's not allowed inside the HTML fragment.
$info_tag_transform  : mixed
Associative array of deprecated tag name to HTMLPurifier_TagTransform.
$manager  : mixed
$optimized  : mixed
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.
$setup  : mixed
Has setup() been called yet?
$type  : mixed
What type of definition is it?
$_anonModule  : mixed

Methods

__construct()  : mixed
Performs low-cost, preliminary initialization.
addAttribute()  : mixed
Adds a custom attribute to a pre-existing element
addBlankElement()  : HTMLPurifier_ElementDef
Adds a blank element to your HTML definition, for overriding existing behavior
addElement()  : mixed
Adds a custom element to your HTML definition
getAnonymousModule()  : HTMLPurifier_HTMLModule
Retrieves a reference to the anonymous module, so you can bust out advanced features without having to make your own module.
parseTinyMCEAllowedList()  : array<string|int, mixed>
Parses a TinyMCE-flavored Allowed Elements and Attributes list into separate lists for processing. Format is element[attr1|attr2],element2.
setup()  : mixed
Setup function that aborts if already setup
doSetup()  : mixed
Sets up the definition object into the final form, something not done by the constructor
processModules()  : mixed
Extract out the information from the manager
setupConfigStuff()  : mixed
Sets up stuff based on config. We need a better way of doing this.

Properties

$doctype

Doctype object

public mixed $doctype
Tags
type

HTMLPurifier_Doctype

$info

Associative array of element names to HTMLPurifier_ElementDef.

public mixed $info = array()
Tags
type

HTMLPurifier_ElementDef[]

$info_attr_transform_post

Indexed list of HTMLPurifier_AttrTransform to be performed after validation.

public mixed $info_attr_transform_post = array()
Tags
type

HTMLPurifier_AttrTransform[]

$info_attr_transform_pre

Indexed list of HTMLPurifier_AttrTransform to be performed before validation.

public mixed $info_attr_transform_pre = array()
Tags
type

HTMLPurifier_AttrTransform[]

$info_block_wrapper

String name of element used to wrap inline elements in block context.

public mixed $info_block_wrapper = 'p'
Tags
type

string

note

This is rarely used except for BLOCKQUOTEs in strict mode

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

public mixed $info_content_sets = array()
Tags
type

array

$info_global_attr

Associative array of global attribute name to attribute definition.

public mixed $info_global_attr = array()
Tags
type

array

$info_injector

Indexed list of HTMLPurifier_Injector to be used.

public mixed $info_injector = array()
Tags
type

HTMLPurifier_Injector[]

$info_parent

String name of parent element HTML will be going into.

public mixed $info_parent = 'div'
Tags
type

string

$info_parent_def

Definition for parent element, allows parent element to be a tag that's not allowed inside the HTML fragment.

public mixed $info_parent_def
Tags
type

HTMLPurifier_ElementDef

$info_tag_transform

Associative array of deprecated tag name to HTMLPurifier_TagTransform.

public mixed $info_tag_transform = array()
Tags
type

array

$manager

public mixed $manager
Tags
type

HTMLPurifier_HTMLModuleManager

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

public mixed $optimized = \null
Tags
type

bool

$setup

Has setup() been called yet?

public mixed $setup = \false
Tags
type

bool

$type

What type of definition is it?

public mixed $type = 'HTML'
Tags
type

string

Methods

__construct()

Performs low-cost, preliminary initialization.

public __construct() : mixed

addAttribute()

Adds a custom attribute to a pre-existing element

public addAttribute(string $element_name, string $attr_name, mixed $def) : mixed
Parameters
$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

Tags
note

This is strictly convenience, and does not have a corresponding method in HTMLPurifier_HTMLModule

addElement()

Adds a custom element to your HTML definition

public addElement(mixed $element_name, mixed $type, mixed $contents, mixed $attr_collections[, mixed $attributes = array() ]) : mixed
Parameters
$element_name : mixed
$type : mixed
$contents : mixed
$attr_collections : mixed
$attributes : mixed = array()
Tags
see
HTMLPurifier_HTMLModule::addElement()

for detailed parameter and return value descriptions.

parseTinyMCEAllowedList()

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

public parseTinyMCEAllowedList(array<string|int, mixed> $list) : array<string|int, mixed>

..

Parameters
$list : array<string|int, mixed>

String list to parse

Tags
warning

Although it's largely drawn from TinyMCE's implementation, it is different, and you'll probably have to modify your lists

todo

Give this its own class, probably static interface

Return values
array<string|int, mixed>

        
On this page

Search results