From 2dd9b59be610454dcd2e07497d7d4eaf90a99259 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 29 Jun 2006 01:17:47 +0000 Subject: [PATCH] r874: Only do template stuff as long as NO_TEMPLATES isn't set --- global.php | 125 +++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/global.php b/global.php index 03a3703..d2a5d44 100755 --- a/global.php +++ b/global.php @@ -40,73 +40,76 @@ $show['admin'] = (bool)can_perform('canadminpanel'); $show['newreport'] = (bool)can_perform('cansubmitbugs'); $show['search'] = (bool)can_perform('cansearch'); -// ################################################################### -// do style vars -if (($raw = @file_get_contents('./templates/stylevars.txt')) !== false) +if (!defined('NO_TEMPLATES') OR (defined('NO_TEMPLATES') AND constant('NO_TEMPLATES') == true)) { - // remove comments - $raw = preg_replace('#/\*(.*?)\*/#s', '', $raw); - $raw = trim($raw); - - // create individual vars - $varsraw = explode(';', $raw); - foreach ($varsraw AS $var) + // ################################################################### + // do style vars + if (($raw = @file_get_contents('./templates/stylevars.txt')) !== false) { - if (($var = trim($var)) == '') + // remove comments + $raw = preg_replace('#/\*(.*?)\*/#s', '', $raw); + $raw = trim($raw); + + // create individual vars + $varsraw = explode(';', $raw); + foreach ($varsraw AS $var) { - continue; + if (($var = trim($var)) == '') + { + continue; + } + + // split into varname - value pair + $temp = explode(':', $var); + + // clean up varnames + $varname = trim($temp[0]); + $varname = preg_replace('#[^a-z0-9]#i', '_', $varname); + + // clean up values + $value = trim($temp[1]); + $value = preg_replace('#[^a-z0-9%\-\.\#]#i', '', $value); + + // put it in the array + $stylevar["$varname"] = $value; } - - // split into varname - value pair - $temp = explode(':', $var); - - // clean up varnames - $varname = trim($temp[0]); - $varname = preg_replace('#[^a-z0-9]#i', '_', $varname); - - // clean up values - $value = trim($temp[1]); - $value = preg_replace('#[^a-z0-9%\-\.\#]#i', '', $value); - - // put it in the array - $stylevar["$varname"] = $value; } + else + { + trigger_error('StyleVars file (./templates/stylevars.txt) could not be loaded', E_USER_WARNING); + } + + // ################################################################### + // cache templates + $globaltemplates = array( + 'doctype', + 'header', + 'headinclude', + 'footer', + 'selectoption', + 'selectoptgroup', + 'std_error', + 'std_redirect', + 'std_message', + 'bugfield_input_text', + 'bugfield_input_checkbox', + 'bugfield_select_single_option', + 'bugfield_select_single', + 'username_display', + 'help_link' + ); + + $start = microtime(); + + $template->cache(array_merge($globaltemplates, (array)$fetchtemplates)); + + $bugsys->debug('time for tpl cache: ' . $funct->fetch_microtime_diff($start)); + + eval('$header = "' . $template->fetch('header') . '";'); + eval('$doctype = "' . $template->fetch('doctype') . '";'); + eval('$headinclude = "' . $template->fetch('headinclude') . '";'); + eval('$footer = "' . $template->fetch('footer') . '";'); } -else -{ - trigger_error('StyleVars file (./templates/stylevars.txt) could not be loaded', E_USER_WARNING); -} - -// ################################################################### -// cache templates -$globaltemplates = array( - 'doctype', - 'header', - 'headinclude', - 'footer', - 'selectoption', - 'selectoptgroup', - 'std_error', - 'std_redirect', - 'std_message', - 'bugfield_input_text', - 'bugfield_input_checkbox', - 'bugfield_select_single_option', - 'bugfield_select_single', - 'username_display', - 'help_link' -); - -$start = microtime(); - -$template->cache(array_merge($globaltemplates, (array)$fetchtemplates)); - -$bugsys->debug('time for tpl cache: ' . $funct->fetch_microtime_diff($start)); - -eval('$header = "' . $template->fetch('header') . '";'); -eval('$doctype = "' . $template->fetch('doctype') . '";'); -eval('$headinclude = "' . $template->fetch('headinclude') . '";'); -eval('$footer = "' . $template->fetch('footer') . '";'); // ################################################################### -- 2.22.5