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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations)
Wed Jul 7 02:23:42 2004 UTC (20 years ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +26 -1 lines
added html_aname

1 <?php
2
3 /**
4 * This file contains some utility functions
5 * to help build some Tag objects that are
6 * commonly used in html.
7 *
8 * $Id: html_utils.inc,v 1.4 2004/05/06 16:27:37 jonen Exp $
9 *
10 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
11 * @package phpHtmlLib
12 *
13 */
14
15
16 /**
17 * build an href with content and attributes.
18 *
19 * @tutorial HTMLTagClass.cls#helper
20 *
21 * @author Walt A. Boring
22 * @param string $url - the url to go to.
23 * @param string $content - the visible link text.
24 * @param string $class - the css class to use.
25 * @param string $target - the target browser
26 * window/frame for the url.
27 * @param string $title - the title attribute
28 * @return Atag object.
29 */
30 function html_a($url, $content, $class=NULL, $target=NULL, $title=NULL) {
31
32 $attributes = array("href" => $url);
33 if ($class) {
34 $attributes["class"] = $class;
35 }
36 if ($target) {
37 $attributes["target"] = $target;
38 }
39
40 if ($title) {
41 $attributes["title"] = $title;
42 }
43
44 $a = new Atag( $attributes, $content);
45 $a->set_collapse();
46
47 return $a;
48 }
49
50 /**
51 * build an <ABBR> tag with content.
52 *
53 * This is to build an abbreviation.
54 * normally its just
55 * <abbr title="foo bar">foo</abbr>
56 *
57 * @param string - the title attribute
58 * @param mixed - the content for the tag
59 * @return ABBRtag object.
60 */
61 function html_abbr($title, $content) {
62 $tag = new ABBRtag(array("title"=>$title));
63 $tag->add( $content );
64 return $tag;
65 }
66
67 /**
68 * build an <ACRONYM> tag with content.
69 *
70 * This is to build an acronym.
71 * normally its just
72 * <acronym title="foo bar">foo</abbr>
73 *
74 * @param string - the title attribute
75 * @param mixed - the content for the tag
76 * @return ACRONYMtag object.
77 */
78 function html_acronym($title, $content) {
79 $tag = new ACRONYMtag( array("title" => $title));
80 $tag->add( $content );
81 return $tag;
82 }
83
84 /**
85 * build an <ADDRESS> tag with content.
86 *
87 * @return ADDRESStag object.
88 */
89 function html_address() {
90 $tag = new ADDRESStag;
91 $num_args = func_num_args();
92 for ($i=0;$i<$num_args;$i++) {
93 $tag->add(func_get_arg($i));
94 }
95 return $tag;
96 }
97
98 /**
99 * build an <APPLET> tag with content.
100 *
101 * @return APPLETtag object.
102 */
103 function html_applet() {
104 $tag = new APPLETtag;
105 $args = func_get_args();
106 call_user_func_array( array(&$tag, "add"), $args);
107 return $tag;
108 }
109
110 /**
111 * build an <AREA> tag with content.
112 *
113 * @param string - the href for the area
114 * @param string - the coords value
115 * circle x,y,radius
116 * poly x1,y1,...xn,yn
117 * left,top,right,bottom
118 * @param string - the shape
119 * DEFAULT: rect
120 * circle, rect, poly, default
121 * @param string - the alt text
122 * @param string - the target
123 * _blank, _parent, _self, _top
124 * @param string - the title text
125 *
126 * @return AREAtag object.
127 */
128 function html_area($href, $coords, $shape="rect",
129 $alt="", $target="", $title="") {
130
131 $attributes = array("href" => $href,
132 "coords" => $coords,
133 "shape" => $shape);
134 if ($alt != "") {
135 $attributes["alt"] = $alt;
136 }
137
138 if ($target != "") {
139 $attributes["target"] = $target;
140 }
141
142 if ($title != "") {
143 $attributes["title"] = $title;
144 }
145
146 $tag = new AREAtag( $attributes );
147 return $tag;
148 }
149
150 /**
151 * build a bold <b> tag with content.
152 *
153 * @author Walt A. Boring
154 * @return BRtag object.
155 */
156 function html_b() {
157 $tag = new Btag;
158 $args = func_get_args();
159 call_user_func_array( array(&$tag, "add"), $args);
160 return $tag;
161 }
162
163 /**
164 * build a <base> tag.
165 * This tag MUST go in the <head>
166 *
167 * @param string - the href
168 * @param string - the target
169 * _blank, _parent, _self, _top
170 * @return BASEtag object.
171 */
172 function html_base($href, $target="") {
173 $attributes = array( "href" => $href);
174
175 if ($target != "") {
176 $attributes["target"] = $target;
177 }
178
179 $tag = new BASEtag( $attributes );
180 return $tag;
181 }
182
183 /**
184 * build a <bdo> tag.
185 * dir attribute is required.
186 *
187 * @param string - the dir attribute
188 * ltr, rtl
189 * @param mixed - any number of text
190 * content params.
191 * @return BDOtag object.
192 */
193 function html_bdo($dir) {
194 $attributes = array( "dir" => $dir);
195
196 $tag = new BDOtag( $attributes );
197
198 $num_args = func_num_args();
199 for ($i=1;$i<$num_args;$i++) {
200 $tag->add(func_get_arg($i));
201 }
202
203 return $tag;
204 }
205
206
207 /**
208 * build a <big> tag with content.
209 *
210 * @author Walt A. Boring
211 * @return BIGtag object.
212 */
213 function html_big() {
214 $tag = new BIGtag;
215 $args = func_get_args();
216 call_user_func_array( array(&$tag, "add"), $args);
217 return $tag;
218 }
219
220 /**
221 * build a <blockquote> tag with content.
222 *
223 * @author Walt A. Boring
224 * @return BLOCKQUOTEtag object.
225 */
226 function html_blockquote() {
227 $tag = new BLOCKQUOTEtag;
228 $args = func_get_args();
229 call_user_func_array( array(&$tag, "add"), $args);
230 return $tag;
231 }
232
233 /**
234 * build a <body> tag with content.
235 *
236 * @author Walt A. Boring
237 * @return BODYtag object.
238 */
239 function html_body() {
240 $tag = new BODYtag;
241 $args = func_get_args();
242 call_user_func_array( array(&$tag, "add"), $args);
243 return $tag;
244 }
245
246 /**
247 * builds n # of <br> tags.
248 *
249 * @param int - the number of
250 * br tags you want
251 *
252 * @return mixed - BRtag object.
253 * or Container
254 */
255 function html_br($num=1) {
256 if ($num == 1){
257 return new BRtag;
258 } else if ($num > 1) {
259 $obj = new Container;
260 $obj->set_collapse();
261 for ($i=0; $i<$num;$i++) {
262 $obj->add( new BRtag );
263 }
264 return $obj;
265 } else if ($num <= 0) {
266 return NULL;
267 }
268 }
269
270 /**
271 * build a <button> tag with content.
272 *
273 * @param string - the button type
274 * button, reset, submit
275 * DEFAULT : button
276 * @param mixed - any number of items as
277 * content.
278 * @return BUTTONtag object.
279 */
280 function html_button($type="button") {
281 $tag = new BUTTONtag( array("type"=> $type));
282 $num_args = func_num_args();
283 for ($i=1;$i<$num_args;$i++) {
284 $tag->add(func_get_arg($i));
285 }
286 return $tag;
287 }
288
289 /**
290 * build a <caption> tag with content.
291 *
292 * @param mixed - n number of arguments
293 * as content for the tag.
294 * @return CAPTIONtag object.
295 */
296 function html_caption() {
297 $tag = new CAPTIONtag;
298 $args = func_get_args();
299 call_user_func_array( array(&$tag, "add"), $args);
300 return $tag;
301 }
302
303 /**
304 * build a <center> tag with some content.
305 * DEPRICATED
306 *
307 * @param mixed - n number of arguments
308 * as content for the tag.
309 * @return CENTERtag object.
310 */
311 function html_center( ) {
312 $tag = new CENTERtag;
313 $args = func_get_args();
314 call_user_func_array( array(&$tag, "add"), $args);
315 return $tag;
316 }
317
318 /**
319 * build a <cite> tag with some content.
320 *
321 * @param mixed - n number of arguments
322 * as content for the tag.
323 * @return CITEtag object.
324 */
325 function html_cite( ) {
326 $tag = new CITEtag;
327 $args = func_get_args();
328 call_user_func_array( array(&$tag, "add"), $args);
329 return $tag;
330 }
331
332 /**
333 * build a <code> tag with some content.
334 *
335 * @param mixed - n number of arguments
336 * as content for the tag.
337 * @return CODEtag object.
338 */
339 function html_code( ) {
340 $tag = new CODEtag;
341 $args = func_get_args();
342 call_user_func_array( array(&$tag, "add"), $args);
343 return $tag;
344 }
345
346 /**
347 * build a <col> tag
348 *
349 * @param mixed - n number of arguments
350 * as content for the tag.
351 * @return CODEtag object.
352 */
353 function html_col($width='', $align='', $span='' ) {
354 $attributes = array();
355 if ($width != '') {
356 $attributes["width"] = $width;
357 }
358 if ($align != '') {
359 $attributes["align"] = $align;
360 }
361 if ($span != '') {
362 $attributes["span"] = $span;
363 }
364 $tag = new COLtag( $attributes );
365 return $tag;
366 }
367
368 /**
369 * build a <colgroup> tag.
370 *
371 * NOTE: The colgroup element is an empty
372 * element that contains attributes
373 * only. To create columns, you must
374 * specify td elements within a tr
375 * element.
376 *
377 * @param array - tag attributes.
378 * @return COLGROUPEtag object.
379 */
380 function html_colgroup( $attributes ) {
381 return new COLGROUPtag( $attributes );
382 }
383
384 /**
385 * render an html comment string
386 *
387 * @param string - the string to comment.
388 * @return string - the string wrapped in
389 * the html comment block
390 */
391 function html_comment( $string ) {
392 return '<!-- ' . $string . ' //-->';
393 }
394
395 /**
396 * build a <dd> tag with some content.
397 *
398 * @param mixed - n number of arguments
399 * as content for the tag.
400 * @return DDtag object.
401 */
402 function html_dd( ) {
403 $tag = new DDtag;
404 $args = func_get_args();
405 call_user_func_array( array(&$tag, "add"), $args);
406 return $tag;
407 }
408
409 /**
410 * build a <del> tag with some content.
411 *
412 * @param mixed - n number of arguments
413 * as content for the tag.
414 * @return DELtag object.
415 */
416 function html_del( ) {
417 $tag = new DELtag;
418 $args = func_get_args();
419 call_user_func_array( array(&$tag, "add"), $args);
420 return $tag;
421 }
422
423
424 /**
425 * build a <dfn> tag with some content.
426 *
427 * @param mixed - n number of arguments
428 * as content for the tag.
429 * @return DFNtag object.
430 */
431 function html_dfn( ) {
432 $tag = new DFNtag;
433 $args = func_get_args();
434 call_user_func_array( array(&$tag, "add"), $args);
435 return $tag;
436 }
437
438 /**
439 * html_div() is defined in
440 * divtag_utils.inc
441 */
442
443 /**
444 * build a <dl> tag with some content.
445 *
446 * @param mixed - n number of arguments
447 * as content for the tag.
448 * @return DLtag object.
449 */
450 function html_dl( ) {
451 $tag = new DLtag;
452 $args = func_get_args();
453 call_user_func_array( array(&$tag, "add"), $args);
454 return $tag;
455 }
456
457 /**
458 * build a <dt> tag with some content.
459 *
460 * @param mixed - n number of arguments
461 * as content for the tag.
462 * @return DTtag object.
463 */
464 function html_dt( ) {
465 $tag = new DTtag;
466 $args = func_get_args();
467 call_user_func_array( array(&$tag, "add"), $args);
468 return $tag;
469 }
470
471 /**
472 * build a <em> tag with some content.
473 *
474 * @param mixed - n number of arguments
475 * as content for the tag.
476 * @return EMtag object.
477 */
478 function html_em( ) {
479 $tag = new EMtag;
480 $args = func_get_args();
481 call_user_func_array( array(&$tag, "add"), $args);
482 return $tag;
483 }
484
485 /**
486 * build a <fieldset> tag with some content.
487 *
488 * @param mixed - The legend text, or the
489 * LEGENDtag for the fieldset.
490 * @param mixed - n number of arguments
491 * as content for the tag.
492 * @return FIELDSETtag object.
493 */
494 function html_fieldset($legend="") {
495 $tag = new FIELDSETtag;
496
497 //see if they passed in the legend
498 if ($legend != "") {
499 if (is_object($legend)) {
500 $tag->add( $legend );
501 } else {
502 $tag->add( html_legend( $legend ) );
503 }
504 }
505
506 $num_args = func_num_args();
507 for ($i=1;$i<$num_args;$i++) {
508 $tag->add(func_get_arg($i));
509 }
510 return $tag;
511 }
512
513 /**
514 * html_form() is defined
515 * in form_utils.inc
516 */
517
518
519 /**
520 * build an H1 tag object with content.
521 *
522 * @author Walt A. Boring
523 * @param mixed - n number of arguments
524 * as content for the tag.
525 * @return H1tag object.
526 */
527 function html_h1( ) {
528 $tag = new H1tag;
529 $tag->set_collapse();
530 $args = func_get_args();
531 call_user_func_array( array(&$tag, "add"), $args);
532 return $tag;
533 }
534
535 /**
536 * build an H2 tag object with content.
537 *
538 * @author Walt A. Boring
539 * @param mixed - n number of arguments
540 * as content for the tag.
541 * @return H2tag object.
542 */
543 function html_h2( ) {
544 $tag = new H2tag;
545 $tag->set_collapse();
546 $args = func_get_args();
547 call_user_func_array( array(&$tag, "add"), $args);
548 return $tag;
549 }
550
551
552 /**
553 * build an H3 tag object with content.
554 *
555 * @author Walt A. Boring
556 * @param mixed - n number of arguments
557 * as content for the tag.
558 * @return H3tag object.
559 */
560 function html_h3( ) {
561 $tag = new H3tag;
562 $tag->set_collapse();
563 $args = func_get_args();
564 call_user_func_array( array(&$tag, "add"), $args);
565 return $tag;
566 }
567
568 /**
569 * build an H4 tag object with content.
570 *
571 * @author Walt A. Boring
572 * @param mixed - n number of arguments
573 * as content for the tag.
574 * @return H4tag object.
575 */
576 function html_h4( ) {
577 $tag = new H4tag;
578 $tag->set_collapse();
579 $args = func_get_args();
580 call_user_func_array( array(&$tag, "add"), $args);
581 return $tag;
582 }
583
584 /**
585 * build an H5 tag object with content.
586 *
587 * @author Walt A. Boring
588 * @param mixed - n number of arguments
589 * as content for the tag.
590 * @return H5tag object.
591 */
592 function html_h5( ) {
593 $tag = new H5tag;
594 $tag->set_collapse();
595 $args = func_get_args();
596 call_user_func_array( array(&$tag, "add"), $args);
597 return $tag;
598 }
599
600
601 /**
602 * build an H6 tag object with content.
603 *
604 * @author Walt A. Boring
605 * @param mixed - n number of arguments
606 * as content for the tag.
607 * @return H6tag object.
608 */
609 function html_h6( ) {
610 $tag = new H6tag;
611 $tag->set_collapse();
612 $args = func_get_args();
613 call_user_func_array( array(&$tag, "add"), $args);
614 return $tag;
615 }
616
617 /**
618 * build an <head> tag object with content.
619 *
620 * @author Walt A. Boring
621 * @param mixed - n number of arguments
622 * as content for the tag.
623 * @return HEADtag object.
624 */
625 function html_head( ) {
626 $tag = new HEADtag;
627 $args = func_get_args();
628 call_user_func_array( array(&$tag, "add"), $args);
629 return $tag;
630 }
631
632 /**
633 * build an <hr> tag object.
634 *
635 * @return HRtag object.
636 */
637 function html_hr( ) {
638 return new HRtag;
639 }
640
641 /**
642 * build an <html> tag object.
643 *
644 * @author Walt A. Boring
645 * @param mixed - n number of arguments
646 * as content for the tag.
647 * @return HTMLtag object.
648 */
649 function html_html( ) {
650 $tag = new HTMLtag;
651 $args = func_get_args();
652 call_user_func_array( array(&$tag, "add"), $args);
653 return $tag;
654 }
655
656
657 /**
658 * build a <i> tag with some content.
659 *
660 * @author Walt A. Boring
661 * @param mixed - n number of arguments
662 * as content for the tag.
663 * @return Itag object.
664 */
665 function html_i( ) {
666 $tag = new Itag;
667 $args = func_get_args();
668 call_user_func_array( array(&$tag, "add"), $args);
669 return $tag;
670 }
671
672 /**
673 * build a <irame> tag with some content.
674 *
675 * @author Walt A. Boring
676 * @param src - the url for the iframe
677 * @return Itag object.
678 */
679 function html_iframe($src, $width="", $height="", $scrolling="") {
680 $attributes = array("src" => $src);
681 if ($width != "") {
682 $attributes["width"] = $width;
683 }
684 if ($height != "") {
685 $attributes["height"] = $height;
686 }
687 if ($width != "") {
688 $attributes["scrolling"] = $scrolling;
689 }
690 return new IFRAMEtag( $attributes );
691 }
692
693
694 /**
695 * Build an <img> tag.
696 * If width and or height are not provided
697 * we do not set them in the tag.
698 *
699 * @author Walter A. Boring IV
700 * @param string - $image - image src
701 * @param int - $width - width of the image.
702 * @param int - $heigth - height of the image
703 * @param int - $border - border flag.
704 * @param string - $alt - alt tag for the image
705 * @param string - $usemap - the image map name
706 * @param string - $align - the align attribute
707 * @return IMGtag object.
708 */
709 function html_img( $image, $width='', $height='', $border=0,
710 $alt="", $usemap=NULL, $title=NULL,
711 $align=NULL ) {
712 $attributes = array( "src" => $image,
713 "border" => $border,
714 "alt" => $alt);
715
716 if ($height != '') {
717 $attributes["height"] = $height;
718 }
719 if ($width != '') {
720 $attributes["width"] = $width;
721 }
722
723 //only add usemap entry if its not NULL
724 if ($usemap) {
725 $attributes["usemap"] = $usemap;
726 }
727
728 if ($title) {
729 $attributes["title"] = $title;
730 }
731
732 if ($align != NULL) {
733 $attributes["align"] = $align;
734 }
735
736 return new IMGtag( $attributes );
737 }
738
739
740 /**
741 * build an hlink for an image.
742 * this automatically turns off indenting
743 * and newlines, so it formats well
744 *
745 * @param string - $url - href for the <a>
746 * @param string - $image - src for the <img>
747 * @param int - $width - width of the image
748 * @param int - $height - height of the image
749 * @param int - $border - for the <img>
750 * @param string - $alt - for the <img ALT="">
751 * @param string - $usemap - the image map name
752 * @param string - $target - the <a target="blah">
753 * @param string - $title - the title attribute
754 * @param string - $align - the align attribute
755 * @return Atag object with <img> as content
756 *
757 */
758 function html_img_href( $url, $image, $width='', $height='', $border=0,
759 $alt="", $usemap=NULL, $target=NULL, $title=NULL, $align=NULL) {
760 $img = html_img($image, $width, $height, $border, $alt, $usemap, $title, $align);
761 $a = html_a($url, $img, NULL, $target);
762 return $a;
763 }
764
765
766 /**
767 * This builds an <input> object
768 * NOTE: This wrapper automatically
769 * calls htmlspecialchars() on
770 * the value attribute's data.
771 *
772 * @param string - the type attribute
773 * @param string - the name attribute
774 * @param string - the value attribute
775 * @param array - any other name=>value attributes
776 * for the tag
777 *
778 * @return INPUTtag object.
779 */
780 function html_input( $type, $name, $value='', $attributes=array() ) {
781 $attrib = array( "type" => $type,
782 "name" => $name,
783 "value" => htmlspecialchars($value, ENT_QUOTES));
784
785 $attributes = array_merge( $attrib, $attributes );
786 return new INPUTtag( $attributes );
787 }
788
789 /**
790 * build a <ins> tag with some content.
791 *
792 * @author Walt A. Boring
793 * @param mixed - n number of arguments
794 * as content for the tag.
795 * @return INStag object.
796 */
797 function html_ins( ) {
798 $tag = new INStag;
799 $args = func_get_args();
800 call_user_func_array( array(&$tag, "add"), $args);
801 return $tag;
802 }
803
804 /**
805 * build a <kbd> tag with some content.
806 *
807 * @param mixed - n number of arguments
808 * as content for the tag.
809 * @return KBDtag object.
810 */
811 function html_kbd( ) {
812 $tag = new KBDtag;
813 $args = func_get_args();
814 call_user_func_array( array(&$tag, "add"), $args);
815 return $tag;
816 }
817
818 /**
819 * build a <label> tag with some content.
820 *
821 * @param string - the id of the form
822 * element to tie this
823 * label to.
824 * @param mixed - n number of arguments
825 * as content for the tag.
826 * @return LABELtag object.
827 */
828 function html_label($for="") {
829
830 $attributes = array();
831 if ($for != "") {
832 $attributes["for"] = $for;
833 }
834 $tag = new LABELtag( $attributes );
835 $num_args = func_num_args();
836 for ($i=1;$i<$num_args;$i++) {
837 $tag->add(func_get_arg($i));
838 }
839 return $tag;
840 }
841
842 /**
843 * build a <legend> tag with some content.
844 *
845 * @param mixed - n number of arguments
846 * as content for the tag.
847 * @return LEGENDtag object.
848 */
849 function html_legend( ) {
850 $tag = new LEGENDtag;
851 $args = func_get_args();
852 call_user_func_array( array(&$tag, "add"), $args);
853 return $tag;
854 }
855
856
857 /**
858 * build a <LI> tag with some content..
859 *
860 * @author Walt A. Boring
861 * @param mixed - n number of arguments
862 * as content for the tag.
863 * @return LItag object.
864 */
865 function html_li( ) {
866 $tag = new LItag;
867 $args = func_get_args();
868 call_user_func_array( array(&$tag, "add"), $args); return $tag;
869 }
870
871 /**
872 * build a <LINK> tag with some content..
873 *
874 *
875 * @param string - the href link
876 * @param string - the rel attribute
877 * @param string - the type of content.
878 * @return LINKtag object.
879 */
880 function html_link($href, $rel, $type ) {
881 return new LINKtag( array("href" => $href,
882 "rel" => $rel,
883 "type" => $type) );
884 }
885
886 /**
887 * build a <map> tag with some content.
888 *
889 * @param string - the name of the map.
890 * @param mixed - n number of arguments
891 * as content for the tag.
892 * @return MAPtag object.
893 */
894 function html_map( $name ) {
895 $tag = new MAPtag(array("name"=>$name) );
896 $num_args = func_num_args();
897 for ($i=1;$i<$num_args;$i++) {
898 $tag->add(func_get_arg($i));
899 }
900 return $tag;
901 }
902
903 /**
904 * build a <meta> tag..
905 *
906 * @param string - the content value.
907 * @param string - the http-equiv value
908 * @param string - the name
909 *
910 * @return METAtag object.
911 */
912 function html_meta( $content, $http_equiv="", $name="" ) {
913 $attributes = array("content" => $content);
914
915 if ($http_equiv != "") {
916 $attributes["http-equiv"] = $http_equiv;
917 }
918 if ($name != "") {
919 $attributes["name"] = $name;
920 }
921
922 $tag = new METAtag( $attributes );
923 return $tag;
924 }
925
926
927 /**
928 * build a <noframes> tag with some content..
929 *
930 * @param mixed - n number of arguments
931 * as content for the tag.
932 * @return NOFRAMEStag object.
933 */
934 function html_noframes( ) {
935 $tag = new NOFRAMEStag;
936 $args = func_get_args();
937 call_user_func_array( array(&$tag, "add"), $args);
938 return $tag;
939 }
940
941 /**
942 * build a <noscript> tag with some content..
943 *
944 * @param mixed - n number of arguments
945 * as content for the tag.
946 * @return NOSCRIPTtag object.
947 */
948 function html_noscript( ) {
949 $tag = new NOSCRIPTtag;
950 $args = func_get_args();
951 call_user_func_array( array(&$tag, "add"), $args);
952 return $tag;
953 }
954
955 /**
956 * build a <object> tag with some content..
957 *
958 * @param mixed - n number of arguments
959 * as content for the tag.
960 * @return OBJECTtag object.
961 */
962 function html_object( ) {
963 $tag = new OBJECTtag;
964 $args = func_get_args();
965 call_user_func_array( array(&$tag, "add"), $args);
966 return $tag;
967 }
968
969 /**
970 * build a <OL> tag with some content..
971 *
972 * @param mixed - n number of arguments
973 * as content for the tag.
974 * @return OLtag object.
975 */
976 function html_ol( ) {
977 $tag = new OLtag;
978 $args = func_get_args();
979 call_user_func_array( array(&$tag, "add"), $args);
980 return $tag;
981 }
982
983 /**
984 * build a <OPTGROUP> tag with some content..
985 *
986 * @param mixed - n number of arguments
987 * as content for the tag.
988 * @return OPTGROUPtag object.
989 */
990 function html_optgroup($label) {
991 $tag = new OPTGROUPtag( array("label" => $label));
992 $num_args = func_num_args();
993 for ($i=1;$i<$num_args;$i++) {
994 $tag->add(func_get_arg($i));
995 }
996 return $tag;
997 }
998
999 /**
1000 * build a <OPTION> tag with some content..
1001 *
1002 * @param string - the value attribute
1003 * @param string - the content for the tag.
1004 *
1005 * @return OPTIONtag object.
1006 */
1007 function html_option($value, $content, $selected=FALSE) {
1008 $tag = new OPTIONtag( array("value"=> $value) );
1009 if ($selected) {
1010 $tag->set_tag_attribute("SELECTED");
1011 }
1012 $tag->add( $content );
1013 return $tag;
1014 }
1015
1016
1017 /**
1018 * build a <p> tag.
1019 *
1020 * @param mixed - n number of arguments
1021 * as content for the tag.
1022 * @return Ptag object.
1023 */
1024 function html_p( ) {
1025 $tag = new Ptag;
1026 $args = func_get_args();
1027 call_user_func_array( array(&$tag, "add"), $args);
1028 return $tag;
1029 }
1030
1031 /**
1032 * build a <param> tag.
1033 *
1034 * @param string - name of the tag
1035 * @return PARAMtag object.
1036 */
1037 function html_param($name, $value="") {
1038 $attributes = array("name" => $name);
1039 if ($value != "") {
1040 $attributes["value"] = $value;
1041 }
1042 return new PARAMtag( $attributes );
1043 }
1044
1045 /**
1046 * build a <pre> tag with some content..
1047 *
1048 * @param mixed - n number of arguments
1049 * as content for the tag.
1050 * @return PREtag object.
1051 */
1052 function html_pre( ) {
1053 $tag = new PREtag;
1054 $args = func_get_args();
1055 call_user_func_array( array(&$tag, "add"), $args);
1056 return $tag;
1057 }
1058
1059 /**
1060 * build a <q> tag with some content..
1061 *
1062 * @param mixed - n number of arguments
1063 * as content for the tag.
1064 * @return Qtag object.
1065 */
1066 function html_q( ) {
1067 $tag = new Qtag;
1068 $args = func_get_args();
1069 call_user_func_array( array(&$tag, "add"), $args);
1070 return $tag;
1071 }
1072
1073 /**
1074 * build a <samp> tag with some content..
1075 *
1076 * @param mixed - n number of arguments
1077 * as content for the tag.
1078 * @return SAMPtag object.
1079 */
1080 function html_samp( ) {
1081 $tag = new SAMPtag;
1082 $args = func_get_args();
1083 call_user_func_array( array(&$tag, "add"), $args);
1084 return $tag;
1085 }
1086
1087 /**
1088 * build a <script> tag with some content..
1089 *
1090 * @param src - the src
1091 * @param string - type of script
1092 * @return SCRIPTtag object.
1093 */
1094 function html_script($src="", $type="text/javascript") {
1095 $attributes = array("type" => $type);
1096 if ($src != "") {
1097 $attributes["src"] = $src;
1098 }
1099 return new SCRIPTtag( $attributes );
1100 }
1101
1102 /**
1103 * <select> tag is defined in
1104 * form_utils.inc as
1105 * form_select()
1106 *
1107 */
1108
1109 /**
1110 * build a small <small> tag with content.
1111 *
1112 * @author Suren Markossian
1113 * @return SMALLtag object.
1114 */
1115 function html_small() {
1116 $tag = new SMALLtag;
1117 $args = func_get_args();
1118 call_user_func_array( array(&$tag, "add"), $args);
1119 return $tag;
1120 }
1121
1122
1123 /**
1124 * build a bold <span> tag with content.
1125 *
1126 * @param string - the class for the
1127 * span.
1128 * @param mixed - n number of arguments
1129 * as content for the tag.
1130 * @return SPANtag object.
1131 */
1132 function html_span($class="") {
1133 $tag = new SPANtag;
1134 if ($class != "") {
1135 $tag->set_class( $class );
1136 }
1137 $num_args = func_num_args();
1138 for ($i=1;$i<$num_args;$i++) {
1139 $tag->add(func_get_arg($i));
1140 }
1141 return $tag;
1142 }
1143
1144
1145 /**
1146 * build a <strong> tag with some content..
1147 *
1148 * @param mixed - n number of arguments
1149 * as content for the tag.
1150 * @return STRONGtag object.
1151 */
1152 function html_strong( ) {
1153 $tag = new STRONGtag;
1154 $args = func_get_args();
1155 call_user_func_array( array(&$tag, "add"), $args);
1156 return $tag;
1157 }
1158
1159 /**
1160 * build a <style> tag with some content.
1161 *
1162 * @param string - the type
1163 * text/css (DEFAULT),
1164 * text/javasript
1165 *
1166 * @param mixed - n number of arguments
1167 * as content for the tag.
1168 * @return STYLEtag object.
1169 */
1170 function html_style($type="text/css") {
1171 $tag = new STYLEtag( array("type" => $type) );
1172 $num_args = func_num_args();
1173 for ($i=1;$i<$num_args;$i++) {
1174 $tag->add(func_get_arg($i));
1175 }
1176 return $tag;
1177 }
1178
1179 /**
1180 * build a <sub> tag with some content..
1181 *
1182 * @param mixed - n number of arguments
1183 * as content for the tag.
1184 * @return SUBtag object.
1185 */
1186 function html_sub( ) {
1187 $tag = new SUBtag;
1188 $args = func_get_args();
1189 call_user_func_array( array(&$tag, "add"), $args);
1190 return $tag;
1191 }
1192
1193 /**
1194 * build a <sup> tag with some content..
1195 *
1196 * @param mixed - n number of arguments
1197 * as content for the tag.
1198 * @return SUPtag object.
1199 */
1200 function html_sup( ) {
1201 $tag = new SUPtag;
1202 $args = func_get_args();
1203 call_user_func_array( array(&$tag, "add"), $args);
1204 return $tag;
1205 }
1206
1207 /**
1208 * Build a TABLEtag object
1209 * with some of the attributes set
1210 *
1211 * @param mixed - width attribute
1212 * default: 100%
1213 * @param mixed - border
1214 * default: 0
1215 * @param mixed - cellspacing
1216 * default: 0
1217 * @param mixed - cellpadding
1218 * default: 0
1219 * @param string - align the align
1220 * attribute
1221 * default: not set.
1222 * @return TABLEtag object.
1223 */
1224 function html_table( $width="100%", $border="0",
1225 $cellspacing="0",
1226 $cellpadding="0",
1227 $align=NULL) {
1228 $attributes = array( "width" => $width,
1229 "border" => $border,
1230 "cellspacing" => $cellspacing,
1231 "cellpadding" => $cellpadding);
1232
1233 if ($align != NULL) {
1234 $attributes["align"] = $align;
1235 }
1236 return new TABLEtag( $attributes );
1237 }
1238
1239 /**
1240 * build a <tbody> tag with some content..
1241 *
1242 * @param mixed - n number of arguments
1243 * as content for the tag.
1244 * @return TBODYtag object.
1245 */
1246 function html_tbody( ) {
1247 $tag = new TBODYtag;
1248 $args = func_get_args();
1249 call_user_func_array( array(&$tag, "add"), $args);
1250 return $tag;
1251 }
1252
1253
1254
1255 /**
1256 * build an td tag object with content.
1257 *
1258 * @param string - the class to use
1259 * @param string - the alignment
1260 * left, right
1261 * @param mixed - n number of arguments
1262 * as content for the tag.
1263 * @return TDtag object.
1264 */
1265 function html_td($class="", $align="") {
1266 $attributes = array();
1267 if ($class != "") {
1268 $attributes["class"] = $class;
1269 }
1270 if ($align != "") {
1271 $attributes["align"] = $align;
1272 }
1273
1274 $tag = new TDtag( $attributes );
1275 $num_args = func_num_args();
1276 for ($i=2;$i<$num_args;$i++) {
1277 $tag->add(func_get_arg($i));
1278 }
1279 return $tag;
1280 }
1281
1282 /**
1283 * build a <tfoot> tag with content.
1284 *
1285 * @param mixed - n number of arguments
1286 * as content for the tag.
1287 * @return TFOOTtag object.
1288 */
1289 function html_tfoot( ) {
1290 $tag = new TFOOTtag;
1291 $args = func_get_args();
1292 call_user_func_array( array(&$tag, "add"), $args);
1293 return $tag;
1294 }
1295
1296
1297 /**
1298 * build a <th>$header</th> tag.
1299 *
1300 * @param mixed - n number of arguments
1301 * as content for the tag.
1302 * @return THtag object.
1303 */
1304 function html_th( ) {
1305 $tag = new THtag;
1306 $args = func_get_args();
1307 call_user_func_array( array(&$tag, "add"), $args);
1308 return $tag;
1309 }
1310
1311 /**
1312 * build a <thhead> tag.
1313 *
1314 * @param mixed - n number of arguments
1315 * as content for the tag.
1316 * @return THEADtag object.
1317 */
1318 function html_thead( ) {
1319 $tag = new THEADtag;
1320 $args = func_get_args();
1321 call_user_func_array( array(&$tag, "add"), $args);
1322 return $tag;
1323 }
1324
1325
1326 /**
1327 * build a <title> tag with some content.
1328 *
1329 * @author Walt A. Boring
1330 * @param mixed - n number of arguments
1331 * as content for the tag.
1332 * @return TITLEtag object.
1333 */
1334 function html_title( ) {
1335 $tag = new TITLEtag;
1336 $args = func_get_args();
1337 call_user_func_array( array(&$tag, "add"), $args);
1338 return $tag;
1339 }
1340
1341 /**
1342 * build a <tr> tag and contents
1343 *
1344 * @param string - class
1345 * @param mixed - n number of arguments
1346 * as content for the tag.
1347 * @return TRtag object.
1348 */
1349 function html_tr( $class="" ) {
1350 $tag = new TRtag;
1351
1352 if ($class != "") {
1353 $tag->set_class( $class );
1354 }
1355
1356 $num_args = func_num_args();
1357 for ($i=1;$i<$num_args;$i++) {
1358 $tag->add(func_get_arg($i));
1359 }
1360 return $tag;
1361 }
1362
1363 /**
1364 * build a <tt> tag and contents
1365 *
1366 * @param mixed - n number of arguments
1367 * as content for the tag.
1368 * @return TTtag object.
1369 */
1370 function html_tt() {
1371 $tag = new TTtag;
1372 $args = func_get_args();
1373 call_user_func_array( array(&$tag, "add"), $args);
1374 return $tag;
1375 }
1376
1377 /**
1378 * build a <u> tag and contents
1379 *
1380 * @param mixed - n number of arguments
1381 * as content for the tag.
1382 * @return Utag object.
1383 */
1384 function html_u( ) {
1385 $tag = new Utag;
1386 $args = func_get_args();
1387 call_user_func_array( array(&$tag, "add"), $args);
1388 return $tag;
1389 }
1390
1391
1392 /**
1393 * build a <UL> tag with content
1394 * wrapped in an <LI> tag.
1395 *
1396 * @author Walt A. Boring
1397 * @param mixed - n number of arguments
1398 * as content for the tag.
1399 * @return ULtag object.
1400 */
1401 function html_ul( ) {
1402 $tag = new ULtag;
1403 $args = func_get_args();
1404 call_user_func_array( array(&$tag, "add"), $args);
1405 return $tag;
1406 }
1407
1408 /**
1409 * build a <var> tag and contents
1410 *
1411 * @param mixed - n number of arguments
1412 * as content for the tag.
1413 * @return VARtag object.
1414 */
1415 function html_var( ) {
1416 $tag = new VARtag;
1417 $args = func_get_args();
1418 call_user_func_array( array(&$tag, "add"), $args);
1419 return $tag;
1420 }
1421
1422
1423 /**
1424 * build a <xmp> tag with some content..
1425 *
1426 * @author Walt A. Boring
1427 * @param mixed - n number of arguments
1428 * as content for the tag.
1429 * @return XMPtag object.
1430 */
1431 function html_xmp( ) {
1432 $tag = new XMPtag;
1433 $args = func_get_args();
1434 call_user_func_array( array(&$tag, "add"), $args);
1435 return $tag;
1436 }
1437
1438 /**
1439 * build a mailto url link .
1440 *
1441 * @author Walt A. Boring
1442 * @param string $email - the email address
1443 * for the mailto
1444 * @param string $subject - the subject for
1445 * the email
1446 * @param string $body - the body conent
1447 * for the email
1448 * @param string $cc = the cc email address.
1449 * @return CENTERtag object.
1450 */
1451 function mailto($email, $subject=NULL, $body=NULL, $cc=NULL){
1452
1453 $mailto = "mailto:".$email."?";
1454 if ($subject) {
1455 $mailto .= "subject=".rawurlencode($subject);
1456 }
1457 if ($body) {
1458 $mailto .= "&body=".rawurlencode($body);
1459 }
1460 if ($cc) {
1461 $mailto .= "&cc=".rawurlencode($cc);
1462 }
1463
1464 return html_a($mailto, $email);
1465 }
1466
1467 /**
1468 * build an <a name> tag with content.
1469 * written by Bill Shaw 3/16/03
1470 * pasted here from http://phphtmllib.newsblob.com/forums/index.php?t=msg&th=189&start=0&rid=0
1471 */
1472 function html_aname($name, $content=NULL, $class=NULL, $target=NULL, $title=NULL) {
1473
1474 $attributes = array("name" => $name);
1475 if ($class) {
1476 $attributes["class"] = $class;
1477 }
1478 if ($target) {
1479 $attributes["target"] = $target;
1480 }
1481
1482 if ($title) {
1483 $attributes["title"] = $title;
1484 }
1485
1486 $a = new Atag( $attributes, $content);
1487 $a->set_collapse();
1488
1489 return $a;
1490 }
1491
1492 ?>

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