mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-09 16:56:20 +02:00
[1.7.0] Implement addAttribute() of advanced API.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1164 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@ -204,6 +204,27 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
|
||||
|
||||
|
||||
|
||||
// RAW CUSTOMIZATION STUFF --------------------------------------------
|
||||
|
||||
/**
|
||||
* Adds a custom attribute to a pre-existing element
|
||||
*/
|
||||
function addAttribute($element_name, $attr_name, $def) {
|
||||
$module =& $this->getAnonymousModule();
|
||||
$element =& $module->addBlankElement($element_name);
|
||||
$element->attr[$attr_name] = $def;
|
||||
}
|
||||
|
||||
var $_anonModule;
|
||||
|
||||
function &getAnonymousModule() {
|
||||
if (!$this->_anonModule) {
|
||||
$this->_anonModule = new HTMLPurifier_HTMLModule();
|
||||
$this->_anonModule->name = 'Anonymous';
|
||||
}
|
||||
return $this->_anonModule;
|
||||
}
|
||||
|
||||
|
||||
// PUBLIC BUT INTERNAL VARIABLES --------------------------------------
|
||||
|
||||
@ -234,6 +255,14 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
|
||||
*/
|
||||
function processModules($config) {
|
||||
|
||||
if ($this->_anonModule) {
|
||||
// for user specific changes
|
||||
// this is late-loaded so we don't have to deal with PHP4
|
||||
// reference wonky-ness
|
||||
$this->manager->addModule($this->_anonModule);
|
||||
unset($this->_anonModule);
|
||||
}
|
||||
|
||||
$this->manager->setup($config);
|
||||
$this->doctype = $this->manager->doctype;
|
||||
|
||||
|
Reference in New Issue
Block a user