diff --git a/application/themehandler.class.inc.php b/application/themehandler.class.inc.php index dc9de8e5b..cc92c0ccb 100644 --- a/application/themehandler.class.inc.php +++ b/application/themehandler.class.inc.php @@ -27,6 +27,29 @@ use ScssPhp\ScssPhp\Compiler; */ class ThemeHandler { + /** + * Return default theme name and parameters + * + * @return array + * @since 2.7.0 + */ + public static function GetDefaultThemeInformation() + { + return array( + 'name' => 'light-grey', + 'parameters' => array( + 'variables' => array(), + 'imports' => array( + 'css-variables' => '../css/css-variables.scss', + ), + 'stylesheets' => array( + 'jqueryui' => '../css/ui-lightness/jqueryui.scss', + 'main' => '../css/light-grey.scss', + ), + ), + ); + } + /** * Return the absolute URL for the default theme CSS file * @@ -35,8 +58,26 @@ class ThemeHandler */ public static function GetDefaultThemeUrl() { - $sThemeId = MetaModel::GetConfig()->Get('backoffice_default_theme'); - static::CompileTheme($sThemeId); + try + { + $sThemeId = MetaModel::GetConfig()->Get('backoffice_default_theme'); + static::CompileTheme($sThemeId); + } + catch(CoreException $oCompileException) + { + // Fallback on our default theme (should always be compilable) + $aDefaultTheme = ThemeHandler::GetDefaultThemeInformation(); + $sThemeId = $aDefaultTheme['name']; + $sDefaultThemeDirPath = APPROOT.'env-'.utils::GetCurrentEnvironment().'/branding/themes/'.$sThemeId.'/'; + + // Create our theme dir if it doesn't exist (XML theme node removed, renamed etc..) + if(!is_dir($sDefaultThemeDirPath)) + { + SetupUtils::builddir($sDefaultThemeDirPath); + } + + static::CompileTheme($sThemeId, $aDefaultTheme['parameters']); + } // Return absolute url to theme compiled css return utils::GetAbsoluteUrlModulesRoot().'/branding/themes/'.$sThemeId.'/main.css'; diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index d5bc92d91..0bd190ef4 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -2737,7 +2737,7 @@ EOF; // Force to have a default theme if none in the DM if(empty($aThemes)) { - $aDefaultThemeInfo = $this->GetDefaultThemeInformation(); + $aDefaultThemeInfo = ThemeHandler::GetDefaultThemeInformation(); $aThemes[$aDefaultThemeInfo['name']] = $aDefaultThemeInfo['parameters']; } @@ -2755,29 +2755,6 @@ EOF; } } - /** - * Return default theme name and parameters - * - * @return array - * @since 2.7.0 - */ - protected function GetDefaultThemeInformation() - { - return array( - 'name' => 'light-grey', - 'parameters' => array( - 'variables' => array(), - 'imports' => array( - 'css-variables' => '../css/css-variables.scss', - ), - 'stylesheets' => array( - 'jqueryui' => '../css/ui-lightness/jqueryui.scss', - 'main' => '../css/light-grey.scss', - ), - ), - ); - } - /** * @param \MFElement $oBrandingNode * @param string $sTempTargetDir