diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-05-08 15:51:55 +0300 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2017-05-08 15:51:55 +0300 |
commit | 099234cf12c4d1ec2d1942ed506f463b28ef738c (patch) | |
tree | 371d6475df8e76f1c1ce62d983f2059cad4b7eae /apps | |
parent | 6acae94a021a6e961a00fe2c33e5468461e65893 (diff) |
Add function to request SVG or regular fallback image
Fixes https://github.com/nextcloud/server/issues/4647
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 10 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 14 |
2 files changed, 19 insertions, 5 deletions
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 9509fc11077..0824a36ccdc 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -129,9 +129,10 @@ class ThemingDefaults extends \OC_Defaults { /** * Themed logo url * + * @param bool $useSvg Whether to point to the SVG image or a fallback * @return string */ - public function getLogo() { + public function getLogo($useSvg = true) { $logo = $this->config->getAppValue('theming', 'logoMime', false); $logoExists = true; @@ -144,7 +145,12 @@ class ThemingDefaults extends \OC_Defaults { $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); if(!$logo || !$logoExists) { - return $this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter; + if($useSvg) { + $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); + } else { + $logo = $this->urlGenerator->imagePath('core', 'logo.png'); + } + return $logo . '?v=' . $cacheBusterCounter; } return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter; diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index e3acab78bb7..a7cb7790aa6 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -431,7 +431,7 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals('custom-background?v=0', $this->template->getBackground()); } - public function testGetLogoDefault() { + private function getLogoHelper($withName, $useSvg) { $this->appData->expects($this->once()) ->method('getFolder') ->willThrowException(new NotFoundException()); @@ -452,9 +452,17 @@ class ThemingDefaultsTest extends TestCase { ->willThrowException(new \Exception()); $this->urlGenerator->expects($this->once()) ->method('imagePath') - ->with('core', 'logo.svg') + ->with('core', $withName) ->willReturn('core-logo'); - $this->assertEquals('core-logo?v=0', $this->template->getLogo()); + $this->assertEquals('core-logo?v=0', $this->template->getLogo($useSvg)); + } + + public function testGetLogoDefaultWithSvg() { + $this->getLogoHelper('logo.svg', true); + } + + public function testGetLogoDefaultWithoutSvg() { + $this->getLogoHelper('logo.png', false); } public function testGetLogoCustom() { |