summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-05-08 13:06:31 +0200
committerJulius Härtl <jus@bitgrid.net>2018-06-05 16:47:38 +0200
commitd132527aa9c4baad344b11adef3a6f4a46cde3ab (patch)
tree701700d4dae0dd2c8b7a7ef7637f9f05e81fa49f
parent9b919245f67f5511d6be7910f61d639b290eab26 (diff)
downloadnextcloud-server-d132527aa9c4baad344b11adef3a6f4a46cde3ab.tar.gz
nextcloud-server-d132527aa9c4baad344b11adef3a6f4a46cde3ab.zip
Use svg opt out as parameter
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--apps/theming/lib/Controller/ThemingController.php9
-rw-r--r--apps/theming/lib/ImageManager.php14
-rw-r--r--apps/theming/tests/ImageManagerTest.php6
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php2
4 files changed, 17 insertions, 14 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php
index f3a7f8cfcc5..7f2130ecbb8 100644
--- a/apps/theming/lib/Controller/ThemingController.php
+++ b/apps/theming/lib/Controller/ThemingController.php
@@ -358,12 +358,13 @@ class ThemingController extends Controller {
* @NoCSRFRequired
*
* @param string $key
+ * @param bool $useSvg
* @return FileDisplayResponse|NotFoundResponse
- * @throws \Exception
+ * @throws NotPermittedException
*/
- public function getImage(string $key, bool $asPng = false) {
+ public function getImage(string $key, bool $useSvg = true) {
try {
- $file = $this->imageManager->getImage($key, $asPng);
+ $file = $this->imageManager->getImage($key, $useSvg);
} catch (NotFoundException $e) {
return new NotFoundResponse();
}
@@ -372,7 +373,7 @@ class ThemingController extends Controller {
$response->cacheFor(3600);
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
$response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
- if ($asPng) {
+ if (!$useSvg) {
$response->addHeader('Content-Type', 'image/png');
} else {
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php
index 850cd3e69bd..77afbbe8a87 100644
--- a/apps/theming/lib/ImageManager.php
+++ b/apps/theming/lib/ImageManager.php
@@ -65,10 +65,10 @@ class ImageManager {
$this->cacheFactory = $cacheFactory;
}
- public function getImageUrl(string $key): string {
+ public function getImageUrl(string $key, bool $useSvg = true): string {
$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
try {
- $this->getImage($key);
+ $image = $this->getImage($key, $useSvg);
return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter;
} catch (NotFoundException $e) {
}
@@ -83,16 +83,18 @@ class ImageManager {
}
}
- public function getImageUrlAbsolute(string $key): string {
- return $this->urlGenerator->getAbsoluteURL($this->getImageUrl($key));
+ public function getImageUrlAbsolute(string $key, bool $useSvg = true): string {
+ return $this->urlGenerator->getAbsoluteURL($this->getImageUrl($key, $useSvg));
}
/**
- * @param $key
+ * @param string $key
+ * @param bool $useSvg
* @return ISimpleFile
* @throws NotFoundException
+ * @throws NotPermittedException
*/
- public function getImage(string $key, bool $useSvg = false): ISimpleFile {
+ public function getImage(string $key, bool $useSvg = true): ISimpleFile {
$logo = $this->config->getAppValue('theming', $key . 'Mime', false);
$folder = $this->appData->getFolder('images');
if ($logo === false || !$folder->fileExists($key)) {
diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php
index 501ec0e1432..6912395268e 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -126,7 +126,7 @@ class ImageManagerTest extends TestCase {
$this->urlGenerator->expects($this->once())
->method('linkToRoute')
->willReturn('url-to-image');
- $this->assertEquals('url-to-image?v=0', $this->imageManager->getImageUrl('logo'));
+ $this->assertEquals('url-to-image?v=0', $this->imageManager->getImageUrl('logo', false));
}
public function testGetImageUrlDefault() {
@@ -164,7 +164,7 @@ class ImageManagerTest extends TestCase {
$this->urlGenerator->expects($this->at(2))
->method('getAbsoluteUrl')
->willReturn('url-to-image-absolute?v=0');
- $this->assertEquals('url-to-image-absolute?v=0', $this->imageManager->getImageUrlAbsolute('logo'));
+ $this->assertEquals('url-to-image-absolute?v=0', $this->imageManager->getImageUrlAbsolute('logo', false));
}
@@ -175,7 +175,7 @@ class ImageManagerTest extends TestCase {
->willReturn('png');
$file = $this->createMock(ISimpleFile::class);
$this->mockGetImage('logo', $file);
- $this->assertEquals($file, $this->imageManager->getImage('logo'));
+ $this->assertEquals($file, $this->imageManager->getImage('logo', false));
}
/**
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 6894b002eb9..ceaf2cc19d5 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -604,7 +604,7 @@ class ThemingDefaultsTest extends TestCase {
$this->urlGenerator->expects($this->once())
->method('linkToRoute')
->with('theming.Theming.getImage')
- ->willReturn('custom-logo');
+ ->willReturn('custom-logo?v=0');
$this->assertEquals('custom-logo' . '?v=0', $this->template->getLogo());
}