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