mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Prevent usage of Less
This commit is contained in:
parent
29cbd0fbb6
commit
7838aee0f1
4 changed files with 27 additions and 13 deletions
|
|
@ -99,25 +99,31 @@ trait Themes
|
||||||
$sTheme = \substr($sTheme, 0, -7);
|
$sTheme = \substr($sTheme, 0, -7);
|
||||||
}
|
}
|
||||||
|
|
||||||
$aResult = array();
|
$mResult = 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';
|
|
||||||
|
|
||||||
$sBase = ($bCustomTheme ? \RainLoop\Utils::WebPath() : \RainLoop\Utils::WebVersionPath())
|
$sBase = ($bCustomTheme ? \RainLoop\Utils::WebPath() : \RainLoop\Utils::WebVersionPath())
|
||||||
. "themes/{$sTheme}/";
|
. "themes/{$sTheme}/";
|
||||||
|
|
||||||
|
$bLess = false;
|
||||||
|
|
||||||
|
$sThemeCSSFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH).'themes/'.$sTheme.'/styles.css';
|
||||||
if (\is_file($sThemeCSSFile)) {
|
if (\is_file($sThemeCSSFile)) {
|
||||||
$aResult[] = \preg_replace('@(url\(["\']?)(\\./)?([a-z]+[^:a-z])@',
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$mResult[] = $this->Plugins()->CompileCss($bAdmin, $bLess);
|
||||||
|
|
||||||
|
$mResult = \preg_replace('@(url\(["\']?)(\\./)?([a-z]+[^:a-z])@',
|
||||||
"\$1{$sBase}\$3",
|
"\$1{$sBase}\$3",
|
||||||
\str_replace('@{base}', $sBase, \file_get_contents($sThemeCSSFile)));
|
\str_replace('@{base}', $sBase, \implode("\n", $mResult)));
|
||||||
} else if (\is_file($sThemeLessFile)) {
|
|
||||||
$aResult[] = "@base: \"{$sBase}\";";
|
|
||||||
$aResult[] = \file_get_contents($sThemeLessFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
$aResult[] = $this->Plugins()->CompileCss($bAdmin);
|
return $bLess ? (new \LessPHP\lessc())->compile($mResult) : $mResult;
|
||||||
|
|
||||||
return (new \LessPHP\lessc())->compile(\implode("\n", $aResult));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,13 +167,14 @@ class Manager
|
||||||
return $this->bIsEnabled && \count($this->aJs[$bAdminScope ? 1 : 0]);
|
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();
|
$aResult = array();
|
||||||
if ($this->bIsEnabled) {
|
if ($this->bIsEnabled) {
|
||||||
foreach ($this->aCss[$bAdminScope ? 1 : 0] as $sFile) {
|
foreach ($this->aCss[$bAdminScope ? 1 : 0] as $sFile) {
|
||||||
if (\is_readable($sFile)) {
|
if (\is_readable($sFile)) {
|
||||||
$aResult[] = \file_get_contents($sFile);
|
$aResult[] = \file_get_contents($sFile);
|
||||||
|
$bLess = $bLess || \str_ends_with($sFile, '.less');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,13 @@ if (!function_exists('str_starts_with')) {
|
||||||
return 0 === strncmp($haystack, $needle, strlen($needle));
|
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')) {
|
if (!defined('APP_VERSION')) {
|
||||||
define('APP_VERSION', basename(__DIR__));
|
define('APP_VERSION', basename(__DIR__));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue