HTMLPurifier 4.4.0
HTMLPurifier_HTMLModule Class Reference

Represents an XHTML 1.1 module, with information on elements, tags and attributes. More...

Inheritance diagram for HTMLPurifier_HTMLModule:
HTMLPurifier_HTMLModule_Bdo HTMLPurifier_HTMLModule_Bdo HTMLPurifier_HTMLModule_CommonAttributes HTMLPurifier_HTMLModule_CommonAttributes HTMLPurifier_HTMLModule_Edit HTMLPurifier_HTMLModule_Edit HTMLPurifier_HTMLModule_Forms HTMLPurifier_HTMLModule_Forms HTMLPurifier_HTMLModule_Hypertext HTMLPurifier_HTMLModule_Hypertext HTMLPurifier_HTMLModule_Iframe HTMLPurifier_HTMLModule_Iframe HTMLPurifier_HTMLModule_Image HTMLPurifier_HTMLModule_Image HTMLPurifier_HTMLModule_Legacy HTMLPurifier_HTMLModule_Legacy HTMLPurifier_HTMLModule_List HTMLPurifier_HTMLModule_List HTMLPurifier_HTMLModule_Name HTMLPurifier_HTMLModule_Name HTMLPurifier_HTMLModule_Nofollow HTMLPurifier_HTMLModule_Nofollow HTMLPurifier_HTMLModule_NonXMLCommonAttributes HTMLPurifier_HTMLModule_NonXMLCommonAttributes HTMLPurifier_HTMLModule_Object HTMLPurifier_HTMLModule_Object HTMLPurifier_HTMLModule_Presentation HTMLPurifier_HTMLModule_Presentation HTMLPurifier_HTMLModule_Proprietary HTMLPurifier_HTMLModule_Proprietary HTMLPurifier_HTMLModule_Ruby HTMLPurifier_HTMLModule_Ruby HTMLPurifier_HTMLModule_SafeEmbed HTMLPurifier_HTMLModule_SafeEmbed HTMLPurifier_HTMLModule_SafeObject HTMLPurifier_HTMLModule_SafeObject HTMLPurifier_HTMLModule_Scripting HTMLPurifier_HTMLModule_Scripting HTMLPurifier_HTMLModule_StyleAttribute HTMLPurifier_HTMLModule_StyleAttribute HTMLPurifier_HTMLModule_Tables HTMLPurifier_HTMLModule_Tables HTMLPurifier_HTMLModule_Target HTMLPurifier_HTMLModule_Target HTMLPurifier_HTMLModule_TargetBlank HTMLPurifier_HTMLModule_TargetBlank HTMLPurifier_HTMLModule_Text HTMLPurifier_HTMLModule_Text HTMLPurifier_HTMLModule_Tidy HTMLPurifier_HTMLModule_Tidy HTMLPurifier_HTMLModule_XMLCommonAttributes HTMLPurifier_HTMLModule_XMLCommonAttributes

List of all members.

Public Member Functions

 getChildDef ($def)
 Retrieves a proper HTMLPurifier_ChildDef subclass based on content_model and content_model_type member variables of the HTMLPurifier_ElementDef class.
 addElement ($element, $type, $contents, $attr_includes=array(), $attr=array())
 Convenience function that sets up a new element.
 addBlankElement ($element)
 Convenience function that creates a totally blank, non-standalone element.
 addElementToContentSet ($element, $type)
 Convenience function that registers an element to a content set.
 parseContents ($contents)
 Convenience function that transforms single-string contents into separate content model and content model type.
 mergeInAttrIncludes (&$attr, $attr_includes)
 Convenience function that merges a list of attribute includes into an attribute array.
 makeLookup ($list)
 Convenience function that generates a lookup table with boolean true as value.
 setup ($config)
 Lazy load construction of the module after determining whether or not it's needed, and also when a finalized configuration object is available.
 getChildDef ($def)
 Retrieves a proper HTMLPurifier_ChildDef subclass based on content_model and content_model_type member variables of the HTMLPurifier_ElementDef class.
 addElement ($element, $type, $contents, $attr_includes=array(), $attr=array())
 Convenience function that sets up a new element.
 addBlankElement ($element)
 Convenience function that creates a totally blank, non-standalone element.
 addElementToContentSet ($element, $type)
 Convenience function that registers an element to a content set.
 parseContents ($contents)
 Convenience function that transforms single-string contents into separate content model and content model type.
 mergeInAttrIncludes (&$attr, $attr_includes)
 Convenience function that merges a list of attribute includes into an attribute array.
 makeLookup ($list)
 Convenience function that generates a lookup table with boolean true as value.
 setup ($config)
 Lazy load construction of the module after determining whether or not it's needed, and also when a finalized configuration object is available.

