Updated favicon support
authorAlexander Ebert <ebert@woltlab.com>
Mon, 12 Jun 2017 10:17:02 +0000 (12:17 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 12 Jun 2017 12:56:55 +0000 (14:56 +0200)
See #2257

14 files changed:
com.woltlab.wcf/templates/headInclude.tpl
wcfsetup/install/files/images/apple-touch-icon.png [deleted file]
wcfsetup/install/files/images/favicon.ico [deleted file]
wcfsetup/install/files/images/favicon/default.android-chrome-192x192.png [new file with mode: 0644]
wcfsetup/install/files/images/favicon/default.android-chrome-256x256.png [new file with mode: 0644]
wcfsetup/install/files/images/favicon/default.apple-touch-icon.png [new file with mode: 0644]
wcfsetup/install/files/images/favicon/default.browserconfig.xml [new file with mode: 0644]
wcfsetup/install/files/images/favicon/default.favicon.ico [new file with mode: 0644]
wcfsetup/install/files/images/favicon/default.manifest.json [new file with mode: 0644]
wcfsetup/install/files/images/favicon/default.mstile-150x150.png [new file with mode: 0644]
wcfsetup/install/files/lib/data/style/ActiveStyle.class.php
wcfsetup/install/files/lib/data/style/Style.class.php
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/setup/db/install.sql

index 146d5b665f3519b591a370f0a4ccd52231390a54..f08fbf457f4d4455e87b61f8e3618a117433cc38 100644 (file)
 {event name='javascriptInclude'}
 
 <!-- Icons -->
-<link rel="icon" href="{@$__wcf->getFavicon()}" type="image/x-icon">
-<link rel="apple-touch-icon" href="{@$__wcf->getPath()}images/apple-touch-icon.png">
-
-<!-- theme color (mobile Chrome) -->
+<link rel="apple-touch-icon" sizes="180x180" href="{$__wcf->getStyleHandler()->getStyle()->getFaviconAppleTouchIcon()}">
+<link rel="manifest" href="{@$__wcf->getStyleHandler()->getStyle()->getFaviconManifest()}">
+<link rel="shortcut icon" href="{@$__wcf->getFavicon()}">
+<meta name="msapplication-config" content="{@$__wcf->getStyleHandler()->getStyle()->getFaviconBrowserconfig()}">
 <meta name="theme-color" content="{$__wcf->getStyleHandler()->getStyle()->getVariable('wcfHeaderBackground')}">
 
 <script data-relocate="true">
diff --git a/wcfsetup/install/files/images/apple-touch-icon.png b/wcfsetup/install/files/images/apple-touch-icon.png
deleted file mode 100644 (file)
index eddf763..0000000
Binary files a/wcfsetup/install/files/images/apple-touch-icon.png and /dev/null differ
diff --git a/wcfsetup/install/files/images/favicon.ico b/wcfsetup/install/files/images/favicon.ico
deleted file mode 100644 (file)
index cc36101..0000000
Binary files a/wcfsetup/install/files/images/favicon.ico and /dev/null differ
diff --git a/wcfsetup/install/files/images/favicon/default.android-chrome-192x192.png b/wcfsetup/install/files/images/favicon/default.android-chrome-192x192.png
new file mode 100644 (file)
index 0000000..ddbbeae
Binary files /dev/null and b/wcfsetup/install/files/images/favicon/default.android-chrome-192x192.png differ
diff --git a/wcfsetup/install/files/images/favicon/default.android-chrome-256x256.png b/wcfsetup/install/files/images/favicon/default.android-chrome-256x256.png
new file mode 100644 (file)
index 0000000..3937b83
Binary files /dev/null and b/wcfsetup/install/files/images/favicon/default.android-chrome-256x256.png differ
diff --git a/wcfsetup/install/files/images/favicon/default.apple-touch-icon.png b/wcfsetup/install/files/images/favicon/default.apple-touch-icon.png
new file mode 100644 (file)
index 0000000..d01b514
Binary files /dev/null and b/wcfsetup/install/files/images/favicon/default.apple-touch-icon.png differ
diff --git a/wcfsetup/install/files/images/favicon/default.browserconfig.xml b/wcfsetup/install/files/images/favicon/default.browserconfig.xml
new file mode 100644 (file)
index 0000000..5c4d1e2
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<browserconfig>
+    <msapplication>
+        <tile>
+            <square150x150logo src="/abc/test/mstile-150x150.png"/>
+            <TileColor>#3a6d9c</TileColor>
+        </tile>
+    </msapplication>
+</browserconfig>
diff --git a/wcfsetup/install/files/images/favicon/default.favicon.ico b/wcfsetup/install/files/images/favicon/default.favicon.ico
new file mode 100644 (file)
index 0000000..19f87b4
Binary files /dev/null and b/wcfsetup/install/files/images/favicon/default.favicon.ico differ
diff --git a/wcfsetup/install/files/images/favicon/default.manifest.json b/wcfsetup/install/files/images/favicon/default.manifest.json
new file mode 100644 (file)
index 0000000..8380019
--- /dev/null
@@ -0,0 +1,18 @@
+{
+    "name": "",
+    "icons": [
+        {
+            "src": "/abc/test/android-chrome-192x192.png",
+            "sizes": "192x192",
+            "type": "image/png"
+        },
+        {
+            "src": "/abc/test/android-chrome-256x256.png",
+            "sizes": "256x256",
+            "type": "image/png"
+        }
+    ],
+    "theme_color": "#ffffff",
+    "background_color": "#ffffff",
+    "display": "standalone"
+}
\ No newline at end of file
diff --git a/wcfsetup/install/files/images/favicon/default.mstile-150x150.png b/wcfsetup/install/files/images/favicon/default.mstile-150x150.png
new file mode 100644 (file)
index 0000000..aef320d
Binary files /dev/null and b/wcfsetup/install/files/images/favicon/default.mstile-150x150.png differ
index 77f61f33f349626ea7f811b3ea75d01b48137bb5..1fafba7b8f58bf37d5aa32dfe3ec7b446bd2f770 100644 (file)
@@ -69,4 +69,29 @@ class ActiveStyle extends DatabaseObjectDecorator {
                
                return WCF::getPath() . 'images/default-logo-small.png';
        }
+       
+       public function getFaviconAppleTouchIcon() {
+               return $this->getFaviconPath('apple-touch-icon.png');
+       }
+       
+       public function getFaviconManifest() {
+               return $this->getFaviconPath('manifest.json');
+       }
+       
+       public function getFaviconBrowserconfig() {
+               return $this->getFaviconPath('browserconfig.xml');
+       }
+       
+       public function getRelativeFavicon() {
+               return $this->getFaviconPath('favicon.ico', false);
+       }
+       
+       protected function getFaviconPath($filename, $absolutePath = true) {
+               $path = 'images/favicon/'. ($this->getDecoratedObject()->hasFavicon ? $this->getDecoratedObject()->styleID : 'default') . ".{$filename}";
+               if ($absolutePath) {
+                       return WCF::getPath() . $path;
+               }
+               
+               return $path;
+       }
 }
