6 * The idea is to inlcude here some functions to make easier
7 * the right to left implementation by "functionize" some
10 * @copyright © 1999-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 * @package squirrelmail
19 * @param string $tag Tag to output
20 * @param string $val Value between tags
21 * @param string $align Alignment (left, center, etc)
22 * @param string $bgcolor Back color in hexadecimal
23 * @param string $xtra Extra options
24 * @return string HTML ready for output
26 function html_tag( $tag, // Tag to output
27 $val = '', // Value between tags
28 $align = '', // Alignment
29 $bgcolor = '', // Back color
30 $xtra = '' ) { // Extra options
32 GLOBAL $languages, $squirrelmail_language;
34 $align = strtolower( $align );
36 $tag = strtolower( $tag );
38 if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
39 $dir = $languages[$squirrelmail_language]['DIR'];
44 if ( $dir == 'ltr' ) {
52 if ( $bgcolor <> '' ) {
53 $bgc = " bgcolor=\"$bgcolor\"";
61 $alg = " align=\"$rgt\"";
64 $alg = " align=\"$lft\"";
67 $alg = " align=\"$align\"";
73 if ( $dir <> 'ltr' ) {
74 $ret .= " dir=\"$dir\"";
83 $ret .= ">$val</$tag>\n";
91 /* handy function to set url vars */
92 /* especially usefull when $url = $PHP_SELF */
93 function set_url_var($url, $var, $val=0, $link=true) {
96 '/.+(\\&'.$var.')=(.*)\\&/AU', /* in the middle */
97 '/.+\\?('.$var.')=(.*\\&).+/AU', /* at front, more follow */
98 '/.+(\\?'.$var.')=(.*)$/AU', /* at front and only var */
99 '/.+(\\&'.$var.')=(.*)$/AU' /* at the end */
101 preg_replace('/&/','&',$url);
103 case (preg_match($pat_a[0],$url,$regs)):
107 case (preg_match($pat_a[1],$url,$regs)):
111 case (preg_match($pat_a[2],$url,$regs)):
115 case (preg_match($pat_a[3],$url,$regs)):
121 if (strpos($url,'?')) {
122 $url .= "&$var=$val";
124 $url .= "?$var=$val";
134 $rpl = preg_replace('/&/','&',$rpl);
139 if( substr($v,-1)=='&' ) {
143 $url = preg_replace($pat,$rpl,$url);
148 /* Temporary test function to proces template vars with formatting.
149 * I use it for viewing the message_header (view_header.php) with
150 * a sort of template.
152 function echo_template_var($var, $format_ar = array() ) {
153 $frm_last = count($format_ar) -1;
155 if (isset($format_ar[0])) echo $format_ar[0];
159 case (is_string($var)):
162 case (is_array($var)):
163 $frm_a = array_slice($format_ar,1,$frm_last-1);
164 foreach ($var as $a_el) {
165 if (is_array($a_el)) {
166 echo_template_var($a_el,$frm_a);
169 if (isset($format_ar[$i])) {
179 if (isset($format_ar[$frm_last]) && $frm_last>$i ) {
180 echo $format_ar[$frm_last];