mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 10:08:45 +02:00
N°2314 - Markup extensibility: Refactor utils::GetCSSFromSASS() to enable SCSS compilation out of a file
This commit is contained in:
@@ -109,18 +109,7 @@ class ThemeHandler
|
||||
// Checking if our compiled css is outdated
|
||||
if (!file_exists($sThemeCssPath) || (is_writable($sThemeFolderPath) && (@filemtime($sThemeCssPath) < $iStyleLastModified)))
|
||||
{
|
||||
$oScss = new Compiler();
|
||||
$oScss->setFormatter('ScssPhp\\ScssPhp\\Formatter\\Expanded');
|
||||
// Setting our xml variables
|
||||
$oScss->setVariables($aThemeParameters['variables']);
|
||||
// Setting our imports paths
|
||||
$oScss->setImportPaths($aImportsPaths);
|
||||
// Temporary disabling max exec time while compiling
|
||||
$iCurrentMaxExecTime = (int)ini_get('max_execution_time');
|
||||
set_time_limit(0);
|
||||
// Compiling our theme
|
||||
$sTmpThemeCssContent = $oScss->compile($sTmpThemeScssContent);
|
||||
set_time_limit($iCurrentMaxExecTime);
|
||||
$sTmpThemeCssContent = utils::CompileCSSFromSASS($sTmpThemeScssContent, $aImportsPaths, $aThemeParameters['variables']);
|
||||
file_put_contents($sThemeCssPath, $sTmpThemeCssContent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
* Copyright (C) 2013-2020 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
@@ -1566,18 +1566,40 @@ class utils
|
||||
clearstatcache();
|
||||
if (!file_exists($sCssPath) || (is_writable($sCssPath) && (filemtime($sCssPath) < filemtime($sSassPath))))
|
||||
{
|
||||
$oScss = new Compiler();
|
||||
$oScss->setImportPaths($aImportPaths);
|
||||
$oScss->setFormatter('ScssPhp\\ScssPhp\\Formatter\\Expanded');
|
||||
// Temporary disabling max exec time while compiling
|
||||
$iCurrentMaxExecTime = (int) ini_get('max_execution_time');
|
||||
set_time_limit(0);
|
||||
$sCss = $oScss->compile(file_get_contents($sSassPath));
|
||||
set_time_limit($iCurrentMaxExecTime);
|
||||
$sCss = static::CompileCSSFromSASS(file_get_contents($sSassPath), $aImportPaths);
|
||||
file_put_contents($sCssPath, $sCss);
|
||||
}
|
||||
return $sCssRelPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string of CSS compiled from the $sSassContent
|
||||
*
|
||||
* @param string $sSassContent
|
||||
* @param array $aImportPaths
|
||||
* @param array $aVariables
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public static function CompileCSSFromSASS($sSassContent, $aImportPaths = array(), $aVariables = array())
|
||||
{
|
||||
$oSass = new Compiler();
|
||||
$oSass->setFormatter('ScssPhp\\ScssPhp\\Formatter\\Expanded');
|
||||
// Setting our variables
|
||||
$oSass->setVariables($aVariables);
|
||||
// Setting our imports paths
|
||||
$oSass->setImportPaths($aImportPaths);
|
||||
// Temporary disabling max exec time while compiling
|
||||
$iCurrentMaxExecTime = (int) ini_get('max_execution_time');
|
||||
set_time_limit(0);
|
||||
// Compiling SASS
|
||||
$sCss = $oSass->compile($sSassContent);
|
||||
set_time_limit($iCurrentMaxExecTime);
|
||||
|
||||
return $sCss;
|
||||
}
|
||||
|
||||
public static function GetImageSize($sImageData)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user