~ubuntu-branches/ubuntu/natty/moodle/natty

« back to all changes in this revision

Viewing changes to lib/htmlpurifier/HTMLPurifier/HTMLModule/Legacy.php

  • Committer: Bazaar Package Importer
  • Author(s): Tomasz Muras
  • Date: 2010-10-30 12:19:28 UTC
  • mfrom: (1.1.12 upstream) (3.1.10 squeeze)
  • Revision ID: james.westby@ubuntu.com-20101030121928-qzobi6mctpnk4dif
Tags: 1.9.9.dfsg2-2
* Added Romanian translation
* Updated Japanese translation (closes: #596820)
* Backporting security fixes from Moodle 1.9.10 (closes: #601384)
   - Updated embedded CAS to 1.1.3
   - Added patch for MDL-24523:
     clean_text() not filtering text in markdown format
   - Added patch for MDL-24810 and upgraded customized HTML Purifier to 4.2.0 
   - Added patch for MDL-24258:
     students can delete their forum posts later than $CFG->maxeditingtime 
     under certain conditions
   - Added patch for MDL-23377:
     Can't delete quiz attempts in course without enrolled students

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
 
3
 
require_once 'HTMLPurifier/AttrDef/HTML/Bool.php';
4
 
 
5
3
/**
6
 
 * XHTML 1.1 Legacy module defines elements that were previously 
 
4
 * XHTML 1.1 Legacy module defines elements that were previously
7
5
 * deprecated.
8
 
 * 
 
6
 *
9
7
 * @note Not all legacy elements have been implemented yet, which
10
8
 *       is a bit of a reverse problem as compared to browsers! In
11
9
 *       addition, this legacy module may implement a bit more than
12
10
 *       mandated by XHTML 1.1.
13
 
 * 
 
11
 *
14
12
 * This module can be used in combination with TransformToStrict in order
15
13
 * to transform as many deprecated elements as possible, but retain
16
14
 * questionably deprecated elements that do not have good alternatives
20
18
 
21
19
class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
22
20
{
23
 
    
24
 
    // incomplete
25
 
    
26
 
    var $name = 'Legacy';
27
 
    
28
 
    function setup($config) {
29
 
        
30
 
        $this->addElement('basefont', true, 'Inline', 'Empty', false, array(
 
21
 
 
22
    public $name = 'Legacy';
 
23
 
 
24
    public function setup($config) {
 
25
 
 
26
        $this->addElement('basefont', 'Inline', 'Empty', false, array(
31
27
            'color' => 'Color',
32
28
            'face' => 'Text', // extremely broad, we should
33
29
            'size' => 'Text', // tighten it
34
30
            'id' => 'ID'
35
31
        ));
36
 
        $this->addElement('center', true, 'Block', 'Flow', 'Common');
37
 
        $this->addElement('dir', true, 'Block', 'Required: li', 'Common', array(
 
32
        $this->addElement('center', 'Block', 'Flow', 'Common');
 
33
        $this->addElement('dir', 'Block', 'Required: li', 'Common', array(
38
34
            'compact' => 'Bool#compact'
39
35
        ));
40
 
        $this->addElement('font', true, 'Inline', 'Inline', array('Core', 'I18N'), array(
 
36
        $this->addElement('font', 'Inline', 'Inline', array('Core', 'I18N'), array(
41
37
            'color' => 'Color',
42
38
            'face' => 'Text', // extremely broad, we should
43
39
            'size' => 'Text', // tighten it
44
40
        ));
45
 
        $this->addElement('menu', true, 'Block', 'Required: li', 'Common', array(
 
41
        $this->addElement('menu', 'Block', 'Required: li', 'Common', array(
46
42
            'compact' => 'Bool#compact'
47
43
        ));
48
 
        $this->addElement('s', true, 'Inline', 'Inline', 'Common');
49
 
        $this->addElement('strike', true, 'Inline', 'Inline', 'Common');
50
 
        $this->addElement('u', true, 'Inline', 'Inline', 'Common');
51
 
        
 
44
 
 
45
        $s = $this->addElement('s', 'Inline', 'Inline', 'Common');
 
46
        $s->formatting = true;
 
47
 
 
48
        $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common');
 
49
        $strike->formatting = true;
 
50
 
 
51
        $u = $this->addElement('u', 'Inline', 'Inline', 'Common');
 
52
        $u->formatting = true;
 
53
 
52
54
        // setup modifications to old elements
53
 
        
 
55
 
54
56
        $align = 'Enum#left,right,center,justify';
55
 
        
56
 
        $address =& $this->addBlankElement('address');
 
57
 
 
58
        $address = $this->addBlankElement('address');
57
59
        $address->content_model = 'Inline | #PCDATA | p';
58
60
        $address->content_model_type = 'optional';
59
61
        $address->child = false;
60
 
        
61
 
        $blockquote =& $this->addBlankElement('blockquote');
 
62
 
 
63
        $blockquote = $this->addBlankElement('blockquote');
62
64
        $blockquote->content_model = 'Flow | #PCDATA';
63
65
        $blockquote->content_model_type = 'optional';
64
66
        $blockquote->child = false;
65
 
        
66
 
        $br =& $this->addBlankElement('br');
 
67
 
 
68
        $br = $this->addBlankElement('br');
67
69
        $br->attr['clear'] = 'Enum#left,all,right,none';
68
 
        
69
 
        $caption =& $this->addBlankElement('caption');
 
70
 
 
71
        $caption = $this->addBlankElement('caption');
70
72
        $caption->attr['align'] = 'Enum#top,bottom,left,right';
71
 
        
72
 
        $div =& $this->addBlankElement('div');
 
73
 
 
74
        $div = $this->addBlankElement('div');
73
75
        $div->attr['align'] = $align;
74
 
        
75
 
        $dl =& $this->addBlankElement('dl');
 
76
 
 
77
        $dl = $this->addBlankElement('dl');
76
78
        $dl->attr['compact'] = 'Bool#compact';
77
 
        
 
79
 
78
80
        for ($i = 1; $i <= 6; $i++) {
79
 
            $h =& $this->addBlankElement("h$i");
 
81
            $h = $this->addBlankElement("h$i");
80
82
            $h->attr['align'] = $align;
81
83
        }
82
 
        
83
 
        $hr =& $this->addBlankElement('hr');
 
84
 
 
85
        $hr = $this->addBlankElement('hr');
84
86
        $hr->attr['align'] = $align;
85
87
        $hr->attr['noshade'] = 'Bool#noshade';
86
88
        $hr->attr['size'] = 'Pixels';
87
89
        $hr->attr['width'] = 'Length';
88
 
        
89
 
        $img =& $this->addBlankElement('img');
 
90
 
 
91
        $img = $this->addBlankElement('img');
90
92
        $img->attr['align'] = 'Enum#top,middle,bottom,left,right';
91
93
        $img->attr['border'] = 'Pixels';
92
94
        $img->attr['hspace'] = 'Pixels';
93
95
        $img->attr['vspace'] = 'Pixels';
94
 
        
 
96
 
95
97
        // figure out this integer business
96
 
        
97
 
        $li =& $this->addBlankElement('li');
 
98
 
 
99
        $li = $this->addBlankElement('li');
98
100
        $li->attr['value'] = new HTMLPurifier_AttrDef_Integer();
99
101
        $li->attr['type']  = 'Enum#s:1,i,I,a,A,disc,square,circle';
100
 
        
101
 
        $ol =& $this->addBlankElement('ol');
 
102
 
 
103
        $ol = $this->addBlankElement('ol');
102
104
        $ol->attr['compact'] = 'Bool#compact';
103
105
        $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
104
106
        $ol->attr['type'] = 'Enum#s:1,i,I,a,A';
105
 
        
106
 
        $p =& $this->addBlankElement('p');
 
107
 
 
108
        $p = $this->addBlankElement('p');
107
109
        $p->attr['align'] = $align;
108
 
        
109
 
        $pre =& $this->addBlankElement('pre');
 
110
 
 
111
        $pre = $this->addBlankElement('pre');
110
112
        $pre->attr['width'] = 'Number';
111
 
        
 
113
 
112
114
        // script omitted
113
 
        
114
 
        $table =& $this->addBlankElement('table');
 
115
 
 
116
        $table = $this->addBlankElement('table');
115
117
        $table->attr['align'] = 'Enum#left,center,right';
116
118
        $table->attr['bgcolor'] = 'Color';
117
 
        
118
 
        $tr =& $this->addBlankElement('tr');
 
119
 
 
120
        $tr = $this->addBlankElement('tr');
119
121
        $tr->attr['bgcolor'] = 'Color';
120
 
        
121
 
        $th =& $this->addBlankElement('th');
 
122
 
 
123
        $th = $this->addBlankElement('th');
122
124
        $th->attr['bgcolor'] = 'Color';
123
125
        $th->attr['height'] = 'Length';
124
126
        $th->attr['nowrap'] = 'Bool#nowrap';
125
127
        $th->attr['width'] = 'Length';
126
 
        
127
 
        $td =& $this->addBlankElement('td');
 
128
 
 
129
        $td = $this->addBlankElement('td');
128
130
        $td->attr['bgcolor'] = 'Color';
129
131
        $td->attr['height'] = 'Length';
130
132
        $td->attr['nowrap'] = 'Bool#nowrap';
131
133
        $td->attr['width'] = 'Length';
132
 
        
133
 
        $ul =& $this->addBlankElement('ul');
 
134
 
 
135
        $ul = $this->addBlankElement('ul');
134
136
        $ul->attr['compact'] = 'Bool#compact';
135
137
        $ul->attr['type'] = 'Enum#square,disc,circle';
136
 
        
 
138
 
137
139
    }
138
 
    
 
140
 
139
141
}
140
142
 
 
143
// vim: et sw=4 sts=4