1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* XHTML 1.1 Text Module, defines basic text containers. Core Module.
|
|
|
5 |
* @note In the normative XML Schema specification, this module
|
|
|
6 |
* is further abstracted into the following modules:
|
|
|
7 |
* - Block Phrasal (address, blockquote, pre, h1, h2, h3, h4, h5, h6)
|
|
|
8 |
* - Block Structural (div, p)
|
|
|
9 |
* - Inline Phrasal (abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var)
|
|
|
10 |
* - Inline Structural (br, span)
|
|
|
11 |
* This module, functionally, does not distinguish between these
|
|
|
12 |
* sub-modules, but the code is internally structured to reflect
|
|
|
13 |
* these distinctions.
|
|
|
14 |
*/
|
|
|
15 |
class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
|
|
|
16 |
{
|
|
|
17 |
/**
|
|
|
18 |
* @type string
|
|
|
19 |
*/
|
|
|
20 |
public $name = 'Text';
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* @type array
|
|
|
24 |
*/
|
|
|
25 |
public $content_sets = array(
|
|
|
26 |
'Flow' => 'Heading | Block | Inline'
|
|
|
27 |
);
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* @param HTMLPurifier_Config $config
|
|
|
31 |
*/
|
|
|
32 |
public function setup($config)
|
|
|
33 |
{
|
|
|
34 |
// Inline Phrasal -------------------------------------------------
|
|
|
35 |
$this->addElement('abbr', 'Inline', 'Inline', 'Common');
|
|
|
36 |
$this->addElement('acronym', 'Inline', 'Inline', 'Common');
|
|
|
37 |
$this->addElement('cite', 'Inline', 'Inline', 'Common');
|
|
|
38 |
$this->addElement('dfn', 'Inline', 'Inline', 'Common');
|
|
|
39 |
$this->addElement('kbd', 'Inline', 'Inline', 'Common');
|
|
|
40 |
$this->addElement('q', 'Inline', 'Inline', 'Common', array('cite' => 'URI'));
|
|
|
41 |
$this->addElement('samp', 'Inline', 'Inline', 'Common');
|
|
|
42 |
$this->addElement('var', 'Inline', 'Inline', 'Common');
|
|
|
43 |
|
|
|
44 |
$em = $this->addElement('em', 'Inline', 'Inline', 'Common');
|
|
|
45 |
$em->formatting = true;
|
|
|
46 |
|
|
|
47 |
$strong = $this->addElement('strong', 'Inline', 'Inline', 'Common');
|
|
|
48 |
$strong->formatting = true;
|
|
|
49 |
|
|
|
50 |
$code = $this->addElement('code', 'Inline', 'Inline', 'Common');
|
|
|
51 |
$code->formatting = true;
|
|
|
52 |
|
|
|
53 |
// Inline Structural ----------------------------------------------
|
|
|
54 |
$this->addElement('span', 'Inline', 'Inline', 'Common');
|
|
|
55 |
$this->addElement('br', 'Inline', 'Empty', 'Core');
|
|
|
56 |
|
|
|
57 |
// Block Phrasal --------------------------------------------------
|
|
|
58 |
$this->addElement('address', 'Block', 'Inline', 'Common');
|
|
|
59 |
$this->addElement('blockquote', 'Block', 'Optional: Heading | Block | List', 'Common', array('cite' => 'URI'));
|
|
|
60 |
$pre = $this->addElement('pre', 'Block', 'Inline', 'Common');
|
|
|
61 |
$pre->excludes = $this->makeLookup(
|
|
|
62 |
'img',
|
|
|
63 |
'big',
|
|
|
64 |
'small',
|
|
|
65 |
'object',
|
|
|
66 |
'applet',
|
|
|
67 |
'font',
|
|
|
68 |
'basefont'
|
|
|
69 |
);
|
|
|
70 |
$this->addElement('h1', 'Heading', 'Inline', 'Common');
|
|
|
71 |
$this->addElement('h2', 'Heading', 'Inline', 'Common');
|
|
|
72 |
$this->addElement('h3', 'Heading', 'Inline', 'Common');
|
|
|
73 |
$this->addElement('h4', 'Heading', 'Inline', 'Common');
|
|
|
74 |
$this->addElement('h5', 'Heading', 'Inline', 'Common');
|
|
|
75 |
$this->addElement('h6', 'Heading', 'Inline', 'Common');
|
|
|
76 |
|
|
|
77 |
// Block Structural -----------------------------------------------
|
|
|
78 |
$p = $this->addElement('p', 'Block', 'Inline', 'Common');
|
|
|
79 |
$p->autoclose = array_flip(
|
|
|
80 |
array("address", "blockquote", "center", "dir", "div", "dl", "fieldset", "ol", "p", "ul")
|
|
|
81 |
);
|
|
|
82 |
|
|
|
83 |
$this->addElement('div', 'Block', 'Flow', 'Common');
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
// vim: et sw=4 sts=4
|