Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / HTMLModule / Text.php
blob6f81dcf389b9f2b6ea16be7d1aac88f57519ad6e
1 <?php
3 require_once 'HTMLPurifier/HTMLModule.php';
5 /**
6 * XHTML 1.1 Text Module, defines basic text containers. Core Module.
7 * @note In the normative XML Schema specification, this module
8 * is further abstracted into the following modules:
9 * - Block Phrasal (address, blockquote, pre, h1, h2, h3, h4, h5, h6)
10 * - Block Structural (div, p)
11 * - Inline Phrasal (abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var)
12 * - Inline Structural (br, span)
13 * We have elected not to follow suite, but this may change.
15 class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
18 var $name = 'Text';
20 var $elements = array('abbr', 'acronym', 'address', 'blockquote',
21 'br', 'cite', 'code', 'dfn', 'div', 'em', 'h1', 'h2', 'h3',
22 'h4', 'h5', 'h6', 'kbd', 'p', 'pre', 'q', 'samp', 'span', 'strong',
23 'var', 'nolink', 'tex', 'algebra'); //moodle modification
25 var $content_sets = array(
26 'Heading' => 'h1 | h2 | h3 | h4 | h5 | h6',
27 'Block' => 'address | blockquote | div | p | pre | nolink | tex | algebra', //moodle modification
28 'Inline' => 'abbr | acronym | br | cite | code | dfn | em | kbd | q | samp | span | strong | var',
29 'Flow' => 'Heading | Block | Inline'
32 function HTMLPurifier_HTMLModule_Text() {
33 foreach ($this->elements as $element) {
34 $this->info[$element] = new HTMLPurifier_ElementDef();
35 // attributes
36 if ($element == 'br') {
37 $this->info[$element]->attr = array(0 => array('Core'));
38 } elseif ($element == 'blockquote' || $element == 'q') {
39 $this->info[$element]->attr = array(0 => array('Common'), 'cite' => 'URI');
40 } else {
41 $this->info[$element]->attr = array(0 => array('Common'));
43 // content models
44 if ($element == 'br') {
45 $this->info[$element]->content_model_type = 'empty';
46 } elseif ($element == 'blockquote') {
47 $this->info[$element]->content_model = 'Heading | Block | List';
48 $this->info[$element]->content_model_type = 'optional';
49 } elseif ($element == 'div') {
50 $this->info[$element]->content_model = '#PCDATA | Flow';
51 $this->info[$element]->content_model_type = 'optional';
52 } else {
53 $this->info[$element]->content_model = '#PCDATA | Inline';
54 $this->info[$element]->content_model_type = 'optional';
57 // SGML permits exclusions for all descendants, but this is
58 // not possible with DTDs or XML Schemas. W3C has elected to
59 // use complicated compositions of content_models to simulate
60 // exclusion for children, but we go the simpler, SGML-style
61 // route of flat-out exclusions. Note that the Abstract Module
62 // is blithely unaware of such distinctions.
63 $this->info['pre']->excludes = array_flip(array(
64 'img', 'big', 'small',
65 'object', 'applet', 'font', 'basefont' // generally not allowed
66 ));
67 $this->info['p']->auto_close = array_flip(array(
68 'address', 'blockquote', 'dd', 'dir', 'div', 'dl', 'dt',
69 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'ol', 'p', 'pre',
70 'table', 'ul', 'nolink', 'tex', 'algebra' //moodle modification
71 ));