File indexing completed on 2024-05-12 06:02:05

0001 <?php
0002 
0003 /**
0004  * XHTML 1.1 Edit Module, defines editing-related elements. Text Extension
0005  * Module.
0006  */
0007 class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule
0008 {
0009 
0010     /**
0011      * @type string
0012      */
0013     public $name = 'Edit';
0014 
0015     /**
0016      * @param HTMLPurifier_Config $config
0017      */
0018     public function setup($config)
0019     {
0020         $contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow';
0021         $attr = array(
0022             'cite' => 'URI',
0023             // 'datetime' => 'Datetime', // not implemented
0024         );
0025         $this->addElement('del', 'Inline', $contents, 'Common', $attr);
0026         $this->addElement('ins', 'Inline', $contents, 'Common', $attr);
0027     }
0028 
0029     // HTML 4.01 specifies that ins/del must not contain block
0030     // elements when used in an inline context, chameleon is
0031     // a complicated workaround to acheive this effect
0032 
0033     // Inline context ! Block context (exclamation mark is
0034     // separator, see getChildDef for parsing)
0035 
0036     /**
0037      * @type bool
0038      */
0039     public $defines_child_def = true;
0040 
0041     /**
0042      * @param HTMLPurifier_ElementDef $def
0043      * @return HTMLPurifier_ChildDef_Chameleon
0044      */
0045     public function getChildDef($def)
0046     {
0047         if ($def->content_model_type != 'chameleon') {
0048             return false;
0049         }
0050         $value = explode('!', $def->content_model);
0051         return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]);
0052     }
0053 }
0054 
0055 // vim: et sw=4 sts=4