Index: trunk/core/kernel/application.php =================================================================== diff -u -r7391 -r7635 --- trunk/core/kernel/application.php (.../application.php) (revision 7391) +++ trunk/core/kernel/application.php (.../application.php) (revision 7635) @@ -363,6 +363,13 @@ return; } + $path = $this->GetFrontThemePath(); + if ($path === false) { + $this->ApplicationDie('No Primary Theme Selected or Current Theme is Unknonw or Disabled'); + } + safeDefine('THEMES_PATH', $path); + /* + $theme_id = $this->GetVar('m_theme'); if (!$theme_id) { $theme_id = $this->GetDefaultThemeId(); @@ -377,8 +384,32 @@ if (!defined('IS_INSTALL')) $this->ApplicationDie('Unknown or disabled theme'); } safeDefine('THEMES_PATH', '/themes/'.$theme->GetDBField('Name')); +*/ + } + function GetFrontThemePath($force=0) + { + static $path=null; + if (!$force && isset($path)) return $path; + + $theme_id = $this->GetVar('m_theme'); + if (!$theme_id) { + $theme_id = $this->GetDefaultThemeId(1); //1 to force front-end mode! + if (!$theme_id) { + return false; + } + } + $this->SetVar('m_theme', $theme_id); + $this->SetVar('theme.current_id', $theme_id ); // KOSTJA: this is to fool theme' getPassedId + $theme =& $this->recallObject('theme.current'); + if (!$theme->IsLoaded() || !$theme->GetDBField('Enabled')) { + return false; + } + $path = '/themes/'.$theme->GetDBField('Name'); + return $path; + } + function GetDefaultLanguageId() { static $language_id = 0; @@ -399,7 +430,7 @@ return $language_id; } - function GetDefaultThemeId() + function GetDefaultThemeId($force_front=0) { static $theme_id = 0; @@ -408,7 +439,7 @@ if (constOn('DBG_FORCE_THEME')) { $theme_id = DBG_FORCE_THEME; } - elseif ($this->IsAdmin()) { + elseif (!$force_front && $this->IsAdmin()) { $theme_id = 999; } else { @@ -590,7 +621,7 @@ * * @access private */ - function SetDefaultConstants() + function SetDefaultConstants() // it's defined in startup.php - can be removed?? { safeDefine('SERVER_NAME', $_SERVER['HTTP_HOST']); } @@ -618,6 +649,7 @@ function ProcessRequest() { $event_manager =& $this->recallObject('EventManager'); + /* @var $event_manager kEventManager */ if($this->isDebugMode() && constOn('DBG_SHOW_HTTPQUERY')) { $this->Debugger->appendHTML('HTTPQuery:'); @@ -1224,7 +1256,14 @@ */ function getPassInfo($pass = 'all') { - $pass = trim(preg_replace('/(?<=,|\\A)all(?=,|\\z)/', trim($this->GetVar('passed'), ','), trim($pass, ',')), ','); + if (!$pass) $pass = 'all'; + $pass = trim( + preg_replace( + '/(?<=,|\\A)all(?=,|\\z)/', + trim($this->GetVar('passed'), ','), + trim($pass, ',') + ), + ','); if (!$pass) { return Array(); @@ -1593,7 +1632,7 @@ if (!$this->IsAdmin()) { // needed for "profile edit", "registration" forms ON FRONT ONLY - $this->SetVar('u_id', $user_id); + $this->SetVar('u_id', $user_id); } $this->StoreVar('user_id', $user_id); @@ -1624,6 +1663,7 @@ $this->Session->LoadPersistentVars(); } + function LoadCache() { $cache_key = $this->GetVar('t').$this->GetVar('m_theme').$this->GetVar('m_lang').$this->IsAdmin(); @@ -2131,10 +2171,10 @@ if ($real_top) return $current_prefix; // 2. find what if parent is passed - $passed = explode(',', $this->GetVar('passed')); - foreach ($prefixes as $current_prefix) { - if (in_array($current_prefix, $passed)) { - break; + $passed = explode(',', $this->GetVar('all_passed')); + foreach ($prefixes as $a_prefix) { + if (in_array($a_prefix, $passed)) { + return $a_prefix; } }