/**
* html.php
*
- * Copyright (c) 1999-2002 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
* the right to left implementation by "functionize" some
* html outputs.
*
- * $Id$
+ * @version $Id$
+ * @package squirrelmail
*/
- function html_tag( $tag, // Tag to output
- $val = '', // Value between tags (if empty only start tag is issued)
+/**
+ * Generate html tags
+ *
+ * @param string $tag Tag to output
+ * @param string $val Value between tags
+ * @param string $align Alignment (left, center, etc)
+ * @param string $bgcolor Back color in hexadecimal
+ * @param string $xtra Extra options
+ * @return string HTML ready for output
+ */
+function html_tag( $tag, // Tag to output
+ $val = '', // Value between tags
$align = '', // Alignment
$bgcolor = '', // Back color
$xtra = '' ) { // Extra options
$align = strtolower( $align );
$bgc = '';
- $tag = strtoupper( $tag );
+ $tag = strtolower( $tag );
if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
- $dir = $languages[$squirrelmail_language]['DIR'];
+ $dir = $languages[$squirrelmail_language]['DIR'];
} else {
$dir = 'ltr';
}
}
if ( $bgcolor <> '' ) {
- $bgc = " BGCOLOR=\"$bgcolor\"";
+ $bgc = " bgcolor=\"$bgcolor\"";
}
switch ( $align ) {
$alg = '';
break;
case 'right':
- $alg = " ALIGN=\"$rgt\"";
+ $alg = " align=\"$rgt\"";
break;
case 'left':
- $alg = " ALIGN=\"$lft\"";
+ $alg = " align=\"$lft\"";
break;
default:
- $alg = " ALIGN=\"$align\"";
+ $alg = " align=\"$align\"";
break;
}
$ret = "<$tag";
if ( $dir <> 'ltr' ) {
- $ret .= " DIR=\"$dir\"";
+ $ret .= " dir=\"$dir\"";
}
- $ret .= "$bgc$alg";
+ $ret .= $bgc . $alg;
if ( $xtra <> '' ) {
$ret .= " $xtra";
}
- $ret .= '>';
if ( $val <> '' ) {
- $ret .= "$val</$tag>";
+ $ret .= ">$val</$tag>\n";
+ } else {
+ $ret .= '>'. "\n";
}
return( $ret );
/* 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('/&/','&',$url);
+ preg_replace('/&/','&',$url);
switch (true) {
case (preg_match($pat_a[0],$url,$regs)):
$k = $regs[1];
if ($k) {
if ($val) {
$rpl = "$k=$val";
- if ($link) {
- $rpl = preg_replace('/&/','&',$rpl);
- }
+ if ($link) {
+ $rpl = preg_replace('/&/','&',$rpl);
+ }
} else {
$rpl = '';
}
+ if( substr($v,-1)=='&' ) {
+ $rpl .= '&';
+ }
$pat = "/$k=$v/";
$url = preg_replace($pat,$rpl,$url);
}
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) {
echo $format_ar[$frm_last];
}
}
-?>
+?>
\ No newline at end of file