diff --git a/application/utils.inc.php b/application/utils.inc.php
index 0c387c129..5607a6fe1 100644
--- a/application/utils.inc.php
+++ b/application/utils.inc.php
@@ -1197,4 +1197,30 @@ class utils
$sText = str_replace("\r", "\n", $sText);
return str_replace("\n", '
', htmlentities($sText, ENT_QUOTES, 'UTF-8'));
}
+
+ /**
+ * Eventually compiles the SASS (.scss) file into the CSS (.css) file
+ *
+ * @param string $sSaasRelPath Relative path to the SCSS file (must have the extension .scss)
+ * @return string Relative path to the CSS file (.css)
+ */
+ static public function GetCSSFromSASS($sSaasRelPath)
+ {
+ $sSaasPath = APPROOT.$sSaasRelPath;
+ $sCssRelPath = preg_replace('/\.scss$/', '.css', $sSaasRelPath);
+ $sCssPath = APPROOT.$sCssRelPath;
+ clearstatcache();
+ if (!file_exists($sCssPath) || (is_writable($sCssPath) && (filemtime($sCssPath) < filemtime($sSaasPath))))
+ {
+ // Rebuild the CSS file from the Saas file
+ if (file_exists(APPROOT.'lib/sass/sass/SassParser.php'))
+ {
+ require_once(APPROOT.'lib/sass/sass/SassParser.php'); //including Sass libary (Syntactically Awesome Stylesheets)
+ $oParser = new SassParser(array('style'=>'expanded'));
+ $sCss = $oParser->toCss($sSaasPath);
+ file_put_contents($sCssPath, $sCss);
+ }
+ }
+ return $sCssRelPath;
+ }
}
diff --git a/application/webpage.class.inc.php b/application/webpage.class.inc.php
index 2bd9ddbdb..56ee4c6c2 100644
--- a/application/webpage.class.inc.php
+++ b/application/webpage.class.inc.php
@@ -270,33 +270,19 @@ class WebPage implements Page
{
$this->a_linked_stylesheets[] = array( 'link' => $s_linked_stylesheet, 'condition' => $s_condition);
}
-
- public function add_saas($sSaasRelPath)
- {
- $sSaasPath = APPROOT.$sSaasRelPath;
- $sCssRelPath = preg_replace('/\.scss$/', '.css', $sSaasRelPath);
- $sCssPath = APPROOT.$sCssRelPath;
- clearstatcache();
- if (!file_exists($sCssPath) || (is_writable($sCssPath) && (filemtime($sCssPath) < filemtime($sSaasPath))))
- {
- // Rebuild the CSS file from the Saas file
- if (file_exists(APPROOT.'lib/sass/sass/SassParser.php'))
- {
- require_once(APPROOT.'lib/sass/sass/SassParser.php'); //including Sass libary (Syntactically Awesome Stylesheets)
- $oParser = new SassParser(array('style'=>'expanded'));
- $sCss = $oParser->toCss($sSaasPath);
- file_put_contents($sCssPath, $sCss);
- }
- }
- $sRootUrl = utils::GetAbsoluteUrlAppRoot();
- if ($sRootUrl === '')
- {
- // We're running the setup of the first install...
- $sRootUrl = '../';
- }
- $sCSSUrl = $sRootUrl.$sCssRelPath;
- $this->add_linked_stylesheet($sCSSUrl);
- }
+
+ public function add_saas($sSaasRelPath)
+ {
+ $sCssRelPath = utils::GetCSSFromSASS($sSaasRelPath);
+ $sRootUrl = utils::GetAbsoluteUrlAppRoot();
+ if ($sRootUrl === '')
+ {
+ // We're running the setup of the first install...
+ $sRootUrl = '../';
+ }
+ $sCSSUrl = $sRootUrl.$sCssRelPath;
+ $this->add_linked_stylesheet($sCSSUrl);
+ }
/**
* Add some custom header to the page
*/