3 require_once 'HTMLPurifier/HTMLModule.php';
4 require_once 'HTMLPurifier/AttrTransform/BdoDir.php';
7 * XHTML 1.1 Bi-directional Text Module, defines elements that
8 * declare directionality of content. Text Extension Module.
10 class HTMLPurifier_HTMLModule_Bdo
extends HTMLPurifier_HTMLModule
14 var $elements = array('bdo');
15 var $content_sets = array('Inline' => 'bdo');
16 var $attr_collections = array(
17 'I18N' => array('dir' => false)
20 function HTMLPurifier_HTMLModule_Bdo() {
21 $dir = new HTMLPurifier_AttrDef_Enum(array('ltr','rtl'), false);
22 $this->attr_collections
['I18N']['dir'] = $dir;
23 $this->info
['bdo'] = new HTMLPurifier_ElementDef();
24 $this->info
['bdo']->attr
= array(
25 0 => array('Core', 'Lang'),
26 'dir' => $dir, // required
27 // The Abstract Module specification has the attribute
28 // inclusions wrong for bdo: bdo allows
29 // xml:lang too (and we'll toss in lang for good measure,
30 // though it is not allowed for XHTML 1.1, this will
31 // be managed with a global attribute transform)
33 $this->info
['bdo']->content_model
= '#PCDATA | Inline';
34 $this->info
['bdo']->content_model_type
= 'optional';
35 // provides fallback behavior if dir's missing (dir is required)
36 $this->info
['bdo']->attr_transform_post
['required-dir'] =
37 new HTMLPurifier_AttrTransform_BdoDir();