6666cd640d768839f7f903cbeeb84d55b63de476
[squirrelmail.git] / functions / html.php
1 <?php
2
3 /**
4 * html.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * The idea is to inlcude here some functions to make easier
10 * the right to left implementation by "functionize" some
11 * html outputs.
12 *
13 * $Id$
14 */
15
16 function html_tag( $tag, // Tag to output
17 $val = '', // Value between tags (if empty only start tag is issued)
18 $align = '', // Alignment
19 $bgcolor = '', // Back color
20 $xtra = '' ) { // Extra options
21
22 GLOBAL $languages, $squirrelmail_language;
23
24 $align = strtolower( $align );
25 $dir = strtolower( $dir );
26 $tag = strtoupper( $tag );
27
28 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
29 $dir = $languages[$squirrelmail_language]['DIR'];
30 } else {
31 $dir = 'ltr';
32 }
33
34 if ( $dir == 'ltr' ) {
35 $rgt = 'right';
36 $lft = 'left';
37 } else {
38 $rgt = 'left';
39 $lft = 'right';
40 }
41
42 if ( $bgcolor <> '' ) {
43 $bgc = " BGCOLOR=\"$bgcolor\"";
44 }
45
46 switch ( $align ) {
47 case '':
48 $alg = '';
49 break;
50 case 'right':
51 $alg = " ALIGN=\"$rgt\"";
52 break;
53 case 'left':
54 $alg = " ALIGN=\"$lft\"";
55 break;
56 default:
57 $alg = " ALIGN=\"$align\"";
58 break;
59 }
60
61 $ret = "<$tag";
62
63 if ( $dir <> 'ltr' ) {
64 $ret .= " DIR=\"$dir\"";
65 }
66 $ret .= "$bgc$alg";
67
68 if ( $xtra <> '' ) {
69 $ret .= " $xtra";
70 }
71 $ret .= '>';
72
73 if ( $val <> '' ) {
74 $ret .= "$val</$tag>";
75 }
76
77 return( $ret );
78 }
79
80 ?>