diff --git a/framework/library/astroid/Document.php b/framework/library/astroid/Document.php index d8904adb..5d0f8fd6 100644 --- a/framework/library/astroid/Document.php +++ b/framework/library/astroid/Document.php @@ -13,6 +13,7 @@ require_once __DIR__ . "/../scssphp/scss.inc.php"; +use Joomla\CMS\Filesystem\File; use ScssPhp\ScssPhp\Compiler; use MatthiasMullie\Minify; @@ -1133,9 +1134,12 @@ public function astroidCSS() // rendering scss Framework::getReporter('Logs')->add('Rendering Scss'); // clearing previous versions - Helper::clearCache($template->template, ['compiled']); + Helper::clearCache($template->template, ['compiled', 'template']); // adding compiled scss in css file $this->renderScss($cssFile); + if ($template->isDefault()) { + File::copy($cssFile, ASTROID_MEDIA_TEMPLATE_PATH . '/css/template.css'); + } } else { // logging compiled scss Framework::getReporter('Logs')->add('Getting SCSS Compiled CSS ' . str_replace(JPATH_SITE . '/', '', $cssFile) . ' from cache.'); diff --git a/framework/library/astroid/Template.php b/framework/library/astroid/Template.php index c98e6ca4..40ab099f 100644 --- a/framework/library/astroid/Template.php +++ b/framework/library/astroid/Template.php @@ -173,6 +173,22 @@ public function getThemeVariables() return $variables; } + public function isDefault($id = 0) + { + if (!$id) { + $id = $this->id; + } + $db = \JFactory::getDbo(); + $query = "SELECT `home` FROM `#__template_styles` WHERE `id`='$id'"; + $db->setQuery($query); + $result = $db->loadResult(); + if ($result == 1) { + return true; + } else { + return false; + } + } + protected function _variableOverrides($variables) { $sass_overrides = $this->params->get('sass_overrides');