mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-10 01:06:20 +02:00
[1.7.0] New compact syntax for AttrDef objects that can be used to instantiate new objects via make()
- Implemented make() for Enum and Bool - Migrate classes over to this new syntax - Add AttrDef_HTML_Bool unit test git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1088 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@ -16,21 +16,17 @@ class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule
|
||||
);
|
||||
|
||||
function HTMLPurifier_HTMLModule_Bdo() {
|
||||
$dir = new HTMLPurifier_AttrDef_Enum(array('ltr','rtl'), false);
|
||||
$bdo =& $this->addElement(
|
||||
'bdo', true, 'Inline', 'Inline', array('Core', 'Lang'),
|
||||
array(
|
||||
'dir' => $dir, // required
|
||||
'dir' => 'Enum#ltr,rtl', // required
|
||||
// The Abstract Module specification has the attribute
|
||||
// inclusions wrong for bdo: bdo allows
|
||||
// xml:lang too (and we'll toss in lang for good measure,
|
||||
// though it is not allowed for XHTML 1.1, this will
|
||||
// be managed with a global attribute transform)
|
||||
// inclusions wrong for bdo: bdo allows Lang
|
||||
)
|
||||
);
|
||||
$bdo->attr_transform_post['required-dir'] = new HTMLPurifier_AttrTransform_BdoDir();
|
||||
|
||||
$this->attr_collections['I18N']['dir'] = $dir;
|
||||
$this->attr_collections['I18N']['dir'] = 'Enum#ltr,rtl';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
));
|
||||
$this->addElement('center', true, 'Block', 'Flow', 'Common');
|
||||
$this->addElement('dir', true, 'Block', 'Required: li', 'Common', array(
|
||||
'compact' => new HTMLPurifier_AttrDef_HTML_Bool('compact')
|
||||
'compact' => 'Bool#compact'
|
||||
));
|
||||
$this->addElement('font', true, 'Inline', 'Inline', array('Core', 'I18N'), array(
|
||||
'color' => 'Color',
|
||||
@ -43,7 +43,7 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
'size' => 'Text', // tighten it
|
||||
));
|
||||
$this->addElement('menu', true, 'Block', 'Required: li', 'Common', array(
|
||||
'compact' => new HTMLPurifier_AttrDef_HTML_Bool('compact')
|
||||
'compact' => 'Bool#compact'
|
||||
));
|
||||
$this->addElement('s', true, 'Inline', 'Inline', 'Common');
|
||||
$this->addElement('strike', true, 'Inline', 'Inline', 'Common');
|
||||
@ -57,7 +57,7 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
$ol =& $this->addBlankElement('ol');
|
||||
$ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
|
||||
|
||||
$align = new HTMLPurifier_AttrDef_Enum(array('left', 'right', 'center', 'justify'));
|
||||
$align = 'Enum#left,right,center,justify';
|
||||
|
||||
$address =& $this->addBlankElement('address');
|
||||
$address->content_model = 'Inline | #PCDATA | p';
|
||||
@ -70,15 +70,16 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
|
||||
$blockquote->child = false;
|
||||
|
||||
$br =& $this->addBlankElement('br');
|
||||
$br->attr['clear'] = new HTMLPurifier_AttrDef_Enum(array('left', 'all', 'right', 'none'));
|
||||
$br->attr['clear'] = 'Enum#left,all,right,none';
|
||||
|
||||
$caption =& $this->addBlankElement('caption');
|
||||
$caption->attr['align'] = new HTMLPurifier_AttrDef_Enum(array('top', 'bottom', 'left', 'right'));
|
||||
$caption->attr['align'] = 'Enum#top,bottom,left,right';
|
||||
|
||||
$div =& $this->addBlankElement('div');
|
||||
$div->attr['align'] = $align;
|
||||
|
||||
// dl.compact omitted
|
||||
$dl =& $this->addBlankElement('dl');
|
||||
$dl->attr['compact'] = 'Bool#compact';
|
||||
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
$h =& $this->addBlankElement("h$i");
|
||||
|
@ -46,6 +46,9 @@ class HTMLPurifier_HTMLModule_Scripting extends HTMLPurifier_HTMLModule
|
||||
// blockquote's custom definition (we would use it but
|
||||
// blockquote's contents are optional while noscript's contents
|
||||
// are required)
|
||||
|
||||
// TODO: convert this to new syntax, main problem is getting
|
||||
// both content sets working
|
||||
foreach ($this->elements as $element) {
|
||||
$this->info[$element] = new HTMLPurifier_ElementDef();
|
||||
$this->info[$element]->safe = false;
|
||||
|
@ -21,13 +21,8 @@ class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule
|
||||
'border' => 'Pixels',
|
||||
'cellpadding' => 'Length',
|
||||
'cellspacing' => 'Length',
|
||||
'frame' => new HTMLPurifier_AttrDef_Enum(array(
|
||||
'void', 'above', 'below', 'hsides', 'lhs', 'rhs',
|
||||
'vsides', 'box', 'border'
|
||||
), false),
|
||||
'rules' => new HTMLPurifier_AttrDef_Enum(array(
|
||||
'none', 'groups', 'rows', 'cols', 'all'
|
||||
), false),
|
||||
'frame' => 'Enum#void,above,below,hsides,lhs,rhs,vsides,box,border',
|
||||
'rules' => 'Enum#none,groups,rows,cols,all',
|
||||
'summary' => 'Text',
|
||||
'width' => 'Length'
|
||||
)
|
||||
@ -35,13 +30,9 @@ class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule
|
||||
|
||||
// common attributes
|
||||
$cell_align = array(
|
||||
'align' => new HTMLPurifier_AttrDef_Enum(array(
|
||||
'left', 'center', 'right', 'justify', 'char'
|
||||
), false),
|
||||
'align' => 'Enum#left,center,right,justify,char',
|
||||
'charoff' => 'Length',
|
||||
'valign' => new HTMLPurifier_AttrDef_Enum(array(
|
||||
'top', 'middle', 'bottom', 'baseline'
|
||||
), false),
|
||||
'valign' => 'Enum#top,middle,bottom,baseline',
|
||||
);
|
||||
|
||||
$cell_t = array_merge(
|
||||
|
Reference in New Issue
Block a user