diff --git a/plugins/change-password/style.less b/plugins/change-password/style.css similarity index 100% rename from plugins/change-password/style.less rename to plugins/change-password/style.css diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Themes.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Themes.php index bd1ee1473..c64aaef6b 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Themes.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Themes.php @@ -99,25 +99,31 @@ trait Themes $sTheme = \substr($sTheme, 0, -7); } - $aResult = array(); - - $sThemeCSSFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH).'themes/'.$sTheme.'/styles.css'; - $sThemeLessFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH).'themes/'.$sTheme.'/styles.less'; + $mResult = array(); $sBase = ($bCustomTheme ? \RainLoop\Utils::WebPath() : \RainLoop\Utils::WebVersionPath()) . "themes/{$sTheme}/"; + $bLess = false; + + $sThemeCSSFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH).'themes/'.$sTheme.'/styles.css'; if (\is_file($sThemeCSSFile)) { - $aResult[] = \preg_replace('@(url\(["\']?)(\\./)?([a-z]+[^:a-z])@', - "\$1{$sBase}\$3", - \str_replace('@{base}', $sBase, \file_get_contents($sThemeCSSFile))); - } else if (\is_file($sThemeLessFile)) { - $aResult[] = "@base: \"{$sBase}\";"; - $aResult[] = \file_get_contents($sThemeLessFile); + $mResult[] = \file_get_contents($sThemeCSSFile); + } else { + $sThemeCSSFile = \str_replace('styles.css', 'styles.less', $sThemeCSSFile); + if (\is_file($sThemeCSSFile)) { + $bLess = true; + $mResult[] = "@base: \"{$sBase}\";"; + $mResult[] = \file_get_contents($sThemeCSSFile); + } } - $aResult[] = $this->Plugins()->CompileCss($bAdmin); + $mResult[] = $this->Plugins()->CompileCss($bAdmin, $bLess); - return (new \LessPHP\lessc())->compile(\implode("\n", $aResult)); + $mResult = \preg_replace('@(url\(["\']?)(\\./)?([a-z]+[^:a-z])@', + "\$1{$sBase}\$3", + \str_replace('@{base}', $sBase, \implode("\n", $mResult))); + + return $bLess ? (new \LessPHP\lessc())->compile($mResult) : $mResult; } } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Manager.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Manager.php index 353371da1..fb6d02189 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Manager.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Manager.php @@ -167,13 +167,14 @@ class Manager return $this->bIsEnabled && \count($this->aJs[$bAdminScope ? 1 : 0]); } - public function CompileCss(bool $bAdminScope = false) : string + public function CompileCss(bool $bAdminScope, bool &$bLess) : string { $aResult = array(); if ($this->bIsEnabled) { foreach ($this->aCss[$bAdminScope ? 1 : 0] as $sFile) { if (\is_readable($sFile)) { $aResult[] = \file_get_contents($sFile); + $bLess = $bLess || \str_ends_with($sFile, '.less'); } } } diff --git a/snappymail/v/0.0.0/include.php b/snappymail/v/0.0.0/include.php index 6ddb5ac65..32f69d868 100644 --- a/snappymail/v/0.0.0/include.php +++ b/snappymail/v/0.0.0/include.php @@ -26,6 +26,13 @@ if (!function_exists('str_starts_with')) { return 0 === strncmp($haystack, $needle, strlen($needle)); } } +if (!function_exists('str_ends_with')) { + function str_ends_with(string $haystack, string $needle) : bool + { + $length = strlen($needle); + return $length ? substr($haystack, -$length) === $needle : true; + } +} if (!defined('APP_VERSION')) { define('APP_VERSION', basename(__DIR__));