Index: trunk/core/kernel/application.php =================================================================== diff -u -r2838 -r2839 --- trunk/core/kernel/application.php (.../application.php) (revision 2838) +++ trunk/core/kernel/application.php (.../application.php) (revision 2839) @@ -155,10 +155,11 @@ $this->SetDefaultConstants(); // 1. to read configs before doing any recallObject (called from "SetDefaultConstants" anyway) - //$config_reader =& $this->recallObject('kUnitConfigReader'); - - if( !$this->GetVar('m_lang') ) $this->SetVar('m_lang', $this->GetDefaultLanguageId() ); - if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId() ); + $config_reader =& $this->recallObject('kUnitConfigReader'); + + $this->VerifyLanguageId(); + $this->VerifyThemeId(); + if( $this->GetVar('m_cat_id') === false ) $this->SetVar('m_cat_id', 0); $this->Phrases = new PhrasesCache( $this->GetVar('m_lang') ); @@ -196,7 +197,41 @@ $this->InitDone = true; return true; } - + + /** + * Checks if passed language id if valid and sets it to primary otherwise + * + */ + function VerifyLanguageId() + { + $language_id = $this->GetVar('m_lang'); + if($language_id) + { + $table = $this->getUnitOption('lang','TableName'); + $id_field = $this->getUnitOption('lang','IDField'); + $language_ids = $this->DB->GetCol('SELECT '.$id_field.' FROM '.$table); + } + + if(!$language_id || !in_array($language_id, $language_ids) ) $this->SetVar('m_lang', $this->GetDefaultLanguageId() ); + } + + /** + * Checks if passed theme id if valid and sets it to primary otherwise + * + */ + function VerifyThemeId() + { + $theme_id = $this->GetVar('m_theme'); + if($theme_id) + { + $table = $this->getUnitOption('theme','TableName'); + $id_field = $this->getUnitOption('theme','IDField'); + $theme_ids = $this->DB->GetCol('SELECT '.$id_field.' FROM '.$table); + } + + if(!$theme_id || !in_array($theme_id, $theme_ids) ) $this->SetVar('m_theme', $this->GetDefaultThemeId() ); + } + function GetDefaultLanguageId() { $table = $this->getUnitOption('lang','TableName'); @@ -321,8 +356,6 @@ $contants_file = FULL_PATH.$module_path.'constants.php'; if( file_exists($contants_file) ) k4_include_once($contants_file); } - - $unit_config_reader =& $this->recallObject('kUnitConfigReader'); } function ProcessRequest() Index: trunk/core/kernel/parser/template.php =================================================================== diff -u -r2600 -r2839 --- trunk/core/kernel/parser/template.php (.../template.php) (revision 2600) +++ trunk/core/kernel/parser/template.php (.../template.php) (revision 2839) @@ -88,7 +88,6 @@ else { $current_theme = $this->Application->GetVar('m_theme'); $folder = $this->Application->DB->GetOne('SELECT Name FROM '.TABLE_PREFIX.'Theme WHERE ThemeId = '.$current_theme); - safeDefine( 'THEMES_PATH', preg_replace('/'.preg_quote(rtrim(FULL_PATH, '/'), '/').'/i','',str_replace('\\', '/', FULL_PATH)). ( defined('ADMIN') ? '/admin/templates' : '/themes/'.$folder)); } }