mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
Implement Style Attribute Module, cleanup some attribute collections and add some documentation.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@716 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
129a4ea506
commit
6478c7c2df
@ -12,6 +12,7 @@ class HTMLPurifier_AttrCollection
|
|||||||
|
|
||||||
var $info = array(
|
var $info = array(
|
||||||
'Core' => array(
|
'Core' => array(
|
||||||
|
0 => array('Style'),
|
||||||
// 'xml:space' => false,
|
// 'xml:space' => false,
|
||||||
'class' => 'NMTOKENS',
|
'class' => 'NMTOKENS',
|
||||||
'id' => 'ID',
|
'id' => 'ID',
|
||||||
@ -21,10 +22,8 @@ class HTMLPurifier_AttrCollection
|
|||||||
'xml:lang' => false, // see constructor
|
'xml:lang' => false, // see constructor
|
||||||
'lang' => false, // see constructor
|
'lang' => false, // see constructor
|
||||||
),
|
),
|
||||||
'Events' => array(),
|
|
||||||
'Style' => array(), // specifically empty
|
|
||||||
'Common' => array(
|
'Common' => array(
|
||||||
0 => array('Core', 'Events', 'I18N', 'Style')
|
0 => array('Core', 'I18N')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -39,6 +38,12 @@ class HTMLPurifier_AttrCollection
|
|||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
foreach ($module->attr_collection as $coll_i => $coll) {
|
foreach ($module->attr_collection as $coll_i => $coll) {
|
||||||
foreach ($coll as $attr_i => $attr) {
|
foreach ($coll as $attr_i => $attr) {
|
||||||
|
if ($attr_i === 0) {
|
||||||
|
// merge in includes
|
||||||
|
$info[$coll_i][$attr_i] = array_merge(
|
||||||
|
$info[$coll_i][$attr_i], $attr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$info[$coll_i][$attr_i] = $attr;
|
$info[$coll_i][$attr_i] = $attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@ class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule
|
|||||||
$this->info['bdo'] = new HTMLPurifier_ElementDef();
|
$this->info['bdo'] = new HTMLPurifier_ElementDef();
|
||||||
$this->info['bdo']->attr = array(
|
$this->info['bdo']->attr = array(
|
||||||
0 => array('Core'),
|
0 => array('Core'),
|
||||||
'dir' => $dir
|
'dir' => $dir, // required
|
||||||
|
'lang' => 'Lang',
|
||||||
|
'xml:lang' => 'Lang'
|
||||||
);
|
);
|
||||||
$this->info['bdo']->content_model = '#PCDATA | Inline';
|
$this->info['bdo']->content_model = '#PCDATA | Inline';
|
||||||
$this->info['bdo']->content_model_type = 'optional';
|
$this->info['bdo']->content_model_type = 'optional';
|
||||||
|
21
library/HTMLPurifier/HTMLModule/StyleAttribute.php
Normal file
21
library/HTMLPurifier/HTMLModule/StyleAttribute.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'HTMLPurifier/HTMLModule.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XHTML 1.1 Edit Module, defines editing-related elements. Text Extension Module.
|
||||||
|
*/
|
||||||
|
class HTMLPurifier_HTMLModule_StyleAttribute extends HTMLPurifier_HTMLModule
|
||||||
|
{
|
||||||
|
var $attr_collection = array(
|
||||||
|
'Style' => array('style' => false),
|
||||||
|
'Core' => array(0 => array('Style'))
|
||||||
|
);
|
||||||
|
|
||||||
|
function HTMLPurifier_HTMLModule_StyleAttribute() {
|
||||||
|
$this->attr_collection['Style']['style'] = new HTMLPurifier_AttrDef_CSS();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -4,6 +4,13 @@ require_once 'HTMLPurifier/HTMLModule.php';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* XHTML 1.1 Text Module, defines basic text containers. Core Module.
|
* XHTML 1.1 Text Module, defines basic text containers. Core Module.
|
||||||
|
* @note In the normative XML Schema specification, this module
|
||||||
|
* is further abstracted into the following modules:
|
||||||
|
* - Block Phrasal (address, blockquote, pre, h1, h2, h3, h4, h5, h6)
|
||||||
|
* - Block Structural (div, p)
|
||||||
|
* - Inline Phrasal (abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var)
|
||||||
|
* - Inline Structural (br, span)
|
||||||
|
* We have elected not to follow suite, but this may change.
|
||||||
*/
|
*/
|
||||||
class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
|
class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,7 @@ require_once 'HTMLPurifier/HTMLModule/Edit.php';
|
|||||||
require_once 'HTMLPurifier/HTMLModule/Bdo.php';
|
require_once 'HTMLPurifier/HTMLModule/Bdo.php';
|
||||||
require_once 'HTMLPurifier/HTMLModule/Tables.php';
|
require_once 'HTMLPurifier/HTMLModule/Tables.php';
|
||||||
require_once 'HTMLPurifier/HTMLModule/Image.php';
|
require_once 'HTMLPurifier/HTMLModule/Image.php';
|
||||||
|
require_once 'HTMLPurifier/HTMLModule/StyleAttribute.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next-generation HTML definition that will supplant HTMLPurifier_HTMLDefinition
|
* Next-generation HTML definition that will supplant HTMLPurifier_HTMLDefinition
|
||||||
@ -36,6 +37,7 @@ class HTMLPurifier_XHTMLDefinition extends HTMLPurifier_HTMLDefinition
|
|||||||
$this->modules['Bdo'] = new HTMLPurifier_HTMLModule_Bdo();
|
$this->modules['Bdo'] = new HTMLPurifier_HTMLModule_Bdo();
|
||||||
$this->modules['Tables'] = new HTMLPurifier_HTMLModule_Tables();
|
$this->modules['Tables'] = new HTMLPurifier_HTMLModule_Tables();
|
||||||
$this->modules['Image'] = new HTMLPurifier_HTMLModule_Image();
|
$this->modules['Image'] = new HTMLPurifier_HTMLModule_Image();
|
||||||
|
$this->modules['StyleAttribute']= new HTMLPurifier_HTMLModule_StyleAttribute();
|
||||||
|
|
||||||
$this->attr_types = new HTMLPurifier_AttrTypes();
|
$this->attr_types = new HTMLPurifier_AttrTypes();
|
||||||
$this->attr_collection = new HTMLPurifier_AttrCollection();
|
$this->attr_collection = new HTMLPurifier_AttrCollection();
|
||||||
|
Loading…
Reference in New Issue
Block a user