]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5661 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Jan 2023 17:17:48 +0000 (18:17 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Jan 2023 17:17:48 +0000 (18:17 +0100)
app/Fluidbook/Packager/WindowsInstaller.php
app/Fluidbook/Packager/WindowsZIP.php
app/Jobs/FluidbookCompiler.php
app/Models/FluidbookTheme.php

index 452e04a14a9a445bf42c11010d058f1cfbe5318d..9fde1e8377103b8348bbe1408eb3983684fd43a2 100644 (file)
@@ -43,7 +43,7 @@ class WindowsInstaller extends WindowsZIP
         $nsi = str_replace('$nwplatform', $this->nwplatform, $nsi);
         $nsi = str_replace('$nsisdir', '/usr/local/share/nsis', $nsi);
         $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi);
-        $nsi = str_replace('$favicon', $this->theme->favicon(), $nsi);
+        $nsi = str_replace('$favicon', $this->theme->getFaviconPath(), $nsi);
 
         $this->nsi = $nsi;
     }
index 63f03404cc1f391201f77d1a2eba6f76dbff899f..386a9d5b49edf267840fd7c2b5263c87f65dc9e4 100644 (file)
@@ -192,7 +192,7 @@ class WindowsZIP extends Base
         }
 
         foreach (['png', 'ico', 'icns'] as $format) {
-            $this->copy($this->theme->favicon($format), $this->vdir . '/icon.' . $format);
+            $this->copy($this->theme->getFaviconPath($format), $this->vdir . '/icon.' . $format);
         }
 
         file_put_contents($this->vdir . '/package.json', json_encode($data));
index db914458f19abdda520f320e437ba82a8d7bda2d..8915f612c364b37e1ec0699a434181b2832fc57a 100644 (file)
@@ -1756,9 +1756,9 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             $this->log('Got index vars 3');
 
             $favicon = '';
-            if ($this->theme->hasFavicon()) {
-                $pngFile = $this->theme->favicon('png');
-                $this->vdir->copy($this->theme->favicon('ico'), 'data/favicon.ico');
+            if ($this->theme->hasFaviconFile()) {
+                $pngFile = $this->theme->getFaviconPath('png');
+                $this->vdir->copy($this->theme->getFaviconPath('ico'), 'data/favicon.ico');
                 $this->vdir->copy($pngFile, 'data/favicon.png');
                 $this->vdir->copy($pngFile, 'data/apple-touch-icon.png');
 
index cc720381468127dffd086a348311bd02752b079a..b7fa2413a278bb6c3a1d0ba752d10b17fd91897c 100644 (file)
@@ -852,13 +852,13 @@ class FluidbookTheme extends ToolboxSettingsModel
     /**
      * @throws \Exception
      */
-    public function favicon($format = 'ico')
+    public function getFaviconPath($format = 'ico')
     {
         $supported = ['ico', 'png', 'icns'];
         if (!in_array($format, $supported)) {
             throw new \Exception('Unsupported format ' . $format);
         }
-        if (!$this->hasFavicon()) {
+        if (!$this->hasFaviconFile()) {
             return resource_path('fluidbookpublication/favicon/fluidbook.' . $format);
         }
         $pngSource = $this->getFirstMediaInField('favicon')->getPath();
@@ -893,10 +893,17 @@ class FluidbookTheme extends ToolboxSettingsModel
 
     }
 
-    public function hasFavicon()
+    /**
+     * @return bool
+     */
+    public function hasFaviconFile()
     {
-        $media=$this->getFirstMediaInField('favicon');
-        return !is_null($media) && !($this->getSettings()->get('favicon', '') == '') && file_exists($media->getPath());
+        try {
+            $media = $this->getFirstMediaInField('favicon');
+            return !is_null($media) && !($this->getSettings()->get('favicon', '') == '') && file_exists($media->getPath());
+        } catch (\Exception $e) {
+            return false;
+        }
     }
 
     /**