From a9ba42a89a16883ba95e7b711f4a006f910316f7 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 8 Sep 2021 09:40:38 +0000 Subject: [PATCH] wait #4673 @2 --- .../class.ws.packager.win.inst.html.php | 164 ++++++++++-------- 1 file changed, 94 insertions(+), 70 deletions(-) diff --git a/inc/ws/Util/packager/class.ws.packager.win.inst.html.php b/inc/ws/Util/packager/class.ws.packager.win.inst.html.php index 05e0a10b8..0cf67ef8f 100644 --- a/inc/ws/Util/packager/class.ws.packager.win.inst.html.php +++ b/inc/ws/Util/packager/class.ws.packager.win.inst.html.php @@ -1,74 +1,98 @@ version = 'win-ins-html'; - } - - protected function preparePackage() { - parent::preparePackage(); - - $this->makeNSI(); - } - - protected function makeNSI() { - global $core; - - $winvdir = $this->getFinalPackageDir(); - - $daoLang = new wsDAOLang($core->con); - $lang = $daoLang->selectById($this->book->lang); - - if ($lang->nsis == 'Arabic') { - $lang->nsis = 'English'; - } - - if (!file_exists(WS_FILES . '/packager/download')) { - mkdir(WS_FILES . '/packager/download', 0777, true); - } - - $fname = $this->exeName; - $title = $this->appName; - - $nsi = file_get_contents(WS_COMPILE_ASSETS . '/' . $this->nsifile . '.nsi'); - $nsi = str_replace('$name', $title, $nsi); - $nsi = str_replace('$htmldir', WS_COMPILE_ASSETS, $nsi); - $nsi = str_replace('$fname', $fname, $nsi); - $nsi = str_replace('$fdir', $winvdir, $nsi); - $nsi = str_replace('$titre', $title, $nsi); - $nsi = str_replace('$lang', $lang->nsis, $nsi); - $nsi = str_replace('$nwplatform', $this->nwplatform, $nsi); - $nsi = str_replace('$nsisdir', '/usr/share/nsis', $nsi); - $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi); - $favicon = $this->vdir . 'data/favicon.ico'; - if ($this->theme->parametres->favicon == '') { - $this->copy(WS_COMPILE_ASSETS . '/fluidbook.ico', $favicon); - } - $nsi = str_replace('$favicon', $favicon, $nsi); - - $this->nsi = $nsi; - } - - public function makePackage($zip) { - $this->preparePackage(); - - $tmp = cubeFiles::tempnam() . '.nsi'; - file_put_contents($tmp, $this->nsi); - $makensis = new CubeIT_CommandLine('/usr/local/bin/makensis'); - $makensis->setArg(null, $tmp); - $makensis->execute(); - $makensis->debug(); - - return $this->getURLBase('exe'); - } - - public function __destruct() { - - } +class wsPackagerWinINSTHTML extends wsPackagerWinEXEHTML +{ + + protected $nsi; + protected $nsifile = 'html'; + + public function __construct($book_id) + { + parent::__construct($book_id); + $this->version = 'win-ins-html'; + } + + protected function preparePackage() + { + parent::preparePackage(); + + $this->makeNSI(); + } + + protected function makeNSI() + { + global $core; + + $winvdir = $this->getFinalPackageDir(); + + $daoLang = new wsDAOLang($core->con); + $lang = $daoLang->selectById($this->book->lang); + + if ($lang->nsis == 'Arabic') { + $lang->nsis = 'English'; + } + + if (!file_exists(WS_FILES . '/packager/download')) { + mkdir(WS_FILES . '/packager/download', 0777, true); + } + + $fname = $this->exeName; + $title = $this->appName; + + $nsi = file_get_contents(WS_COMPILE_ASSETS . '/' . $this->nsifile . '.nsi'); + $nsi = str_replace('$name', $title, $nsi); + $nsi = str_replace('$htmldir', WS_COMPILE_ASSETS, $nsi); + $nsi = str_replace('$fname', $fname, $nsi); + $nsi = str_replace('$fdir', $winvdir, $nsi); + $nsi = str_replace('$titre', $title, $nsi); + $nsi = str_replace('$lang', $lang->nsis, $nsi); + $nsi = str_replace('$nwplatform', $this->nwplatform, $nsi); + $nsi = str_replace('$nsisdir', '/usr/share/nsis', $nsi); + $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi); + $favicon = $this->vdir . 'data/favicon.ico'; + if ($this->theme->parametres->favicon == '') { + $this->copy(WS_COMPILE_ASSETS . '/fluidbook.ico', $favicon); + } else if (!file_exists($favicon)) { + $pngFile = WS_THEMES . '/' . $this->theme->theme_id . '/' . $this->theme->parametres->favicon; + $icoFile = WS_THEMES . '/' . $this->theme->theme_id . '/favicon.ico'; + if (!file_exists($icoFile) || filemtime($icoFile) < filemtime($pngFile) || filemtime(__FILE__) > filemtime($icoFile)) { + $tmp = CubeIT_Files::tempnam() . '.png'; + $convert = "convert $pngFile -resize 64x64^ -gravity center $tmp"; + `$convert`; + + $icotool = new CubeIT_CommandLine('icotool'); + $icotool->setArg('c'); + $icotool->setArg('o', $icoFile); + $icotool->setArg(null, $tmp); + $icotool->execute(); + + unlink($tmp); + } + $this->copy($icoFile, $favicon); + + } + $nsi = str_replace('$favicon', $favicon, $nsi); + + $this->nsi = $nsi; + } + + public function makePackage($zip) + { + $this->preparePackage(); + + $tmp = cubeFiles::tempnam() . '.nsi'; + file_put_contents($tmp, $this->nsi); + $makensis = new CubeIT_CommandLine('/usr/local/bin/makensis'); + $makensis->setArg(null, $tmp); + $makensis->execute(); + $makensis->debug(); + + return $this->getURLBase('exe'); + } + + public function __destruct() + { + + } } \ No newline at end of file -- 2.39.5