From e2940150c37011bd77ca8c47ea9b09607115ef7a Mon Sep 17 00:00:00 2001 From: odain Date: Mon, 15 Feb 2021 17:23:58 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02982=20-=20Speed=20up=20SCSS=20themes=20?= =?UTF-8?q?compilation=20during=20setup=20:=20create=20a=20php=20file=20de?= =?UTF-8?q?dicated=20to=20CompileCSSService/FindStylesheetObject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/compilecssservice.class.inc.php | 38 ++++++ .../findstylesheetobject.class.inc.php | 114 ++++++++++++++++++ lib/composer/autoload_classmap.php | 3 +- lib/composer/autoload_static.php | 3 +- 4 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 application/compilecssservice.class.inc.php create mode 100644 application/findstylesheetobject.class.inc.php diff --git a/application/compilecssservice.class.inc.php b/application/compilecssservice.class.inc.php new file mode 100644 index 000000000..dde4af42b --- /dev/null +++ b/application/compilecssservice.class.inc.php @@ -0,0 +1,38 @@ + + * @since 3.0.0 N°2982 + */ +class CompileCSSService +{ + /** + * CompileCSSService constructor. + */ + public function __construct() + { + } + + public function CompileCSSFromSASS($sSassContent, $aImportPaths = [], $aVariables = []){ + return utils::CompileCSSFromSASS($sSassContent, $aImportPaths, $aVariables); + } +} \ No newline at end of file diff --git a/application/findstylesheetobject.class.inc.php b/application/findstylesheetobject.class.inc.php new file mode 100644 index 000000000..43985f378 --- /dev/null +++ b/application/findstylesheetobject.class.inc.php @@ -0,0 +1,114 @@ + + * @since 3.0.0 N°3588 + */ +class FindStylesheetObject{ + + //file URIs + private $aStylesheetFileURIs; + + //fill paths + private $aStylesheetImportPaths; + private $aAllStylesheetFilePaths; + private $sLastStyleSheetPath; + + private $iLastModified; + + /** + * FindStylesheetObject constructor. + */ + public function __construct() + { + $this->aStylesheetFileURIs = []; + $this->aStylesheetImportPaths = []; + $this->aAllStylesheetFilePaths = []; + $this->sLastStyleSheetPath = ""; + $this->iLastModified = 0; + } + + public function GetLastStylesheetFile(): string + { + return $this->sLastStyleSheetPath; + } + + public function GetImportPaths(): array + { + return $this->aStylesheetImportPaths; + } + + /** + * @return array : main stylesheets URIs + */ + public function GetStylesheetFileURIs(): array + { + return $this->aStylesheetFileURIs; + } + + public function GetLastModified() : int + { + return $this->iLastModified; + } + + /** + * @return array : main stylesheets paths + included files paths + */ + public function GetAllStylesheetPaths(): array + { + return $this->aAllStylesheetFilePaths; + } + + /** + * @return string : last found stylesheet URI + */ + public function GetLastStyleSheetPath(): string + { + return $this->sLastStyleSheetPath; + } + + public function AddStylesheet(string $sStylesheetFileURI, string $sStylesheetFilePath): void + { + $this->aStylesheetFileURIs[] = $sStylesheetFileURI; + $this->aAllStylesheetFilePaths[] = $sStylesheetFilePath; + $this->sLastStyleSheetPath = $sStylesheetFilePath; + } + + public function AlreadyFetched(string $sStylesheetFilePath) : bool { + return in_array($sStylesheetFilePath, $this->aAllStylesheetFilePaths); + } + + public function AddImport(string $sStylesheetFileURI, string $sStylesheetFilePath): void + { + $this->aStylesheetImportPaths[$sStylesheetFileURI] = $sStylesheetFilePath; + $this->aAllStylesheetFilePaths[] = $sStylesheetFilePath; + } + + public function UpdateLastModified(string $sStylesheetFile): void + { + $this->iLastModified = max($this->iLastModified, @filemtime($sStylesheetFile)); + } + + public function ResetLastStyleSheet(): void + { + $this->sLastStyleSheetPath = ""; + } +} \ No newline at end of file diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index c1164c983..17feab59d 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -335,7 +335,7 @@ return array( 'Combodo\\iTop\\Renderer\\FormRenderer' => $baseDir . '/sources/Renderer/FormRenderer.php', 'Combodo\\iTop\\Renderer\\RenderingOutput' => $baseDir . '/sources/Renderer/RenderingOutput.php', 'Combodo\\iTop\\TwigExtension' => $baseDir . '/application/twigextension.class.inc.php', - 'CompileCSSService' => $baseDir . '/application/themehandler.class.inc.php', + 'CompileCSSService' => $baseDir . '/application/compilecssservice.class.inc.php', 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 'Config' => $baseDir . '/core/config.class.inc.php', 'ConfigException' => $baseDir . '/application/exceptions/ConfigException.php', @@ -443,6 +443,7 @@ return array( 'FilterDefinition' => $baseDir . '/core/filterdef.class.inc.php', 'FilterFromAttribute' => $baseDir . '/core/filterdef.class.inc.php', 'FilterPrivateKey' => $baseDir . '/core/filterdef.class.inc.php', + 'FindStylesheetObject' => $baseDir . '/application/findstylesheetobject.class.inc.php', 'FunctionExpression' => $baseDir . '/core/oql/expression.class.inc.php', 'FunctionOqlExpression' => $baseDir . '/core/oql/oqlquery.class.inc.php', 'GraphEdge' => $baseDir . '/core/simplegraph.class.inc.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index f3480ebe1..e17765b4a 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -565,7 +565,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Combodo\\iTop\\Renderer\\FormRenderer' => __DIR__ . '/../..' . '/sources/Renderer/FormRenderer.php', 'Combodo\\iTop\\Renderer\\RenderingOutput' => __DIR__ . '/../..' . '/sources/Renderer/RenderingOutput.php', 'Combodo\\iTop\\TwigExtension' => __DIR__ . '/../..' . '/application/twigextension.class.inc.php', - 'CompileCSSService' => __DIR__ . '/../..' . '/application/themehandler.class.inc.php', + 'CompileCSSService' => __DIR__ . '/../..' . '/application/compilecssservice.class.inc.php', 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 'Config' => __DIR__ . '/../..' . '/core/config.class.inc.php', 'ConfigException' => __DIR__ . '/../..' . '/application/exceptions/ConfigException.php', @@ -673,6 +673,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'FilterDefinition' => __DIR__ . '/../..' . '/core/filterdef.class.inc.php', 'FilterFromAttribute' => __DIR__ . '/../..' . '/core/filterdef.class.inc.php', 'FilterPrivateKey' => __DIR__ . '/../..' . '/core/filterdef.class.inc.php', + 'FindStylesheetObject' => __DIR__ . '/../..' . '/application/findstylesheetobject.class.inc.php', 'FunctionExpression' => __DIR__ . '/../..' . '/core/oql/expression.class.inc.php', 'FunctionOqlExpression' => __DIR__ . '/../..' . '/core/oql/oqlquery.class.inc.php', 'GraphEdge' => __DIR__ . '/../..' . '/core/simplegraph.class.inc.php',