index dac458dbf12f9221c94a1ce409210cd66c337ef2..6b35f624074d260de9dcd770a241416043932ee8 100644 (file)
@@ -28,6 +28,7 @@ use wcf\system\WCF;
  * @property-read      string          $imagePath              path (relative to `WCF_DIR`) to the images used by the style or empty if style has no special image path
  * @property-read      string          $packageName            package identifier used to export the style as a package or empty (thus style cannot be exported as package)
  * @property-read      integer         $isTainted              is `0` if the original declarations of an imported or installed style are not and cannot be altered, otherwise `1`
+ * @property-read      integer         $hasFavicon             is `0` if the default favicon data should be used
  */
 class Style extends DatabaseObject {
        /**
index 6a0b38664985d5da038d5139c29b43ff39fa943c..b9ed2b0a5467d340bf7befbd70a6574eae6eb6f2 100644 (file)
@@ -969,16 +969,17 @@ class WCF {
        public function getFavicon() {
                $activeApplication = ApplicationHandler::getInstance()->getActiveApplication();
                $wcf = ApplicationHandler::getInstance()->getWCF();
+               $favicon = StyleHandler::getInstance()->getStyle()->getRelativeFavicon();
                
                if ($activeApplication->domainName !== $wcf->domainName) {
-                       if (file_exists(WCF_DIR.'images/favicon.ico')) {
-                               $favicon = file_get_contents(WCF_DIR.'images/favicon.ico');
+                       if (file_exists(WCF_DIR.$favicon)) {
+                               $favicon = file_get_contents(WCF_DIR.$favicon);
                                
                                return 'data:image/x-icon;base64,' . base64_encode($favicon);
                        }
                }
                
-               return self::getPath() . 'images/favicon.ico';
+               return self::getPath() . $favicon;
        }
        
        /**
index e98c7e87e02d6c33146661516a9c1612f5134418..de90d01626350a6261ca6b3095769357df39e127 100644 (file)
@@ -1194,7 +1194,8 @@ CREATE TABLE wcf1_style (
        authorURL VARCHAR(255) NOT NULL DEFAULT '',
        imagePath VARCHAR(255) NOT NULL DEFAULT '',
        packageName VARCHAR(255) NOT NULL DEFAULT '',
-       isTainted TINYINT(1) NOT NULL DEFAULT 0
+       isTainted TINYINT(1) NOT NULL DEFAULT 0,
+       hasFavicon TINYINT(1) NOT NULL DEFAULT 0
 );
 
 DROP TABLE IF EXISTS wcf1_style_variable;