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;
|| $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;
+ }
}
return false;
}
- /**
- * 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 \OC\Template\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;
- }
-
/**
* append the $file resource at $root
*
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Exception\ParserException;
+use Leafo\ScssPhp\Formatter\Crunched;
+use Leafo\ScssPhp\Formatter\Expanded;
use OC\Files\SimpleFS\SimpleFolder;
+use OC\SystemConfig;
+use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
+use OCP\ILogger;
+use OCP\IURLGenerator;
class SCSSCacher {
- /**
- * @var string The root path to the nextcloud installation
- * @var array The exploded absolute path to the file
- * @var string The scss filename with extension
- * @var string The css filename with extension
- * @var string Absolute path to scss file location folder
- * @var string Path to scss file from the root installation
- * @var SimpleFolder The folder we're putting our compiled css files
- */
- protected $root, $file, $fileNameSCSS, $fileNameCSS, $fileLoc, $rootCssLoc, $folder;
+ /** @var string The root path to the nextcloud installation */
+ protected $root;
- /**
- * @var \OCP\ILogger
- * @var \OCP\Files\IAppData
- * @var \OCP\IURLGenerator
- * @var \OC\SystemConfig
- */
- protected $logger, $appData, $urlGenerator, $systemConfig;
+ /** @var array The exploded absolute path to the file */
+ protected $file;
+
+ /** @var string The scss filename with extension */
+ protected $fileNameSCSS;
+
+ /** @var string The css filename with extension */
+ protected $fileNameCSS;
+
+ /** @var string Absolute path to scss file location folder */
+ protected $fileLoc;
+
+ /** @var string Path to scss file from the root installation */
+ protected $rootCssLoc;
+
+ /** @var SimpleFolder The folder we're putting our compiled css files */
+ protected $folder;
+
+ /** @var ILogger */
+ protected $logger;
+
+ /** @var IAppData */
+ protected $appData;
+
+ /** @var IURLGenerator */
+ protected $urlGenerator;
+
+ /** @var SystemConfig */
+ protected $systemConfig;
/**
- * @param \OCP\ILogger $logger
+ * @param ILogger $logger
* @param string $root Root path to the nextcloud installation
* @param string $file
- * @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, $root, $file, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, \OC\SystemConfig $systemConfig) {
+ public function __construct(ILogger $logger, $root, $file, IAppData $appData, IURLGenerator $urlGenerator, SystemConfig $systemConfig) {
$this->logger = $logger;
$this->appData = $appData;
$this->urlGenerator = $urlGenerator;
$scss->setImportPaths($this->fileLoc);
if($this->systemConfig->getValue('debug')) {
// Debug mode
- $scss->setFormatter('Leafo\ScssPhp\Formatter\Expanded');
+ $scss->setFormatter(Expanded::class);
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
} else {
// Compression
- $scss->setFormatter('Leafo\ScssPhp\Formatter\Crunched');
+ $scss->setFormatter(Crunched::class);
}
try {