From: vincent@cubedesigners.com Date: Tue, 8 Dec 2020 11:48:03 +0000 (+0000) Subject: wait #4116 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a9ebfd6768a2addb6892a7a2090dea8784b7bd3a;p=cubeextranet.git wait #4116 @2 --- diff --git a/fluidbook/compile/html.nsi b/fluidbook/compile/html.nsi index 95790fca9..38c4bedaf 100644 --- a/fluidbook/compile/html.nsi +++ b/fluidbook/compile/html.nsi @@ -4,6 +4,8 @@ !define FLUIDBOOKNAME "$name" !define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname" +Unicode true + ; The name of the installer Name "${FLUIDBOOKNAME}" diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index a381129ff..89a971ad4 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -3,265 +3,274 @@ class wsPackager { - protected $dir; - protected $vdir; - public $book; - protected $pages; - protected $theme; - protected $version; - protected $book_id; - protected $themeRoot; - protected $daoBook; - protected $zip; - protected $workingDir; - protected $whole = true; - protected $_clean = true; - public $cleanOnDestruct = true; - - public static function package($book_id, $version, $zip = true, $cleanOnDestruct = true) - { - global $packager; - - cubePHP::neverStop(); - if ($version == 'html') { - $packager = new wsPackagerHTML($book_id); - } else if ($version == 'scorm') { - $packager = new wsPackagerSCORM($book_id); - } elseif ($version == 'win-html') { - $packager = new wsPackagerWinHTML($book_id); - } else if ($version == 'phonegap') { - $packager = new wsPackagerPhonegap($book_id); - } else if ($version == 'win-exe-html') { - $packager = new wsPackagerWinEXEHTML($book_id); - } else if ($version == 'mac-exe-html') { - $packager = new wsPackagerMacEXEHTML($book_id); - } else if ($version == 'win-ins-html') { - $packager = new wsPackagerWinINSTHTML($book_id); - } else if ($version == 'win-inss-html') { - $packager = new wsPackagerWinINSTSilentHTML($book_id); - } else if ($version == 'win-cd-html') { - $packager = new wsPackagerWinCDHTML($book_id); - } - $packager->cleanOnDestruct = $packager->cleanOnDestruct && $cleanOnDestruct; - - return $packager->makePackage($zip); - } - - public function __construct($book_id, $vdir = null, $whole = true) - { - - $this->_clean = (null === $vdir); - global $core; - - $this->book_id = $book_id; - - $this->vdir = $vdir; - $this->dir = ROOT . '/fluidbook/packager/' . $book_id . '/'; - $this->whole = $whole; - - if (!file_exists($this->dir)) { - mkdir($this->dir, 0777, true); - } - - $this->daoBook = new wsDAOBook($core->con); - $this->book = $this->daoBook->selectById($book_id); - $this->pages = $this->daoBook->getPagesOfBook($book_id, false); - - $daoTheme = new wsDAOTheme($core->con); - $this->theme = $daoTheme->getThemeOfBook($book_id, true); - $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/'; - - $this->workingDir = WS_BOOKS . '/working/' . $book_id . '/'; - - $this->compile(); - } - - protected function compile() - { - $this->daoBook->compile($this->book_id, '2', false, $this->book->parametres->forceCompileOnDownload, false, $this->book); - } - - protected function preparePackage() - { - $this->initTempDir(); - } - - public function makePackage($zip) - { - $this->preparePackage(); - } - - protected function replaceContents($str, $toReplace) - { - $res = $str; - foreach ($toReplace as $k => $v) { - if (is_null($v)) { - return; - } - $res = str_replace('$' . $k, $v, $res); - } - return $res; - } - - protected function copyFluidbookFiles() - { - // Copie du FB vers un répertoire temporaire - $cp = new cubeCommandLine('cp'); - $cp->setArg('R'); - $cp->setArg('p'); - $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*'); - $cp->setArg(null, $this->vdir); - $cp->execute(); - } - - protected function copyOtherFiles($files) - { - foreach ($files as $source => $dest) { - if (is_int($source)) { - $source = $dest; - } - - $s = WS_COMPILE_ASSETS . '/' . $source; - if (is_file($s) && !file_exists($this->vdir . $dest)) { - $this->copy($s, $this->vdir . $dest); - } else if (is_dir($s)) { - $cp = new cubeCommandLine('cp'); - $cp->setArg('R'); - $cp->setArg('p'); - $cp->setArg(null, $s); - $cp->setArg(null, $this->vdir); - $cp->execute(); - - $mv = new cubeCommandLine('mv'); - $mv->setArg($this->vdir . '/' . $source); - $mv->setArg($this->vdir . '/' . $dest); - $mv->execute(); - } - } - } - - protected function getBaseFile() - { - return $this->version . '-' . date('Ymdhis', TIME) . '-' . cubeText::str2URL($this->book->parametres->title); - } - - protected function getRelativeBase() - { - return '/packager/download/' . $this->getBaseFile(); - } - - protected function getURLBase($ext = '') - { - $res = '/fluidbook' . $this->getRelativeBase(); - if ($ext != '') { - $res .= '.' . $ext; - } - return $res; - } - - protected function getPathBase($ext = '') - { - $res = WS_FILES . $this->getRelativeBase(); - if ($ext != '') { - $res .= '.' . $ext; - } - - return $res; - } - - protected function zip($zipfile = null) - { - if (!$this->whole) { - return; - } - $url = $this->getURLBase('zip'); - $final = $this->getPathBase('zip'); - $rename = false; - if (is_null($zipfile)) { - $zipfile = $final; - } else { - $rename = true; - } - - $dir = $this->getFinalPackageDir(); - if (file_exists($dir)) { - $zip = new CubeIT_CommandLine('zip'); - $zip->cd($dir); - $zip->setArg(null, $zipfile); - $zip->setArg('symlinks'); - $zip->setArg('0'); - $zip->setArg('r'); - $zip->setArg('u'); - $zip->setArg(null, '.'); - $zip->setManualArg('-x "*/\.*"'); - $zip->execute(); - $zip->debug(); - } - - if (!file_exists(WS_FILES . '/packager/download')) { - mkdir(WS_FILES . '/packager/download', 0777, true); - } - - if ($rename) { - rename($zipfile, $final); - } - return $url; - } - - public function getFinalPackageDir() - { - $dir = $this->vdir; - if ($this->book->parametres->alwaysHTML5) { - $dir .= '/m/'; - } - return $dir; - } - - protected function initTempDir() - { - if (is_null($this->vdir)) { - $this->vdir = $this->dir . $this->version . '/'; - } - $this->cleanVdir(); - if (!file_exists($this->vdir . '/data')) { - mkdir($this->vdir . '/data', 0777, true); - } - } - - protected function cleanVdir() - { - if (!$this->_clean) { - return; - } - if (file_exists($this->vdir)) { - // Suppression du répertoire si il existe - $rm = new cubeCommandLine('rm'); - $rm->setArg('r'); - $rm->setArg('f'); - $rm->setArg(null, $this->vdir); - $rm->execute(); - } - } - - protected function postPackage() - { - - } - - public function __destruct() - { - if ($this->whole && $this->cleanOnDestruct) { - $this->cleanVdir(); - } - } - - public function copy($source, $dest) - { - if (!file_exists($source)) { - return; - } - copy($source, $dest); - touch($dest, filemtime($source)); - } + protected $dir; + protected $vdir; + public $book; + protected $pages; + protected $theme; + protected $version; + protected $book_id; + protected $themeRoot; + protected $daoBook; + protected $zip; + protected $workingDir; + protected $whole = true; + protected $_clean = true; + public $cleanOnDestruct = true; + + public static function package($book_id, $version, $zip = true, $cleanOnDestruct = true) + { + global $packager; + + cubePHP::neverStop(); + if ($version == 'html') { + $packager = new wsPackagerHTML($book_id); + } else if ($version == 'scorm') { + $packager = new wsPackagerSCORM($book_id); + } elseif ($version == 'win-html') { + $packager = new wsPackagerWinHTML($book_id); + } else if ($version == 'phonegap') { + $packager = new wsPackagerPhonegap($book_id); + } else if ($version == 'win-exe-html') { + $packager = new wsPackagerWinEXEHTML($book_id); + } else if ($version == 'mac-exe-html') { + $packager = new wsPackagerMacEXEHTML($book_id); + } else if ($version == 'win-ins-html') { + $packager = new wsPackagerWinINSTHTML($book_id); + } else if ($version == 'win-inss-html') { + $packager = new wsPackagerWinINSTSilentHTML($book_id); + } else if ($version == 'win-cd-html') { + $packager = new wsPackagerWinCDHTML($book_id); + } + $packager->cleanOnDestruct = $packager->cleanOnDestruct && $cleanOnDestruct; + + return $packager->makePackage($zip); + } + + public function __construct($book_id, $vdir = null, $whole = true) + { + + $this->_clean = (null === $vdir); + global $core; + + $this->book_id = $book_id; + + $this->vdir = $vdir; + $this->dir = ROOT . '/fluidbook/packager/' . $book_id . '/'; + $this->whole = $whole; + + if (!file_exists($this->dir)) { + mkdir($this->dir, 0777, true); + } + + $this->daoBook = new wsDAOBook($core->con); + $this->book = $this->daoBook->selectById($book_id); + $this->pages = $this->daoBook->getPagesOfBook($book_id, false); + + $daoTheme = new wsDAOTheme($core->con); + $this->theme = $daoTheme->getThemeOfBook($book_id, true); + $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/'; + + $this->workingDir = WS_BOOKS . '/working/' . $book_id . '/'; + + $this->compile(); + } + + protected function compile() + { + $this->daoBook->compile($this->book_id, '2', false, $this->book->parametres->forceCompileOnDownload, false, $this->book); + } + + protected function preparePackage() + { + $this->initTempDir(); + } + + public function makePackage($zip) + { + $this->preparePackage(); + } + + protected function replaceContents($str, $toReplace) + { + $res = $str; + foreach ($toReplace as $k => $v) { + if (is_null($v)) { + return; + } + $res = str_replace('$' . $k, $v, $res); + } + return $res; + } + + protected function copyFluidbookFiles() + { + // Copie du FB vers un répertoire temporaire + $cp = new cubeCommandLine('cp'); + $cp->setArg('R'); + $cp->setArg('p'); + $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*'); + $cp->setArg(null, $this->vdir); + $cp->execute(); + } + + protected function copyOtherFiles($files) + { + foreach ($files as $source => $dest) { + if (is_int($source)) { + $source = $dest; + } + + $s = WS_COMPILE_ASSETS . '/' . $source; + if (is_file($s) && !file_exists($this->vdir . $dest)) { + $this->copy($s, $this->vdir . $dest); + } else if (is_dir($s)) { + $cp = new cubeCommandLine('cp'); + $cp->setArg('R'); + $cp->setArg('p'); + $cp->setArg(null, $s); + $cp->setArg(null, $this->vdir); + $cp->execute(); + + $mv = new cubeCommandLine('mv'); + $mv->setArg($this->vdir . '/' . $source); + $mv->setArg($this->vdir . '/' . $dest); + $mv->execute(); + } + } + } + + protected function getBaseFile() + { + return $this->version . '-' . date('Ymdhis', TIME) . '-' . $this->escapeTitle(); + } + + protected function escapeTitle() + { + $res = cubeText::str2URL($this->book->parametres->title); + if ($res == '') { + $res = 'fluidbook'; + } + return $res; + } + + protected function getRelativeBase() + { + return '/packager/download/' . $this->getBaseFile(); + } + + protected function getURLBase($ext = '') + { + $res = '/fluidbook' . $this->getRelativeBase(); + if ($ext != '') { + $res .= '.' . $ext; + } + return $res; + } + + protected function getPathBase($ext = '') + { + $res = WS_FILES . $this->getRelativeBase(); + if ($ext != '') { + $res .= '.' . $ext; + } + + return $res; + } + + protected function zip($zipfile = null) + { + if (!$this->whole) { + return; + } + $url = $this->getURLBase('zip'); + $final = $this->getPathBase('zip'); + $rename = false; + if (is_null($zipfile)) { + $zipfile = $final; + } else { + $rename = true; + } + + $dir = $this->getFinalPackageDir(); + if (file_exists($dir)) { + $zip = new CubeIT_CommandLine('zip'); + $zip->cd($dir); + $zip->setArg(null, $zipfile); + $zip->setArg('symlinks'); + $zip->setArg('0'); + $zip->setArg('r'); + $zip->setArg('u'); + $zip->setArg(null, '.'); + $zip->setManualArg('-x "*/\.*"'); + $zip->execute(); + $zip->debug(); + } + + if (!file_exists(WS_FILES . '/packager/download')) { + mkdir(WS_FILES . '/packager/download', 0777, true); + } + + if ($rename) { + rename($zipfile, $final); + } + return $url; + } + + public function getFinalPackageDir() + { + $dir = $this->vdir; + if ($this->book->parametres->alwaysHTML5) { + $dir .= '/m/'; + } + return $dir; + } + + protected function initTempDir() + { + if (is_null($this->vdir)) { + $this->vdir = $this->dir . $this->version . '/'; + } + $this->cleanVdir(); + if (!file_exists($this->vdir . '/data')) { + mkdir($this->vdir . '/data', 0777, true); + } + } + + protected function cleanVdir() + { + if (!$this->_clean) { + return; + } + if (file_exists($this->vdir)) { + // Suppression du répertoire si il existe + $rm = new cubeCommandLine('rm'); + $rm->setArg('r'); + $rm->setArg('f'); + $rm->setArg(null, $this->vdir); + $rm->execute(); + } + } + + protected function postPackage() + { + + } + + public function __destruct() + { + if ($this->whole && $this->cleanOnDestruct) { + $this->cleanVdir(); + } + } + + public function copy($source, $dest) + { + if (!file_exists($source)) { + return; + } + copy($source, $dest); + touch($dest, filemtime($source)); + } } \ No newline at end of file diff --git a/inc/ws/Util/packager/class.ws.packager.win.exe.html.php b/inc/ws/Util/packager/class.ws.packager.win.exe.html.php index d87276036..234ade5f8 100644 --- a/inc/ws/Util/packager/class.ws.packager.win.exe.html.php +++ b/inc/ws/Util/packager/class.ws.packager.win.exe.html.php @@ -2,171 +2,175 @@ class wsPackagerWinEXEHTML extends wsPackager { - protected $exeName; - protected $appName; - protected $buildPath; - protected $nwplatform = 'windows-x32'; - protected $nwversion = '0.49.2'; - protected $appversion = ''; - protected $node_platform = 'win'; - protected $exenameMaxlength = 30; - - public function __construct($book_id) - { - parent::__construct($book_id, null, true, true); - $this->version = 'win-exe-html'; - $this->appName = ''; - $this->appversion = '1.0.' . time(); - $this->_clean = false; - - if ($this->book->parametres->offlineTitle == "") { - $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, $this->exenameMaxlength)); - $this->appName = $this->book->parametres->title; - } else { - $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength)); - $this->appName = $this->book->parametres->offlineTitle; - } - } - - protected function preparePackage() - { - parent::preparePackage(); - $this->copyFluidbookFiles(); - $this->makeJSON(); - - $this->buildPath = WS_PACKAGER . '/nwbuild/' . $this->version . '/' . $this->book_id; - - $cl = new CubeIT_CommandLine('/usr/local/web2exe/web2exe-linux'); - $cl->setPath(CONVERTER_PATH); - $cl->setEnv('TMPDIR', '/home/extranetfiles/tmp'); - $cl->setLongArgumentSeparator(' '); - $cl->setArg('export-to', $this->nwplatform); - $cl->setArg('uncompressed-folder'); - $cl->setArg('title', $this->appName); - $cl->setArg('output-dir', $this->buildPath); - $cl->setArg('nw-version', $this->nwversion); - //$cl->setArg('sdk-build'); - $cl->setArg('main', 'index.html'); - $cl->setArg('name', $this->exeName); - $cl->setArg('mac-icon', $this->vdir . 'icon.icns'); - $cl->setArg('exe-icon', $this->vdir . 'icon.ico'); - $cl->setArg('icon', $this->vdir . 'icon.png'); - $cl->setArg('width', 1024); - $cl->setArg('height', 768); - $cl->setArg('app-name', $this->exeName); - $cl->setArg('version', $this->appversion); - $cl->setArg('id', 'com.fluidbook.' . $this->book_id); - $cl->setArg('verbose'); - $cl->setArg(null, $this->vdir); - $cl->execute(); - $cl->debug(); - - $this->replaceFFMpeg(); - } - - function replaceFFMpeg() - { - copy(WS_COMPILE_ASSETS . '/_exehtml/_ffmpeg/ffmpeg.dll', $this->getFinalPackageDir() . '/ffmpeg.dll'); - } - - function makeJSON() - { - $data = ['app_name' => $this->appName, 'main' => 'index.html', 'name' => $this->exeName, 'version' => '1.0.' . time(), - 'webkit' => [], - 'window' => ['height' => 768, 'width' => 1024, 'title' => $this->appName, 'id' => 'main', 'icon' => 'icon.png', 'mac_icon' => 'icon.icns'], - 'dependencies' => ['child_process' => "^1.0.2", - 'fs' => '0.0.1-security', - 'path' => '^0.12.7'], - ]; - $pngIcon = $this->vdir . '/icon.png'; - $winIcon = $this->vdir . '/icon.ico'; - - $png = WS_COMPILE_ASSETS . '/fluidbook.png'; - $ico = WS_COMPILE_ASSETS . '/fluidbook.ico'; - - if ($this->theme->parametres->favicon != '') { - if (file_exists($this->vdir . '/data/favicon.png')) { - $png = $this->vdir . '/data/favicon.png'; - } - if (file_exists($this->vdir . '/data/favicon.ico')) { - $ico = $this->vdir . '/data/favicon.ico'; - } - } - - $icns = $this->vdir . '/icon.icns'; - $this->copy($png, $pngIcon); - $this->copy($ico, $winIcon); - - commonTools::pngToIcns($png, $icns); - - file_put_contents($this->vdir . '/package.json', json_encode($data)); - } - - public function makePackage($zip) - { - parent::makePackage($zip); - $res = $this->zip(); - $this->postPackage(); - return $res; - } - - public function getFinalPackageDir() - { - return $this->buildPath . '/' . $this->exeName . '/' . $this->nwplatform; - } - - protected function compile() - { - // For exe version, force to export only the html5 version - $this->book->parametres->alwaysHTML5 = true; - // No need to export pages with texts for this version, we are certain that svg is supported if enabled - if ($this->book->parametres->mobileVersion == 'html5-desktop') { - $this->book->parametres->mobileVersion = 'html5'; - } - // No need to have the widget - $this->book->parametres->widget = false; - - $this->daoBook->compile($this->book_id, 'html5', false, $this->book->parametres->forceCompileOnDownload, false, $this->book); - } - - protected function copyFluidbookFiles() - { - // Copie du FB vers un répertoire temporaire - $cp = new cubeCommandLine('cp'); - $cp->setArg('R'); - $cp->setArg('p'); - $cp->setArg(null, WS_BOOKS . '/html5/' . $this->book->book_id . '/*'); - $cp->setArg(null, $this->vdir); - $cp->execute(); - - $this->copyExtras(); - $this->copyNodeModules(); - } - - protected function copyExtras() - { - - if ($this->book->parametres->form == 'bourbon') { - - $dest = $this->vdir . '/exe'; - if (!file_exists($dest)) { - mkdir($dest, 0777, true); - } - $this->copy(WS_FILES . '/bourbon/sendemail.exe', $dest . '/sendemail.exe'); - } - } - - protected function copyNodeModules() - { - $dest = $this->vdir . '/node_modules'; - if (!file_exists($dest)) { - mkdir($dest, 0777, true); - } - $cp = new cubeCommandLine('cp'); - $cp->setArg('R'); - $cp->setArg('p'); - $cp->setArg(null, WS_COMPILE_ASSETS . '/_exehtml/_node_modules_' . $this->node_platform . '/*'); - $cp->setArg(null, $dest); - $cp->execute(); - } + protected $exeName; + protected $appName; + protected $buildPath; + protected $nwplatform = 'windows-x32'; + protected $nwversion = '0.49.2'; + protected $appversion = ''; + protected $node_platform = 'win'; + protected $exenameMaxlength = 30; + + public function __construct($book_id) + { + parent::__construct($book_id, null, true, true); + $this->version = 'win-exe-html'; + $this->appName = ''; + $this->appversion = '1.0.' . time(); + $this->_clean = false; + + if ($this->book->parametres->offlineTitle == "") { + $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, $this->exenameMaxlength)); + $this->appName = $this->book->parametres->title; + } else { + $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength)); + $this->appName = $this->book->parametres->offlineTitle; + } + + if ($this->exeName === '') { + $this->exeName = $book_id . '-fluidbook'; + } + } + + protected function preparePackage() + { + parent::preparePackage(); + $this->copyFluidbookFiles(); + $this->makeJSON(); + + $this->buildPath = WS_PACKAGER . '/nwbuild/' . $this->version . '/' . $this->book_id; + + $cl = new CubeIT_CommandLine('/usr/local/web2exe/web2exe-linux'); + $cl->setPath(CONVERTER_PATH); + $cl->setEnv('TMPDIR', '/home/extranetfiles/tmp'); + $cl->setLongArgumentSeparator(' '); + $cl->setArg('export-to', $this->nwplatform); + $cl->setArg('uncompressed-folder'); + $cl->setArg('title', $this->appName); + $cl->setArg('output-dir', $this->buildPath); + $cl->setArg('nw-version', $this->nwversion); + //$cl->setArg('sdk-build'); + $cl->setArg('main', 'index.html'); + $cl->setArg('name', $this->exeName); + $cl->setArg('mac-icon', $this->vdir . 'icon.icns'); + $cl->setArg('exe-icon', $this->vdir . 'icon.ico'); + $cl->setArg('icon', $this->vdir . 'icon.png'); + $cl->setArg('width', 1024); + $cl->setArg('height', 768); + $cl->setArg('app-name', $this->exeName); + $cl->setArg('version', $this->appversion); + $cl->setArg('id', 'com.fluidbook.' . $this->book_id); + $cl->setArg('verbose'); + $cl->setArg(null, $this->vdir); + $cl->execute(); + $cl->debug(); + + $this->replaceFFMpeg(); + } + + function replaceFFMpeg() + { + copy(WS_COMPILE_ASSETS . '/_exehtml/_ffmpeg/ffmpeg.dll', $this->getFinalPackageDir() . '/ffmpeg.dll'); + } + + function makeJSON() + { + $data = ['app_name' => $this->appName, 'main' => 'index.html', 'name' => $this->exeName, 'version' => '1.0.' . time(), + 'webkit' => [], + 'window' => ['height' => 768, 'width' => 1024, 'title' => $this->appName, 'id' => 'main', 'icon' => 'icon.png', 'mac_icon' => 'icon.icns'], + 'dependencies' => ['child_process' => "^1.0.2", + 'fs' => '0.0.1-security', + 'path' => '^0.12.7'], + ]; + $pngIcon = $this->vdir . '/icon.png'; + $winIcon = $this->vdir . '/icon.ico'; + + $png = WS_COMPILE_ASSETS . '/fluidbook.png'; + $ico = WS_COMPILE_ASSETS . '/fluidbook.ico'; + + if ($this->theme->parametres->favicon != '') { + if (file_exists($this->vdir . '/data/favicon.png')) { + $png = $this->vdir . '/data/favicon.png'; + } + if (file_exists($this->vdir . '/data/favicon.ico')) { + $ico = $this->vdir . '/data/favicon.ico'; + } + } + + $icns = $this->vdir . '/icon.icns'; + $this->copy($png, $pngIcon); + $this->copy($ico, $winIcon); + + commonTools::pngToIcns($png, $icns); + + file_put_contents($this->vdir . '/package.json', json_encode($data)); + } + + public function makePackage($zip) + { + parent::makePackage($zip); + $res = $this->zip(); + $this->postPackage(); + return $res; + } + + public function getFinalPackageDir() + { + return $this->buildPath . '/' . $this->exeName . '/' . $this->nwplatform; + } + + protected function compile() + { + // For exe version, force to export only the html5 version + $this->book->parametres->alwaysHTML5 = true; + // No need to export pages with texts for this version, we are certain that svg is supported if enabled + if ($this->book->parametres->mobileVersion == 'html5-desktop') { + $this->book->parametres->mobileVersion = 'html5'; + } + // No need to have the widget + $this->book->parametres->widget = false; + + $this->daoBook->compile($this->book_id, 'html5', false, $this->book->parametres->forceCompileOnDownload, false, $this->book); + } + + protected function copyFluidbookFiles() + { + // Copie du FB vers un répertoire temporaire + $cp = new cubeCommandLine('cp'); + $cp->setArg('R'); + $cp->setArg('p'); + $cp->setArg(null, WS_BOOKS . '/html5/' . $this->book->book_id . '/*'); + $cp->setArg(null, $this->vdir); + $cp->execute(); + + $this->copyExtras(); + $this->copyNodeModules(); + } + + protected function copyExtras() + { + + if ($this->book->parametres->form == 'bourbon') { + + $dest = $this->vdir . '/exe'; + if (!file_exists($dest)) { + mkdir($dest, 0777, true); + } + $this->copy(WS_FILES . '/bourbon/sendemail.exe', $dest . '/sendemail.exe'); + } + } + + protected function copyNodeModules() + { + $dest = $this->vdir . '/node_modules'; + if (!file_exists($dest)) { + mkdir($dest, 0777, true); + } + $cp = new cubeCommandLine('cp'); + $cp->setArg('R'); + $cp->setArg('p'); + $cp->setArg(null, WS_COMPILE_ASSETS . '/_exehtml/_node_modules_' . $this->node_platform . '/*'); + $cp->setArg(null, $dest); + $cp->execute(); + } } \ No newline at end of file