From aee9cdc08ff1629836f6cb6cd45a39f3db9fe76c Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 8 Feb 2011 14:50:49 +0000 Subject: [PATCH] --- inc/ws/Controlleur/packager/_common.php | 1 + .../packager/class.ws.packager.mac.exe.php | 2 +- .../packager/class.ws.packager.php | 36 +++++++++++-- .../packager/class.ws.packager.win.cd.php | 2 +- .../packager/class.ws.packager.win.exe.php | 2 +- .../packager/class.ws.packager.win.inst.php | 54 +++++++++++++++++++ inc/ws/DAO/class.ws.dao.book.php | 1 - 7 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 inc/ws/Controlleur/packager/class.ws.packager.win.inst.php diff --git a/inc/ws/Controlleur/packager/_common.php b/inc/ws/Controlleur/packager/_common.php index 8fdc81c2e..e5bca614a 100644 --- a/inc/ws/Controlleur/packager/_common.php +++ b/inc/ws/Controlleur/packager/_common.php @@ -4,5 +4,6 @@ $__autoload['wsPackagerHTML'] = dirname(__FILE__) . '/class.ws.packager.html.php $__autoload['wsPackagerWinEXE'] = dirname(__FILE__) . '/class.ws.packager.win.exe.php'; $__autoload['wsPackagerWinCD'] = dirname(__FILE__) . '/class.ws.packager.win.cd.php'; $__autoload['wsPackagerMacEXE'] = dirname(__FILE__) . '/class.ws.packager.mac.exe.php'; +$__autoload['wsPackagerWinINST'] = dirname(__FILE__) . '/class.ws.packager.win.inst.php'; ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/packager/class.ws.packager.mac.exe.php b/inc/ws/Controlleur/packager/class.ws.packager.mac.exe.php index 9335c357e..d93ec19ff 100644 --- a/inc/ws/Controlleur/packager/class.ws.packager.mac.exe.php +++ b/inc/ws/Controlleur/packager/class.ws.packager.mac.exe.php @@ -10,7 +10,7 @@ class wsPackagerMacEXE extends wsPackager { $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 16)); } - public function preparePackage() + protected function preparePackage() { parent::preparePackage(); diff --git a/inc/ws/Controlleur/packager/class.ws.packager.php b/inc/ws/Controlleur/packager/class.ws.packager.php index 691a53973..7bcd01c90 100644 --- a/inc/ws/Controlleur/packager/class.ws.packager.php +++ b/inc/ws/Controlleur/packager/class.ws.packager.php @@ -15,6 +15,8 @@ class wsPackager { $packager = new wsPackagerWinEXE($book_id); } elseif ($version == 'win-cd') { $packager = new wsPackagerWinCD($book_id); + } elseif ($version == 'win-ins') { + $packager = new wsPackagerWinINST($book_id); } elseif ($version == 'mac-exe') { $packager = new wsPackagerMacEXE($book_id); } @@ -83,11 +85,39 @@ class wsPackager { } } + 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) { - $base = '/packager/download/' . $this->version . '-' . date('Ymdhis') . '-' . cubeText::str2URL($this->book->parametres->title) . '.zip'; - $url = '/fluidbook' . $base; - $final = WS_FILES . $base ; + $url = $this->getURLBase('zip'); + $final = $this->getPathBase('zip'); $rename = false; if (is_null($zipfile)) { $zipfile = $final; diff --git a/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php b/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php index 9ea107a49..d70a06b91 100644 --- a/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php +++ b/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php @@ -6,7 +6,7 @@ class wsPackagerWinCD extends wsPackagerWinEXE { $this->version = 'win-cd'; } - public function preparePackage() + protected function preparePackage() { parent::preparePackage(); diff --git a/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php b/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php index 94dcc3cef..2ebd4e4fe 100644 --- a/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php +++ b/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php @@ -10,7 +10,7 @@ class wsPackagerWinEXE extends wsPackager { $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 16)).'.exe'; } - public function preparePackage() + protected function preparePackage() { parent::preparePackage(); diff --git a/inc/ws/Controlleur/packager/class.ws.packager.win.inst.php b/inc/ws/Controlleur/packager/class.ws.packager.win.inst.php new file mode 100644 index 000000000..52958bcb9 --- /dev/null +++ b/inc/ws/Controlleur/packager/class.ws.packager.win.inst.php @@ -0,0 +1,54 @@ +version = 'win-ins'; + } + + protected function preparePackage() + { + parent::preparePackage(); + + $this->copyFluidbookFiles(); + $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName)); + + $this->makeNSI(); + } + + protected function makeNSI() + { + $winvdir = trim($this->vdir, '/'); + $winvdir = str_replace('/', '\\' , $winvdir); + $winvdir = "\\" . $winvdir; + + $nsi = file_get_contents(WS_COMPILE_ASSETS . '/script.nsi'); + $nsi = str_replace('$name', utf8_decode($this->book->parametres->title), $nsi); + $nsi = str_replace('$htmldir', utf8_decode(WS_COMPILE_ASSETS), $nsi); + $nsi = str_replace('$fname', str_replace('.exe', '', $this->exeName), $nsi); + $nsi = str_replace('$fdir', $winvdir, $nsi); + $nsi = str_replace('$titre', utf8_decode($this->book->parametres->title), $nsi); + $nsi = str_replace('$lang', 'English', $nsi); + $nsi = str_replace('$nsisdir', '/usr/local/nsis/nsis-2.46/share/nsis', $nsi); + $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi); + + $this->nsi = $nsi; + } + public function makePackage() + { + $this->preparePackage(); + $url = 'http://installer.fluidbook.com/make.php?nsi=' . base64_encode($this->nsi) ; + fb($url); + + file_get_contents('http://installer.fluidbook.com/make.php?nsi=' . base64_encode($this->nsi) . '&junk=' . TIME); + return $this->getURLBase('exe'); + } + + public function __destruct() + { + } +} + +?> \ No newline at end of file diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index d303ba612..06bc47690 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -677,7 +677,6 @@ class wsDAOBook extends commonDAO { $filesToCopy['FluidbookDatas.swf'] = $compilerDir . '/FluidbookDatas.swf'; $filesToCopy['FluidbookDatasLight.swf'] = $compilerDir . '/FluidbookDatasLight.swf'; - $filesToCopy['index.swf'] = WS_COMPILE_ASSETS . '/index.swf'; // Copy of files // Check if dest dir exists if (!file_exists($finalDir . 'data')) { -- 2.39.5