X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fhtml.php;h=747d68ede2c347859388d01c56cbd45242efb329;hb=96862638ef65bfd5438320fc30adf6edf5f1429d;hp=246808e1b88c1782aacee14ef632b179c13cd12d;hpb=c9aa0b4588d80d645a3b9ad4293bb646b0f62feb;p=squirrelmail.git diff --git a/functions/html.php b/functions/html.php index 246808e1..747d68ed 100644 --- a/functions/html.php +++ b/functions/html.php @@ -3,18 +3,29 @@ /** * html.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Copyright (c) 1999-2004 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 @@ -23,10 +34,10 @@ $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'; } @@ -40,7 +51,7 @@ } if ( $bgcolor <> '' ) { - $bgc = " BGCOLOR=\"$bgcolor\""; + $bgc = " bgcolor=\"$bgcolor\""; } switch ( $align ) { @@ -48,30 +59,31 @@ $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"; + $ret .= ">$val"; + } else { + $ret .= '>'; } return( $ret ); @@ -79,15 +91,15 @@ /* handy function to set url vars */ /* especially usefull when $url = $PHP_SELF */ - function set_url_var($url, $var, $val=0) { + 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); switch (true) { case (preg_match($pat_a[0],$url,$regs)): $k = $regs[1]; @@ -108,7 +120,7 @@ default: if ($val) { if (strpos($url,'?')) { - $url .= "&$var=$val"; + $url .= "&$var=$val"; } else { $url .= "?$var=$val"; } @@ -119,7 +131,9 @@ if ($k) { if ($val) { $rpl = "$k=$val"; - $rpl = preg_replace('/&/','&',$rpl); + if ($link) { + $rpl = preg_replace('/&/','&',$rpl); + } } else { $rpl = ''; } @@ -136,7 +150,7 @@ 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) { @@ -164,4 +178,4 @@ echo $format_ar[$frm_last]; } } -?> +?> \ No newline at end of file