mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00: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:
parent
6e1b540d99
commit
e55babdc53
@ -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
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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.
|
||||
|
@ -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();
|
||||
|
@ -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',
|
||||
|
@ -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');
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user