]> _ Git - cubeextranet.git/commitdiff
wait #4116 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Dec 2020 11:48:03 +0000 (11:48 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Dec 2020 11:48:03 +0000 (11:48 +0000)
fluidbook/compile/html.nsi
inc/ws/Util/packager/class.ws.packager.php
inc/ws/Util/packager/class.ws.packager.win.exe.html.php

index 95790fca949ea4d593042f035f101d7ad760d23d..38c4bedafd4d47992bafad80f506855531fd6223 100644 (file)
@@ -4,6 +4,8 @@
 !define FLUIDBOOKNAME "$name"\r
 !define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname"\r
 \r
+Unicode true\r
+\r
 ; The name of the installer\r
 Name "${FLUIDBOOKNAME}"\r
 \r
index a381129ffc59bf93ad80d945f644da9e84447c74..89a971ad4ee7c7573a4e5837c6ac4f00b44d48c3 100644 (file)
 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
index d87276036aad5d374e0361ecc7ccbdf0e2b14093..234ade5f8299ea3755c957884c8b6df8d577f7cb 100644 (file)
 \r
 class wsPackagerWinEXEHTML extends wsPackager\r
 {\r
-       protected $exeName;\r
-       protected $appName;\r
-       protected $buildPath;\r
-       protected $nwplatform = 'windows-x32';\r
-       protected $nwversion = '0.49.2';\r
-       protected $appversion = '';\r
-       protected $node_platform = 'win';\r
-       protected $exenameMaxlength = 30;\r
-\r
-       public function __construct($book_id)\r
-       {\r
-               parent::__construct($book_id, null, true, true);\r
-               $this->version = 'win-exe-html';\r
-               $this->appName = '';\r
-               $this->appversion = '1.0.' . time();\r
-               $this->_clean = false;\r
-\r
-               if ($this->book->parametres->offlineTitle == "") {\r
-                       $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, $this->exenameMaxlength));\r
-                       $this->appName = $this->book->parametres->title;\r
-               } else {\r
-                       $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength));\r
-                       $this->appName = $this->book->parametres->offlineTitle;\r
-               }\r
-       }\r
-\r
-       protected function preparePackage()\r
-       {\r
-               parent::preparePackage();\r
-               $this->copyFluidbookFiles();\r
-               $this->makeJSON();\r
-\r
-               $this->buildPath = WS_PACKAGER . '/nwbuild/' . $this->version . '/' . $this->book_id;\r
-\r
-               $cl = new CubeIT_CommandLine('/usr/local/web2exe/web2exe-linux');\r
-               $cl->setPath(CONVERTER_PATH);\r
-               $cl->setEnv('TMPDIR', '/home/extranetfiles/tmp');\r
-               $cl->setLongArgumentSeparator(' ');\r
-               $cl->setArg('export-to', $this->nwplatform);\r
-               $cl->setArg('uncompressed-folder');\r
-               $cl->setArg('title', $this->appName);\r
-               $cl->setArg('output-dir', $this->buildPath);\r
-               $cl->setArg('nw-version', $this->nwversion);\r
-               //$cl->setArg('sdk-build');\r
-               $cl->setArg('main', 'index.html');\r
-               $cl->setArg('name', $this->exeName);\r
-               $cl->setArg('mac-icon', $this->vdir . 'icon.icns');\r
-               $cl->setArg('exe-icon', $this->vdir . 'icon.ico');\r
-               $cl->setArg('icon', $this->vdir . 'icon.png');\r
-               $cl->setArg('width', 1024);\r
-               $cl->setArg('height', 768);\r
-               $cl->setArg('app-name', $this->exeName);\r
-               $cl->setArg('version', $this->appversion);\r
-               $cl->setArg('id', 'com.fluidbook.' . $this->book_id);\r
-               $cl->setArg('verbose');\r
-               $cl->setArg(null, $this->vdir);\r
-               $cl->execute();\r
-               $cl->debug();\r
-\r
-               $this->replaceFFMpeg();\r
-       }\r
-\r
-       function replaceFFMpeg()\r
-       {\r
-               copy(WS_COMPILE_ASSETS . '/_exehtml/_ffmpeg/ffmpeg.dll', $this->getFinalPackageDir() . '/ffmpeg.dll');\r
-       }\r
-\r
-       function makeJSON()\r
-       {\r
-               $data = ['app_name' => $this->appName, 'main' => 'index.html', 'name' => $this->exeName, 'version' => '1.0.' . time(),\r
-                       'webkit' => [],\r
-                       'window' => ['height' => 768, 'width' => 1024, 'title' => $this->appName, 'id' => 'main', 'icon' => 'icon.png', 'mac_icon' => 'icon.icns'],\r
-                       'dependencies' => ['child_process' => "^1.0.2",\r
-                               'fs' => '0.0.1-security',\r
-                               'path' => '^0.12.7'],\r
-               ];\r
-               $pngIcon = $this->vdir . '/icon.png';\r
-               $winIcon = $this->vdir . '/icon.ico';\r
-\r
-               $png = WS_COMPILE_ASSETS . '/fluidbook.png';\r
-               $ico = WS_COMPILE_ASSETS . '/fluidbook.ico';\r
-\r
-               if ($this->theme->parametres->favicon != '') {\r
-                       if (file_exists($this->vdir . '/data/favicon.png')) {\r
-                               $png = $this->vdir . '/data/favicon.png';\r
-                       }\r
-                       if (file_exists($this->vdir . '/data/favicon.ico')) {\r
-                               $ico = $this->vdir . '/data/favicon.ico';\r
-                       }\r
-               }\r
-\r
-               $icns = $this->vdir . '/icon.icns';\r
-               $this->copy($png, $pngIcon);\r
-               $this->copy($ico, $winIcon);\r
-\r
-               commonTools::pngToIcns($png, $icns);\r
-\r
-               file_put_contents($this->vdir . '/package.json', json_encode($data));\r
-       }\r
-\r
-       public function makePackage($zip)\r
-       {\r
-               parent::makePackage($zip);\r
-               $res = $this->zip();\r
-               $this->postPackage();\r
-               return $res;\r
-       }\r
-\r
-       public function getFinalPackageDir()\r
-       {\r
-               return $this->buildPath . '/' . $this->exeName . '/' . $this->nwplatform;\r
-       }\r
-\r
-       protected function compile()\r
-       {\r
-               // For exe version, force to export only the html5 version\r
-               $this->book->parametres->alwaysHTML5 = true;\r
-               // No need to export pages with texts for this version, we are certain that svg is supported if enabled\r
-               if ($this->book->parametres->mobileVersion == 'html5-desktop') {\r
-                       $this->book->parametres->mobileVersion = 'html5';\r
-               }\r
-               // No need to have the widget\r
-               $this->book->parametres->widget = false;\r
-\r
-               $this->daoBook->compile($this->book_id, 'html5', false, $this->book->parametres->forceCompileOnDownload, false, $this->book);\r
-       }\r
-\r
-       protected function copyFluidbookFiles()\r
-       {\r
-               // Copie du FB vers un répertoire temporaire\r
-               $cp = new cubeCommandLine('cp');\r
-               $cp->setArg('R');\r
-               $cp->setArg('p');\r
-               $cp->setArg(null, WS_BOOKS . '/html5/' . $this->book->book_id . '/*');\r
-               $cp->setArg(null, $this->vdir);\r
-               $cp->execute();\r
-\r
-               $this->copyExtras();\r
-               $this->copyNodeModules();\r
-       }\r
-\r
-       protected function copyExtras()\r
-       {\r
-\r
-               if ($this->book->parametres->form == 'bourbon') {\r
-\r
-                       $dest = $this->vdir . '/exe';\r
-                       if (!file_exists($dest)) {\r
-                               mkdir($dest, 0777, true);\r
-                       }\r
-                       $this->copy(WS_FILES . '/bourbon/sendemail.exe', $dest . '/sendemail.exe');\r
-               }\r
-       }\r
-\r
-       protected function copyNodeModules()\r
-       {\r
-               $dest = $this->vdir . '/node_modules';\r
-               if (!file_exists($dest)) {\r
-                       mkdir($dest, 0777, true);\r
-               }\r
-               $cp = new cubeCommandLine('cp');\r
-               $cp->setArg('R');\r
-               $cp->setArg('p');\r
-               $cp->setArg(null, WS_COMPILE_ASSETS . '/_exehtml/_node_modules_' . $this->node_platform . '/*');\r
-               $cp->setArg(null, $dest);\r
-               $cp->execute();\r
-       }\r
+    protected $exeName;\r
+    protected $appName;\r
+    protected $buildPath;\r
+    protected $nwplatform = 'windows-x32';\r
+    protected $nwversion = '0.49.2';\r
+    protected $appversion = '';\r
+    protected $node_platform = 'win';\r
+    protected $exenameMaxlength = 30;\r
+\r
+    public function __construct($book_id)\r
+    {\r
+        parent::__construct($book_id, null, true, true);\r
+        $this->version = 'win-exe-html';\r
+        $this->appName = '';\r
+        $this->appversion = '1.0.' . time();\r
+        $this->_clean = false;\r
+\r
+        if ($this->book->parametres->offlineTitle == "") {\r
+            $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, $this->exenameMaxlength));\r
+            $this->appName = $this->book->parametres->title;\r
+        } else {\r
+            $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength));\r
+            $this->appName = $this->book->parametres->offlineTitle;\r
+        }\r
+\r
+        if ($this->exeName === '') {\r
+            $this->exeName = $book_id . '-fluidbook';\r
+        }\r
+    }\r
+\r
+    protected function preparePackage()\r
+    {\r
+        parent::preparePackage();\r
+        $this->copyFluidbookFiles();\r
+        $this->makeJSON();\r
+\r
+        $this->buildPath = WS_PACKAGER . '/nwbuild/' . $this->version . '/' . $this->book_id;\r
+\r
+        $cl = new CubeIT_CommandLine('/usr/local/web2exe/web2exe-linux');\r
+        $cl->setPath(CONVERTER_PATH);\r
+        $cl->setEnv('TMPDIR', '/home/extranetfiles/tmp');\r
+        $cl->setLongArgumentSeparator(' ');\r
+        $cl->setArg('export-to', $this->nwplatform);\r
+        $cl->setArg('uncompressed-folder');\r
+        $cl->setArg('title', $this->appName);\r
+        $cl->setArg('output-dir', $this->buildPath);\r
+        $cl->setArg('nw-version', $this->nwversion);\r
+        //$cl->setArg('sdk-build');\r
+        $cl->setArg('main', 'index.html');\r
+        $cl->setArg('name', $this->exeName);\r
+        $cl->setArg('mac-icon', $this->vdir . 'icon.icns');\r
+        $cl->setArg('exe-icon', $this->vdir . 'icon.ico');\r
+        $cl->setArg('icon', $this->vdir . 'icon.png');\r
+        $cl->setArg('width', 1024);\r
+        $cl->setArg('height', 768);\r
+        $cl->setArg('app-name', $this->exeName);\r
+        $cl->setArg('version', $this->appversion);\r
+        $cl->setArg('id', 'com.fluidbook.' . $this->book_id);\r
+        $cl->setArg('verbose');\r
+        $cl->setArg(null, $this->vdir);\r
+        $cl->execute();\r
+        $cl->debug();\r
+\r
+        $this->replaceFFMpeg();\r
+    }\r
+\r
+    function replaceFFMpeg()\r
+    {\r
+        copy(WS_COMPILE_ASSETS . '/_exehtml/_ffmpeg/ffmpeg.dll', $this->getFinalPackageDir() . '/ffmpeg.dll');\r
+    }\r
+\r
+    function makeJSON()\r
+    {\r
+        $data = ['app_name' => $this->appName, 'main' => 'index.html', 'name' => $this->exeName, 'version' => '1.0.' . time(),\r
+            'webkit' => [],\r
+            'window' => ['height' => 768, 'width' => 1024, 'title' => $this->appName, 'id' => 'main', 'icon' => 'icon.png', 'mac_icon' => 'icon.icns'],\r
+            'dependencies' => ['child_process' => "^1.0.2",\r
+                'fs' => '0.0.1-security',\r
+                'path' => '^0.12.7'],\r
+        ];\r
+        $pngIcon = $this->vdir . '/icon.png';\r
+        $winIcon = $this->vdir . '/icon.ico';\r
+\r
+        $png = WS_COMPILE_ASSETS . '/fluidbook.png';\r
+        $ico = WS_COMPILE_ASSETS . '/fluidbook.ico';\r
+\r
+        if ($this->theme->parametres->favicon != '') {\r
+            if (file_exists($this->vdir . '/data/favicon.png')) {\r
+                $png = $this->vdir . '/data/favicon.png';\r
+            }\r
+            if (file_exists($this->vdir . '/data/favicon.ico')) {\r
+                $ico = $this->vdir . '/data/favicon.ico';\r
+            }\r
+        }\r
+\r
+        $icns = $this->vdir . '/icon.icns';\r
+        $this->copy($png, $pngIcon);\r
+        $this->copy($ico, $winIcon);\r
+\r
+        commonTools::pngToIcns($png, $icns);\r
+\r
+        file_put_contents($this->vdir . '/package.json', json_encode($data));\r
+    }\r
+\r
+    public function makePackage($zip)\r
+    {\r
+        parent::makePackage($zip);\r
+        $res = $this->zip();\r
+        $this->postPackage();\r
+        return $res;\r
+    }\r
+\r
+    public function getFinalPackageDir()\r
+    {\r
+        return $this->buildPath . '/' . $this->exeName . '/' . $this->nwplatform;\r
+    }\r
+\r
+    protected function compile()\r
+    {\r
+        // For exe version, force to export only the html5 version\r
+        $this->book->parametres->alwaysHTML5 = true;\r
+        // No need to export pages with texts for this version, we are certain that svg is supported if enabled\r
+        if ($this->book->parametres->mobileVersion == 'html5-desktop') {\r
+            $this->book->parametres->mobileVersion = 'html5';\r
+        }\r
+        // No need to have the widget\r
+        $this->book->parametres->widget = false;\r
+\r
+        $this->daoBook->compile($this->book_id, 'html5', false, $this->book->parametres->forceCompileOnDownload, false, $this->book);\r
+    }\r
+\r
+    protected function copyFluidbookFiles()\r
+    {\r
+        // Copie du FB vers un répertoire temporaire\r
+        $cp = new cubeCommandLine('cp');\r
+        $cp->setArg('R');\r
+        $cp->setArg('p');\r
+        $cp->setArg(null, WS_BOOKS . '/html5/' . $this->book->book_id . '/*');\r
+        $cp->setArg(null, $this->vdir);\r
+        $cp->execute();\r
+\r
+        $this->copyExtras();\r
+        $this->copyNodeModules();\r
+    }\r
+\r
+    protected function copyExtras()\r
+    {\r
+\r
+        if ($this->book->parametres->form == 'bourbon') {\r
+\r
+            $dest = $this->vdir . '/exe';\r
+            if (!file_exists($dest)) {\r
+                mkdir($dest, 0777, true);\r
+            }\r
+            $this->copy(WS_FILES . '/bourbon/sendemail.exe', $dest . '/sendemail.exe');\r
+        }\r
+    }\r
+\r
+    protected function copyNodeModules()\r
+    {\r
+        $dest = $this->vdir . '/node_modules';\r
+        if (!file_exists($dest)) {\r
+            mkdir($dest, 0777, true);\r
+        }\r
+        $cp = new cubeCommandLine('cp');\r
+        $cp->setArg('R');\r
+        $cp->setArg('p');\r
+        $cp->setArg(null, WS_COMPILE_ASSETS . '/_exehtml/_node_modules_' . $this->node_platform . '/*');\r
+        $cp->setArg(null, $dest);\r
+        $cp->execute();\r
+    }\r
 }
\ No newline at end of file