From 9b8e36a4671d4a24318d5ad38a49ec2178a5c8d2 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 7 Dec 2021 09:09:53 +0000 Subject: [PATCH] wait #4891 @2 --- inc/commons/class.common.tools.php | 3 +- inc/ws/Controlleur/class.ws.ajax.php | 4 +- inc/ws/Controlleur/class.ws.flash.php | 1 + inc/ws/DAO/class.ws.dao.book.php | 1 - inc/ws/Util/class.ws.exporter.php | 9 ++-- inc/ws/Util/html5/class.ws.html5.php | 6 ++- .../html5/master/class.ws.html5.compiler.php | 2 - .../packager/class.ws.packager.chromeos.php | 30 ++++++------- .../Util/packager/class.ws.packager.html.php | 5 ++- .../class.ws.packager.mac.exe.html.php | 4 +- inc/ws/Util/packager/class.ws.packager.php | 45 +++++++++++-------- .../class.ws.packager.precompiled.php | 4 +- .../Util/packager/class.ws.packager.scorm.php | 4 +- .../packager/class.ws.packager.sharepoint.php | 4 +- .../class.ws.packager.win.cd.html.php | 4 +- .../class.ws.packager.win.exe.html.php | 4 +- .../class.ws.packager.win.inst.html.php | 4 +- ...class.ws.packager.win.inst.silent.html.php | 14 +++--- 18 files changed, 82 insertions(+), 66 deletions(-) diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 851aabdc7..67a6cc881 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1188,7 +1188,8 @@ class commonTools 'ascocelda' => 'Asco & Celda', 'wesco' => 'Wesco', 'mopec' => 'Mopec', - 'intex' => 'Intex']; + 'intex' => 'Intex', + 'grosfillex'=>'Grosfillex']; $options = array_flip($options); ksort($options); diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index a8d099ec7..eff68450e 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -1123,7 +1123,9 @@ class wsAjax extends cubeAjax } $exporter = new wsExporter(); - $exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $dest['dir'], $dest['file']); + + file_put_contents(WS_CACHE . '/' . $_POST['book_id'] . '.post.options', print_r($_POST, true)); + $exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $dest['dir'], $dest['file'], $_POST['options']); $x->addClosePopup(); } diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 977345bad..0bc58c2c1 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -779,6 +779,7 @@ class wsFlash extends cubeFlashGateway $this->xml->addChild('title', htmlspecialchars($book->nom)); $this->xml->addChild('date', $book->changedate); $this->xml->addChild('lang', $book->lang); + $this->xml->addChild('settings', json_encode($book->parametres->toArray())); } public function getBookInfos() diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index d53e76a28..3488e6ad6 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1205,7 +1205,6 @@ class wsDAOBook extends commonDAO $this->_compileLock = WS_BOOKS . '/locks/' . $lockId . '.lock'; - while (file_exists($this->_compileLock) && filemtime($this->_compileLock) > (time() - 900)) { sleep(10); } diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index 3cba98bd4..5ebbc1750 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -17,6 +17,7 @@ class wsExporter public $ftpPassiveMode = false; const VINCENT = "paris.cubedesigners.com"; + //const VINCENT = "tortuga.enhydra.fr"; public function exportCollection($collectionId, $os) @@ -287,7 +288,7 @@ class wsExporter $cl->execute(); } - public function export($book_id, &$x, $action = 'download', $version = 'online', $destinationDir = null, $destinationFile = null) + public function export($book_id, &$x, $action = 'download', $version = 'online', $destinationDir = null, $destinationFile = null, $options = []) { global $core; set_time_limit(0); @@ -322,7 +323,7 @@ class wsExporter $this->_saveDestination(); if ($this->metaAction == 'download') { - $this->_download(); + $this->_download($options); } else if ($this->metaAction == 'phonegap') { $this->_phonegap(); } else if ($this->metaAction == 'install') { @@ -505,9 +506,9 @@ class wsExporter } } - protected function _download() + protected function _download($options = []) { - $r = wsPackager::package($this->book_id, $this->version); + $r = wsPackager::package($this->book_id, $this->version, true, true, $options); $this->x->addRedirection($r); } diff --git a/inc/ws/Util/html5/class.ws.html5.php b/inc/ws/Util/html5/class.ws.html5.php index f9bd69c61..033903fae 100644 --- a/inc/ws/Util/html5/class.ws.html5.php +++ b/inc/ws/Util/html5/class.ws.html5.php @@ -20,8 +20,10 @@ class wsHTML5 { if (is_null($version)) { global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($book_id); + if (null === $book) { + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($book_id); + } $version = $book->parametres->mobileLVersion; } diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index d4b4776df..8e6b0e992 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -276,7 +276,6 @@ class wsHTML5Compiler } $this->vdir = new CubeIT_Files_VirtualDirectory($this->dir); - $this->daoBook = new wsDAOBook($core->con); if (null === $book) { $this->book = $this->daoBook->selectById($book_id); @@ -338,7 +337,6 @@ class wsHTML5Compiler $this->initMobileFirst(); } - $this->svgfiles = array_unique([$this->assets . '/images/symbols/interface.svg', WS_ICONS . '/15/interface.svg']); if ($this->theme->parametres->iconSet > 15) { diff --git a/inc/ws/Util/packager/class.ws.packager.chromeos.php b/inc/ws/Util/packager/class.ws.packager.chromeos.php index 2c3b16d3a..31d667ec6 100644 --- a/inc/ws/Util/packager/class.ws.packager.chromeos.php +++ b/inc/ws/Util/packager/class.ws.packager.chromeos.php @@ -2,11 +2,11 @@ class wsPackagerChromeOS extends wsPackagerHTML { - public function __construct($book_id, $vdir = null, $whole = true) + public function __construct($book_id, $vdir = null, $whole = true, $options = []) { - parent::__construct($book_id, $vdir, $whole); + parent::__construct($book_id, $vdir, $whole, $options); $this->version = 'chromeos'; - $this->cleanOnDestruct = false; + $this->cleanOnDestruct = true; } protected function preparePackage() @@ -31,16 +31,16 @@ class wsPackagerChromeOS extends wsPackagerHTML return $res; } -// public function makePackage($zip) -// { -// $this->preparePackage(); -// -// $chrome = new CubeIT_CommandLine('crx3'); -// $chrome->setArg('o', WS_PACKAGER . '/download/' . $this->getBaseFile() . '.crx'); -// $chrome->setArg(null, $this->vdir.'/m/'); -// $chrome->execute(); -// $chrome->debug(); -// -// return $this->getURLBase('crx'); -// } + public function makePackage($zip) + { + $this->preparePackage(); + + $chrome = new CubeIT_CommandLine('crx3'); + $chrome->setArg('o', WS_PACKAGER . '/download/' . $this->getBaseFile() . '.crx'); + $chrome->setArg(null, $this->vdir . '/m/'); + $chrome->execute(); + $chrome->debug(); + + return $this->getURLBase('crx'); + } } \ No newline at end of file diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 078985409..0bc22c174 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -10,9 +10,9 @@ class wsPackagerHTML extends wsPackager protected $_disableScorm = true; protected $_compileOnConstruct = false; - public function __construct($book_id, $vdir = null, $whole = true) + public function __construct($book_id, $vdir = null, $whole = true, $options = []) { - parent::__construct($book_id, $vdir, $whole); + parent::__construct($book_id, $vdir, $whole, $options); $this->version = 'html'; } @@ -248,6 +248,7 @@ class wsPackagerHTML extends wsPackager protected function _compileHTML5($bookId, $book, $dest) { + $this->daoBook->compile($bookId, 'html5', false, $book->parametres->forceCompileOnDownload, false, $book); if (!file_exists($dest)) { diff --git a/inc/ws/Util/packager/class.ws.packager.mac.exe.html.php b/inc/ws/Util/packager/class.ws.packager.mac.exe.html.php index 1b868d2c9..fa19bc552 100644 --- a/inc/ws/Util/packager/class.ws.packager.mac.exe.html.php +++ b/inc/ws/Util/packager/class.ws.packager.mac.exe.html.php @@ -7,9 +7,9 @@ class wsPackagerMacEXEHTML extends wsPackagerWinEXEHTML protected $node_platform = 'mac'; protected $exenameMaxlength = 28; - public function __construct($book_id) + public function __construct($book_id, $options = []) { - parent::__construct($book_id); + parent::__construct($book_id, $options); $this->version = 'mac_exe_html'; } diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index fba50a74b..fccc27208 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -16,45 +16,45 @@ class wsPackager protected $workingDir; protected $whole = true; protected $_clean = true; - protected $_compileOnConstruct = true; + protected $_compileOnConstruct = false; public $cleanOnDestruct = true; - public static function package($book_id, $version, $zip = true, $cleanOnDestruct = true) + public static function package($book_id, $version, $zip = true, $cleanOnDestruct = true, $options = []) { global $packager; cubePHP::neverStop(); if ($version === 'html') { - $packager = new wsPackagerHTML($book_id); + $packager = new wsPackagerHTML($book_id, null, true, $options); } else if ($version === 'scorm') { - $packager = new wsPackagerSCORM($book_id); + $packager = new wsPackagerSCORM($book_id, null, true, $options); } else if ($version === 'sharepoint') { - $packager = new wsPackagerSharepoint($book_id); + $packager = new wsPackagerSharepoint($book_id, null, true, $options); } elseif ($version === 'win_html') { - $packager = new wsPackagerWinHTML($book_id); + $packager = new wsPackagerWinHTML($book_id, null, true, $options); } else if ($version === 'phonegap') { - $packager = new wsPackagerPhonegap($book_id); + $packager = new wsPackagerPhonegap($book_id, null, true, $options); } else if ($version === 'win_exe_html') { - $packager = new wsPackagerWinEXEHTML($book_id); + $packager = new wsPackagerWinEXEHTML($book_id, $options); } else if ($version === 'mac_exe_html') { - $packager = new wsPackagerMacEXEHTML($book_id); + $packager = new wsPackagerMacEXEHTML($book_id, $options); } else if ($version === 'win_ins_html') { - $packager = new wsPackagerWinINSTHTML($book_id); + $packager = new wsPackagerWinINSTHTML($book_id, $options); } else if ($version === 'win_inss_html') { - $packager = new wsPackagerWinINSTSilentHTML($book_id); + $packager = new wsPackagerWinINSTSilentHTML($book_id, $options); } else if ($version === 'win_cd_html') { - $packager = new wsPackagerWinCDHTML($book_id); + $packager = new wsPackagerWinCDHTML($book_id, $options); } else if ($version === 'precompiled') { - $packager = new wsPackagerPrecompiled($book_id); + $packager = new wsPackagerPrecompiled($book_id, null, true, $options); } else if ($version === 'chromeos') { - $packager = new wsPackagerChromeOS($book_id); + $packager = new wsPackagerChromeOS($book_id, null, true, $options); } $packager->cleanOnDestruct = $packager->cleanOnDestruct && $cleanOnDestruct; return $packager->makePackage($zip); } - public function __construct($book_id, $vdir = null, $whole = true) + public function __construct($book_id, $vdir = null, $whole = true, $options = []) { $this->_clean = (null === $vdir); @@ -72,6 +72,14 @@ class wsPackager $this->daoBook = new wsDAOBook($core->con); $this->book = $this->daoBook->selectById($book_id); + $forceCompile = false; + if (count($options)) { + $options['forceCompileOnDownload'] = true; + } + foreach ($options as $k => $v) { + $this->book->parametres->$k = $v; + } + $this->pages = $this->daoBook->getPagesOfBook($book_id, false); $daoTheme = new wsDAOTheme($core->con); @@ -81,13 +89,14 @@ class wsPackager $this->workingDir = $this->book->getAssetDir(); if ($this->_compileOnConstruct) { - $this->compile(); + $this->compile($forceCompile); } } - protected function compile() + + protected function compile($forceCompile = false) { - $this->daoBook->compile($this->book_id, '2', false, $this->book->parametres->forceCompileOnDownload, false, $this->book); + $this->daoBook->compile($this->book_id, '2', false, $this->book->parametres->forceCompileOnDownload || $forceCompile, false, $this->book); } protected function preparePackage() diff --git a/inc/ws/Util/packager/class.ws.packager.precompiled.php b/inc/ws/Util/packager/class.ws.packager.precompiled.php index dc1ecce90..08a06d1f2 100644 --- a/inc/ws/Util/packager/class.ws.packager.precompiled.php +++ b/inc/ws/Util/packager/class.ws.packager.precompiled.php @@ -2,9 +2,9 @@ class wsPackagerPrecompiled extends wsPackagerHTML { - public function __construct($book_id, $vdir = null, $whole = true) + public function __construct($book_id, $vdir = null, $whole = true,$options=[]) { - parent::__construct($book_id, $vdir, $whole); + parent::__construct($book_id, $vdir, $whole,$options); $this->version = 'precompiled'; $this->book->parametres->embedAllLibraries = true; } diff --git a/inc/ws/Util/packager/class.ws.packager.scorm.php b/inc/ws/Util/packager/class.ws.packager.scorm.php index 44744e5b6..e389c4c60 100644 --- a/inc/ws/Util/packager/class.ws.packager.scorm.php +++ b/inc/ws/Util/packager/class.ws.packager.scorm.php @@ -2,9 +2,9 @@ class wsPackagerSCORM extends wsPackagerHTML { - public function __construct($book_id, $vdir = null, $whole = true) + public function __construct($book_id, $vdir = null, $whole = true, $options = []) { - parent::__construct($book_id, $vdir, $whole); + parent::__construct($book_id, $vdir, $whole, $options); $this->version = 'scorm'; $this->_disableScorm = false; } diff --git a/inc/ws/Util/packager/class.ws.packager.sharepoint.php b/inc/ws/Util/packager/class.ws.packager.sharepoint.php index 61a20532d..dfbb484e5 100644 --- a/inc/ws/Util/packager/class.ws.packager.sharepoint.php +++ b/inc/ws/Util/packager/class.ws.packager.sharepoint.php @@ -2,9 +2,9 @@ class wsPackagerSharepoint extends wsPackagerHTML { - public function __construct($book_id, $vdir = null, $whole = true) + public function __construct($book_id, $vdir = null, $whole = true, $options = []) { - parent::__construct($book_id, $vdir, $whole); + parent::__construct($book_id, $vdir, $whole, $options); $this->version = 'sharepoint'; $this->book->parametres->seoVersion = false; $this->book->parametres->maxResolution = 150; diff --git a/inc/ws/Util/packager/class.ws.packager.win.cd.html.php b/inc/ws/Util/packager/class.ws.packager.win.cd.html.php index 26a1d5596..6a8ad1712 100644 --- a/inc/ws/Util/packager/class.ws.packager.win.cd.html.php +++ b/inc/ws/Util/packager/class.ws.packager.win.cd.html.php @@ -3,9 +3,9 @@ class wsPackagerWinCDHTML extends wsPackagerMacEXEHTML { - public function __construct($book_id) + public function __construct($book_id,$options=[]) { - parent::__construct($book_id); + parent::__construct($book_id,$options); $this->book->parametres->alwaysHTML5 = true; $this->version = 'win_cd_html'; } 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 924e46fe5..99f30ebc1 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 @@ -11,9 +11,9 @@ class wsPackagerWinEXEHTML extends wsPackager protected $node_platform = 'win'; protected $exenameMaxlength = 30; - public function __construct($book_id) + public function __construct($book_id, $options = []) { - parent::__construct($book_id, null, true, true); + parent::__construct($book_id, null, true, $options); $this->version = 'win_exe_html'; $this->appName = ''; $this->appversion = '1.0.' . time(); 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 452958eb3..677d8854a 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 @@ -6,9 +6,9 @@ class wsPackagerWinINSTHTML extends wsPackagerWinEXEHTML protected $nsi; protected $nsifile = 'html'; - public function __construct($book_id) + public function __construct($book_id, $options = []) { - parent::__construct($book_id); + parent::__construct($book_id, $options); $this->version = 'win_ins_html'; } diff --git a/inc/ws/Util/packager/class.ws.packager.win.inst.silent.html.php b/inc/ws/Util/packager/class.ws.packager.win.inst.silent.html.php index 877b302f1..37ef4f441 100644 --- a/inc/ws/Util/packager/class.ws.packager.win.inst.silent.html.php +++ b/inc/ws/Util/packager/class.ws.packager.win.inst.silent.html.php @@ -1,11 +1,13 @@ version = 'win_inss_html'; - } + public function __construct($book_id, $options = []) + { + parent::__construct($book_id, $options); + $this->version = 'win_inss_html'; + } } \ No newline at end of file -- 2.39.5