Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 Class Reference
Inheritance diagram for HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4:
HTMLPurifier_HTMLModule_Tidy HTMLPurifier_HTMLModule HTMLPurifier_HTMLModule_Tidy_Strict HTMLPurifier_HTMLModule_Tidy_Transitional

Public Member Functions

 addBlankElement ($element)
 Convenience function that creates a totally blank, non-standalone element.
 
 addElement ($element, $type, $contents, $attr_includes=array(), $attr=array())
 Convenience function that sets up a new element.
 
 addElementToContentSet ($element, $type)
 Convenience function that registers an element to a content set.
 
 getChildDef ($def)
 Retrieves a proper HTMLPurifier_ChildDef subclass based on content_model and content_model_type member variables of the HTMLPurifier_ElementDef class.
 
 getFixesForLevel ($level)
 Retrieves all fixes per a level, returning fixes for that specific level as well as all levels below it.
 
 getFixType ($name)
 Parses a fix name and determines what kind of fix it is, as well as other information defined by the fix.
 
 makeFixes ()
 Defines all fixes the module will perform in a compact associative array of fix name to fix implementation.
 
 makeFixesForLevel ($fixes)
 Dynamically populates the $fixesForLevel member variable using the fixes array.
 
 makeLookup ($list)
 Convenience function that generates a lookup table with boolean true as value.
 
 mergeInAttrIncludes (&$attr, $attr_includes)
 Convenience function that merges a list of attribute includes into an attribute array.
 
 parseContents ($contents)
 Convenience function that transforms single-string contents into separate content model and content model type.
 
 populate ($fixes)
 Populates the module with transforms and other special-case code based on a list of fixes passed to it.
 
 setup ($config)
 Lazy load constructs the module by determining the necessary fixes to create and then delegating to the populate() function.
 

Public Attributes

 $attr_collections = array()
 Associative array of attribute collection names to attribute collection additions.
 
 $content_sets = array()
 Associative array of content set names to content set additions.
 
 $defaultLevel = null
 Default level to place all fixes in.
 
 $defines_child_def = false
 Boolean flag that indicates whether or not getChildDef is implemented.
 
 $elements = array()
 Informally, a list of elements this module changes.
 
 $fixesForLevel
 Lists of fixes used by getFixesForLevel().
 
 $info = array()
 Associative array of element names to element definitions.
 
 $info_attr_transform_post = array()
 List of HTMLPurifier_AttrTransform to be performed after validation.
 
 $info_attr_transform_pre = array()
 List of HTMLPurifier_AttrTransform to be performed before validation.
 
 $info_injector = array()
 List of HTMLPurifier_Injector to be performed during well-formedness fixing.
 
 $info_tag_transform = array()
 Associative array of deprecated tag name to HTMLPurifier_TagTransform.
 
 $levels = array(0 => 'none', 'light', 'medium', 'heavy')
 List of supported levels.
 
 $name
 Short unique string identifier of the module.
 
 $safe = true
 Boolean flag whether or not this module is safe.
 

Member Function Documentation

◆ addBlankElement()

HTMLPurifier_HTMLModule::addBlankElement ( $element)
inherited

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

Parameters
string$elementName of element to create
Return values
HTMLPurifier_ElementDefCreated element

◆ addElement()

HTMLPurifier_HTMLModule::addElement ( $element,
$type,
$contents,
$attr_includes = array(),
$attr = array() )
inherited

Convenience function that sets up a new element.

Parameters
string$elementName of element to add
string | bool$typeWhat content set should element be registered to? Set as false to skip this step.
string | HTMLPurifier_ChildDef$contentsAllowed children in form of: "$content_model_type: $content_model"
array | string$attr_includesWhat attribute collections to register to element?
array$attrWhat unique attributes does the element define?
See also
HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters.
Return values
HTMLPurifier_ElementDefCreated element definition object, so you can set advanced parameters

◆ addElementToContentSet()

HTMLPurifier_HTMLModule::addElementToContentSet ( $element,
$type )
inherited

Convenience function that registers an element to a content set.

Parameters
string$elementElement to register
string$typeName content set (warning: case sensitive, usually upper-case first letter)

◆ getChildDef()

HTMLPurifier_HTMLModule::getChildDef ( $def)
inherited

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
Return values
HTMLPurifier_ChildDefsubclass

Reimplemented in HTMLPurifier_HTMLModule_Edit, and HTMLPurifier_HTMLModule_Tidy_Strict.

