\HTMLPurifier_HTMLModule_Tidy_Proprietary

Abstract class for a set of proprietary modules that clean up (tidy) poorly written HTML.

Summary

Methods
Properties
Constants
setup()
getFixesForLevel()
makeFixesForLevel()
populate()
getFixType()
makeFixes()
getChildDef()
addElement()
addBlankElement()
addElementToContentSet()
parseContents()
mergeInAttrIncludes()
makeLookup()
$levels
$defaultLevel
$fixesForLevel
$name
$elements
$info
$content_sets
$attr_collections
$info_tag_transform
$info_attr_transform_pre
$info_attr_transform_post
$info_injector
$defines_child_def
$safe
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$levels

$levels

List of supported levels.

Index zero is a special case "no fixes" level.

$defaultLevel

$defaultLevel

Default level to place all fixes in.

$fixesForLevel

$fixesForLevel

Lists of fixes used by getFixesForLevel().

Format is: HTMLModule_Tidy->fixesForLevel[$level] = array('fix-1', 'fix-2');

$name

$name

$elements

$elements

Informally, a list of elements this module changes.

Not used in any significant way.

$info

$info

Associative array of element names to element definitions.

Some definitions may be incomplete, to be merged in later with the full definition.

$content_sets

$content_sets

Associative array of content set names to content set additions.

This is commonly used to, say, add an A element to the Inline content set. This corresponds to an internal variable $content_sets and NOT info_content_sets member variable of HTMLDefinition.

$attr_collections

$attr_collections

Associative array of attribute collection names to attribute collection additions. More rarely used for adding attributes to the global collections. Example is the StyleAttribute module adding the style attribute to the Core. Corresponds to HTMLDefinition's attr_collections->info, since the object's data is only info, with extra behavior associated with it.

$info_tag_transform

$info_tag_transform

Associative array of deprecated tag name to HTMLPurifier_TagTransform.

$info_attr_transform_pre

$info_attr_transform_pre

List of HTMLPurifier_AttrTransform to be performed before validation.

$info_attr_transform_post

$info_attr_transform_post

List of HTMLPurifier_AttrTransform to be performed after validation.

$info_injector

$info_injector

List of HTMLPurifier_Injector to be performed during well-formedness fixing.

An injector will only be invoked if all of it's pre-requisites are met; if an injector fails setup, there will be no error; it will simply be silently disabled.

$defines_child_def

$defines_child_def

Boolean flag that indicates whether or not getChildDef is implemented.

For optimization reasons: may save a call to a function. Be sure to set it if you do implement getChildDef(), otherwise it will have no effect!

$safe

$safe

Boolean flag whether or not this module is safe. If it is not safe, all of its members are unsafe. Modules are safe by default (this might be slightly dangerous, but it doesn't make much sense to force HTML Purifier, which is based off of safe HTML, to explicitly say, "This is safe," even though there are modules which are "unsafe")

Methods

setup()

setup(\HTMLPurifier_Config  $config) : mixed

Lazy load construction of the module after determining whether or not it's needed, and also when a finalized configuration object is available.

Parameters

\HTMLPurifier_Config $config

Returns

mixed —

getFixesForLevel()

getFixesForLevel(string  $level) : array

Retrieves all fixes per a level, returning fixes for that specific level as well as all levels below it.

Parameters

string $level

level identifier, see $levels for valid values

Returns

array —

Lookup up table of fixes

makeFixesForLevel()

makeFixesForLevel(array  $fixes) : mixed

Dynamically populates the $fixesForLevel member variable using the fixes array. It may be custom overloaded, used in conjunction with $defaultLevel, or not used at all.

Parameters

array $fixes

Returns

mixed —

populate()

populate(array  $fixes) : mixed

Populates the module with transforms and other special-case code based on a list of fixes passed to it

Parameters

array $fixes

Lookup table of fixes to activate

Returns

mixed —

getFixType()

getFixType( $name) : mixed

Parses a fix name and determines what kind of fix it is, as well as other information defined by the fix

Parameters

$name

String name of fix

Returns

mixed —

makeFixes()

makeFixes() : array

Defines all fixes the module will perform in a compact associative array of fix name to fix implementation.

Returns

array —

getChildDef()

getChildDef(\HTMLPurifier_ElementDef  $def) : \HTMLPurifier_ChildDef

Retrieves a proper HTMLPurifier_ChildDef subclass based on content_model and content_model_type member variables of the HTMLPurifier_ElementDef class. There is a similar function in HTMLPurifier_HTMLDefinition.

Parameters

\HTMLPurifier_ElementDef $def

Returns

\HTMLPurifier_ChildDef —

subclass

addElement()

addElement(string  $element, string|bool  $type, string|\HTMLPurifier_ChildDef  $contents, array|string  $attr_includes = array(), array  $attr = array()) : \HTMLPurifier_ElementDef

Convenience function that sets up a new element

Parameters

string $element

Name of element to add

string|bool $type

What content set should element be registered to? Set as false to skip this step.

string|\HTMLPurifier_ChildDef $contents

Allowed children in form of: "$content_model_type: $content_model"

array|string $attr_includes

What attribute collections to register to element?

array $attr

What unique attributes does the element define?

Returns

\HTMLPurifier_ElementDef —

Created element definition object, so you can set advanced parameters

addBlankElement()

addBlankElement(string  $element) : \HTMLPurifier_ElementDef

Convenience function that creates a totally blank, non-standalone element.

Parameters

string $element

Name of element to create

Returns

\HTMLPurifier_ElementDef —

Created element

addElementToContentSet()

addElementToContentSet(string  $element, string  $type) : mixed

Convenience function that registers an element to a content set

Parameters

string $element

Element to register

string $type

Name content set (warning: case sensitive, usually upper-case first letter)

Returns

mixed —

parseContents()

parseContents(string  $contents) : array

Convenience function that transforms single-string contents into separate content model and content model type

Parameters

string $contents

Allowed children in form of: "$content_model_type: $content_model"

Returns

array —

mergeInAttrIncludes()

mergeInAttrIncludes(array  $attr, array  $attr_includes) : mixed

Convenience function that merges a list of attribute includes into an attribute array.

Parameters

array $attr

Reference to attr array to modify

array $attr_includes

Array of includes / string include to merge in

Returns

mixed —

makeLookup()

makeLookup(string  $list) : array

Convenience function that generates a lookup table with boolean true as value.

Parameters

string $list

List of values to turn into a lookup

Returns

array —

array equivalent of list