cvs: phpweb /include layout.inc

From: Date: Thu, 14 Aug 2003 13:32:37 +0000
Subject: cvs: phpweb /include layout.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-20290@lists.php.net to get a copy of this message
goba Thu Aug 14 09:32:37 2003 EDT Modified files: /phpweb/include layout.inc Log: Support site_header customization through a config array, and handle language related things here too Index: phpweb/include/layout.inc diff -u phpweb/include/layout.inc:1.183 phpweb/include/layout.inc:1.184 --- phpweb/include/layout.inc:1.183 Thu Aug 14 09:20:53 2003 +++ phpweb/include/layout.inc Thu Aug 14 09:32:37 2003 @@ -1,5 +1,5 @@ <?php -/* $Id: layout.inc,v 1.183 2003/08/14 13:20:53 goba Exp $ */ +/* $Id: layout.inc,v 1.184 2003/08/14 13:32:37 goba Exp $ */ // Set the static content root differently on php.net $_SERVER['STATIC_ROOT'] = ($MYSITE == 'http://www.php.net/') ? @@ -48,15 +48,32 @@ /* These functions are only used on the new XHTML 1.0 Strict compatible pages, and are used as an experiment, but are going to replace the commonHeader and commonFooter functions in the future altogether */ -function site_header($title = '', $onload = '') +function site_header($title = '', $config = array()) { global $EXPL_LANG; + // Default to empty array if improper parameter passed + if (!is_array($config)) { $config = array(); } + + // Print out lang and charset headers + if (!isset($config["lang"])) { $config["lang"] = "en"; } + if (!isset($config["charset"])) { $config["charset"] = "ISO-8859-1"; } + header("Content-type: text/html;charset={$config['charset']}"); + header("Content-language: {$config['lang']}"); + if (!empty($title)) { $title = ": $title"; } - if (empty($onload)) { $onload = "searchHistory(); tocImages();"; } + + // Decide on onload event handler + if (!isset($config['onload'])) { + $config['onload'] = "searchHistory(); tocImages();"; + } + + // Explicit language setting means that we should put that into the form if (isset($EXPL_LANG)) { $lang_input = "\n <input type=\"hidden\" name=\"lang\" value=\"$EXPL_LANG\" />"; } else { $lang_input = ''; } + + // Base href setting for URL shortcuts to work if (!empty($_SERVER['BASE_HREF'])) { $base = "\n <base href=\"{$_SERVER['BASE_HREF']}\" />"; } else { $base = ''; } @@ -71,7 +88,7 @@ <link rel="shortcut icon" href="{$_SERVER['STATIC_ROOT']}/favicon.ico" /> <script type="text/javascript" src="{$_SERVER['STATIC_ROOT']}/userprefs.js"></script>$base </head> -<body onload="{$onload}"> +<body onload="{$config['onload']}"> <div id="headnav"> <a href="/"><img src="{$_SERVER['STATIC_ROOT']}/images/php.gif"

« previous php.mirrors (#20290) next »