1: <?php
2:
3: class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule_Tidy
4: {
5:
6: public function makeFixes() {
7:
8: $r = array();
9:
10:
11:
12: $r['font'] = new HTMLPurifier_TagTransform_Font();
13: $r['menu'] = new HTMLPurifier_TagTransform_Simple('ul');
14: $r['dir'] = new HTMLPurifier_TagTransform_Simple('ul');
15: $r['center'] = new HTMLPurifier_TagTransform_Simple('div', 'text-align:center;');
16: $r['u'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:underline;');
17: $r['s'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:line-through;');
18: $r['strike'] = new HTMLPurifier_TagTransform_Simple('span', 'text-decoration:line-through;');
19:
20:
21:
22: $r['caption@align'] =
23: new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
24:
25:
26:
27:
28: 'left' => 'text-align:left;',
29: 'right' => 'text-align:right;',
30: 'top' => 'caption-side:top;',
31: 'bottom' => 'caption-side:bottom;'
32: ));
33:
34:
35: $r['img@align'] =
36: new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
37: 'left' => 'float:left;',
38: 'right' => 'float:right;',
39: 'top' => 'vertical-align:top;',
40: 'middle' => 'vertical-align:middle;',
41: 'bottom' => 'vertical-align:baseline;',
42: ));
43:
44:
45: $r['table@align'] =
46: new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
47: 'left' => 'float:left;',
48: 'center' => 'margin-left:auto;margin-right:auto;',
49: 'right' => 'float:right;'
50: ));
51:
52:
53: $r['hr@align'] =
54: new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
55:
56:
57:
58:
59: 'left' => 'margin-left:0;margin-right:auto;text-align:left;',
60: 'center' => 'margin-left:auto;margin-right:auto;text-align:center;',
61: 'right' => 'margin-left:auto;margin-right:0;text-align:right;'
62: ));
63:
64:
65:
66: $align_lookup = array();
67: $align_values = array('left', 'right', 'center', 'justify');
68: foreach ($align_values as $v) $align_lookup[$v] = "text-align:$v;";
69:
70: $r['h1@align'] =
71: $r['h2@align'] =
72: $r['h3@align'] =
73: $r['h4@align'] =
74: $r['h5@align'] =
75: $r['h6@align'] =
76: $r['p@align'] =
77: $r['div@align'] =
78: new HTMLPurifier_AttrTransform_EnumToCSS('align', $align_lookup);
79:
80:
81: $r['table@bgcolor'] =
82: $r['td@bgcolor'] =
83: $r['th@bgcolor'] =
84: new HTMLPurifier_AttrTransform_BgColor();
85:
86:
87: $r['img@border'] = new HTMLPurifier_AttrTransform_Border();
88:
89:
90: $r['br@clear'] =
91: new HTMLPurifier_AttrTransform_EnumToCSS('clear', array(
92: 'left' => 'clear:left;',
93: 'right' => 'clear:right;',
94: 'all' => 'clear:both;',
95: 'none' => 'clear:none;',
96: ));
97:
98:
99: $r['td@height'] =
100: $r['th@height'] =
101: new HTMLPurifier_AttrTransform_Length('height');
102:
103:
104: $r['img@hspace'] = new HTMLPurifier_AttrTransform_ImgSpace('hspace');
105:
106:
107:
108:
109: $r['hr@noshade'] =
110: new HTMLPurifier_AttrTransform_BoolToCSS(
111: 'noshade',
112: 'color:#808080;background-color:#808080;border:0;'
113: );
114:
115:
116: $r['td@nowrap'] =
117: $r['th@nowrap'] =
118: new HTMLPurifier_AttrTransform_BoolToCSS(
119: 'nowrap',
120: 'white-space:nowrap;'
121: );
122:
123:
124: $r['hr@size'] = new HTMLPurifier_AttrTransform_Length('size', 'height');
125:
126:
127:
128: $ul_types = array(
129: 'disc' => 'list-style-type:disc;',
130: 'square' => 'list-style-type:square;',
131: 'circle' => 'list-style-type:circle;'
132: );
133: $ol_types = array(
134: '1' => 'list-style-type:decimal;',
135: 'i' => 'list-style-type:lower-roman;',
136: 'I' => 'list-style-type:upper-roman;',
137: 'a' => 'list-style-type:lower-alpha;',
138: 'A' => 'list-style-type:upper-alpha;'
139: );
140: $li_types = $ul_types + $ol_types;
141:
142:
143: $r['ul@type'] = new HTMLPurifier_AttrTransform_EnumToCSS('type', $ul_types);
144: $r['ol@type'] = new HTMLPurifier_AttrTransform_EnumToCSS('type', $ol_types, true);
145: $r['li@type'] = new HTMLPurifier_AttrTransform_EnumToCSS('type', $li_types, true);
146:
147:
148: $r['img@vspace'] = new HTMLPurifier_AttrTransform_ImgSpace('vspace');
149:
150:
151: $r['td@width'] =
152: $r['th@width'] =
153: $r['hr@width'] = new HTMLPurifier_AttrTransform_Length('width');
154:
155: return $r;
156:
157: }
158:
159: }
160:
161:
162: