Index: branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php =================================================================== diff -u -r7368 -r7456 --- branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php (.../application.php) (revision 7368) +++ branches/unlabeled/unlabeled-1.166.4/core/kernel/application.php (.../application.php) (revision 7456) @@ -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']); } @@ -1592,7 +1623,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);