moving include to the top.
[squirrelmail.git] / functions / html.php
index 01e3ab1524aec26c0322cffdc03cc51082aecc17..f575572480eb5fac7d25313a43e31a799d01ca2a 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * html.php
  *
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Copyright (c) 1999-2005 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * The idea is to inlcude here some functions to make easier
@@ -51,7 +51,7 @@ function html_tag( $tag,                // Tag to output
         }
 
         if ( $bgcolor <> '' ) {
-            $bgc = " bgcolor=\"$bgcolor\""; 
+            $bgc = " bgcolor=\"$bgcolor\"";
         }
 
         switch ( $align ) {
@@ -81,10 +81,10 @@ function html_tag( $tag,                // Tag to output
         }
 
         if ( $val <> '' ) {
-            $ret .= ">$val</$tag>";
+            $ret .= ">$val</$tag>\n";
         } else {
-            $ret .= '>';
-        } 
+            $ret .= '>'. "\n";
+        }
 
         return( $ret );
     }
@@ -93,14 +93,13 @@ function html_tag( $tag,                // Tag to output
     /* especially usefull when $url = $PHP_SELF */
     function set_url_var($url, $var, $val=0, $link=true) {
         $k = '';
-        $ret = '';
         $pat_a = array (
                        '/.+(\\&'.$var.')=(.*)\\&/AU',   /* in the middle */
                        '/.+\\?('.$var.')=(.*\\&).+/AU', /* at front, more follow */
                        '/.+(\\?'.$var.')=(.*)$/AU',     /* at front and only var */
                        '/.+(\\&'.$var.')=(.*)$/AU'      /* at the end */
                      );
-       preg_replace('/&amp;/','&',$url);            
+        preg_replace('/&amp;/','&',$url);
         switch (true) {
             case (preg_match($pat_a[0],$url,$regs)):
                 $k = $regs[1];
@@ -132,12 +131,15 @@ function html_tag( $tag,                // Tag to output
         if ($k) {
             if ($val) {
                 $rpl = "$k=$val";
-               if ($link) {
-                   $rpl = preg_replace('/&/','&amp;',$rpl);
-               }
+                if ($link) {
+                    $rpl = preg_replace('/&/','&amp;',$rpl);
+                }
             } else {
                 $rpl = '';
             }
+            if( substr($v,-1)=='&' ) {
+                $rpl .= '&';
+            }
             $pat = "/$k=$v/";
             $url = preg_replace($pat,$rpl,$url);
         }
@@ -151,7 +153,7 @@ function html_tag( $tag,                // Tag to output
     function echo_template_var($var, $format_ar = array() ) {
         $frm_last = count($format_ar) -1;
 
-        if (isset($format_ar[0])) echo $format_ar[0]; 
+        if (isset($format_ar[0])) echo $format_ar[0];
             $i = 1;
 
         switch (true) {
@@ -179,4 +181,4 @@ function html_tag( $tag,                // Tag to output
             echo $format_ar[$frm_last];
         }
     }
-?>
+?>
\ No newline at end of file