mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
Migrate default attribute collections to their own module, do late-loading of the attribute collection.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@754 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
e55babdc53
commit
5c4a0a6785
@ -15,32 +15,7 @@ class HTMLPurifier_AttrCollections
|
||||
* @note Technically, the composition of these is more complicated,
|
||||
* but we bypass it using our own excludes property
|
||||
*/
|
||||
var $info = array(
|
||||
'Core' => array(
|
||||
0 => array('Style'),
|
||||
// 'xml:space' => false,
|
||||
'class' => 'NMTOKENS',
|
||||
'id' => 'ID',
|
||||
'title' => 'CDATA',
|
||||
),
|
||||
'Lang' => array(
|
||||
'xml:lang' => false, // see constructor
|
||||
),
|
||||
'I18N' => array(
|
||||
0 => array('Lang'), // proprietary, for xml:lang/lang
|
||||
),
|
||||
'Common' => array(
|
||||
0 => array('Core', 'I18N')
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Sets up direct objects not registered to HTMLPurifier_AttrTypes
|
||||
*/
|
||||
function HTMLPurifier_AttrCollections() {
|
||||
// setup direct objects
|
||||
$this->info['Lang']['xml:lang'] = new HTMLPurifier_AttrDef_Lang();
|
||||
}
|
||||
var $info = array();
|
||||
|
||||
/**
|
||||
* Performs all expansions on internal data for use by other inclusions
|
||||
@ -49,7 +24,7 @@ class HTMLPurifier_AttrCollections
|
||||
* @param $attr_types HTMLPurifier_AttrTypes instance
|
||||
* @param $modules Hash array of HTMLPurifier_HTMLModule members
|
||||
*/
|
||||
function setup($attr_types, $modules) {
|
||||
function HTMLPurifier_AttrCollections($attr_types, $modules) {
|
||||
$info =& $this->info;
|
||||
// load extensions from the modules
|
||||
foreach ($modules as $module) {
|
||||
|
32
library/HTMLPurifier/HTMLModule/CommonAttributes.php
Normal file
32
library/HTMLPurifier/HTMLModule/CommonAttributes.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class HTMLPurifier_HTMLModule_CommonAttributes extends HTMLPurifier_HTMLModule
|
||||
{
|
||||
var $name = 'CommonAttributes';
|
||||
var $type = 'define';
|
||||
|
||||
var $attr_collections = array(
|
||||
'Core' => array(
|
||||
0 => array('Style'),
|
||||
// 'xml:space' => false,
|
||||
'class' => 'NMTOKENS',
|
||||
'id' => 'ID',
|
||||
'title' => 'CDATA',
|
||||
),
|
||||
'Lang' => array(
|
||||
'xml:lang' => false, // see constructor
|
||||
),
|
||||
'I18N' => array(
|
||||
0 => array('Lang'), // proprietary, for xml:lang/lang
|
||||
),
|
||||
'Common' => array(
|
||||
0 => array('Core', 'I18N')
|
||||
)
|
||||
);
|
||||
|
||||
function HTMLPurifier_HTMLModule_CommonAttributes() {
|
||||
$this->attr_collections['Lang']['xml:lang'] = new HTMLPurifier_AttrDef_Lang();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -4,6 +4,7 @@ require_once 'HTMLPurifier/ContentSets.php';
|
||||
require_once 'HTMLPurifier/HTMLModule.php';
|
||||
|
||||
// W3C modules
|
||||
require_once 'HTMLPurifier/HTMLModule/CommonAttributes.php';
|
||||
require_once 'HTMLPurifier/HTMLModule/Text.php';
|
||||
require_once 'HTMLPurifier/HTMLModule/Hypertext.php';
|
||||
require_once 'HTMLPurifier/HTMLModule/List.php';
|
||||
@ -41,6 +42,7 @@ class HTMLPurifier_HTMLModuleManager
|
||||
*/
|
||||
var $collectionsSafe = array(
|
||||
'_Common' => array( // leading _ indicates private
|
||||
'CommonAttributes',
|
||||
'Text',
|
||||
'Hypertext',
|
||||
'List',
|
||||
@ -103,6 +105,7 @@ class HTMLPurifier_HTMLModuleManager
|
||||
// modules
|
||||
$modules = array(
|
||||
// define
|
||||
'CommonAttributes',
|
||||
'Text', 'Hypertext', 'List', 'Presentation',
|
||||
'Edit', 'Bdo', 'Tables', 'Image', 'StyleAttribute',
|
||||
// define-redefine
|
||||
@ -115,8 +118,9 @@ class HTMLPurifier_HTMLModuleManager
|
||||
$this->addModule($module);
|
||||
}
|
||||
|
||||
// the only editable internal object. The rest need to
|
||||
// be manipulated through modules
|
||||
$this->attrTypes = new HTMLPurifier_AttrTypes();
|
||||
$this->attrCollections = new HTMLPurifier_AttrCollections();
|
||||
|
||||
}
|
||||
|
||||
@ -200,7 +204,7 @@ class HTMLPurifier_HTMLModuleManager
|
||||
$this->contentSets = new HTMLPurifier_ContentSets(
|
||||
$this->getModules($config, true)
|
||||
);
|
||||
$this->attrCollections->setup($this->attrTypes,
|
||||
$this->attrCollections = new HTMLPurifier_AttrCollections($this->attrTypes,
|
||||
$this->getModules($config));
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user