◆ getFixesForLevel()

HTMLPurifier_HTMLModule_Tidy::getFixesForLevel ( $level)
inherited

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

Parameters
string$levellevel identifier, see $levels for valid values
Return values
arrayLookup up table of fixes

◆ getFixType()

HTMLPurifier_HTMLModule_Tidy::getFixType ( $name)
inherited

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

Parameters
$nameString name of fix
Return values
array(string$fix_type, array $fix_parameters)
Note
$fix_parameters is type dependant, see populate() for usage of these parameters

◆ makeFixes()

HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4::makeFixes ( )

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

Return values
array

Reimplemented from HTMLPurifier_HTMLModule_Tidy.

Reimplemented in HTMLPurifier_HTMLModule_Tidy_Strict.

◆ makeFixesForLevel()

HTMLPurifier_HTMLModule_Tidy::makeFixesForLevel ( $fixes)
inherited

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

◆ makeLookup()

HTMLPurifier_HTMLModule::makeLookup ( $list)
inherited

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

Parameters
string$listList of values to turn into a lookup
Note
You can also pass an arbitrary number of arguments in place of the regular argument
Return values
arrayarray equivalent of list

◆ mergeInAttrIncludes()

HTMLPurifier_HTMLModule::mergeInAttrIncludes ( & $attr,
$attr_includes )
inherited

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

Parameters
array$attrReference to attr array to modify
array$attr_includesArray of includes / string include to merge in

◆ parseContents()

HTMLPurifier_HTMLModule::parseContents ( $contents)
inherited

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

Parameters
string$contentsAllowed children in form of: "$content_model_type: $content_model"
Return values
array
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.

◆ populate()

HTMLPurifier_HTMLModule_Tidy::populate ( $fixes)
inherited

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

Parameters
array$fixesLookup table of fixes to activate

◆ setup()

HTMLPurifier_HTMLModule_Tidy::setup ( $config)
inherited

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

Parameters
HTMLPurifier_Config$config
Todo
Wildcard matching and error reporting when an added or subtracted fix has no effect.

Reimplemented from HTMLPurifier_HTMLModule.

Member Data Documentation

◆ $attr_collections

HTMLPurifier_HTMLModule::$attr_collections = array()
inherited

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. @type array

◆ $content_sets

HTMLPurifier_HTMLModule::$content_sets = array()
inherited

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. @type array

◆ $defaultLevel

HTMLPurifier_HTMLModule_Tidy::$defaultLevel = null
inherited

Default level to place all fixes in.

Disabled by default. @type string

◆ $defines_child_def

HTMLPurifier_HTMLModule::$defines_child_def = false
inherited

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! @type bool

◆ $elements

HTMLPurifier_HTMLModule::$elements = array()
inherited

Informally, a list of elements this module changes.

Not used in any significant way. @type array

◆ $fixesForLevel

HTMLPurifier_HTMLModule_Tidy::$fixesForLevel
inherited
Initial value:
= array(
'light' => array(),
'medium' => array(),
'heavy' => array()
)

Lists of fixes used by getFixesForLevel().

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

◆ $info

HTMLPurifier_HTMLModule::$info = array()
inherited

Associative array of element names to element definitions.

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

◆ $info_attr_transform_post

HTMLPurifier_HTMLModule::$info_attr_transform_post = array()
inherited

List of HTMLPurifier_AttrTransform to be performed after validation.

@type array

◆ $info_attr_transform_pre

HTMLPurifier_HTMLModule::$info_attr_transform_pre = array()
inherited

List of HTMLPurifier_AttrTransform to be performed before validation.

@type array

◆ $info_injector

HTMLPurifier_HTMLModule::$info_injector = array()
inherited

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. @type array

◆ $info_tag_transform

HTMLPurifier_HTMLModule::$info_tag_transform = array()
inherited

Associative array of deprecated tag name to HTMLPurifier_TagTransform.

@type array

◆ $levels

HTMLPurifier_HTMLModule_Tidy::$levels = array(0 => 'none', 'light', 'medium', 'heavy')
inherited

List of supported levels.

Index zero is a special case "no fixes" level. @type array

◆ $name

HTMLPurifier_HTMLModule::$name
inherited

Short unique string identifier of the module.

@type string

◆ $safe

HTMLPurifier_HTMLModule::$safe = true
inherited

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

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

The documentation for this class was generated from the following file: