diff --git a/library/HTMLPurifier/HTMLModule.php b/library/HTMLPurifier/HTMLModule.php
index 8ccde459..2be7b067 100644
--- a/library/HTMLPurifier/HTMLModule.php
+++ b/library/HTMLPurifier/HTMLModule.php
@@ -21,6 +21,16 @@ class HTMLPurifier_HTMLModule
*/
var $name;
+ /**
+ * Type of module. Currently three supported values: define,
+ * define-redefine and redefine. Define means that the module solely
+ * creates new elements. Redefine means that the module solely
+ * redefines aspects of already existing elements. Define-Redefine
+ * is a combo of the two. This affects the order in which the module
+ * will be loaded, see HTMLPurifier_HTMLModuleManager for more details.
+ */
+ var $type;
+
/**
* List of elements that the module implements or substantially
* modifies, either through a new ElementDef or a modified
diff --git a/library/HTMLPurifier/HTMLModule/Bdo.php b/library/HTMLPurifier/HTMLModule/Bdo.php
index 17e5e987..08a20aa7 100644
--- a/library/HTMLPurifier/HTMLModule/Bdo.php
+++ b/library/HTMLPurifier/HTMLModule/Bdo.php
@@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule
{
var $name = 'Bdo';
+ var $type = 'define';
var $elements = array('bdo');
var $info = array();
var $content_sets = array('Inline' => 'bdo');
diff --git a/library/HTMLPurifier/HTMLModule/Edit.php b/library/HTMLPurifier/HTMLModule/Edit.php
index 6a415906..43441217 100644
--- a/library/HTMLPurifier/HTMLModule/Edit.php
+++ b/library/HTMLPurifier/HTMLModule/Edit.php
@@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule
{
var $name = 'Edit';
+ var $type = 'define';
var $elements = array('del', 'ins');
var $info = array();
var $content_sets = array('Inline' => 'del | ins');
diff --git a/library/HTMLPurifier/HTMLModule/Hypertext.php b/library/HTMLPurifier/HTMLModule/Hypertext.php
index 0b8a2e98..f0a8a652 100644
--- a/library/HTMLPurifier/HTMLModule/Hypertext.php
+++ b/library/HTMLPurifier/HTMLModule/Hypertext.php
@@ -9,6 +9,7 @@ class HTMLPurifier_HTMLModule_Hypertext extends HTMLPurifier_HTMLModule
{
var $name = 'Hypertext';
+ var $type = 'define';
var $elements = array('a');
var $info = array();
var $content_sets = array('Inline' => 'a');
diff --git a/library/HTMLPurifier/HTMLModule/Image.php b/library/HTMLPurifier/HTMLModule/Image.php
index 3852836d..3b3e4041 100644
--- a/library/HTMLPurifier/HTMLModule/Image.php
+++ b/library/HTMLPurifier/HTMLModule/Image.php
@@ -14,6 +14,7 @@ class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
{
var $name = 'Image';
+ var $type = 'define';
var $elements = array('img');
var $info = array();
var $content_sets = array('Inline' => 'img');
diff --git a/library/HTMLPurifier/HTMLModule/Legacy.php b/library/HTMLPurifier/HTMLModule/Legacy.php
index a0613a2f..f734aed2 100644
--- a/library/HTMLPurifier/HTMLModule/Legacy.php
+++ b/library/HTMLPurifier/HTMLModule/Legacy.php
@@ -22,6 +22,7 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
// incomplete
var $name = 'Legacy';
+ var $type = 'define-redefine';
var $elements = array('u', 's', 'strike');
var $non_standalone_elements = array('li', 'ol', 'address', 'blockquote');
diff --git a/library/HTMLPurifier/HTMLModule/List.php b/library/HTMLPurifier/HTMLModule/List.php
index c74982df..73e57ef1 100644
--- a/library/HTMLPurifier/HTMLModule/List.php
+++ b/library/HTMLPurifier/HTMLModule/List.php
@@ -9,6 +9,7 @@ class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule
{
var $name = 'List';
+ var $type = 'define';
var $elements = array('dl', 'dt', 'dd', 'ol', 'ul', 'li');
var $info = array();
// According to the abstract schema, the List content set is a fully formed
diff --git a/library/HTMLPurifier/HTMLModule/Presentation.php b/library/HTMLPurifier/HTMLModule/Presentation.php
index 42d9c11e..f1b9f25d 100644
--- a/library/HTMLPurifier/HTMLModule/Presentation.php
+++ b/library/HTMLPurifier/HTMLModule/Presentation.php
@@ -16,6 +16,7 @@ class HTMLPurifier_HTMLModule_Presentation extends HTMLPurifier_HTMLModule
{
var $name = 'Presentation';
+ var $type = 'define';
var $elements = array('b', 'big', 'hr', 'i', 'small', 'sub', 'sup', 'tt');
var $info = array();
var $content_sets = array(
diff --git a/library/HTMLPurifier/HTMLModule/StyleAttribute.php b/library/HTMLPurifier/HTMLModule/StyleAttribute.php
index 5ee5d1cf..b06a337e 100644
--- a/library/HTMLPurifier/HTMLModule/StyleAttribute.php
+++ b/library/HTMLPurifier/HTMLModule/StyleAttribute.php
@@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_StyleAttribute extends HTMLPurifier_HTMLModule
{
var $name = 'StyleAttribute';
+ var $type = 'define';
var $attr_collections = array(
// The inclusion routine differs from the Abstract Modules but
// is in line with the DTD and XML Schemas.
diff --git a/library/HTMLPurifier/HTMLModule/Tables.php b/library/HTMLPurifier/HTMLModule/Tables.php
index ea41f5b1..9268be95 100644
--- a/library/HTMLPurifier/HTMLModule/Tables.php
+++ b/library/HTMLPurifier/HTMLModule/Tables.php
@@ -10,6 +10,7 @@ class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule
{
var $name = 'Tables';
+ var $type = 'define';
var $elements = array('caption', 'table', 'td', 'th', 'tr', 'col',
'colgroup', 'tbody', 'thead', 'tfoot');
var $info = array();
diff --git a/library/HTMLPurifier/HTMLModule/Text.php b/library/HTMLPurifier/HTMLModule/Text.php
index 56361a39..8a07d9c8 100644
--- a/library/HTMLPurifier/HTMLModule/Text.php
+++ b/library/HTMLPurifier/HTMLModule/Text.php
@@ -16,6 +16,7 @@ class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
{
var $name = 'Text';
+ var $type = 'define';
var $elements = array('abbr', 'acronym', 'address', 'blockquote',
'br', 'cite', 'code', 'dfn', 'div', 'em', 'h1', 'h2', 'h3',
diff --git a/library/HTMLPurifier/HTMLModule/TransformToStrict.php b/library/HTMLPurifier/HTMLModule/TransformToStrict.php
index 5c75a0da..b3e896af 100644
--- a/library/HTMLPurifier/HTMLModule/TransformToStrict.php
+++ b/library/HTMLPurifier/HTMLModule/TransformToStrict.php
@@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_TransformToStrict extends HTMLPurifier_HTMLModule
{
var $name = 'TransformToStrict';
+ var $type = 'redefine';
// we're actually modifying these elements, not defining them
var $elements = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'blockquote');
diff --git a/library/HTMLPurifier/HTMLModule/TransformToXHTML11.php b/library/HTMLPurifier/HTMLModule/TransformToXHTML11.php
index 0915f5b6..e208aea7 100644
--- a/library/HTMLPurifier/HTMLModule/TransformToXHTML11.php
+++ b/library/HTMLPurifier/HTMLModule/TransformToXHTML11.php
@@ -15,6 +15,7 @@ class HTMLPurifier_HTMLModule_TransformToXHTML11 extends HTMLPurifier_HTMLModule
{
var $name = 'TransformToXHTML11';
+ var $type = 'redefine';
var $attr_collections = array(
'Lang' => array(
'lang' => false // remove it
diff --git a/library/HTMLPurifier/HTMLModuleManager.php b/library/HTMLPurifier/HTMLModuleManager.php
index 739ac2ce..cf9a9215 100644
--- a/library/HTMLPurifier/HTMLModuleManager.php
+++ b/library/HTMLPurifier/HTMLModuleManager.php
@@ -102,22 +102,17 @@ class HTMLPurifier_HTMLModuleManager
// modules
$modules = array(
- 'define' => array(
- 'Text', 'Hypertext', 'List', 'Presentation',
- 'Edit', 'Bdo', 'Tables', 'Image', 'StyleAttribute'
- ),
- 'define-redefine' => array(
- 'Legacy'
- ),
- 'redefine' => array(
- 'TransformToStrict', 'TransformToXHTML11'
- )
+ // define
+ 'Text', 'Hypertext', 'List', 'Presentation',
+ 'Edit', 'Bdo', 'Tables', 'Image', 'StyleAttribute',
+ // define-redefine
+ 'Legacy',
+ // redefine
+ 'TransformToStrict', 'TransformToXHTML11'
);
- foreach ($modules as $order => $modules_of_order) {
- foreach ($modules_of_order as $module) {
- $this->addModule($module, $order);
- }
+ foreach ($modules as $module) {
+ $this->addModule($module);
}
$this->attrTypes = new HTMLPurifier_AttrTypes();
@@ -131,7 +126,7 @@ class HTMLPurifier_HTMLModuleManager
* HTMLPurifier_HTMLModule prefix, or instance of
* subclass of HTMLPurifier_HTMLModule.
*/
- function addModule($module, $order = 'main') {
+ function addModule($module) {
if (is_string($module)) {
$original_module = $module;
if (!class_exists($module)) {
@@ -146,6 +141,7 @@ class HTMLPurifier_HTMLModuleManager
}
$module = new $module();
}
+ $order = $module->type;
if (!isset($this->orderKeywords[$order])) {
trigger_error('Order keyword does not exist', E_USER_ERROR);
return;