1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-17 20:01:47 +02:00

Template-path changes.

This commit is contained in:
Cameron
2013-03-20 16:58:39 -07:00
parent 22c86fda7a
commit 3b953d1315
5 changed files with 23 additions and 9 deletions

View File

@@ -0,0 +1,409 @@
<?php
/*
* e107 website system
*
* Copyright 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Default footer for user pages
*
* $URL$
* $Id$
*
*/
if (!defined('e107_INIT'))
{
exit;
}
$In_e107_Footer = TRUE; // For registered shutdown function
global $error_handler,$db_time,$FOOTER;
// Clean session shutdown
e107::getSession()->shutdown();
// System browser CACHE control - defaults to no cache; override in e107_config or on the fly
// This is temporary solution, we'll implement more flexible way for cache control override
// per page, more investigation needed about cache related headers, browser quirks etc
// Auto-detect from session (registered per page, per user session)
if(!defined('e_NOCACHE'))
{
define('e_NOCACHE', !e107::canCache());
}
//
// SHUTDOWN SEQUENCE
//
// The following items have been carefully designed so page processing will finish properly
// Please DO NOT re-order these items without asking first! You WILL break something ;)
// These letters match the ADMIN footer (that's why there is B.1,B.2)
//
// A Ensure sql and traffic objects exist
// [Next few ONLY if a regular page; not done for popups]
// B.1 Clear cache (if admin page, not here)
// B.2 Send the footer templated data
// C Dump any/all traffic and debug information
// [end of regular-page-only items]
// D Close the database connection
// E Themed footer code
// F Configured footer scripts
// G Browser-Server time sync script (must be the last one generated/sent)
// H Final HTML (/body, /html)
// I collect and send buffered page, along with needed headers
//
$e107 = e107::getInstance();
$sql = e107::getDb();
$pref = e107::getPref();
if (varset($e107_popup) != 1)
{
//
// B.1 Clear cache (admin-only)
//
//
// B.2 Send footer template, stop timing, send simple page stats
//
if(!deftrue('e_IFRAME'))
{
parseheader((varset($ph) ? $cust_footer : $FOOTER));
}
$eTimingStop = microtime();
global $eTimingStart;
$clockTime = e107::getSingleton('e107_traffic')->TimeDelta($eTimingStart, $eTimingStop);
$dbPercent = 100.0 * $db_time / $clockTime;
// Format for display or logging
$rendertime = number_format($clockTime, 2); // Clock time during page render
$db_time = number_format($db_time, 2); // Clock time in DB render
$dbPercent = number_format($dbPercent, 0); // DB as percent of clock
$memuse = eHelper::getMemoryUsage(); // Memory at end, in B/KB/MB/GB ;)
$queryCount = $sql->db_QueryCount();
$rinfo = '';
$logLine = '';
if ($pref['log_page_accesses'])
{ // Collect the first batch of data to log
$logLine .= "'".($now = time())."','".gmstrftime('%y-%m-%d %H:%M:%S', $now)."','".e107::getIPHandler()->getIP(FALSE)."','".e_PAGE.'?'.e_QUERY."','".$rendertime."','".$db_time."','".$queryCount."','".$memuse."','".$_SERVER['HTTP_USER_AGENT']."','{$_SERVER["REQUEST_METHOD"]}'";
}
if (function_exists('getrusage'))
{
$ru = getrusage();
$cpuUTime = $ru['ru_utime.tv_sec'] + ($ru['ru_utime.tv_usec'] * 1e-6);
$cpuSTime = $ru['ru_stime.tv_sec'] + ($ru['ru_stime.tv_usec'] * 1e-6);
$cpuUStart = $eTimingStartCPU['ru_utime.tv_sec'] + ($eTimingStartCPU['ru_utime.tv_usec'] * 1e-6);
$cpuSStart = $eTimingStartCPU['ru_stime.tv_sec'] + ($eTimingStartCPU['ru_stime.tv_usec'] * 1e-6);
$cpuStart = $cpuUStart + $cpuSStart;
$cpuTot = $cpuUTime + $cpuSTime;
$cpuTime = $cpuTot - $cpuStart;
$cpuPct = 100.0 * $cpuTime / $rendertime; /* CPU load during known clock time */
// Format for display or logging (Uncomment as needed for logging)
//$cpuUTime = number_format($cpuUTime, 3); // User cpu
//$cpuSTime = number_format($cpuSTime, 3); // System cpu
//$cpuTot = number_format($cpuTot, 3); // Total (User+System)
$cpuStart = number_format($cpuStart, 3); // Startup time (i.e. CPU used before class2.php)
$cpuTime = number_format($cpuTime, 3); // CPU while we were measuring the clock (cpuTot-cpuStart)
$cpuPct = number_format($cpuPct, 0); // CPU Load (CPU/Clock)
}
//
// Here's a good place to log CPU usage in case you want graphs and/or your host cares about that
// e.g. (on a typical vhosted linux host)
//
// $logname = "/home/mysite/public_html/queryspeed.log";
// $logfp = fopen($logname, 'a+'); fwrite($logfp, "$cpuTot,$cpuPct,$cpuStart,$rendertime,$db_time\n"); fclose($logfp);
if ($pref['displayrendertime'])
{
$rinfo .= CORE_LAN11;
if (isset($cpuTime))
{
// $rinfo .= "{$cpuTime} cpu sec ({$cpuPct}% load, {$cpuStart} startup). Clock: ";
$rinfo .= sprintf(CORE_LAN14, $cpuTime, $cpuPct, $cpuStart);
}
$rinfo .= $rendertime.CORE_LAN12.$dbPercent.CORE_LAN13.'&nbsp;';
}
if ($pref['displaysql'])
{
$rinfo .= CORE_LAN15.$queryCount.". ";
}
if (isset($pref['display_memory_usage']) && $pref['display_memory_usage'])
{
$rinfo .= CORE_LAN16.$memuse;
}
if (isset($pref['displaycacheinfo']) && $pref['displaycacheinfo'])
{
$rinfo .= $cachestring.".";
}
if ($pref['log_page_accesses'])
{
// Need to log the page info to a text file as CSV data
$logname = e_LOG."logd_".date("Y-m-d", time()).".csv";
$logHeader = "Unix time,Date/Time,IP,URL,RenderTime,DbTime,Qrys,Memory-Usage,User-Agent,Request-Method";
$logfp = fopen($logname, 'a+');
if(filesize($logname) == 0 || !is_file($logname))
{
fwrite($logfp, $logHeader."\n");
}
fwrite($logfp, $logLine."\n");
fclose($logfp);
}
if (function_exists('theme_renderinfo'))
{
theme_renderinfo($rinfo);
}
else
{
echo($rinfo ? "\n<div class='e-footer-info smalltext'><small>{$rinfo}</small></div>\n" : "");
}
} // End of regular-page footer (the above NOT done for popups)
//
// C Dump all debug and traffic information
//
if ((ADMIN || $pref['developer']) && E107_DEBUG_LEVEL)
{
global $db_debug;
echo "\n<!-- DEBUG -->\n<div class='e-debug debug-info'>";
$db_debug->Show_All();
echo "</div>\n";
}
/*
changes by jalist 24/01/2005:
show sql queries
usage: add ?showsql to query string, must be admin
*/
if (ADMIN && isset($queryinfo) && is_array($queryinfo))
{
$c = 1;
$mySQLInfo = $sql->mySQLinfo;
echo "<div class='e-debug query-notice'><table class='fborder' style='width: 100%;'>
<tr>
<td class='fcaption' style='width: 5%;'>ID</td><td class='fcaption' style='width: 95%;'>SQL Queries</td>\n</tr>\n";
foreach ($queryinfo as $infovalue)
{
echo "<tr>\n<td class='forumheader3' style='width: 5%;'>{$c}</td><td class='forumheader3' style='width: 95%;'>{$infovalue}</td>\n</tr>\n";
$c++;
}
echo "</table></div>";
}
//
// D Close DB connection. We're done talking to underlying MySQL
//
$sql->db_Close(); // Only one is needed; the db is only connected once even with several $sql objects
//
// Just before we quit: dump quick timer if there is any
// Works any time we get this far. Not calibrated, but it is quick and simple to use.
// To use: eQTimeOn(); eQTimeOff();
//
$tmp = eQTimeElapsed();
if (strlen($tmp))
{
global $ns;
$ns->tablerender('Quick Admin Timer', "Results: {$tmp} microseconds");
}
if ($pref['developer'])
{
global $oblev_at_start,$oblev_before_start;
if (ob_get_level() != $oblev_at_start)
{
$oblev = ob_get_level();
$obdbg = "<div class='e-debug ob-error'>Software defect detected; ob_*() level {$oblev} at end instead of ($oblev_at_start). POPPING EXTRA BUFFERS!</div>";
while (ob_get_level() > $oblev_at_start)
{
ob_end_flush();
}
echo $obdbg;
}
// 061109 PHP 5 has a bug such that the starting level might be zero or one.
// Until they work that out, we'll disable this message.
// Devs can re-enable for testing as needed.
//
if (0 && $oblev_before_start != 0)
{
$obdbg = "<div class='e-debug ob-error'>Software warning; ob_*() level {$oblev_before_start} at start; this page not properly integrated into its wrapper.</div>";
echo $obdbg;
}
}
if ((ADMIN == true || $pref['developer']) && count($error_handler->errors) && $error_handler->debug == true)
{
$tmp = $error_handler->return_errors();
if($tmp)
{
echo "
<div class='e-debug php-errors block-text'>
<h3>PHP Errors:</h3><br />
".$tmp."
</div>
";
}
unset($tmp);
}
//
// E Last themed footer code, usually JS
//
if (function_exists('theme_foot'))
{
echo theme_foot();
}
//
// F any included JS footer scripts
// DEPRECATED - use e107::getJs()->footerFile('{e_PLUGIN}myplug/js/my.js', $zone = 2)
//
global $footer_js;
if (isset($footer_js) && is_array($footer_js))
{
$footer_js = array_unique($footer_js);
foreach ($footer_js as $fname)
{
echo "<script type='text/javascript' src='{$fname}'></script>\n";
$js_included[] = $fname;
}
}
// [JSManager] Load JS Footer Includes by priority
e107::getJs()->renderJs('footer', true);
// [JSManager] Load JS Footer inline code by priority
e107::getJs()->renderJs('footer_inline', true);
//
// G final JS script keeps user and server time in sync.
// It must be the last thing created before sending the page to the user.
//
// see e107.js and class2.php
// This must be done as late as possible in page processing.
$_serverTime = time();
$lastSet = isset($_COOKIE['e107_tdSetTime']) ? intval($_COOKIE['e107_tdSetTime']) : 0;
$_serverPath = e_HTTP;
$_serverDomain = deftrue('MULTILANG_SUBDOMAIN') ? '.'.e_DOMAIN : '';
if (abs($_serverTime - $lastSet) > 120)
{
/* update time delay every couple of minutes.
* Benefit: account for user time corrections and changes in internet delays
* Drawback: each update may cause all server times to display a bit different
*/
echo "<script type='text/javascript'>\n";
echo " SyncWithServerTime('', '{$_serverPath}', '{$_serverDomain}');\n";
//tdOffset disabled as it can't live together with HTTP_IF_NONE_MATCH (page load speed)
//echo " SyncWithServerTime('{$_serverTime}', '{$_serverPath}', '{$_serverDomain}');\n";
echo "</script>\n";
}
//
// H Final HTML
//
// browser cache control - FIXME - use this value as AJAX requests cache control!
// TODO - create the $bcache string via e107 class method, use it in the canCache() method
$uclist = e107::getUser()->getClassList();
sort($uclist, SORT_NUMERIC);
$bcache = (deftrue('e_NOCACHE') ? time() : e107::getPref('e_jslib_browser_cache')).'.'.implode(',', $uclist);
echo "\n<!-- ".md5($bcache)." -->\n";
unset($uclist, $bcache);
if(!deftrue('e_POWEREDBY_DISABLE'))
{
// No IDs or Classes - hinder js disable.
echo "<div style='text-align:center; display:block; position: absolute; width:100%;height:20px; margin-top:-30px; z-index:30000; opacity:1.0; color: silver'>Proudly powered by <a style='color:silver' href='http://e107.org/' title='e107 Content Management System'>e107</a></div>";
}
echo "\n</body>\n</html>";
//
// I Send the buffered page data, along with appropriate headers
//
$page = ob_get_clean();
$etag = md5($page);
//header('Pragma:');
// previously disabled or there is posted data
$canCache = e107::canCache();
header("Cache-Control: must-revalidate", true); //XXX testing it here to check for improvement.
if($canCache && !deftrue('e_NOCACHE') && $_SERVER['REQUEST_METHOD'] === 'GET' && $_SERVER['QUERY_STRING'] != 'logout')
{
// header("Cache-Control: must-revalidate", true);
if(e107::getPref('site_page_expires')) // TODO - allow per page
{
if (function_exists('date_default_timezone_set'))
{
date_default_timezone_set('UTC');
}
$time = time()+ (integer) e107::getPref('site_page_expires');
header('Expires: '.gmdate("D, d M Y H:i:s", $time).' GMT', true);
}
}
else
{
$canCache = false;
}
$pref['compression_level'] = 6;
$browser_support = FALSE;
$server_support = FALSE;
if (strstr(varset($_SERVER['HTTP_ACCEPT_ENCODING'], ''), 'gzip'))
{
$browser_support = true;
}
if(ini_get("zlib.output_compression") == '' && function_exists("gzencode"))
{
$server_support = true;
}
if(varset($pref['compress_output'],false) && $server_support == true && $browser_support == true)
{
$level = intval($pref['compression_level']);
header("ETag: \"{$etag}-gzip\"");
$page = gzencode($page, $level);
header("Content-Encoding: gzip", true);
header("Content-Length: ".strlen($page), true);
}
else
{
if($browser_support==TRUE)
{
header("ETag: \"{$etag}-gzip\"");
}
else
{
header("ETag: \"{$etag}\"");
}
header("Content-Length: ".strlen($page), true);
}
header("X-Powered-By: e107", true); // no less secure than e107-specific html.
// should come after the Etag header
if ($canCache && isset($_SERVER['HTTP_IF_NONE_MATCH']))
{
$IF_NONE_MATCH = str_replace('"','',$_SERVER['HTTP_IF_NONE_MATCH']);
if($IF_NONE_MATCH == $etag || ($IF_NONE_MATCH == ($etag."-gzip")))
{
header('HTTP/1.1 304 Not Modified');
exit();
}
}
// real output
echo $page;
unset($In_e107_Footer);
$e107_Clean_Exit=TRUE; // For registered shutdown function -- let it know all is well!
?>

