/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/tag_utils/wml_utils.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/tag_utils/wml_utils.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Thu May 6 16:27:38 2004 UTC (20 years, 2 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2
3 /**
4 * This file contains some utility functions
5 * to help build some Tag objects that are
6 * commonly used in wml.
7 *
8 * This file only builds the helper functions that
9 * build wml specific tags. Some wml tags are identical
10 * to their HTML counterparts. You should use the html_*
11 * functions for those.
12 *
13 * $Id: wml_utils.inc,v 1.2 2002/11/01 22:33:54 hemna Exp $
14 *
15 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
16 * @package phpHtmlLib
17 *
18 */
19
20 /**
21 * the list of html_* helper functions for HTML tags
22 * that are valid for WML.
23 *
24 * html_head()
25 * html_meta()
26 * html_comment()
27 * html_br()
28 * html_p()
29 * html_table()
30 * html_td()
31 * html_tr()
32 * html_b()
33 * html_big()
34 * html_em()
35 * html_i()
36 * html_small()
37 * html_strong()
38 * html_u()
39 * html_optgroup()
40 * html_option()
41 *
42 */
43
44
45 /**
46 * build an href with content and attributes.
47 *
48 * @param string $url - the href attribute.
49 * @param string $content - the visible link text.
50 * @param string $class - the css class to use.
51 * @param string $title - the title attribute
52 * @return Atag object.
53 */
54 function wml_a($url, $content, $class=NULL, $title=NULL) {
55 return html_a($url, $content, $class, NULL, $title);
56 }
57
58 /**
59 * this builds an <anchor> tag
60 *
61 * @return ANCHORtag object
62 */
63 function wml_anchor() {
64 $tag = new ANCHORtag;
65 $args = func_get_args();
66 call_user_func_array( array(&$tag, "add"), $args);
67 return $tag;
68 }
69
70 /**
71 * this function builds a wml <access /> tag
72 *
73 * @param string - the domain attribute
74 * @param string - the path attribute
75 * @param string - the id attribute
76 * @param string - the class attribute
77 *
78 * @return ACCESStag object
79 */
80 function wml_access( $domain, $path=NULL, $id=NULL, $class=NULL ) {
81 $attributes = array("domain" => $domain );
82
83 if ($path != NULL) {
84 $attributes["path"] = $path;
85 }
86
87 if ($id != NULL) {
88 $attributes["id"] = $id;
89 }
90
91 if ($class != NULL) {
92 $attributes["class"] = $class;
93 }
94
95 return new ACCESStag( $attributes );
96 }
97
98
99 /**
100 * This function helps build a <card> tag
101 *
102 * @param string - the title attribute
103 * @param string - the id attribute
104 * @param string - the class attribute
105 * @param mixed - any N number of params for
106 * content for the tag
107 * @return CARDtag object
108 */
109 function wml_card( $title, $id=NULL, $class=NULL ) {
110 $attributes = array("title" => $title);
111
112 if ($id != NULL) {
113 $attributes["id"] = $id;
114 }
115
116 if ($class != NULL) {
117 $attributes["class"] = $class;
118 }
119
120 $tag = new CARDtag( $attributes );
121 $num_args = func_num_args();
122 for ($i=3;$i<$num_args;$i++) {
123 $tag->add(func_get_arg($i));
124 }
125 return $tag;
126 }
127
128
129 /**
130 * This function builds the WML <do> tag
131 *
132 * @param string - the required 'type' attribute
133 * @param mixed - any N number of params for
134 * content for the tag
135 * @return DOtag object
136 */
137 function wml_do($type) {
138 $tag = new DOtag( array("type" => $type ) );
139 $num_args = func_num_args();
140 for ($i=1;$i<$num_args;$i++) {
141 $tag->add(func_get_arg($i));
142 }
143 return $tag;
144 }
145
146
147 /**
148 * This function builds an <fieldset> tag
149 * for WML.
150 *
151 * @param mixed - any N number of params for
152 * content for the tag
153 * @return FIELDSETtag object
154 */
155 function wml_fieldset() {
156 $tag = new FIELDSETtag;
157 $args = func_get_args();
158 call_user_func_array( array(&$tag, "add"), $args);
159 return $tag;
160 }
161
162
163 /**
164 * This function builds the WML <go> tag
165 *
166 * @param string - the required 'href' attribute
167 * @param string - the optional 'method' attribute
168 * @param mixed - any N number of params for
169 * content for the tag
170 * @return GOtag object
171 */
172 function wml_go($href, $method="get") {
173 $tag = new GOtag(array("href" => $href,
174 "method" => $method));
175 $num_args = func_num_args();
176 for ($i=2;$i<$num_args;$i++) {
177 $tag->add(func_get_arg($i));
178 }
179 return $tag;
180 }
181
182 /**
183 * This function builds an <img> tag,
184 * which refers to a .wbmp format image.
185 *
186 *
187 * @return IMGtag object
188 */
189 function wml_img( $src, $width=NULL, $height=NULL, $alt=NULL) {
190 $attributes = array("src" => $src);
191
192 if ($width != NULL) {
193 $attributes["width"] = $width;
194 }
195 if ($height != NULL) {
196 $attributes["height"] = $height;
197 }
198 if ($alt != NULL) {
199 $attributes["alt"] = $alt;
200 }
201
202 return new IMGtag( $attributes );
203 }
204
205
206 /**
207 * This function builds the WML <input> tag object
208 *
209 * @param string - the required 'name' attribute
210 *
211 * @return INPUTtag object
212 */
213 function wml_input($name, $type="text", $value=NULL, $size=NULL ) {
214 $attributes = array( "name" => $name,
215 "type" => $text );
216
217 if ($value != NULL) {
218 $attributes["value"] = $value;
219 }
220 if ($size != NULL) {
221 $attributes["size"] = $size;
222 }
223
224
225 return new INPUTtag( $attributes );
226 }
227
228 /**
229 * This function builds the WML <noop> tag
230 *
231 * @return NOOPtag object
232 */
233 function wml_noop() {
234 return new NOOPtag;
235 }
236
237
238 /**
239 * This function builds a WML <onevent> tag
240 *
241 * @param string - the required 'type' attribute
242 *
243 * @return ONEVENTtag object
244 */
245 function wml_onevent( $type ) {
246 $tag = new ONEVENTtag( array("type" => $type ) );
247 $num_args = func_num_args();
248 for ($i=1;$i<$num_args;$i++) {
249 $tag->add(func_get_arg($i));
250 }
251 return $tag;
252 }
253
254 /**
255 * This function builds a WML <postfield> tag
256 *
257 * @param string - the required 'name' attribute
258 * @param string - the required 'value' attribute
259 *
260 * @return POSTFIELDtag object
261 */
262 function wml_postfield( $name, $value ) {
263 return new POSTFIELDtag( array( "name" => $name,
264 "value" => $value ));
265 }
266
267 /**
268 * This function builds a WML <prev> tag object
269 *
270 * @param mixed - any N number of params for
271 * content for the tag
272 *
273 * @return PREVtag object
274 */
275 function wml_prev() {
276 $tag = new PREVtag;
277 $args = func_get_args();
278 call_user_func_array( array(&$tag, "add"), $args);
279 return $tag;
280 }
281
282 /**
283 * This function builds a WML <refresh> tag object
284 *
285 * @param mixed - any N number of params for
286 * content for the tag
287 *
288 * @return REFRESHtag object
289 */
290 function wml_refresh() {
291 $tag = new REFRESHtag;
292 $args = func_get_args();
293 call_user_func_array( array(&$tag, "add"), $args);
294 return $tag;
295 }
296
297 /**
298 * This function builds the WML <select> tag
299 *
300 * @param array - an array of name value pairs for
301 * the options. the format is
302 * array( LABEL => VALUE );
303 * each <option value="VALUE">LABEL</option>
304 * ie
305 * array( "test" => "foo") would give an option
306 * of <option value="foo">test</option>
307 *
308 * @return SELECTtag object
309 */
310 function wml_select($options=array()) {
311 $tag = new SELECTtag;
312 foreach ( $options as $content => $value ) {
313 $select->add( html_option($value, $content) );
314 }
315 return $select;
316
317 }
318
319 /**
320 * This function builds the WML <setvar> tag
321 *
322 * @param string - the required 'name' attribute
323 * @param string - the required 'value' attribute
324 * @return SETVARtag object
325 */
326 function wml_setvar($name, $value) {
327 return new SETVARtag( array("name" => $name,
328 "value" => $value));
329 }
330
331 /**
332 * this function builds a <template> tag
333 * and it's content
334 *
335 * @param mixed - any N number of params for
336 * content for the tag
337 *
338 * @return TEMPLATEtag object
339 */
340 function wml_template() {
341 $tag = new TEMPLATEtag;
342 $args = func_get_args();
343 call_user_func_array( array(&$tag, "add"), $args);
344 return $tag;
345 }
346
347 /**
348 * This function builds the WML <timer> tag
349 * the time unit of the value is 1/10 of a second.
350 *
351 * @param string - the required 'value' attribute
352 *
353 * @return TIMERtag object
354 */
355 function wml_timer( $value ) {
356 return new TIMERtag( array("value" => $value ));
357 }
358
359
360 /**
361 * This function builds a <wml> tag
362 *
363 * @param mixed - any N number of params for
364 * content for the tag
365 *
366 * @return WMLtag object
367 */
368 function wml_tag( ) {
369 $tag = new TEMPLATEtag;
370 $args = func_get_args();
371 call_user_func_array( array(&$tag, "add"), $args);
372 return $tag;
373 }
374
375 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed