diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-30 16:30:04 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-01-06 09:42:14 +0100 |
commit | d9eaed5ffafd5252545f490401981d1e9b0fc889 (patch) | |
tree | 5e901570ee6bb8baa55bc5e6c7071a3c5341a376 /lib/private/Template/CSSResourceLocator.php | |
parent | 1e44a15dd1cba215bf10d0f73a7ef2730a77c2b0 (diff) | |
download | nextcloud-server-d9eaed5ffafd5252545f490401981d1e9b0fc889.tar.gz nextcloud-server-d9eaed5ffafd5252545f490401981d1e9b0fc889.zip |
Formatting
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Template/CSSResourceLocator.php')
-rwxr-xr-x | lib/private/Template/CSSResourceLocator.php | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index b592dd63ae1..59b49c73376 100755 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -25,25 +25,30 @@ namespace OC\Template; +use OC\SystemConfig; +use OCP\Files\IAppData; +use OCP\ILogger; +use OCP\IURLGenerator; + class CSSResourceLocator extends ResourceLocator { - /** @var \OCP\Files\IAppData */ + /** @var IAppData */ protected $appData; - /** @var \OCP\IURLGenerator */ + /** @var IURLGenerator */ protected $urlGenerator; - /** @var \OC\SystemConfig */ + /** @var SystemConfig */ protected $systemConfig; /** - * @param \OCP\ILogger $logger + * @param ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map - * @param \OCP\Files\IAppData $appData - * @param \OCP\IURLGenerator $urlGenerator - * @param \OC\SystemConfig $systemConfig + * @param IAppData $appData + * @param IURLGenerator $urlGenerator + * @param SystemConfig $systemConfig */ - public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, \OC\SystemConfig $systemConfig) { + public function __construct(ILogger $logger, $theme, $core_map, $party_map, IAppData $appData, IURLGenerator $urlGenerator, SystemConfig $systemConfig) { $this->appData = $appData; $this->urlGenerator = $urlGenerator; $this->systemConfig = $systemConfig; @@ -80,4 +85,36 @@ class CSSResourceLocator extends ResourceLocator { || $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css') || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css'); } + + /** + * cache and append the scss $file if exist at $root + * + * @param string $root path to check + * @param string $file the filename + * @param \OCP\Files\IAppData $appData + * @param \OCP\IURLGenerator $urlGenerator + * @param \OC\SystemConfig $systemConfig + * @param string|null $webRoot base for path, default map $root to $webRoot + * @return bool True if the resource was found and cached, false otherwise + */ + protected function cacheAndAppendScssIfExist($root, $file, $appData, $urlGenerator, $systemConfig, $webRoot = null) { + if (is_file($root.'/'.$file)) { + $scssCache = new SCSSCacher( + $this->logger, + $root, + $file, + $appData, + $urlGenerator, + $systemConfig); + + if($scssCache->process()) { + $this->append($root, $scssCache->getCachedSCSS('core'), $webRoot, false); + return true; + } else { + $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); + return false; + } + } + return false; + } } |