From: Vincent Vanwaelscappel Date: Mon, 9 Jan 2023 17:17:48 +0000 (+0100) Subject: wip #5661 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=de7566db6554391f229b81352f200e7f103514c4;p=fluidbook-toolbox.git wip #5661 @3 --- diff --git a/app/Fluidbook/Packager/WindowsInstaller.php b/app/Fluidbook/Packager/WindowsInstaller.php index 452e04a14..9fde1e837 100644 --- a/app/Fluidbook/Packager/WindowsInstaller.php +++ b/app/Fluidbook/Packager/WindowsInstaller.php @@ -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; } diff --git a/app/Fluidbook/Packager/WindowsZIP.php b/app/Fluidbook/Packager/WindowsZIP.php index 63f03404c..386a9d5b4 100644 --- a/app/Fluidbook/Packager/WindowsZIP.php +++ b/app/Fluidbook/Packager/WindowsZIP.php @@ -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)); diff --git a/app/Jobs/FluidbookCompiler.php b/app/Jobs/FluidbookCompiler.php index db914458f..8915f612c 100644 --- a/app/Jobs/FluidbookCompiler.php +++ b/app/Jobs/FluidbookCompiler.php @@ -1756,9 +1756,9 @@ height="0" width="0" style="display:none;visibility:hidden"> $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'); diff --git a/app/Models/FluidbookTheme.php b/app/Models/FluidbookTheme.php index cc7203814..b7fa2413a 100644 --- a/app/Models/FluidbookTheme.php +++ b/app/Models/FluidbookTheme.php @@ -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; + } } /**