[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------------------------+ 4 | e107 website system : http://e107.org 5 | Steve Dunstan 2001-2002 : jalist@e107.org 6 | Released under the terms and conditions of the GNU General Public License (http://gnu.org). 7 | 8 | $Source: /cvsroot/e107/e107_0.7/e107_themes/templates/header_default.php,v $ 9 | $Revision: 1.103 $ 10 | $Date: 2007/01/18 00:36:16 $ 11 | $Author: mrpete $ 12 +-----------------------------------------------------------------------------------------------+ 13 */ 14 15 if (!defined('e107_INIT')) { exit; } 16 define("USER_AREA",TRUE); 17 define("ADMIN_AREA",FALSE); 18 $sql->db_Mark_Time('(Header Top)'); 19 20 // 21 // *** Code sequence for headers *** 22 // IMPORTANT: These items are in a carefully constructed order. DO NOT REARRANGE 23 // without checking with experienced devs! Various subtle things WILL break. 24 // 25 // We realize this is a bit (!) of a mess and hope to make further cleanups in a future release. 26 // 27 // A: Define themable header parsing 28 // B: Send HTTP headers that come before any html 29 // C: Send start of HTML 30 // D: Send JS 31 // E: Send CSS 32 // F: Send Meta Tags and Icon links 33 // G: Send final theme headers (theme_head() function) 34 // H: Generate JS for image preloading (setup for onload) 35 // I: Calculate onload() JS functions to be called 36 // J: Send end of html <head> and start of <body> 37 // K: (The rest is ignored for popups, which have no menus) 38 // L: (optional) Body JS to disable right clicks 39 // M: Send top of body for custom pages and for news 40 // N: Send other top-of-body HTML 41 // 42 // Load order notes for devs 43 // * Browsers wait until ALL HTML has loaded before executing ANY JS 44 // * The last CSS tag downloaded supercedes earlier CSS tags 45 // * Browsers don't care when Meta tags are loaded. We load last due to 46 // a quirk of e107's log subsystem. 47 // * Multiple external <link> file references slow down page load. Each one requires 48 // browser-server interaction even when cached. 49 // 50 51 // 52 // A: Define themeable header parsing 53 // 54 55 if (!function_exists("parseheader")) { 56 function parseheader($LAYOUT){ 57 global $tp; 58 $tmp = explode("\n", $LAYOUT); 59 for ($c=0; $c < count($tmp); $c++) { 60 if (preg_match("/{.+?}/", $tmp[$c])) { 61 echo $tp -> parseTemplate($tmp[$c]); 62 } else { 63 echo $tmp[$c]; 64 } 65 } 66 } 67 } 68 69 // 70 // B: Send HTTP headers (these come before ANY html) 71 // 72 73 // send the charset to the browser - overrides spurious server settings with the lan pack settings. 74 header("Content-type: text/html; charset=".CHARSET, true); 75 76 77 echo (defined("STANDARDS_MODE") ? "" : "<?xml version='1.0' encoding='".CHARSET."' "."?".">\n")."<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"; 78 79 // 80 // C: Send start of HTML 81 // 82 83 echo "<html xmlns='http://www.w3.org/1999/xhtml'".(defined("TEXTDIRECTION") ? " dir='".TEXTDIRECTION."'" : "").(defined("CORE_LC") ? " xml:lang=\"".CORE_LC."\"" : "")."> 84 <head> 85 <title>".SITENAME.(defined("e_PAGETITLE") ? ": ".e_PAGETITLE : (defined("PAGE_NAME") ? ": ".PAGE_NAME : ""))."</title>\n"; 86 87 // 88 // D: Send JS 89 // 90 echo "<!-- *JS* -->\n"; 91 92 // Wysiwyg JS support on or off. 93 if (varset($pref['wysiwyg'],FALSE) && check_class($pref['post_html']) && varset($e_wysiwyg) != "") { 94 require_once(e_HANDLER."tiny_mce/wysiwyg.php"); 95 define("e_WYSIWYG",TRUE); 96 echo wysiwyg($e_wysiwyg); 97 }else{ 98 define("e_WYSIWYG",FALSE); 99 } 100 101 if (isset($theme_js_php) && $theme_js_php) { 102 echo "<link rel='stylesheet' href='".THEME_ABS."theme-js.php' type='text/css />"; 103 } else { 104 echo "<script type='text/javascript' src='".e_FILE_ABS."e107.js'></script>\n"; 105 if (file_exists(THEME.'theme.js')) { echo "<script type='text/javascript' src='".THEME_ABS."theme.js'></script>\n"; } 106 if (filesize(e_FILE.'user.js')) { echo "<script type='text/javascript' src='".e_FILE_ABS."user.js'></script>\n"; } 107 } 108 109 if (isset($eplug_js) && $eplug_js) { 110 echo "\n<!-- eplug_js -->\n"; 111 echo "<script type='text/javascript' src='{$eplug_js}'></script>\n"; 112 } 113 114 if((isset($pref['enable_png_image_fix']) && $pref['enable_png_image_fix'] == true) || (isset($sleight) && $sleight == true)) { 115 echo "<script type='text/javascript' src='".e_FILE_ABS."sleight_js.php'></script>\n"; 116 } 117 118 if (function_exists('headerjs')){echo headerjs(); } 119 120 // 121 // E: Send CSS 122 // 123 echo "<!-- *CSS* -->\n"; 124 125 if (isset($eplug_css) && $eplug_css) { 126 echo "\n<!-- eplug_css -->\n"; 127 echo "<link rel='stylesheet' href='{$eplug_css}' type='text/css' />\n"; 128 } 129 130 echo "<!-- Theme css -->\n"; 131 if(defined("PREVIEWTHEME")) { 132 echo "<link rel='stylesheet' href='".PREVIEWTHEME."style.css' type='text/css' />\n"; 133 } else { 134 $css_default = "all"; 135 if (isset($theme_css_php) && $theme_css_php) { 136 echo "<link rel='stylesheet' href='".THEME_ABS."theme-css.php' type='text/css' />\n"; 137 } else { 138 if(isset($pref['themecss']) && $pref['themecss'] && file_exists(THEME.$pref['themecss'])) 139 { 140 // Support for print and handheld media. 141 if(file_exists(THEME."style_mobile.css")){ 142 echo "<link rel='stylesheet' href='".THEME_ABS."style_mobile.css' type='text/css' media='handheld' />\n"; 143 $css_default = "screen"; 144 } 145 if(file_exists(THEME."style_print.css")){ 146 echo "<link rel='stylesheet' href='".THEME_ABS."style_print.css' type='text/css' media='print' />\n"; 147 $css_default = "screen"; 148 } 149 echo "<link rel='stylesheet' href='".THEME_ABS."{$pref['themecss']}' type='text/css' media='{$css_default}' />\n"; 150 151 152 } 153 else 154 { 155 // Support for print and handheld media. 156 if(file_exists(THEME."style_mobile.css")){ 157 echo "<link rel='stylesheet' href='".THEME_ABS."style_mobile.css' type='text/css' media='handheld' />\n"; 158 $css_default = "screen"; 159 } 160 if(file_exists(THEME."style_print.css")){ 161 echo "<link rel='stylesheet' href='".THEME_ABS."style_print.css' type='text/css' media='print' />\n"; 162 $css_default = "screen"; 163 } 164 echo "<link rel='stylesheet' href='".THEME_ABS."style.css' type='text/css' media='{$css_default}' />\n"; 165 } 166 if (!isset($no_core_css) || !$no_core_css) { 167 echo "<link rel='stylesheet' href='".e_FILE_ABS."e107.css' type='text/css' />\n"; 168 } 169 } 170 } 171 172 // 173 // DEPRECATED!!! This is used in log/stats.php to generate some css. We'll clean this up in a future release. 174 // 175 176 if(function_exists('core_head')){ echo core_head(); } 177 178 // 179 // F: Send Meta Tags and Icon links 180 // 181 echo "<!-- *META* -->\n"; 182 183 // Multi-Language meta-tags with merge and override option. 184 185 echo "<meta http-equiv='content-type' content='text/html; charset=".CHARSET."' /> 186 <meta http-equiv='content-style-type' content='text/css' />\n"; 187 188 echo (defined("CORE_LC")) ? "<meta http-equiv='content-language' content='".CORE_LC."' />\n" : ""; 189 190 // --- Load plugin Meta files and eplug_ before others -------- 191 if (is_array($pref['e_meta_list'])) 192 { 193 foreach($pref['e_meta_list'] as $val) 194 { 195 if(is_readable(e_PLUGIN.$val."/e_meta.php")) 196 { 197 echo "<!-- $val meta -->\n"; 198 require_once(e_PLUGIN.$val."/e_meta.php"); 199 } 200 } 201 } 202 203 $diz_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_description'][e_LANGUAGE]) ? $pref['meta_description'][e_LANGUAGE]." " : ""; 204 $key_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_keywords'][e_LANGUAGE]) ? $pref['meta_keywords'][e_LANGUAGE]."," : ""; 205 206 function render_meta($type) 207 { 208 global $pref,$tp; 209 210 if (!isset($pref['meta_'.$type][e_LANGUAGE])){ return;} 211 if (!$pref['meta_'.$type][e_LANGUAGE]){ return; } 212 213 if($type == "tag") 214 { 215 return str_replace("<", "<", $tp -> toHTML($pref['meta_tag'][e_LANGUAGE], FALSE, "nobreak, no_hook, no_make_clickable"))."\n"; 216 } 217 else 218 { 219 return '<meta name="'.$type.'" content="'.$pref['meta_'.$type][e_LANGUAGE].'" />'."\n"; 220 } 221 } 222 223 echo "\n<!-- Core Meta Tags -->\n"; 224 echo (defined("META_DESCRIPTION")) ? "<meta name=\"description\" content=\"".$diz_merge.META_DESCRIPTION."\" />\n" : render_meta('description'); 225 echo (defined("META_KEYWORDS")) ? "<meta name=\"keywords\" content=\"".$key_merge.META_KEYWORDS."\" />\n" : render_meta('keywords'); 226 echo render_meta('copyright'); 227 echo render_meta('author'); 228 echo render_meta('tag'); 229 230 unset($key_merge,$diz_merge); 231 232 // ---------- Favicon --------- 233 if (file_exists(THEME."favicon.ico")) { 234 echo "<link rel='icon' href='".THEME_ABS."favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='".THEME_ABS."favicon.ico' type='image/xicon' />\n"; 235 }elseif (file_exists(e_BASE."favicon.ico")) { 236 echo "<link rel='icon' href='".SITEURL."favicon.ico' type='image/x-icon' />\n<link rel='shortcut icon' href='".SITEURL."favicon.ico' type='image/xicon' />\n"; 237 } 238 239 // 240 // G: Send Theme Headers 241 // 242 243 244 if(function_exists('theme_head')){ 245 echo "\n<!-- *THEME HEAD* -->\n"; 246 echo theme_head(); 247 } 248 249 250 // 251 // H: Generate JS for image preloads 252 // 253 echo "\n<!-- *PRELOAD* -->\n"; 254 if ($pref['image_preload']) { 255 $ejs_listpics = ''; 256 $handle=opendir(THEME.'images'); 257 while ($file = readdir($handle)) { 258 if(preg_match("#(jpg|jpeg|gif|bmp|png)$#i", $file)) { 259 $ejs_listpics .= $file.","; 260 } 261 } 262 263 $ejs_listpics = substr($ejs_listpics, 0, -1); 264 closedir($handle); 265 266 if (!isset($script_text)) $script_text = ''; 267 $script_text .= "ejs_preload('".THEME_ABS."images/','".$ejs_listpics."');\n"; 268 } 269 270 if (isset($script_text) && $script_text) { 271 echo "<script type='text/javascript'>\n"; 272 echo "<!--\n"; 273 echo $script_text; 274 echo "// -->\n"; 275 echo "</script>\n"; 276 } 277 278 279 // 280 // I: Calculate JS onload() functions for the BODY tag 281 // 282 global $eMenuActive; 283 $fader_onload=''; 284 if(in_array('fader_menu', $eMenuActive)) 285 { 286 $fader_onload = 'changecontent(); '; 287 } 288 289 $links_onload = 'externalLinks();'; 290 $theme_onload = (defined('THEME_ONLOAD') ? THEME_ONLOAD : ''); 291 $body_onload = ($fader_onload != '' || $links_onload != '' || $theme_onload != '' ? " onload='".$fader_onload.$links_onload.$theme_onload."'" : ""); 292 293 // 294 // J: Send end of <head> and start of <body> 295 // 296 echo "</head> 297 <body".$body_onload.">\n"; 298 $sql->db_Mark_Time("Main Page Body"); 299 300 // 301 // K: (The rest is ignored for popups, which have no menus) 302 // 303 //echo "XX - ".$e107_popup; 304 // require $e107_popup =1; to use it as header for popup without menus 305 if(!isset($e107_popup)) 306 { 307 $e107_popup = 0; 308 } 309 if ($e107_popup != 1) { 310 311 // 312 // L: (optional) Body JS to disable right clicks 313 // 314 if (isset($pref['no_rightclick']) && $pref['no_rightclick']) { 315 echo "<script language='javascript'>\n"; 316 echo "<!--\n"; 317 echo "var message=\"Not Allowed\";\n"; 318 echo "function click(e) {\n"; 319 echo " if (document.all) {\n"; 320 echo " if (event.button==2||event.button==3) {\n"; 321 echo " alert(message);\n"; 322 echo " return false;\n"; 323 echo " }\n"; 324 echo " }\n"; 325 echo " if (document.layers) {\n"; 326 echo " if (e.which == 3) {\n"; 327 echo " alert(message);\n"; 328 echo " return false;\n"; 329 echo " }\n"; 330 echo " }\n"; 331 echo "}\n"; 332 echo "if (document.layers) {\n"; 333 echo " document.captureevents(event.mousedown);\n"; 334 echo "}\n"; 335 echo "document.onmousedown=click;\n"; 336 echo "// -->\n"; 337 echo "</script>\n"; 338 } 339 340 // 341 // M: Send top of body for custom pages and for news 342 // 343 if(isset($CUSTOMPAGES)) 344 { 345 if (is_array($CUSTOMPAGES)) 346 { 347 foreach ($CUSTOMPAGES as $cust_key => $cust_value) 348 { 349 $custompage[$cust_key] = explode(' ', $cust_value); 350 } 351 } 352 else 353 { 354 $custompage['no_array'] = explode(' ', $CUSTOMPAGES); 355 } 356 } 357 else 358 { 359 $custompage['no_array'] = array(); 360 } 361 362 $ph = FALSE; 363 if (e_PAGE == 'news.php' && isset($NEWSHEADER)) { 364 parseheader($NEWSHEADER); 365 } else { 366 foreach ($custompage as $key_extract => $cust_extract) { 367 foreach ($cust_extract as $key => $kpage) { 368 if ($kpage && strstr(e_SELF, $kpage) || strstr(e_SELF."?".e_QUERY,$kpage)) { 369 $ph = TRUE; 370 if ($key_extract=='no_array') { 371 $cust_header = $CUSTOMHEADER ? $CUSTOMHEADER : $HEADER; 372 $cust_footer = $CUSTOMFOOTER ? $CUSTOMFOOTER : $FOOTER; 373 } else { 374 $cust_header = $CUSTOMHEADER[$key_extract] ? $CUSTOMHEADER[$key_extract] : $HEADER; 375 $cust_footer = $CUSTOMFOOTER[$key_extract] ? $CUSTOMFOOTER[$key_extract] : $FOOTER; 376 } 377 break; 378 } 379 } 380 } 381 parseheader(($ph ? $cust_header : $HEADER)); 382 } 383 384 385 // 386 // N: Send other top-of-body HTML 387 // 388 389 if(ADMIN){ 390 if(file_exists(e_BASE.'install.php')){ echo "<div class='installe' style='text-align:center'><br /><b>*** ".CORE_LAN4." ***</b><br />".CORE_LAN5."</div><br /><br />"; } 391 } 392 393 // Display Welcome Message when old method activated. 394 395 echo $tp->parseTemplate("{WMESSAGE=header}"); 396 397 398 399 if(defined("PREVIEWTHEME")) { 400 themeHandler :: showPreview(); 401 } 402 403 404 unset($text); 405 } 406 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |