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

0001 <?php
0002 
0003 /**
0004  * XHTML 1.1 Text Module, defines basic text containers. Core Module.
0005  * @note In the normative XML Schema specification, this module
0006  *       is further abstracted into the following modules:
0007  *          - Block Phrasal (address, blockquote, pre, h1, h2, h3, h4, h5, h6)
0008  *          - Block Structural (div, p)
0009  *          - Inline Phrasal (abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var)
0010  *          - Inline Structural (br, span)
0011  *       This module, functionally, does not distinguish between these
0012  *       sub-modules, but the code is internally structured to reflect
0013  *       these distinctions.
0014  */
0015 class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
0016 {
0017     /**
0018      * @type string
0019      */
0020     public $name = 'Text';
0021 
0022     /**
0023      * @type array
0024      */
0025     public $content_sets = array(
0026         'Flow' => 'Heading | Block | Inline'
0027     );
0028 
0029     /**
0030      * @param HTMLPurifier_Config $config
0031      */
0032     public function setup($config)
0033     {
0034         // Inline Phrasal -------------------------------------------------
0035         $this->addElement('abbr', 'Inline', 'Inline', 'Common');
0036         $this->addElement('acronym', 'Inline', 'Inline', 'Common');
0037         $this->addElement('cite', 'Inline', 'Inline', 'Common');
0038         $this->addElement('dfn', 'Inline', 'Inline', 'Common');
0039         $this->addElement('kbd', 'Inline', 'Inline', 'Common');
0040         $this->addElement('q', 'Inline', 'Inline', 'Common', array('cite' => 'URI'));
0041         $this->addElement('samp', 'Inline', 'Inline', 'Common');
0042         $this->addElement('var', 'Inline', 'Inline', 'Common');
0043 
0044         $em = $this->addElement('em', 'Inline', 'Inline', 'Common');
0045         $em->formatting = true;
0046 
0047         $strong = $this->addElement('strong', 'Inline', 'Inline', 'Common');
0048         $strong->formatting = true;
0049 
0050         $code = $this->addElement('code', 'Inline', 'Inline', 'Common');
0051         $code->formatting = true;
0052 
0053         // Inline Structural ----------------------------------------------
0054         $this->addElement('span', 'Inline', 'Inline', 'Common');
0055         $this->addElement('br', 'Inline', 'Empty', 'Core');
0056 
0057         // Block Phrasal --------------------------------------------------
0058         $this->addElement('address', 'Block', 'Inline', 'Common');
0059         $this->addElement('blockquote', 'Block', 'Optional: Heading | Block | List', 'Common', array('cite' => 'URI'));
0060         $pre = $this->addElement('pre', 'Block', 'Inline', 'Common');
0061         $pre->excludes = $this->makeLookup(
0062             'img',
0063             'big',
0064             'small',
0065             'object',
0066             'applet',
0067             'font',
0068             'basefont'
0069         );
0070         $this->addElement('h1', 'Heading', 'Inline', 'Common');
0071         $this->addElement('h2', 'Heading', 'Inline', 'Common');
0072         $this->addElement('h3', 'Heading', 'Inline', 'Common');
0073         $this->addElement('h4', 'Heading', 'Inline', 'Common');
0074         $this->addElement('h5', 'Heading', 'Inline', 'Common');
0075         $this->addElement('h6', 'Heading', 'Inline', 'Common');
0076 
0077         // Block Structural -----------------------------------------------
0078         $p = $this->addElement('p', 'Block', 'Inline', 'Common');
0079         $p->autoclose = array_flip(
0080             array("address", "blockquote", "center", "dir", "div", "dl", "fieldset", "ol", "p", "ul")
0081         );
0082 
0083         $this->addElement('div', 'Block', 'Flow', 'Common');
0084     }
0085 }
0086 
0087 // vim: et sw=4 sts=4