]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/HtmlElement.php
Added caption, thead, tbody table elements.
[SourceForge/phpwiki.git] / lib / HtmlElement.php
1 <?php rcs_id('$Id: HtmlElement.php,v 1.3 2002-01-21 16:51:12 carstenklapp Exp $');
2 /*
3  * Code for writing XML.
4  */
5 require_once("lib/XmlElement.php");
6 /**
7  * An XML element.
8  */
9
10 class HtmlElement extends XmlElement
11 {
12     function printXML () {
13         if (!$this->_content) {
14             if (HTML::isEmptyTag($this->getTag())) {
15                 echo "<" . $this->_startTag() . " />";
16                 return;
17             }
18             $this->pushContent('');
19         }
20         XmlElement::printXML();
21     }
22 };
23
24 class HTML {
25     function raw ($html_text) {
26         return new RawXML($html_text);
27     }
28
29
30     function link (/*...*/) {
31         $el = new HtmlElement('link');
32         $el->_init(func_get_args());
33         return $el;
34     }
35
36     function style (/*...*/) {
37         $el = new HtmlElement('style');
38         $el->_init(func_get_args());
39         return $el;
40     }
41
42     function script (/*...*/) {
43         $el = new HtmlElement('script');
44         $el->_init(func_get_args());
45         return $el;
46     }
47
48     function noscript (/*...*/) {
49         $el = new HtmlElement('noscript');
50         $el->_init(func_get_args());
51         return $el;
52     }
53
54     
55     function a (/*...*/) {
56         $el = new HtmlElement('a');
57         $el->_init(func_get_args());
58         return $el;
59     }
60
61     function img (/*...*/) {
62         $el = new HtmlElement('img');
63         $el->_init(func_get_args());
64         return $el;
65     }
66
67     function h1 (/*...*/) {
68         $el = new HtmlElement('h1');
69         $el->_init(func_get_args());
70         return $el;
71     }
72
73     function h1 (/*...*/) {
74         $el = new HtmlElement('h1');
75         $el->_init(func_get_args());
76         return $el;
77     }
78
79     function h2 (/*...*/) {
80         $el = new HtmlElement('h2');
81         $el->_init(func_get_args());
82         return $el;
83     }
84
85     function h3 (/*...*/) {
86         $el = new HtmlElement('h3');
87         $el->_init(func_get_args());
88         return $el;
89     }
90
91     function h4 (/*...*/) {
92         $el = new HtmlElement('h4');
93         $el->_init(func_get_args());
94         return $el;
95     }
96
97     function h5 (/*...*/) {
98         $el = new HtmlElement('h5');
99         $el->_init(func_get_args());
100         return $el;
101     }
102
103     function h6 (/*...*/) {
104         $el = new HtmlElement('h6');
105         $el->_init(func_get_args());
106         return $el;
107     }
108
109     function div (/*...*/) {
110         $el = new HtmlElement('div');
111         $el->_init(func_get_args());
112         return $el;
113     }
114
115     function p (/*...*/) {
116         $el = new HtmlElement('p');
117         $el->_init(func_get_args());
118         return $el;
119     }
120
121     function blockquote (/*...*/) {
122         $el = new HtmlElement('blockquote');
123         $el->_init(func_get_args());
124         return $el;
125     }
126
127     function span (/*...*/) {
128         $el = new HtmlElement('span');
129         $el->_init(func_get_args());
130         return $el;
131     }
132
133     function em (/*...*/) {
134         $el = new HtmlElement('em');
135         $el->_init(func_get_args());
136         return $el;
137     }
138
139     function strong (/*...*/) {
140         $el = new HtmlElement('strong');
141         $el->_init(func_get_args());
142         return $el;
143     }
144     
145     function small (/*...*/) {
146         $el = new HtmlElement('small');
147         $el->_init(func_get_args());
148         return $el;
149     }
150     
151     function tt (/*...*/) {
152         $el = new HtmlElement('tt');
153         $el->_init(func_get_args());
154         return $el;
155     }
156
157     function u (/*...*/) {
158         $el = new HtmlElement('u');
159         $el->_init(func_get_args());
160         return $el;
161     }
162
163     function ul (/*...*/) {
164         $el = new HtmlElement('ul');
165         $el->_init(func_get_args());
166         return $el;
167     }
168
169     function ol (/*...*/) {
170         $el = new HtmlElement('ol');
171         $el->_init(func_get_args());
172         return $el;
173     }
174
175     function dl (/*...*/) {
176         $el = new HtmlElement('dl');
177         $el->_init(func_get_args());
178         return $el;
179     }
180
181     function li (/*...*/) {
182         $el = new HtmlElement('li');
183         $el->_init(func_get_args());
184         return $el;
185     }
186
187     function dt (/*...*/) {
188         $el = new HtmlElement('dt');
189         $el->_init(func_get_args());
190         return $el;
191     }
192
193     function dd (/*...*/) {
194         $el = new HtmlElement('dd');
195         $el->_init(func_get_args());
196         return $el;
197     }
198
199     function table (/*...*/) {
200         $el = new HtmlElement('table');
201         $el->_init(func_get_args());
202         return $el;
203     }
204
205     function caption (/*...*/) {
206         $el = new HtmlElement('caption');
207         $el->_init(func_get_args());
208         return $el;
209     }
210
211     function thead (/*...*/) {
212         $el = new HtmlElement('thead');
213         $el->_init(func_get_args());
214         return $el;
215     }
216
217     function tbody (/*...*/) {
218         $el = new HtmlElement('tbody');
219         $el->_init(func_get_args());
220         return $el;
221     }
222
223     function tr (/*...*/) {
224         $el = new HtmlElement('tr');
225         $el->_init(func_get_args());
226         return $el;
227     }
228
229     function td (/*...*/) {
230         $el = new HtmlElement('td');
231         $el->_init(func_get_args());
232         return $el;
233     }
234
235     function th (/*...*/) {
236         $el = new HtmlElement('th');
237         $el->_init(func_get_args());
238         return $el;
239     }
240
241     function form (/*...*/) {
242         $el = new HtmlElement('form');
243         $el->_init(func_get_args());
244         return $el;
245     }
246
247     function input (/*...*/) {
248         $el = new HtmlElement('input');
249         $el->_init(func_get_args());
250         return $el;
251     }
252
253     function isEmptyTag($tag) {
254         global $HTML_TagProperties;
255         if (!isset($HTML_TagProperties[$tag]))
256             return false;
257         $props = $HTML_TagProperties[$tag];
258         return ($props & HTMLTAG_EMPTY) != 0;
259     }
260 }
261
262 define('HTMLTAG_EMPTY', 1);
263
264 $GLOBALS['HTML_TagProperties']
265 = array('area' => HTMLTAG_EMPTY,
266         'base' => HTMLTAG_EMPTY,
267         'basefont' => HTMLTAG_EMPTY,
268         'br' => HTMLTAG_EMPTY,
269         'col' => HTMLTAG_EMPTY,
270         'frame' => HTMLTAG_EMPTY,
271         'hr' => HTMLTAG_EMPTY,
272         'img' => HTMLTAG_EMPTY,
273         'input' => HTMLTAG_EMPTY,
274         'isindex' => HTMLTAG_EMPTY,
275         'link' => HTMLTAG_EMPTY,
276         'meta' => HTMLTAG_EMPTY,
277         'param' => HTMLTAG_EMPTY);
278         
279 // (c-file-style: "gnu")
280 // Local Variables:
281 // mode: php
282 // tab-width: 8
283 // c-basic-offset: 4
284 // c-hanging-comment-ender-p: nil
285 // indent-tabs-mode: nil
286 // End:   
287 ?>