View File

@@ -0,0 +1,639 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Default Header
*
* $URL$
* $Id$
*/
if (!defined('e107_INIT')) { exit; }
if(!defined('USER_AREA'))
{
//overload is now possible, prevent warnings
define('USER_AREA',TRUE);
}
define('ADMIN_AREA',FALSE);
$e107 = e107::getInstance();
$e107->sql->db_Mark_Time('(Header Top)');
e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2);
e107::css('core', 'colorbox/colorbox.css', 'jquery');
// Used for Signup form elements - could be on any page of the site.
e107::js('core', 'jquery.mailcheck.min.js','jquery',2);
e107::js('core','bootstrap/js/bootstrap-tooltip.js','jquery');
e107::css('core','bootstrap/css/tooltip.css','jquery');
//e107::js("core", "tooltip/jquery.tipsy.js","jquery",3);
// e107::css('core', 'tooltip/tipsy.css', 'jquery');
// ------------------
e107::js('core', 'jquery.elastic.js', 'jquery', 2);
e107::js('core', 'rate/js/jquery.raty.js', 'jquery', 2);
e107::css('core', 'core/all.jquery.css', 'jquery');
e107::js("core", "core/front.jquery.js","jquery",5); // Load all default functions.
e107::js("core", "core/all.jquery.js","jquery",5); // Load all default functions.
//
// *** Code sequence for headers ***
// IMPORTANT: These items are in a carefully constructed order. DO NOT REARRANGE
// without checking with experienced devs! Various subtle things WILL break.
//
// We realize this is a bit (!) of a mess and hope to make further cleanups in a future release.
//
// A: Define themable header parsing
// B: Send HTTP headers that come before any html
// C: Send start of HTML
// D: Send CSS
// E: Send JS
// F: Send Meta Tags and Icon links
// G: Send final theme headers (theme_head() function)
// H: Generate JS for image preloading (setup for onload)
// I: Calculate onload() JS functions to be called
// J: Send end of html <head> and start of <body>
// K: (The rest is ignored for popups, which have no menus)
// L: Removed
// M: Send top of body for custom pages and for news
// N: Send other top-of-body HTML
//
// Load order notes for devs
// * Browsers wait until ALL HTML has loaded before executing ANY JS
// * The last CSS tag downloaded supercedes earlier CSS tags
// * Browsers don't care when Meta tags are loaded. We load last due to
// a quirk of e107's log subsystem.
// * Multiple external <link> file references slow down page load. Each one requires
// browser-server interaction even when cached.
//
//
// A: Define themeable header parsing
//
if (!function_exists("parseheader")) {
function parseheader($LAYOUT){
global $tp;
$tmp = explode("\n", $LAYOUT);
for ($c=0; $c < count($tmp); $c++) {
if (preg_match("/{.+?}/", $tmp[$c])) {
echo $tp -> parseTemplate($tmp[$c]);
} else {
echo $tmp[$c];
}
}
}
}
//
// B: Send HTTP headers (these come before ANY html)
//
// send the charset to the browser - overrides spurious server settings with the lan pack settings.
// Would like to set the MIME type appropriately - but it broke other things
//if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml"))
// header("Content-type: application/xhtml+xml; charset=utf-8", TRUE);
//else
header("Content-type: text/html; charset=utf-8", TRUE);
// NEW - HTML5 default
// TODO - more precise controlo over page header depending on the HTML5 mode
if(!defined("XHTML4"))
{
echo "<!doctype html>\n";
echo "<html".(defined("TEXTDIRECTION") ? " dir='".TEXTDIRECTION."'" : "").(defined("CORE_LC") ? " lang=\"".CORE_LC."\"" : "").">\n";
echo "<head>\n";
echo "<meta charset='utf-8' />\n";
}
else
{
echo (defined("STANDARDS_MODE") ? "" : "<?xml version='1.0' encoding='utf-8' "."?".">\n")."<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
echo "<html xmlns='http://www.w3.org/1999/xhtml'".(defined("TEXTDIRECTION") ? " dir='".TEXTDIRECTION."'" : "").(defined("XMLNS") ? " ".XMLNS." " : "").(defined("CORE_LC") ? " xml:lang=\"".CORE_LC."\"" : "").">\n";
echo "<head>
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
<meta http-equiv='content-style-type' content='text/css' />
";
echo (defined("CORE_LC")) ? "<meta http-equiv='content-language' content='".CORE_LC."' />\n" : "";
}
//
// C: Send start of HTML
//
if(vartrue($pref['meta_copyright'][e_LANGUAGE])) e107::meta('copyright',$pref['meta_copyright'][e_LANGUAGE]);
if(vartrue($pref['meta_author'][e_LANGUAGE])) e107::meta('author',$pref['meta_author'][e_LANGUAGE]);
if($pref['sitebutton']) e107::meta('og:image',$tp->replaceConstants($pref['sitelogo'],'full'));
if(defined("VIEWPORT")) e107::meta('viewport',VIEWPORT);
echo e107::getUrl()->response()->renderMeta()."\n";
echo "<title>".(defined('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."</title>\n\n";
// Wysiwyg JS support on or off.
if (varset($pref['wysiwyg'],FALSE))
{
define("e_WYSIWYG",TRUE);
}
else
{
define("e_WYSIWYG",FALSE);
}
//
// D: Register CSS
//
$e_js = e107::getJs();
$e_pref = e107::getConfig('core');
// Other Meta tags.
// Register Core CSS first, TODO - convert $no_core_css to constant, awaiting for path changes
// NOTE: PREVIEWTHEME check commented - It shouldn't break anything as it's overridden by theme CSS now
if (/*!defined("PREVIEWTHEME") && */!isset($no_core_css) || !$no_core_css)
{
//echo "<link rel='stylesheet' href='".e_FILE_ABS."e107.css' type='text/css' />\n";
$e_js->otherCSS('{e_WEB_CSS}e107.css');
}
// Load Plugin Header Files, allow them to load CSS/JSS via JS Manager early enouhg
// NOTE: e_header.php should not output content, it should only register stuff! e_meta.php is more appropriate for outputting header content.
$e_headers = $e_pref->get('e_header_list');
if ($e_headers && is_array($e_headers))
{
foreach($e_headers as $val)
{
// no checks fore existing file - performance
e107_include(e_PLUGIN.$val."/e_header.php");
}
}
unset($e_headers);
// re-initalize in case globals are destroyed from $e_headers includes
$e_js = e107::getJs();
$e_pref = e107::getConfig('core');
// --- Load plugin Meta files - now possible to add to all zones! --------
$e_meta_content = '';
if (is_array($pref['e_meta_list']))
{
// $pref = e107::getPref();
ob_start();
foreach($pref['e_meta_list'] as $val)
{
$fname = e_PLUGIN.$val."/e_meta.php"; // Do not place inside a function - BC $pref required. .
if(is_readable($fname))
{
$ret = ($e107_debug || isset($_E107['debug'])) ? include_once($fname) : @include_once($fname);
}
}
// content will be added later
// NOTE: not wise to do e_meta output, use JS Manager!
$e_meta_content = ob_get_contents();
ob_end_clean();
unset($ret);
}
// Register Plugin specific CSS
// DEPRECATED, use $e_js->pluginCSS('myplug', 'style/myplug.css'[, $media = 'all|screen|...']);
if (isset($eplug_css) && $eplug_css)
{
if(!is_array($eplug_css))
{
$eplug_css = array($eplug_css);
}
foreach($eplug_css as $kcss)
{
// echo ($kcss[0] == "<") ? $kcss : "<link rel='stylesheet' href='{$kcss}' type='text/css' />\n";
$e_js->otherCSS($kcss);
}
}
// Register Theme CSS
// Writing link tags is DEPRECATED, use $e_js->themeCSS('style/mytheme.css'[, $media = 'all|screen|...']); - current theme is auto-detected
if(defined("PREVIEWTHEME"))
{
// XXX - can be PREVIEWTHEME done in a better way than this?
//echo "<link rel='stylesheet' href='".PREVIEWTHEME."style.css' type='text/css' />\n";
//var_dump(PREVIEWTHEMENAME);
$e_js->otherCSS(PREVIEWTHEME.'style.css');
}
else
{
$css_default = "all"; // TODO - default should be defined by the theme
// theme-css.php auto-detection TODO - convert it to constant or anything different from GLOBAL
if (isset($theme_css_php) && $theme_css_php)
{
//echo "<link rel='stylesheet' href='".THEME_ABS."theme-css.php' type='text/css' />\n";
$e_js->themeCSS('theme-css.php', $css_default);
}
else
{
// Theme default
if($e_pref->get('themecss') && file_exists(THEME.$e_pref->get('themecss')))
{
//echo "<link rel='stylesheet' href='".THEME_ABS."{$pref['themecss']}' type='text/css' media='{$css_default}' />\n";
$e_js->themeCSS($e_pref->get('themecss'), $css_default);
}
else
{
echo "<link rel='stylesheet' href='".THEME_ABS."style.css' type='text/css' media='{$css_default}' />\n";
$e_js->themeCSS('style.css', $css_default);
}
// Support for print and handheld media - override theme default CSS
if(file_exists(THEME."style_mobile.css"))
{
//echo "<link rel='stylesheet' href='".THEME_ABS."style_mobile.css' type='text/css' media='handheld' />\n";
//$css_default = "screen";
$e_js->themeCSS('style_mobile.css', 'handheld');
}
if(file_exists(THEME."style_print.css"))
{
// echo "<link rel='stylesheet' href='".THEME_ABS."style_print.css' type='text/css' media='print' />\n";
// $css_default = "screen";
$e_js->themeCSS('style_print.css', 'print');
}
}
// FIXME: TEXTDIRECTION compatibility CSS (marj?)
// TODO: probably better to externalise along with some other things above
// possibility to overwrite some CSS definition according to TEXTDIRECTION
// especially usefull for rtl.css
// see _blank theme for examples
if(defined('TEXTDIRECTION') && file_exists(THEME.'/'.strtolower(TEXTDIRECTION).'.css'))
{
//echo '
//<link rel="stylesheet" href="'.THEME_ABS.strtolower(TEXTDIRECTION).'.css" type="text/css" media="all" />';
$e_js->themeCSS(TEXTDIRECTION.'.css', 'all');
}
}
//
// Render CSS - all in once
// Read here why - http://code.google.com/speed/page-speed/docs/rtt.html#PutStylesBeforeScripts
//
// Other CSS - from unknown location, different from core/theme/plugin location or backward compatibility; NOTE - could be removed in the future!!!
$e_js->renderJs('other_css', false, 'css', false);
echo "\n<!-- footer_other_css -->\n";
// Core CSS
$e_js->renderJs('core_css', false, 'css', false);
echo "\n<!-- footer_core_css -->\n";
// Plugin CSS
$e_js->renderJs('plugin_css', false, 'css', false);
echo "\n<!-- footer_plugin_css -->\n";
// Theme CSS
//echo "<!-- Theme css -->\n";
$e_js->renderJs('theme_css', false, 'css', false);
echo "\n<!-- footer_theme_css -->\n";
// Inline CSS - not sure if this should stay at all!
$e_js->renderJs('inline_css', false, 'css', false);
echo "\n<!-- footer_inline_css -->\n";
//
// Style for unobtrusive JS, prevent 3rd party code overload
//
// require_once(e_FILE."/e_css.php"); see e107_web/css/e107.css
//
// E: Send JS all in once
// Read here why - http://code.google.com/speed/page-speed/docs/rtt.html#PutStylesBeforeScripts
// TODO - more work (zones, eplug_js, headerjs etc order, external JS/CSS)
// TODO - mobile support
// [JSManager] Load JS Includes - Zone 1 - Before Library
e107::getJs()->renderJs('header', 1);
e107::getJs()->renderJs('header_inline', 1);
// Send Javascript Libraries ALWAYS (for now)
$jslib = e107::getObject('e_jslib', null, e_HANDLER.'jslib_handler.php');
$jslib->renderHeader('front', false);
// [JSManager] Load JS Includes - Zone 2 - After Library
e107::getJs()->renderJs('header', 2);
e107::getJs()->renderJs('header_inline', 2);
// Send Plugin JS Files
//DEPRECATED, $eplug_js will be removed soon - use e107::getJs()->headerPlugin('myplug', 'myplug/js/my.js');
if (isset($eplug_js) && $eplug_js)
{
echo "\n<!-- eplug_js -->\n";
if(is_array($eplug_js))
{
$eplug_js_unique = array_unique($eplug_js);
foreach($eplug_js_unique as $kjs)
{
echo ($kjs[0] == "<") ? $kjs : "<script type='text/javascript' src='{$kjs}'></script>\n";
}
}
else
{
echo "<script type='text/javascript' src='{$eplug_js}'></script>\n";
}
}
// Send Theme JS Files
//DEPRECATE this as well?
if (isset($theme_js_php) && $theme_js_php)
{
echo "<script type='text/javascript' src='".THEME_ABS."theme-js.php'></script>\n";
}
else
{
if (file_exists(THEME.'theme.js')) { echo "<script type='text/javascript' src='".THEME_ABS."theme.js'></script>\n"; }
if (is_readable(e_FILE.'user.js') && filesize(e_FILE.'user.js')) { echo "<script type='text/javascript' src='".e_FILE_ABS."user.js'></script>\n"; }
if (file_exists(THEME.'theme.vbs')) { echo "<script type='text/vbscript' src='".THEME_ABS."theme.vbs'></script>\n"; }
if (is_readable(e_FILE.'user.vbs') && filesize(e_FILE.'user.vbs')) { echo "<script type='text/vbscript' src='".e_FILE_ABS."user.vbs'></script>\n"; }
}
//FIXME - CHAP JS
// TODO - convert it to e107::getJs()->header/footerFile() call
if (!USER && ($pref['user_tracking'] == "session") && varset($pref['password_CHAP'],0))
{
if ($pref['password_CHAP'] == 2)
{
// *** Add in the code to swap the display tags
$js_body_onload[] = "expandit('loginmenuchap','nologinmenuchap');";
}
echo "<script type='text/javascript' src='".e_JS."chap_script.js'></script>\n";
$js_body_onload[] = "getChallenge();";
}
//headerjs moved below
// Deprecated function finally removed
//if(function_exists('core_head')){ echo core_head(); }
// [JSManager] Load JS Includes - Zone 3 - After e_plug/theme.js, before headerjs()
e107::getJs()->renderJs('header', 3);
e107::getJs()->renderJs('header_inline', 3);
// [JSManager] Load JS Includes - Zone 4 - After headerjs
e107::getJs()->renderJs('header', 4);
e107::getJs()->renderJs('header_inline', 4);
// [JSManager] Load JS Includes - Zone 5 - End of header JS, just before e_meta content and e107:loaded trigger
e107::getJs()->renderJs('header', 5);
//
// F: Send Meta Tags, Icon links
//
// --- Send plugin Meta --------
echo $e_meta_content; // e_meta already loaded
//
// G: Send Theme Headers
//
if(function_exists('theme_head'))
{
echo theme_head();
}
// FIXME description and keywords meta tags shouldn't be sent on all pages
$diz_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_description'][e_LANGUAGE]) ? $pref['meta_description'][e_LANGUAGE]." " : "";
$key_merge = (defined("META_MERGE") && META_MERGE != FALSE && $pref['meta_keywords'][e_LANGUAGE]) ? $pref['meta_keywords'][e_LANGUAGE]."," : "";
function render_meta($type)
{
global $pref,$tp;
if (!isset($pref['meta_'.$type][e_LANGUAGE]) || empty($pref['meta_'.$type][e_LANGUAGE]))
{
return '';
}
if($type == "tag")
{
return str_replace("&lt;", "<", $tp -> toHTML($pref['meta_tag'][e_LANGUAGE], FALSE, "nobreak, no_hook, no_make_clickable"))."\n";
}
else
{
return '<meta name="'.$type.'" content="'.$pref['meta_'.$type][e_LANGUAGE].'" />'."\n";
}
}
echo (defined("META_DESCRIPTION")) ? "\n<meta name=\"description\" content=\"".$diz_merge.META_DESCRIPTION."\" />\n" : render_meta('description');
echo (defined("META_KEYWORDS")) ? "\n<meta name=\"keywords\" content=\"".$key_merge.META_KEYWORDS."\" />\n" : render_meta('keywords');
//echo render_meta('copyright');
//echo render_meta('author');
echo render_meta('tag');
unset($key_merge,$diz_merge);
// ---------- Favicon ---------
if (file_exists(THEME."favicon.ico"))
{
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";
}
elseif (file_exists(e_BASE."favicon.ico"))
{
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";
}
//
// FIXME H: Generate JS for image preloads (do we really need this?)
//
if ($pref['image_preload'] && is_dir(THEME.'images'))
{
$ejs_listpics = '';
$handle=opendir(THEME.'images');
while ($file = readdir($handle))
{
if(preg_match("#(jpg|jpeg|gif|bmp|png)$#i", $file))
{
$ejs_listpics .= $file.",";
}
}
$ejs_listpics = substr($ejs_listpics, 0, -1);
closedir($handle);
if (!isset($script_text)) $script_text = '';
$script_text .= "ejs_preload('".THEME_ABS."images/','".$ejs_listpics."');\n";
}
if (isset($script_text) && $script_text)
{
echo "<script type='text/javascript'>\n";
echo "<!--\n";
echo $script_text;
echo "// -->\n";
echo "</script>\n";
}
//
// FIXME - I: Calculate JS onload() functions for the BODY tag
//
// Fader menu
// OLD CODE REMOVAL
//global $eMenuActive, $eMenuArea;
//if(in_array('fader_menu', $eMenuActive)) $js_body_onload[] = 'changecontent(); ';
// External links handling
$js_body_onload = array();//'externalLinks();'; - already registered to e107:loaded Event by the new JS API
// Theme JS
// XXX DEPRECATED $body_onload and related functionality
if (defined('THEME_ONLOAD')) $js_body_onload[] = THEME_ONLOAD;
$body_onload='';
if (count($js_body_onload)) $body_onload = " onload=\"".implode(" ",$js_body_onload)."\"";
//
// J: Send end of <head> and start of <body>
//
/*
* Fire Event e107:loaded
* core JS available only in Prototype front-end environment
*/
// e_css.php is removed
//\$('e-js-css').remove();
e107::js('inline',"
document.observe('dom:loaded', function () {
e107Event.trigger('loaded', null, document);
});
",'prototype',5);
e107::getJs()->renderJs('header_inline', 5);
echo "</head>\n";
// ---------- New in 2.0 -------------------------------------------------------
$def = THEME_LAYOUT; // The active layout based on custompage matches.
// echo "DEF = ".$def."<br />";
if($def == 'legacyCustom' || $def=='legacyDefault' ) // 0.6 themes.
{
// echo "MODE 0.6";
if($def == 'legacyCustom')
{
$HEADER = ($CUSTOMHEADER) ? $CUSTOMHEADER : $HEADER;
$FOOTER = ($CUSTOMFOOTER) ? $CUSTOMFOOTER : $FOOTER;
}
}
elseif($def && $def != "legacyCustom" && (isset($CUSTOMHEADER[$def]) || isset($CUSTOMFOOTER[$def]))) // 0.7 themes
{
// echo " MODE 0.7";
$HEADER = ($CUSTOMHEADER[$def]) ? $CUSTOMHEADER[$def] : $HEADER;
$FOOTER = ($CUSTOMFOOTER[$def]) ? $CUSTOMFOOTER[$def] : $FOOTER;
}
elseif($def && isset($HEADER[$def]) && isset($FOOTER[$def])) // 0.8 themes - we use only $HEADER and $FOOTER arrays.
{
// echo " MODE 0.8";
$HEADER = $HEADER[$def];
$FOOTER = $FOOTER[$def];
}
if(deftrue('e_IFRAME'))
{
$HEADER = "";
$FOOTER = "";
$body_onload = " style='padding:15px;margin:0px'"; //TODO e-iframe css class.
}
echo "<body".$body_onload.">\n";
// Header included notification, from this point header includes are not possible
define('HEADER_INIT', TRUE);
$e107->sql->db_Mark_Time("Main Page Body");
//
// K: (The rest is ignored for popups, which have no menus)
//
//echo "XXX - ".$e107_popup;
// require $e107_popup =1; to use it as header for popup without menus
if(!isset($e107_popup))
{
$e107_popup = 0;
}
if ($e107_popup != 1) {
//
// L: Removed
//
//
// M: Send top of body for custom pages and for news
//
//XXX - remove all page detections
if (e_PAGE == 'news.php' && isset($NEWSHEADER))
{
parseheader($NEWSHEADER);
}
else
{
parseheader($HEADER);
}
unset($def);
// -----------------------------------------------------------------------------
//
// N: Send other top-of-body HTML
//
if(ADMIN)
{
if(file_exists(e_BASE.'install.php')){ echo "<div class='installer'><br /><b>*** ".CORE_LAN4." ***</b><br />".CORE_LAN5."</div><br /><br />"; }
}
// Display Welcome Message when old method activated.
echo $e107->tp->parseTemplate("{WMESSAGE=header}");
if(defined("PREVIEWTHEME"))
{
themeHandler::showPreview();
}
unset($text);
}
//Trim whitepsaces after end of the script

View File

@@ -0,0 +1,81 @@
<?php
// $Id$
if (!defined('e107_INIT')) { exit; }
// ##### LOGIN HEADER TABLE -----------------------------------------------------------------------
if(!isset($LOGIN_TABLE_HEADER))
{
$LOGIN_TABLE_HEADER .= "
<div style='width:100%;text-align:center; margin-left: auto;margin-right: auto'><br />
<div style='text-align:center;width:70%;margin-left: auto;margin-right: auto'>
".(file_exists(THEME."images/login_logo.png") ? "<img src='".THEME_ABS."images/login_logo.png' alt='' />\n" : "<img src='".e_IMAGE."logo.png' alt='' />\n" );
}
// ##### LOGIN TABLE -----------------------------------------------------------------------------
if(!isset($LOGIN_TABLE))
{
$LOGIN_TABLE = "";
if($LOGIN_TABLE_LOGINMESSAGE != "")
{
$LOGIN_TABLE .= "<div style='text-align:center'>{LOGIN_TABLE_LOGINMESSAGE}</div>";
}
if (($pref['user_tracking'] == "session") && varset($pref['password_CHAP'],0))
{
if ($pref['password_CHAP'] == 2)
{
$LOGIN_TABLE .= "
<div style='text-align: center' id='nologinmenuchap'>"."Javascript must be enabled in your browser if you wish to log into this site"."
</div>
<div style='text-align: center; display:none' id='loginmenuchap'>";
}
else
{
$LOGIN_TABLE .= "<div style='text-align:center'>";
}
$LOGIN_TABLE .= $rs -> form_open("post", e_SELF,'','','',' onsubmit="hashLoginPassword(this)"');
}
else
{
$LOGIN_TABLE .= "<div style='text-align:center'>".$rs -> form_open("post", e_SELF);
}
$LOGIN_TABLE .=
"<table class='fborder' style='width:60%;margin-right:auto;margin-left:auto' >\n
<tr>\n
<td class='forumheader' style='text-align:center;' colspan='3'>".LAN_LOGIN_4."</td>\n
</tr>\n
<tr>\n
<td class='forumheader3' style='width:40%'>{LOGIN_USERNAME_LABEL}</td>\n
<td class='forumheader3' style='width:40%'>{LOGIN_TABLE_USERNAME}</td>\n
<td class='forumheader3' rowspan='".($LOGIN_TABLE_SECIMG_SECIMG ? 3 : 2)."' style='width:20%; vertical-align: middle; margin-left: auto; margin-right: auto; text-align: center;'>".(file_exists(THEME."images/password.png") ? "<img src='".THEME_ABS."images/password.png' alt='' />\n" : "<img src='".e_IMAGE."generic/password.png' alt='' />\n" )."</td>\n</tr>\n
<tr>\n<td class='forumheader3'>".LAN_LOGIN_2."</td>\n<td class='forumheader3'>{LOGIN_TABLE_PASSWORD}
</td>\n</tr>\n";
if($LOGIN_TABLE_SECIMG_SECIMG)
{
$LOGIN_TABLE .= "<tr><td class='forumheader3'>{LOGIN_TABLE_SECIMG_LAN}</td>\n<td class='forumheader3'>{LOGIN_TABLE_SECIMG_HIDDEN} {LOGIN_TABLE_SECIMG_SECIMG} {LOGIN_TABLE_SECIMG_TEXTBOC}</td>\n</tr>\n";
}
$LOGIN_TABLE .= "<tr>\n<td class='forumheader2' style='text-align:center;' colspan='3'>{LOGIN_TABLE_AUTOLOGIN}<span class='smalltext'>{LOGIN_TABLE_AUTOLOGIN_LAN}</span><br />{LOGIN_TABLE_SUBMIT}</td>\n</tr>\n</table>".
$rs -> form_close()."\n</div>";
}
// ##### ------------------------------------------------------------------------------------------
// ##### LOGIN TABLE FOOTER -----------------------------------------------------------------------
if(!isset($LOGIN_TABLE_FOOTER))
{
$LOGIN_TABLE_FOOTER = "
<div style='width:70%;margin-right:auto;margin-left:auto'>
<div style='text-align:center'><br />
{LOGIN_TABLE_FOOTER_USERREG}
&nbsp;&nbsp;&nbsp;<a href='".e_BASE."fpw.php'>".LAN_LOGIN_12."</a>
</div>
</div>
</div>
</div>";
}
// ##### ------------------------------------------------------------------------------------------
?>