HumHub Documentation (unofficial)

HTMLPurifier_HTMLModule_Tidy_Proprietary extends HTMLPurifier_HTMLModule_Tidy
in package

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

Table of Contents

Properties

$attr_collections  : mixed
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.
$content_sets  : mixed
Associative array of content set names to content set additions.
$defaultLevel  : mixed
Default level to place all fixes in.
$defines_child_def  : mixed
Boolean flag that indicates whether or not getChildDef is implemented.
$elements  : mixed
Informally, a list of elements this module changes.
$fixesForLevel  : mixed
Lists of fixes used by getFixesForLevel().
$info  : mixed
Associative array of element names to element definitions.
$info_attr_transform_post  : mixed
List of HTMLPurifier_AttrTransform to be performed after validation.
$info_attr_transform_pre  : mixed
List of HTMLPurifier_AttrTransform to be performed before validation.
$info_injector  : mixed
List of HTMLPurifier_Injector to be performed during well-formedness fixing.
$info_tag_transform  : mixed
Associative array of deprecated tag name to HTMLPurifier_TagTransform.
$levels  : mixed
List of supported levels.
$name  : mixed
$safe  : mixed
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

addBlankElement()  : HTMLPurifier_ElementDef
Convenience function that creates a totally blank, non-standalone element.
addElement()  : HTMLPurifier_ElementDef
Convenience function that sets up a new element
addElementToContentSet()  : mixed
Convenience function that registers an element to a content set
getChildDef()  : 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.
getFixesForLevel()  : array<string|int, mixed>
Retrieves all fixes per a level, returning fixes for that specific level as well as all levels below it.
getFixType()  : mixed
Parses a fix name and determines what kind of fix it is, as well as other information defined by the fix
makeFixes()  : array<string|int, mixed>
Defines all fixes the module will perform in a compact associative array of fix name to fix implementation.
makeFixesForLevel()  : 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.
makeLookup()  : array<string|int, mixed>
Convenience function that generates a lookup table with boolean true as value.
mergeInAttrIncludes()  : mixed
Convenience function that merges a list of attribute includes into an attribute array.
parseContents()  : array<string|int, mixed>
Convenience function that transforms single-string contents into separate content model and content model type
populate()  : mixed
Populates the module with transforms and other special-case code based on a list of fixes passed to it
setup()  : mixed
Lazy load constructs the module by determining the necessary fixes to create and then delegating to the populate() function.

Properties

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

public mixed $attr_collections = array()
Tags
type

array

$content_sets

Associative array of content set names to content set additions.

public mixed $content_sets = array()

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.

Tags
type

array

$defaultLevel

Default level to place all fixes in.

public mixed $defaultLevel = 'light'
Tags
type

string

$defines_child_def

Boolean flag that indicates whether or not getChildDef is implemented.

public mixed $defines_child_def = \false

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!

Tags
type

bool

$elements

Informally, a list of elements this module changes.

public mixed $elements = array()

Not used in any significant way.

Tags
type

array

$fixesForLevel

Lists of fixes used by getFixesForLevel().

public mixed $fixesForLevel = array('light' => array(), 'medium' => array(), 'heavy' => array())

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

Tags
type

array

$info

Associative array of element names to element definitions.

public mixed $info = array()

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

Tags
type

array

$info_attr_transform_post

List of HTMLPurifier_AttrTransform to be performed after validation.

public mixed $info_attr_transform_post = array()
Tags
type

array

$info_attr_transform_pre

List of HTMLPurifier_AttrTransform to be performed before validation.

public mixed $info_attr_transform_pre = array()
Tags
type

array

$info_injector

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

public mixed $info_injector = array()

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.

Tags
type

array

$info_tag_transform

Associative array of deprecated tag name to HTMLPurifier_TagTransform.

public mixed $info_tag_transform = array()
Tags
type

array

$levels

List of supported levels.

public mixed $levels = array(0 => 'none', 'light', 'medium', 'heavy')

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

Tags
type

array

$name

public mixed $name = 'Tidy_Proprietary'
Tags
type

string

$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")

public mixed $safe = \true
Tags
type

bool

note

Previously, safety could be applied at an element level granularity. We've removed this ability, so in order to add "unsafe" elements or attributes, a dedicated module with this property set to false must be used.

Methods

addElement()

Convenience function that sets up a new element

public addElement(string $element, string|bool $type, string|HTMLPurifier_ChildDef $contents[, array<string|int, mixed>|string $attr_includes = array() ][, array<string|int, mixed> $attr = array() ]) : HTMLPurifier_ElementDef
Parameters
$element : string

Name of element to add

$type : string|bool

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

$contents : string|HTMLPurifier_ChildDef

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

$attr_includes : array<string|int, mixed>|string = array()

What attribute collections to register to element?

$attr : array<string|int, mixed> = array()

What unique attributes does the element define?

Tags
see

HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters.

Return values
HTMLPurifier_ElementDef

Created element definition object, so you can set advanced parameters

addElementToContentSet()

Convenience function that registers an element to a content set

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

Element to register

$type : string

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

getFixesForLevel()

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

public getFixesForLevel(string $level) : array<string|int, mixed>
Parameters
$level : string

level identifier, see $levels for valid values

Return values
array<string|int, mixed>

Lookup up table of fixes

getFixType()

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

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

String name of fix

Tags
@return

array(string $fix_type, array $fix_parameters)

note

$fix_parameters is type dependant, see populate() for usage of these parameters

makeFixes()

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

public makeFixes() : array<string|int, mixed>
Return values
array<string|int, mixed>

makeFixesForLevel()

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.

public makeFixesForLevel(array<string|int, mixed> $fixes) : mixed
Parameters
$fixes : array<string|int, mixed>

makeLookup()

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

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

List of values to turn into a lookup

Tags
note

You can also pass an arbitrary number of arguments in place of the regular argument

Return values
array<string|int, mixed>

array equivalent of list

mergeInAttrIncludes()

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

public mergeInAttrIncludes(array<string|int, mixed> &$attr, array<string|int, mixed> $attr_includes) : mixed
Parameters
$attr : array<string|int, mixed>

Reference to attr array to modify

$attr_includes : array<string|int, mixed>

Array of includes / string include to merge in

parseContents()

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

public parseContents(string $contents) : array<string|int, mixed>
Parameters
$contents : string

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

Tags
note

If contents is an object, an array of two nulls will be returned, and the callee needs to take the original $contents and use it directly.

Return values
array<string|int, mixed>

populate()

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

public populate(array<string|int, mixed> $fixes) : mixed
Parameters
$fixes : array<string|int, mixed>

Lookup table of fixes to activate

setup()

Lazy load constructs the module by determining the necessary fixes to create and then delegating to the populate() function.

public setup(HTMLPurifier_Config $config) : mixed
Parameters
$config : HTMLPurifier_Config
Tags
todo

Wildcard matching and error reporting when an added or subtracted fix has no effect.


        
On this page

Search results