Public Attributes

 $name
 Short unique string identifier of the module.
 $elements = array()
 Informally, a list of elements this module changes.
 $info = array()
 Associative array of element names to element definitions.
 $content_sets = array()
 Associative array of content set names to content set additions.
 $attr_collections = array()
 Associative array of attribute collection names to attribute collection additions.
 $info_tag_transform = array()
 Associative array of deprecated tag name to HTMLPurifier_TagTransform.
 $info_attr_transform_pre = array()
 List of HTMLPurifier_AttrTransform to be performed before validation.
 $info_attr_transform_post = array()
 List of HTMLPurifier_AttrTransform to be performed after validation.
 $info_injector = array()
 List of HTMLPurifier_Injector to be performed during well-formedness fixing.
 $defines_child_def = false
 Boolean flag that indicates whether or not getChildDef is implemented.
 $safe = true
 Boolean flag whether or not this module is safe.

Detailed Description

Represents an XHTML 1.1 module, with information on elements, tags and attributes.

Note:
Even though this is technically XHTML 1.1, it is also used for regular HTML parsing. We are using modulization as a convenient way to represent the internals of HTMLDefinition, and our implementation is by no means conforming and does not directly use the normative DTDs or XML schemas.
The public variables in a module should almost directly correspond to the variables in HTMLPurifier_HTMLDefinition. However, the prefix info carries no special meaning in these objects (include it anyway if that's the correspondence though).
Todo:
Consider making some member functions protected
Note:
Even though this is technically XHTML 1.1, it is also used for regular HTML parsing. We are using modulization as a convenient way to represent the internals of HTMLDefinition, and our implementation is by no means conforming and does not directly use the normative DTDs or XML schemas.
The public variables in a module should almost directly correspond to the variables in HTMLPurifier_HTMLDefinition. However, the prefix info carries no special meaning in these objects (include it anyway if that's the correspondence though).
Todo:
Consider making some member functions protected

Definition at line 18 of file HTMLModule.php.


Member Function Documentation

HTMLPurifier_HTMLModule::addBlankElement ( element)

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

Parameters:
$elementName of element to create
Returns:
Created element

Definition at line 153 of file HTMLModule.php.

Referenced by HTMLPurifier_HTMLModule_Tidy::populate(), HTMLPurifier_HTMLModule_TargetBlank::setup(), HTMLPurifier_HTMLModule_Target::setup(), HTMLPurifier_HTMLModule_Nofollow::setup(), HTMLPurifier_HTMLModule_Name::setup(), and HTMLPurifier_HTMLModule_Legacy::setup().

HTMLPurifier_HTMLModule::addBlankElement ( element)

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

Parameters:
$elementName of element to create
Returns:
Created element

Definition at line 4912 of file HTMLPurifier.standalone.php.

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

Convenience function that sets up a new element.

Parameters:
$elementName of element to add
$typeWhat content set should element be registered to? Set as false to skip this step.
$contentsAllowed children in form of: "$content_model_type: $content_model"
$attr_includesWhat attribute collections to register to element?
$attrWhat unique attributes does the element define?
Note:
See ElementDef for in-depth descriptions of these parameters.
Returns:
Created element definition object, so you can set advanced parameters

Definition at line 4889 of file HTMLPurifier.standalone.php.

References addElementToContentSet(), HTMLPurifier_ElementDef::create(), mergeInAttrIncludes(), and parseContents().

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

Convenience function that sets up a new element.

Parameters:
$elementName of element to add
$typeWhat content set should element be registered to? Set as false to skip this step.
$contentsAllowed children in form of: "$content_model_type: $content_model"
$attr_includesWhat attribute collections to register to element?
$attrWhat unique attributes does the element define?
Note:
See ElementDef for in-depth descriptions of these parameters.
Returns:
Created element definition object, so you can set advanced parameters

Definition at line 130 of file HTMLModule.php.

References addElementToContentSet(), HTMLPurifier_ElementDef::create(), mergeInAttrIncludes(), and parseContents().

Referenced by HTMLPurifier_HTMLModule_Text::setup(), HTMLPurifier_HTMLModule_Tables::setup(), HTMLPurifier_HTMLModule_SafeObject::setup(), HTMLPurifier_HTMLModule_SafeEmbed::setup(), HTMLPurifier_HTMLModule_Ruby::setup(), HTMLPurifier_HTMLModule_Proprietary::setup(), HTMLPurifier_HTMLModule_Presentation::setup(), HTMLPurifier_HTMLModule_Object::setup(), HTMLPurifier_HTMLModule_List::setup(), HTMLPurifier_HTMLModule_Legacy::setup(), HTMLPurifier_HTMLModule_Image::setup(), HTMLPurifier_HTMLModule_Iframe::setup(), HTMLPurifier_HTMLModule_Hypertext::setup(), HTMLPurifier_HTMLModule_Forms::setup(), HTMLPurifier_HTMLModule_Edit::setup(), and HTMLPurifier_HTMLModule_Bdo::setup().

HTMLPurifier_HTMLModule::addElementToContentSet ( element,
type 
)

Convenience function that registers an element to a content set.

Parameters:
Elementto register
Namecontent set (warning: case sensitive, usually upper-case first letter)

Definition at line 170 of file HTMLModule.php.

Referenced by addElement().

HTMLPurifier_HTMLModule::addElementToContentSet ( element,
type 
)

Convenience function that registers an element to a content set.

Parameters:
Elementto register
Namecontent set (warning: case sensitive, usually upper-case first letter)

Definition at line 4929 of file HTMLPurifier.standalone.php.

HTMLPurifier_HTMLModule::getChildDef ( def)

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:
$defHTMLPurifier_ElementDef instance
Returns:
HTMLPurifier_ChildDef subclass

Reimplemented in HTMLPurifier_HTMLModule_Edit, HTMLPurifier_HTMLModule_Tidy_Strict, HTMLPurifier_HTMLModule_Edit, and HTMLPurifier_HTMLModule_Tidy_Strict.

Definition at line 112 of file HTMLModule.php.

HTMLPurifier_HTMLModule::getChildDef ( def)

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:
$defHTMLPurifier_ElementDef instance
Returns:
HTMLPurifier_ChildDef subclass

Reimplemented in HTMLPurifier_HTMLModule_Edit, HTMLPurifier_HTMLModule_Tidy_Strict, HTMLPurifier_HTMLModule_Edit, and HTMLPurifier_HTMLModule_Tidy_Strict.

Definition at line 4871 of file HTMLPurifier.standalone.php.

HTMLPurifier_HTMLModule::makeLookup ( list)

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

Parameters:
$listList of values to turn into a lookup
Note:
You can also pass an arbitrary number of arguments in place of the regular argument
Returns:
Lookup array equivalent of list

Definition at line 4983 of file HTMLPurifier.standalone.php.

HTMLPurifier_HTMLModule::makeLookup ( list)

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

Parameters:
$listList of values to turn into a lookup
Note:
You can also pass an arbitrary number of arguments in place of the regular argument
Returns:
Lookup array equivalent of list

Definition at line 224 of file HTMLModule.php.

Referenced by HTMLPurifier_HTMLModule_Text::setup(), and HTMLPurifier_HTMLModule_Forms::setup().

HTMLPurifier_HTMLModule::mergeInAttrIncludes ( &$  attr,
attr_includes 
)

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

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

Definition at line 208 of file HTMLModule.php.

Referenced by addElement().

HTMLPurifier_HTMLModule::mergeInAttrIncludes ( &$  attr,
attr_includes 
)

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

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

Definition at line 4967 of file HTMLPurifier.standalone.php.

HTMLPurifier_HTMLModule::parseContents ( contents)

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

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

Definition at line 185 of file HTMLModule.php.

Referenced by addElement().

HTMLPurifier_HTMLModule::parseContents ( contents)

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

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

Definition at line 4944 of file HTMLPurifier.standalone.php.

HTMLPurifier_HTMLModule::setup ( config)

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

Parameters:
$configInstance of HTMLPurifier_Config

Reimplemented in HTMLPurifier_HTMLModule_Bdo, HTMLPurifier_HTMLModule_Edit, HTMLPurifier_HTMLModule_Forms, HTMLPurifier_HTMLModule_Hypertext, HTMLPurifier_HTMLModule_Iframe, HTMLPurifier_HTMLModule_Image, HTMLPurifier_HTMLModule_Legacy, HTMLPurifier_HTMLModule_List, HTMLPurifier_HTMLModule_Name, HTMLPurifier_HTMLModule_Nofollow, HTMLPurifier_HTMLModule_Object, HTMLPurifier_HTMLModule_Presentation, HTMLPurifier_HTMLModule_Proprietary, HTMLPurifier_HTMLModule_Ruby, HTMLPurifier_HTMLModule_SafeEmbed, HTMLPurifier_HTMLModule_SafeObject, HTMLPurifier_HTMLModule_Scripting, HTMLPurifier_HTMLModule_StyleAttribute, HTMLPurifier_HTMLModule_Tables, HTMLPurifier_HTMLModule_Target, HTMLPurifier_HTMLModule_TargetBlank, HTMLPurifier_HTMLModule_Text, HTMLPurifier_HTMLModule_Tidy, HTMLPurifier_HTMLModule_Bdo, HTMLPurifier_HTMLModule_Edit, HTMLPurifier_HTMLModule_Forms, HTMLPurifier_HTMLModule_Hypertext, HTMLPurifier_HTMLModule_Iframe, HTMLPurifier_HTMLModule_Image, HTMLPurifier_HTMLModule_Legacy, HTMLPurifier_HTMLModule_List, HTMLPurifier_HTMLModule_Name, HTMLPurifier_HTMLModule_Nofollow, HTMLPurifier_HTMLModule_Object, HTMLPurifier_HTMLModule_Presentation, HTMLPurifier_HTMLModule_Proprietary, HTMLPurifier_HTMLModule_Ruby, HTMLPurifier_HTMLModule_SafeEmbed, HTMLPurifier_HTMLModule_SafeObject, HTMLPurifier_HTMLModule_Scripting, HTMLPurifier_HTMLModule_StyleAttribute, HTMLPurifier_HTMLModule_Tables, HTMLPurifier_HTMLModule_Target, HTMLPurifier_HTMLModule_TargetBlank, HTMLPurifier_HTMLModule_Text, and HTMLPurifier_HTMLModule_Tidy.

Definition at line 240 of file HTMLModule.php.

HTMLPurifier_HTMLModule::setup ( config)

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

Parameters:
$configInstance of HTMLPurifier_Config

Reimplemented in HTMLPurifier_HTMLModule_Bdo, HTMLPurifier_HTMLModule_Edit, HTMLPurifier_HTMLModule_Forms, HTMLPurifier_HTMLModule_Hypertext, HTMLPurifier_HTMLModule_Iframe, HTMLPurifier_HTMLModule_Image, HTMLPurifier_HTMLModule_Legacy, HTMLPurifier_HTMLModule_List, HTMLPurifier_HTMLModule_Name, HTMLPurifier_HTMLModule_Nofollow, HTMLPurifier_HTMLModule_Object, HTMLPurifier_HTMLModule_Presentation, HTMLPurifier_HTMLModule_Proprietary, HTMLPurifier_HTMLModule_Ruby, HTMLPurifier_HTMLModule_SafeEmbed, HTMLPurifier_HTMLModule_SafeObject, HTMLPurifier_HTMLModule_Scripting, HTMLPurifier_HTMLModule_StyleAttribute, HTMLPurifier_HTMLModule_Tables, HTMLPurifier_HTMLModule_Target, HTMLPurifier_HTMLModule_TargetBlank, HTMLPurifier_HTMLModule_Text, HTMLPurifier_HTMLModule_Tidy, HTMLPurifier_HTMLModule_Bdo, HTMLPurifier_HTMLModule_Edit, HTMLPurifier_HTMLModule_Forms, HTMLPurifier_HTMLModule_Hypertext, HTMLPurifier_HTMLModule_Iframe, HTMLPurifier_HTMLModule_Image, HTMLPurifier_HTMLModule_Legacy, HTMLPurifier_HTMLModule_List, HTMLPurifier_HTMLModule_Name, HTMLPurifier_HTMLModule_Nofollow, HTMLPurifier_HTMLModule_Object, HTMLPurifier_HTMLModule_Presentation, HTMLPurifier_HTMLModule_Proprietary, HTMLPurifier_HTMLModule_Ruby, HTMLPurifier_HTMLModule_SafeEmbed, HTMLPurifier_HTMLModule_SafeObject, HTMLPurifier_HTMLModule_Scripting, HTMLPurifier_HTMLModule_StyleAttribute, HTMLPurifier_HTMLModule_Tables, HTMLPurifier_HTMLModule_Target, HTMLPurifier_HTMLModule_TargetBlank, HTMLPurifier_HTMLModule_Text, and HTMLPurifier_HTMLModule_Tidy.

Definition at line 4999 of file HTMLPurifier.standalone.php.


Member Data Documentation

HTMLPurifier_HTMLModule::$attr_collections = array()

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.

Reimplemented in HTMLPurifier_HTMLModule_Bdo, HTMLPurifier_HTMLModule_CommonAttributes, HTMLPurifier_HTMLModule_NonXMLCommonAttributes, HTMLPurifier_HTMLModule_StyleAttribute, and HTMLPurifier_HTMLModule_XMLCommonAttributes.

Definition at line 57 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$content_sets = array()

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.

Reimplemented in HTMLPurifier_HTMLModule_Forms, HTMLPurifier_HTMLModule_List, HTMLPurifier_HTMLModule_Scripting, and HTMLPurifier_HTMLModule_Text.

Definition at line 47 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$defines_child_def = false

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!

Reimplemented in HTMLPurifier_HTMLModule_Edit, and HTMLPurifier_HTMLModule_Tidy_Strict.

Definition at line 88 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$elements = array()

Informally, a list of elements this module changes.

Not used in any significant way.

Reimplemented in HTMLPurifier_HTMLModule_Scripting.

Definition at line 32 of file HTMLModule.php.

Referenced by HTMLPurifier_HTMLModule_Target::setup(), and HTMLPurifier_HTMLModule_Name::setup().

HTMLPurifier_HTMLModule::$info = array()

Associative array of element names to element definitions.

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

Definition at line 39 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$info_attr_transform_post = array()

List of HTMLPurifier_AttrTransform to be performed after validation.

Definition at line 72 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$info_attr_transform_pre = array()

List of HTMLPurifier_AttrTransform to be performed before validation.

Definition at line 67 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$info_injector = array()

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.

Definition at line 80 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$info_tag_transform = array()

Associative array of deprecated tag name to HTMLPurifier_TagTransform.

Definition at line 62 of file HTMLModule.php.

HTMLPurifier_HTMLModule::$safe = true

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

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.

Reimplemented in HTMLPurifier_HTMLModule_Forms, HTMLPurifier_HTMLModule_Iframe, HTMLPurifier_HTMLModule_Object, and HTMLPurifier_HTMLModule_Scripting.

Definition at line 102 of file HTMLModule.php.


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