diff options
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/appinfo/info.xml | 2 | ||||
-rw-r--r-- | apps/theming/l10n/es_CL.js | 1 | ||||
-rw-r--r-- | apps/theming/l10n/es_CL.json | 1 | ||||
-rw-r--r-- | apps/theming/l10n/ru.js | 1 | ||||
-rw-r--r-- | apps/theming/l10n/ru.json | 1 | ||||
-rw-r--r-- | apps/theming/lib/IconBuilder.php | 28 | ||||
-rw-r--r-- | apps/theming/tests/IconBuilderTest.php | 21 |
7 files changed, 49 insertions, 6 deletions
diff --git a/apps/theming/appinfo/info.xml b/apps/theming/appinfo/info.xml index ee3126c0781..883dfbbb2ec 100644 --- a/apps/theming/appinfo/info.xml +++ b/apps/theming/appinfo/info.xml @@ -5,7 +5,7 @@ <description>Adjust the Nextcloud theme</description> <licence>AGPL</licence> <author>Nextcloud</author> - <version>1.4.0</version> + <version>1.4.1</version> <namespace>Theming</namespace> <category>other</category> diff --git a/apps/theming/l10n/es_CL.js b/apps/theming/l10n/es_CL.js index 4f98160b142..fba2c6263c0 100644 --- a/apps/theming/l10n/es_CL.js +++ b/apps/theming/l10n/es_CL.js @@ -33,6 +33,7 @@ OC.L10N.register( "Login image" : "Imágen de inicio de sesión", "Upload new login background" : "Cargar nueva imagen de fondo para inicio de sesión", "Remove background image" : "Eliminar imagen de fondo", + "Install the Imagemagick PHP extension with support for SVG images to automatically generate favicons based on the uploaded logo and color." : "Instala la extensión Imagemagick de PHP con soporte a imagenes SVG para generar los favicons en automático con base en el logotipo cargado y el color.", "reset to default" : "restaurar a predeterminado", "Log in image" : "Imagen de inicio de sesión" }, diff --git a/apps/theming/l10n/es_CL.json b/apps/theming/l10n/es_CL.json index 866eb07f7fa..d0be021859a 100644 --- a/apps/theming/l10n/es_CL.json +++ b/apps/theming/l10n/es_CL.json @@ -31,6 +31,7 @@ "Login image" : "Imágen de inicio de sesión", "Upload new login background" : "Cargar nueva imagen de fondo para inicio de sesión", "Remove background image" : "Eliminar imagen de fondo", + "Install the Imagemagick PHP extension with support for SVG images to automatically generate favicons based on the uploaded logo and color." : "Instala la extensión Imagemagick de PHP con soporte a imagenes SVG para generar los favicons en automático con base en el logotipo cargado y el color.", "reset to default" : "restaurar a predeterminado", "Log in image" : "Imagen de inicio de sesión" },"pluralForm" :"nplurals=2; plural=(n != 1);" diff --git a/apps/theming/l10n/ru.js b/apps/theming/l10n/ru.js index 2a46add3c0d..18c907f6cea 100644 --- a/apps/theming/l10n/ru.js +++ b/apps/theming/l10n/ru.js @@ -33,6 +33,7 @@ OC.L10N.register( "Login image" : "Изображение экрана входа в систему", "Upload new login background" : "Загрузить новый фон для экрана входа в систему", "Remove background image" : "Убрать фоновое изображение ", + "Install the Imagemagick PHP extension with support for SVG images to automatically generate favicons based on the uploaded logo and color." : "Для автоматической генерации favicon на основе загруженного логотипа и цвета нужно установить PHP расширение Imagemagick с поддержкой изображений SVG ", "reset to default" : "сброс до настроек по-умолчанию", "Log in image" : "Изображение экрана входа в систему" }, diff --git a/apps/theming/l10n/ru.json b/apps/theming/l10n/ru.json index f363f3ab151..2d996c8f3e5 100644 --- a/apps/theming/l10n/ru.json +++ b/apps/theming/l10n/ru.json @@ -31,6 +31,7 @@ "Login image" : "Изображение экрана входа в систему", "Upload new login background" : "Загрузить новый фон для экрана входа в систему", "Remove background image" : "Убрать фоновое изображение ", + "Install the Imagemagick PHP extension with support for SVG images to automatically generate favicons based on the uploaded logo and color." : "Для автоматической генерации favicon на основе загруженного логотипа и цвета нужно установить PHP расширение Imagemagick с поддержкой изображений SVG ", "reset to default" : "сброс до настроек по-умолчанию", "Log in image" : "Изображение экрана входа в систему" },"pluralForm" :"nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);" diff --git a/apps/theming/lib/IconBuilder.php b/apps/theming/lib/IconBuilder.php index 83258341985..ad44dd7ed6c 100644 --- a/apps/theming/lib/IconBuilder.php +++ b/apps/theming/lib/IconBuilder.php @@ -55,14 +55,38 @@ class IconBuilder { * @return string|false image blob */ public function getFavicon($app) { + if (!$this->themingDefaults->shouldReplaceIcons()) { + return false; + } try { - $icon = $this->renderAppIcon($app, 32); + $favicon = new Imagick(); + $favicon->setFormat("ico"); + $icon = $this->renderAppIcon($app, 128); if ($icon === false) { return false; } $icon->setImageFormat("png32"); - $data = $icon->getImageBlob(); + + $clone = clone $icon; + $clone->scaleImage(16,0); + $favicon->addImage($clone); + + $clone = clone $icon; + $clone->scaleImage(32,0); + $favicon->addImage($clone); + + $clone = clone $icon; + $clone->scaleImage(64,0); + $favicon->addImage($clone); + + $clone = clone $icon; + $clone->scaleImage(128,0); + $favicon->addImage($clone); + + $data = $favicon->getImagesBlob(); + $favicon->destroy(); $icon->destroy(); + $clone->destroy(); return $data; } catch (\ImagickException $e) { return false; diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php index f25f76a8180..4f5078d4c56 100644 --- a/apps/theming/tests/IconBuilderTest.php +++ b/apps/theming/tests/IconBuilderTest.php @@ -71,6 +71,9 @@ class IconBuilderTest extends TestCase { if (count($checkImagick->queryFormats('SVG')) < 1) { $this->markTestSkipped('No SVG provider present.'); } + if (count($checkImagick->queryFormats('PNG')) < 1) { + $this->markTestSkipped('No PNG provider present.'); + } } public function dataRenderAppIcon() { @@ -147,16 +150,22 @@ class IconBuilderTest extends TestCase { public function testGetFavicon($app, $color, $file) { $this->checkImagick(); $this->themingDefaults->expects($this->once()) + ->method('shouldReplaceIcons') + ->willReturn(true); + $this->themingDefaults->expects($this->once()) ->method('getColorPrimary') ->willReturn($color); $expectedIcon = new \Imagick(realpath(dirname(__FILE__)). "/data/" . $file); + $actualIcon = $this->iconBuilder->getFavicon($app); + $icon = new \Imagick(); - $icon->readImageBlob($this->iconBuilder->getFavicon($app)); + $icon->setFormat('ico'); + $icon->readImageBlob($actualIcon); $this->assertEquals(true, $icon->valid()); - $this->assertEquals(32, $icon->getImageWidth()); - $this->assertEquals(32, $icon->getImageHeight()); + $this->assertEquals(128, $icon->getImageWidth()); + $this->assertEquals(128, $icon->getImageHeight()); $icon->destroy(); $expectedIcon->destroy(); // FIXME: We may need some comparison of the generated and the test images @@ -167,8 +176,12 @@ class IconBuilderTest extends TestCase { * @expectedException \PHPUnit_Framework_Error_Warning */ public function testGetFaviconNotFound() { + $this->checkImagick(); $util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock(); $iconBuilder = new IconBuilder($this->themingDefaults, $util); + $this->themingDefaults->expects($this->once()) + ->method('shouldReplaceIcons') + ->willReturn(true); $util->expects($this->once()) ->method('getAppIcon') ->willReturn('notexistingfile'); @@ -179,6 +192,7 @@ class IconBuilderTest extends TestCase { * @expectedException \PHPUnit_Framework_Error_Warning */ public function testGetTouchIconNotFound() { + $this->checkImagick(); $util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock(); $iconBuilder = new IconBuilder($this->themingDefaults, $util); $util->expects($this->once()) @@ -191,6 +205,7 @@ class IconBuilderTest extends TestCase { * @expectedException \PHPUnit_Framework_Error_Warning */ public function testColorSvgNotFound() { + $this->checkImagick(); $util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock(); $iconBuilder = new IconBuilder($this->themingDefaults, $util); $util->expects($this->once()) |