mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-02 12:21:09 +02:00
Add preProcess and postProcess infrastructure to HTMLModule and HTMLDefinition so that almost all functionality that does not involve merging the modules together can be factored into modules.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@733 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -305,6 +305,9 @@ class HTMLPurifier_HTMLDefinition
|
|||||||
$this->info_content_sets = $this->content_sets->lookup;
|
$this->info_content_sets = $this->content_sets->lookup;
|
||||||
|
|
||||||
foreach ($this->modules as $module_i => $module) {
|
foreach ($this->modules as $module_i => $module) {
|
||||||
|
|
||||||
|
$module->preProcess($this, $config);
|
||||||
|
|
||||||
// process element-wise definitions
|
// process element-wise definitions
|
||||||
foreach ($module->info as $name => $def) {
|
foreach ($module->info as $name => $def) {
|
||||||
// setup info
|
// setup info
|
||||||
@@ -348,6 +351,9 @@ class HTMLPurifier_HTMLDefinition
|
|||||||
foreach($module->info_tag_transform as $k => $v) $this->info_tag_transform[$k] = $v;
|
foreach($module->info_tag_transform as $k => $v) $this->info_tag_transform[$k] = $v;
|
||||||
foreach($module->info_attr_transform_pre as $k => $v) $this->info_attr_transform_pre[$k] = $v;
|
foreach($module->info_attr_transform_pre as $k => $v) $this->info_attr_transform_pre[$k] = $v;
|
||||||
foreach($module->info_attr_transform_post as $k => $v) $this->info_attr_transform_post[$k]= $v;
|
foreach($module->info_attr_transform_post as $k => $v) $this->info_attr_transform_post[$k]= $v;
|
||||||
|
|
||||||
|
$module->postProcess($this, $config);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -91,6 +91,22 @@ class HTMLPurifier_HTMLModule
|
|||||||
*/
|
*/
|
||||||
function getChildDef($def) {return false;}
|
function getChildDef($def) {return false;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook method that lets module perform arbitrary operations on
|
||||||
|
* HTMLPurifier_HTMLDefinition before the module gets processed.
|
||||||
|
* @param $definition Reference to HTMLDefinition being setup
|
||||||
|
* @param $config Instance of HTMLPurifier_Config
|
||||||
|
*/
|
||||||
|
function preProcess(&$definition, $config) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook method that lets module perform arbitrary operations
|
||||||
|
* on HTMLPurifier_HTMLDefinition after the module gets processed.
|
||||||
|
* @param $definition Reference to HTMLDefinition being setup
|
||||||
|
* @param $config Instance of HTMLPurifier_Config
|
||||||
|
*/
|
||||||
|
function postProcess(&$definition, $config) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -5,7 +5,9 @@
|
|||||||
* deprecated.
|
* deprecated.
|
||||||
*
|
*
|
||||||
* @note Not all legacy elements have been implemented yet, which
|
* @note Not all legacy elements have been implemented yet, which
|
||||||
* is a bit of a reverse problem as compared to browsers!
|
* is a bit of a reverse problem as compared to browsers! In
|
||||||
|
* addition, this legacy module may implement a bit more than
|
||||||
|
* mandated by XHTML 1.1.
|
||||||
*
|
*
|
||||||
* This module can be used in combination with TransformToStrict in order
|
* This module can be used in combination with TransformToStrict in order
|
||||||
* to transform as many deprecated elements as possible, but retain
|
* to transform as many deprecated elements as possible, but retain
|
||||||
|
@@ -27,6 +27,10 @@ class HTMLPurifier_HTMLModule_TransformToStrict extends HTMLPurifier_HTMLModule
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var $info_attr_transform_post = array(
|
||||||
|
'lang' => false // placeholder
|
||||||
|
);
|
||||||
|
|
||||||
function HTMLPurifier_HTMLModule_TransformToStrict($config) {
|
function HTMLPurifier_HTMLModule_TransformToStrict($config) {
|
||||||
// deprecated tag transforms
|
// deprecated tag transforms
|
||||||
$this->info_tag_transform['font'] = new HTMLPurifier_TagTransform_Font();
|
$this->info_tag_transform['font'] = new HTMLPurifier_TagTransform_Font();
|
||||||
|
@@ -14,7 +14,15 @@
|
|||||||
class HTMLPurifier_HTMLModule_TransformToXHTML11 extends HTMLPurifier_HTMLModule
|
class HTMLPurifier_HTMLModule_TransformToXHTML11 extends HTMLPurifier_HTMLModule
|
||||||
{
|
{
|
||||||
|
|
||||||
// unimplemented
|
var $attr_collections = array(
|
||||||
|
'Lang' => array(
|
||||||
|
'lang' => false // remove it
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
var $info_attr_transform_post = array(
|
||||||
|
'lang' => false // remove it
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user