Re: phpweb /include langchooser.inc layout.inc

From: Date: Fri, 16 May 2003 08:52:07 +0000
Subject: Re: phpweb /include langchooser.inc layout.inc
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-17737@lists.php.net to get a copy of this message
> Modified files: > /phpweb/include layout.inc langchooser.inc > Log: > * More of the E_NOTICE fixes. Also make the spacer.gif pull from the > seperate images server if www.php.net > > --jm There are quite some wrong things here... > // Print an image for a sized spacer > function spacer($width = 1, $height = 1, $return = false, $align = false, $extras = false) > { > - $function = ($return ? "sprintf" : "printf"); > - return $function('<img src="/images/spacer.gif" width="%d" height="%d" border="0" alt="" %s%s />', > - $width, > - $height, > - ($align ? "align=\"$align\" " : ""), > - ($extras ? $extras : "") > - ); > + global $HTTP_SERVER_VARS; > + static $image_root = null; > + > + if ($image_root === null) { > + $image_root = ($HTTP_SERVER_VARS['SERVER_NAME'] == 'www.php.net') ? 'http://64.246.30.196/www.php.net' : ''; > + } > + > + $function = ($return ? "sprintf" : "printf"); > + return $function('<img src="%s/images/spacer.gif" width="%d" > height="%d" border="0" alt="" %s%s />', > + $image_root, > + $width, > + $height, > + ($align ? "align=\"$align\" " : ""), > + ($extras ? $extras : "") > + ); > } Wouldn't it be better to make this go though make_image, instead of duplicating code to make our life harder the next time?? > function commonHeader($title="",$dont_enclose=0,$headers_gone=0) { > - global $MYSITE, $base, $enclosed, $EXPL_LANG, $SIDEBAR_DATA, $SEARCH_BASE, $ONLOAD; > + global $MYSITE, $base, $enclosed, $EXPL_LANG, $SIDEBAR_DATA, $SEARCH_BASE, $ONLOAD, $COUNTRY; $COUNTRY is not used here anymore, the code was changed since James' error report... > function language_choose_code() > { > - global $_REQUEST, $_SERVER, $_COOKIE; > + global $_REQUEST, $_SERVER, $_COOKIE, $langs; > > // Contains all the languages picked up by the > // process in priority order (without repeating codes) > - $languages = array(); > + $languages = array(); /* $langs = array(); */ Well, this is plainly wrong (including the last change from Wez). We don't have a global array named $langs. It is used internally in another function. And we don't have any language in $langs[0] as Wez used it... We have the first language in $languages[0]. See the foreach() code, commented out by Wez. He added wrong code there, and you patched it to make it even more wrong. So the selection should be: $selected = $languages[0]; and the whole $langs thing you added should go away. I would correct this instead of saying bad things, but I am behind a CVS blocking firewall, and had no checkout nor a CVS tool here... Goba

« previous php.mirrors (#17737) next »