diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-07-04 10:04:38 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-07-19 08:16:58 +0200 |
commit | 9e5885963c5dc09c20183732f0f94ca01598530e (patch) | |
tree | 92a3d5d2e9707644ec9c6b68ce0d3fe6d1f7165e /apps/accessibility/lib | |
parent | 8977c71f8842f19077fdd0bfe27a4f48f2bc4726 (diff) | |
download | nextcloud-server-9e5885963c5dc09c20183732f0f94ca01598530e.tar.gz nextcloud-server-9e5885963c5dc09c20183732f0f94ca01598530e.zip |
Fixed icons detection and caching
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/accessibility/lib')
-rw-r--r-- | apps/accessibility/lib/Controller/AccessibilityController.php | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php index f5ec1b8fab1..3ef305511e0 100644 --- a/apps/accessibility/lib/Controller/AccessibilityController.php +++ b/apps/accessibility/lib/Controller/AccessibilityController.php @@ -36,7 +36,7 @@ use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\IUserSession; -use OC\Template\SCSSCacher; +use OC\Template\IconsCacher; class AccessibilityController extends Controller { @@ -67,6 +67,9 @@ class AccessibilityController extends Controller { /** @var IAppManager */ private $appManager; + /** @var IconsCacher */ + protected $iconsCacher; + /** * Account constructor. * @@ -88,7 +91,8 @@ class AccessibilityController extends Controller { IURLGenerator $urlGenerator, ITimeFactory $timeFactory, IUserSession $userSession, - IAppManager $appManager) { + IAppManager $appManager, + IconsCacher $iconsCacher) { parent::__construct($appName, $request); $this->appName = $appName; $this->config = $config; @@ -98,6 +102,7 @@ class AccessibilityController extends Controller { $this->timeFactory = $timeFactory; $this->userSession = $userSession; $this->appManager = $appManager; + $this->iconsCacher = $iconsCacher; $this->serverRoot = \OC::$SERVERROOT; $this->appRoot = $this->appManager->getAppPath($this->appName); @@ -148,7 +153,12 @@ class AccessibilityController extends Controller { // Rebase all urls $appWebRoot = substr($this->appRoot, strlen($this->serverRoot) - strlen(\OC::$WEBROOT)); - $css = $this->rebaseUrls($css, $appWebRoot . '/css'); + $css = $this->rebaseUrls($css, $appWebRoot . '/css'); + + if ($this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) { + $iconsCss = $this->invertSvgIconsColor($this->iconsCacher->getCachedCSS()->getContent()); + $css = $css . $iconsCss; + } $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']); @@ -200,4 +210,14 @@ class AccessibilityController extends Controller { return preg_replace($re, $subst, $css); } + + /** + * Remove all matches from the $rule regex + * + * @param string $css string to parse + * @return string + */ + private function invertSvgIconsColor(string $css) { + return str_replace(['/000', '/fff'], ['/fff', '/000'], $css); + } } |