Index: trunk/core/units/general/inp1_parser.php
===================================================================
diff -u -N -r4446 -r4567
--- trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 4446)
+++ trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 4567)
@@ -1,12 +1,15 @@
InportalInited) {
//$save_t = $this->Application->GetVar('t');
$this->InitInPortal();
@@ -31,6 +34,7 @@
$template_body = $this->Application->Parser->Parse( $template_cache->GetTemplateBody($t), $t, 0 );
}
else {
+ $this->InitParser();
$template_body = $objTemplate->ParseTemplateFromBuffer($tname, $template_body);
}
return $template_body;
@@ -45,6 +49,25 @@
return $tname;
}
+ function InitParser()
+ {
+ global $objTemplate, $CurrentTheme, $objThemes, $objLanguageCache, $var_list;
+ if ($this->InpParsetInited) return true;
+
+ $theme_id = $this->Application->GetVar('m_theme');
+ if ($theme_id) {
+ $CurrentTheme = $objThemes->GetItem($theme_id);
+
+ $timeout = $CurrentTheme->Get('CacheTimeout');
+ $objLanguageCache->LoadTemplateCache($var_list['t'], $timeout, $theme_id);
+ $objLanguageCache->LoadCachedVars($this->Application->GetVar('m_lang'));
+
+ $objTemplate = new clsTemplateList(FULL_PATH.THEMES_PATH.'/');
+ }
+
+ $this->InpParsetInited = true;
+ }
+
function InitInPortal()
{
$this->InportalInited = true;
@@ -94,100 +117,39 @@
include_once(FULL_PATH."/kernel/startup.php");
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
-
- //$secureURL = "https://".ThisDomain().$objConfig->Get("Site_Path");
$secureURL = $rootURL;
- $html= '';
-
if( !$var_list['t'] ) $var_list['t'] = 'index';
- if( !isset($CurrentTheme) ) $CurrentTheme = null;
+ $this->InitParser();
- $theme_id = defined('DBG_FORCE_THEME') && DBG_FORCE_THEME ? DBG_FORCE_THEME : $m_var_list['theme'];
-
- if( !is_object($CurrentTheme) ) $CurrentTheme = $objThemes->GetItem($theme_id);
-
- if(is_object($CurrentTheme))
- {
- if(!$CurrentTheme->Get("Enabled"))
- {
- $CurrentTheme = $objThemes->GetItem($objThemes->GetPrimaryTheme());
- }
- if((int)$CurrentTheme->Get("ThemeId")>0)
- {
- $timeout = $CurrentTheme->Get("CacheTimeout");
- $objLanguageCache->LoadTemplateCache($var_list["t"],$timeout,$CurrentTheme->Get("ThemeId"));
- $objLanguageCache->LoadCachedVars($objSession->Get("Language"));
-
- $TemplateRoot = $CurrentTheme->ThemeDirectory()."/";
-
- $objTemplate = new clsTemplateList($TemplateRoot);
- //$html = $objTemplate->ParseTemplate($var_list["t"]);
- }
- else
- {
- echo "No Primary Theme Selected";
- die();
- }
- }
- else
- {
- echo "No Primary Theme Selected\n";
- die();
- }
-
- if(is_object($objSession))
- {
+ // process referer in session: begin
+ if (is_object($objSession)) {
$k4_referer = $objSession->GetVariable('K4_Template_Referer');
- if($k4_referer)
- {
+ if ($k4_referer) {
$_local_t = $k4_referer;
$this->Application->RemoveVar('K4_Template_Referer');
}
- $objSession->SetVariable("Template_Referer", $_local_t);
+ $objSession->SetVariable('Template_Referer', $_local_t);
}
- if($objTemplate->ErrorNo == -1)
- {
- $html = $objTemplate->ParseTemplate('error_template');
- }
- //$html = replacePngTags($html);
- LogEntry("Output Start\n");
- $html .= "";
- if( IsDebugMode() )
- {
- if($Action) $debugger->setHTMLByIndex(1,'Front Action: '.$Action.'','append');
- //$html = 'Show Debugger
'.$html;
- }
- else
- {
-// header("Content-length: ".strlen($html));
- }
-// header("Connection-Type: Keep-Alive");
-// echo $html;
+ // process referer in session: end
- LogEntry("Output End\n");
-
- if( isset($template) && $template->ErrorNo != 0 )
- {
- print "\n(".$objTemplate->ErrorNo.") ".$objTemplate->ErrorStr."\n";
+ if ($this->Application->isDebugMode() && $Action) {
+ $this->Application->Debugger->setHTMLByIndex(1, 'Front Action: '.$Action.'', 'append');
}
LogEntry("Output Complete\n");
$objLanguageCache->SaveTemplateCache();
LogEntry("Templates Cached\n");
- //if($objSession->SessionEnabled())
- // $objSession->SaveSessionData();
- //echo "Cookie:
"; print_r($_COOKIE); echo "
\n";
- //ob_end_flush();
$timeend = getmicrotime();
$diff = $timeend - $timestart;
LogEntry("\nTotal Queries Executed: $sqlcount in $totalsql seconds\n");
LogEntry("\nPage Execution Time: $diff seconds\n", true);
- if($LogFile)
+ if ($LogFile) {
fclose($LogFile);
+ }
}
}
Index: trunk/core/kernel/application.php
===================================================================
diff -u -N -r4529 -r4567
--- trunk/core/kernel/application.php (.../application.php) (revision 4529)
+++ trunk/core/kernel/application.php (.../application.php) (revision 4567)
@@ -252,15 +252,16 @@
function VerifyLanguageId()
{
$language_id = $this->GetVar('m_lang');
- if($language_id)
- {
+ if ($language_id) {
$table = $this->getUnitOption('lang', 'TableName');
$id_field = $this->getUnitOption('lang', 'IDField');
- $language_ids = $this->DB->GetCol('SELECT '.$id_field.' FROM '.$table);
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table.'
+ WHERE Enabled = 1';
+ $language_ids = $this->DB->GetCol($sql);
}
- if ( !$language_id || !in_array($language_id, $language_ids) )
- {
+ if (!$language_id || !in_array($language_id, $language_ids)) {
$this->SetVar('m_lang', $this->GetDefaultLanguageId() );
}
$this->SetVar('lang.current_id', $this->GetVar('m_lang') );
@@ -273,15 +274,16 @@
function VerifyThemeId()
{
$theme_id = $this->GetVar('m_theme');
- if($theme_id)
- {
+ if ($theme_id) {
$table = $this->getUnitOption('theme', 'TableName');
$id_field = $this->getUnitOption('theme', 'IDField');
- $theme_ids = $this->DB->GetCol('SELECT '.$id_field.' FROM '.$table);
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table.'
+ WHERE Enabled = 1';
+ $theme_ids = $this->DB->GetCol($sql);
}
- if ( !$theme_id || !in_array($theme_id, $theme_ids) )
- {
+ if (!$theme_id || !in_array($theme_id, $theme_ids)) {
$this->SetVar('m_theme', $this->GetDefaultThemeId() );
}
$this->SetVar('theme.current_id', $this->GetVar('m_theme') );
@@ -295,7 +297,10 @@
$table = $this->getUnitOption('lang','TableName');
$id_field = $this->getUnitOption('lang','IDField');
- $language_id = $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryLang = 1');
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table.'
+ WHERE (PrimaryLang = 1) AND (Enabled = 1)';
+ $language_id = $this->DB->GetOne($sql);
return $language_id;
}
@@ -306,15 +311,16 @@
if($theme_id > 0) return $theme_id;
- if ( constOn('DBG_FORCE_THEME') )
- {
+ if (constOn('DBG_FORCE_THEME')) {
$theme_id = DBG_FORCE_THEME;
}
- else
- {
+ else {
$table = $this->getUnitOption('theme','TableName');
$id_field = $this->getUnitOption('theme','IDField');
- $theme_id = $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryTheme = 1');
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table.'
+ WHERE (PrimaryTheme = 1) AND (Enabled = 1)';
+ $theme_id = $this->DB->GetOne($sql);
}
return $theme_id;
}
Index: trunk/kernel/include/parse.php
===================================================================
diff -u -N -r3576 -r4567
--- trunk/kernel/include/parse.php (.../parse.php) (revision 3576)
+++ trunk/kernel/include/parse.php (.../parse.php) (revision 4567)
@@ -424,6 +424,7 @@
function clsTemplateList($root_dir)
{
+ $GLOBALS['TemplateRoot'] = $root_dir;
$this->templates = Array();
$this->root_dir = $root_dir;
$this->ErrorStr = '';
Index: trunk/core/kernel/parser/template.php
===================================================================
diff -u -N -r4490 -r4567
--- trunk/core/kernel/parser/template.php (.../template.php) (revision 4490)
+++ trunk/core/kernel/parser/template.php (.../template.php) (revision 4567)
@@ -88,19 +88,20 @@
function SetThemePath()
{
- if ( defined('SPECIAL_TEMPLATES_FOLDER') )
- {
+ if (defined('SPECIAL_TEMPLATES_FOLDER')) {
$sub_folder = SPECIAL_TEMPLATES_FOLDER;
}
- elseif( $this->Application->IsAdmin() )
- {
+ elseif ($this->Application->IsAdmin()) {
$sub_folder = '/admin/templates';
}
- else
- {
- $current_theme = $this->Application->GetVar('m_theme');
- $theme_folder = $this->Application->DB->GetOne('SELECT Name FROM '.TABLE_PREFIX.'Theme WHERE ThemeId = '.$current_theme);
- $sub_folder = '/themes/'.$theme_folder;
+ else {
+ $theme =& $this->Application->recallObject('theme.current');
+ if ($theme->isLoaded()) {
+ $sub_folder = '/themes/'.$theme->GetDBField('Name');
+ }
+ else {
+ die('No Primary Theme Selected');
+ }
}
safeDefine('THEMES_PATH', $sub_folder);
}
Index: trunk/kernel/units/general/inp1_parser.php
===================================================================
diff -u -N -r4446 -r4567
--- trunk/kernel/units/general/inp1_parser.php (.../inp1_parser.php) (revision 4446)
+++ trunk/kernel/units/general/inp1_parser.php (.../inp1_parser.php) (revision 4567)
@@ -1,12 +1,15 @@
InportalInited) {
//$save_t = $this->Application->GetVar('t');
$this->InitInPortal();
@@ -31,6 +34,7 @@
$template_body = $this->Application->Parser->Parse( $template_cache->GetTemplateBody($t), $t, 0 );
}
else {
+ $this->InitParser();
$template_body = $objTemplate->ParseTemplateFromBuffer($tname, $template_body);
}
return $template_body;
@@ -45,6 +49,25 @@
return $tname;
}
+ function InitParser()
+ {
+ global $objTemplate, $CurrentTheme, $objThemes, $objLanguageCache, $var_list;
+ if ($this->InpParsetInited) return true;
+
+ $theme_id = $this->Application->GetVar('m_theme');
+ if ($theme_id) {
+ $CurrentTheme = $objThemes->GetItem($theme_id);
+
+ $timeout = $CurrentTheme->Get('CacheTimeout');
+ $objLanguageCache->LoadTemplateCache($var_list['t'], $timeout, $theme_id);
+ $objLanguageCache->LoadCachedVars($this->Application->GetVar('m_lang'));
+
+ $objTemplate = new clsTemplateList(FULL_PATH.THEMES_PATH.'/');
+ }
+
+ $this->InpParsetInited = true;
+ }
+
function InitInPortal()
{
$this->InportalInited = true;
@@ -94,100 +117,39 @@
include_once(FULL_PATH."/kernel/startup.php");
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
-
- //$secureURL = "https://".ThisDomain().$objConfig->Get("Site_Path");
$secureURL = $rootURL;
- $html= '';
-
if( !$var_list['t'] ) $var_list['t'] = 'index';
- if( !isset($CurrentTheme) ) $CurrentTheme = null;
+ $this->InitParser();
- $theme_id = defined('DBG_FORCE_THEME') && DBG_FORCE_THEME ? DBG_FORCE_THEME : $m_var_list['theme'];
-
- if( !is_object($CurrentTheme) ) $CurrentTheme = $objThemes->GetItem($theme_id);
-
- if(is_object($CurrentTheme))
- {
- if(!$CurrentTheme->Get("Enabled"))
- {
- $CurrentTheme = $objThemes->GetItem($objThemes->GetPrimaryTheme());
- }
- if((int)$CurrentTheme->Get("ThemeId")>0)
- {
- $timeout = $CurrentTheme->Get("CacheTimeout");
- $objLanguageCache->LoadTemplateCache($var_list["t"],$timeout,$CurrentTheme->Get("ThemeId"));
- $objLanguageCache->LoadCachedVars($objSession->Get("Language"));
-
- $TemplateRoot = $CurrentTheme->ThemeDirectory()."/";
-
- $objTemplate = new clsTemplateList($TemplateRoot);
- //$html = $objTemplate->ParseTemplate($var_list["t"]);
- }
- else
- {
- echo "No Primary Theme Selected";
- die();
- }
- }
- else
- {
- echo "No Primary Theme Selected\n";
- die();
- }
-
- if(is_object($objSession))
- {
+ // process referer in session: begin
+ if (is_object($objSession)) {
$k4_referer = $objSession->GetVariable('K4_Template_Referer');
- if($k4_referer)
- {
+ if ($k4_referer) {
$_local_t = $k4_referer;
$this->Application->RemoveVar('K4_Template_Referer');
}
- $objSession->SetVariable("Template_Referer", $_local_t);
+ $objSession->SetVariable('Template_Referer', $_local_t);
}
- if($objTemplate->ErrorNo == -1)
- {
- $html = $objTemplate->ParseTemplate('error_template');
- }
- //$html = replacePngTags($html);
- LogEntry("Output Start\n");
- $html .= "";
- if( IsDebugMode() )
- {
- if($Action) $debugger->setHTMLByIndex(1,'Front Action: '.$Action.'','append');
- //$html = 'Show Debugger
'.$html;
- }
- else
- {
-// header("Content-length: ".strlen($html));
- }
-// header("Connection-Type: Keep-Alive");
-// echo $html;
+ // process referer in session: end
- LogEntry("Output End\n");
-
- if( isset($template) && $template->ErrorNo != 0 )
- {
- print "\n(".$objTemplate->ErrorNo.") ".$objTemplate->ErrorStr."\n";
+ if ($this->Application->isDebugMode() && $Action) {
+ $this->Application->Debugger->setHTMLByIndex(1, 'Front Action: '.$Action.'', 'append');
}
LogEntry("Output Complete\n");
$objLanguageCache->SaveTemplateCache();
LogEntry("Templates Cached\n");
- //if($objSession->SessionEnabled())
- // $objSession->SaveSessionData();
- //echo "Cookie: "; print_r($_COOKIE); echo "
\n";
- //ob_end_flush();
$timeend = getmicrotime();
$diff = $timeend - $timestart;
LogEntry("\nTotal Queries Executed: $sqlcount in $totalsql seconds\n");
LogEntry("\nPage Execution Time: $diff seconds\n", true);
- if($LogFile)
+ if ($LogFile) {
fclose($LogFile);
+ }
}
}