1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-01-17 14:08:15 +01:00

Move order to module itself, as member variable type.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@753 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2007-02-16 03:01:23 +00:00
parent 6e1b540d99
commit e55babdc53
14 changed files with 33 additions and 15 deletions

View File

@ -21,6 +21,16 @@ class HTMLPurifier_HTMLModule
*/ */
var $name; 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 * List of elements that the module implements or substantially
* modifies, either through a new ElementDef or a modified * modifies, either through a new ElementDef or a modified

View File

@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule
{ {
var $name = 'Bdo'; var $name = 'Bdo';
var $type = 'define';
var $elements = array('bdo'); var $elements = array('bdo');
var $info = array(); var $info = array();
var $content_sets = array('Inline' => 'bdo'); var $content_sets = array('Inline' => 'bdo');

View File

@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule
{ {
var $name = 'Edit'; var $name = 'Edit';
var $type = 'define';
var $elements = array('del', 'ins'); var $elements = array('del', 'ins');
var $info = array(); var $info = array();
var $content_sets = array('Inline' => 'del | ins'); var $content_sets = array('Inline' => 'del | ins');

View File

@ -9,6 +9,7 @@ class HTMLPurifier_HTMLModule_Hypertext extends HTMLPurifier_HTMLModule
{ {
var $name = 'Hypertext'; var $name = 'Hypertext';
var $type = 'define';
var $elements = array('a'); var $elements = array('a');
var $info = array(); var $info = array();
var $content_sets = array('Inline' => 'a'); var $content_sets = array('Inline' => 'a');

View File

@ -14,6 +14,7 @@ class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
{ {
var $name = 'Image'; var $name = 'Image';
var $type = 'define';
var $elements = array('img'); var $elements = array('img');
var $info = array(); var $info = array();
var $content_sets = array('Inline' => 'img'); var $content_sets = array('Inline' => 'img');

View File

@ -22,6 +22,7 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
// incomplete // incomplete
var $name = 'Legacy'; var $name = 'Legacy';
var $type = 'define-redefine';
var $elements = array('u', 's', 'strike'); var $elements = array('u', 's', 'strike');
var $non_standalone_elements = array('li', 'ol', 'address', 'blockquote'); var $non_standalone_elements = array('li', 'ol', 'address', 'blockquote');

View File

@ -9,6 +9,7 @@ class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule
{ {
var $name = 'List'; var $name = 'List';
var $type = 'define';
var $elements = array('dl', 'dt', 'dd', 'ol', 'ul', 'li'); var $elements = array('dl', 'dt', 'dd', 'ol', 'ul', 'li');
var $info = array(); var $info = array();
// According to the abstract schema, the List content set is a fully formed // According to the abstract schema, the List content set is a fully formed

View File

@ -16,6 +16,7 @@ class HTMLPurifier_HTMLModule_Presentation extends HTMLPurifier_HTMLModule
{ {
var $name = 'Presentation'; var $name = 'Presentation';
var $type = 'define';
var $elements = array('b', 'big', 'hr', 'i', 'small', 'sub', 'sup', 'tt'); var $elements = array('b', 'big', 'hr', 'i', 'small', 'sub', 'sup', 'tt');
var $info = array(); var $info = array();
var $content_sets = array( var $content_sets = array(

View File

@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_StyleAttribute extends HTMLPurifier_HTMLModule
{ {
var $name = 'StyleAttribute'; var $name = 'StyleAttribute';
var $type = 'define';
var $attr_collections = array( var $attr_collections = array(
// The inclusion routine differs from the Abstract Modules but // The inclusion routine differs from the Abstract Modules but
// is in line with the DTD and XML Schemas. // is in line with the DTD and XML Schemas.

View File

@ -10,6 +10,7 @@ class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule
{ {
var $name = 'Tables'; var $name = 'Tables';
var $type = 'define';
var $elements = array('caption', 'table', 'td', 'th', 'tr', 'col', var $elements = array('caption', 'table', 'td', 'th', 'tr', 'col',
'colgroup', 'tbody', 'thead', 'tfoot'); 'colgroup', 'tbody', 'thead', 'tfoot');
var $info = array(); var $info = array();

View File

@ -16,6 +16,7 @@ class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
{ {
var $name = 'Text'; var $name = 'Text';
var $type = 'define';
var $elements = array('abbr', 'acronym', 'address', 'blockquote', var $elements = array('abbr', 'acronym', 'address', 'blockquote',
'br', 'cite', 'code', 'dfn', 'div', 'em', 'h1', 'h2', 'h3', 'br', 'cite', 'code', 'dfn', 'div', 'em', 'h1', 'h2', 'h3',

View File

@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_TransformToStrict extends HTMLPurifier_HTMLModule
{ {
var $name = 'TransformToStrict'; var $name = 'TransformToStrict';
var $type = 'redefine';
// we're actually modifying these elements, not defining them // we're actually modifying these elements, not defining them
var $elements = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'blockquote'); var $elements = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'blockquote');

View File

@ -15,6 +15,7 @@ class HTMLPurifier_HTMLModule_TransformToXHTML11 extends HTMLPurifier_HTMLModule
{ {
var $name = 'TransformToXHTML11'; var $name = 'TransformToXHTML11';
var $type = 'redefine';
var $attr_collections = array( var $attr_collections = array(
'Lang' => array( 'Lang' => array(
'lang' => false // remove it 'lang' => false // remove it

View File

@ -102,22 +102,17 @@ class HTMLPurifier_HTMLModuleManager
// modules // modules
$modules = array( $modules = array(
'define' => array( // define
'Text', 'Hypertext', 'List', 'Presentation', 'Text', 'Hypertext', 'List', 'Presentation',
'Edit', 'Bdo', 'Tables', 'Image', 'StyleAttribute' 'Edit', 'Bdo', 'Tables', 'Image', 'StyleAttribute',
), // define-redefine
'define-redefine' => array( 'Legacy',
'Legacy' // redefine
), 'TransformToStrict', 'TransformToXHTML11'
'redefine' => array(
'TransformToStrict', 'TransformToXHTML11'
)
); );
foreach ($modules as $order => $modules_of_order) { foreach ($modules as $module) {
foreach ($modules_of_order as $module) { $this->addModule($module);
$this->addModule($module, $order);
}
} }
$this->attrTypes = new HTMLPurifier_AttrTypes(); $this->attrTypes = new HTMLPurifier_AttrTypes();
@ -131,7 +126,7 @@ class HTMLPurifier_HTMLModuleManager
* HTMLPurifier_HTMLModule prefix, or instance of * HTMLPurifier_HTMLModule prefix, or instance of
* subclass of HTMLPurifier_HTMLModule. * subclass of HTMLPurifier_HTMLModule.
*/ */
function addModule($module, $order = 'main') { function addModule($module) {
if (is_string($module)) { if (is_string($module)) {
$original_module = $module; $original_module = $module;
if (!class_exists($module)) { if (!class_exists($module)) {
@ -146,6 +141,7 @@ class HTMLPurifier_HTMLModuleManager
} }
$module = new $module(); $module = new $module();
} }
$order = $module->type;
if (!isset($this->orderKeywords[$order])) { if (!isset($this->orderKeywords[$order])) {
trigger_error('Order keyword does not exist', E_USER_ERROR); trigger_error('Order keyword does not exist', E_USER_ERROR);
return; return;