d49617344cb85cee6cab339d66a93e941069c592
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * The idea is to inlcude here some functions to make easier
10 * the right to left implementation by "functionize" some
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
22 GLOBAL $languages, $squirrelmail_language;
24 $align = strtolower( $align );
26 $tag = strtoupper( $tag );
28 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
29 $dir = $languages[$squirrelmail_language]['DIR'];
34 if ( $dir == 'ltr' ) {
42 if ( $bgcolor <> '' ) {
43 $bgc = " BGCOLOR=\"$bgcolor\"";
51 $alg = " ALIGN=\"$rgt\"";
54 $alg = " ALIGN=\"$lft\"";
57 $alg = " ALIGN=\"$align\"";
63 if ( $dir <> 'ltr' ) {
64 $ret .= " DIR=\"$dir\"";
74 $ret .= "$val</$tag>";
80 /* handy function to set url vars */
81 /* especially usefull when $url = $PHP_SELF */
82 function set_url_var($url, $var, $val=0) {
85 $url = trim(preg_replace('/&/','&',$url));
88 '/.+(\\&'.$var.')=(.*)\\&/AU', /* in the middle */
89 '/.+\\?('.$var.')=(.*\\&).+/AU', /* at front, more follow */
90 '/.+(\\?'.$var.')=(.*)$/AU', /* at front and only var */
91 '/.+(\\&'.$var.')=(.*)$/AU' /* at the end */
94 case (preg_match($pat_a[0],$url,$regs)):
98 case (preg_match($pat_a[1],$url,$regs)):
102 case (preg_match($pat_a[2],$url,$regs)):
106 case (preg_match($pat_a[3],$url,$regs)):
112 if (strpos($url,'?')) {
113 $url .= "&$var=$val";
115 $url .= "?$var=$val";
128 $url = preg_replace($pat,$rpl,$url);
130 return preg_replace('/&/','&',$url);
133 /* Temporary test function to proces template vars with formatting.
134 * I use it for viewing the message_header (view_header.php) with
135 * a sort of template.
137 function echo_template_var($var, $format_ar = array() ) {
138 $frm_last = count($format_ar) -1;
140 if (isset($format_ar[0])) echo $format_ar[0];
144 case (is_string($var)):
147 case (is_array($var)):
148 $frm_a = array_slice($format_ar,1,$frm_last-1);
149 foreach ($var as $a_el) {
150 if (is_array($a_el)) {
151 echo_template_var($a_el,$frm_a);
154 if (isset($format_ar[$i])) {
164 if (isset($format_ar[$frm_last]) && $frm_last>$i ) {
165 echo $format_ar[$frm_last];