From bf81d8e158864681aea89b0cae9305335c9365bf Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 8 Feb 2011 13:09:48 +0000 Subject: [PATCH] --- inc/ws/Controlleur/packager/_common.php | 2 ++ .../packager/class.ws.packager.html.php | 19 ++++++------- .../packager/class.ws.packager.php | 28 +++++++++++++++++-- .../packager/class.ws.packager.win.cd.php | 26 +++++++++++++++++ .../packager/class.ws.packager.win.exe.php | 27 ++++++++++++++++++ 5 files changed, 89 insertions(+), 13 deletions(-) create mode 100644 inc/ws/Controlleur/packager/class.ws.packager.win.cd.php create mode 100644 inc/ws/Controlleur/packager/class.ws.packager.win.exe.php diff --git a/inc/ws/Controlleur/packager/_common.php b/inc/ws/Controlleur/packager/_common.php index 99b8a6890..de7a2c8f6 100644 --- a/inc/ws/Controlleur/packager/_common.php +++ b/inc/ws/Controlleur/packager/_common.php @@ -1,5 +1,7 @@ \ No newline at end of file diff --git a/inc/ws/Controlleur/packager/class.ws.packager.html.php b/inc/ws/Controlleur/packager/class.ws.packager.html.php index 6e4d0fca4..83cf17c8d 100644 --- a/inc/ws/Controlleur/packager/class.ws.packager.html.php +++ b/inc/ws/Controlleur/packager/class.ws.packager.html.php @@ -8,9 +8,9 @@ class wsPackagerHTML extends wsPackager { $this->version = 'html'; } - public function makePackage() + protected function preparePackage() { - parent::makePackage(); + parent::preparePackage(); $this->copyFluidbookFiles(); $this->copyOtherFiles(array('fluidbook.js', 'getflash.gif', 'index.html', 'index.swf', 'player.swf', 'style.css')); @@ -46,12 +46,14 @@ class wsPackagerHTML extends wsPackager { foreach($this->pages as $page => $infos) { $pathToIndex = 'index.swf'; + $pathToGetflash = 'getflash.gif'; $redirectScript = ''; if ($page == 1) { $dest = 'index.html'; } else { $dest = 'pages/page' . $page . '.html'; $pathToIndex = '../index.swf'; + $pathToGetflash = '../getflash.gif'; $redirectScript = ''; } $alt = ''; @@ -79,11 +81,15 @@ class wsPackagerHTML extends wsPackager { $data = str_replace('$alt', $alt , $this->origHTML); $data = str_replace('$pathToIndex', $pathToIndex, $data); + $data = str_replace('$pathToGetflash', $pathToGetflash, $data); $data = str_replace('$redirectScript', $redirectScript, $data); file_put_contents($this->vdir . $dest, $data); } + } + public function makePackage() + { return $this->zip(); } @@ -125,14 +131,7 @@ class wsPackagerHTML extends wsPackager { protected function replaceHTML($toReplace) { - $res = $this->origHTML; - foreach($toReplace as $k => $v) { - if (is_null($v)) { - return; - } - $res = str_replace('$' . $k, $v, $res); - } - return $res; + return $this->replaceContents($this->origHTML, $toReplace); } } diff --git a/inc/ws/Controlleur/packager/class.ws.packager.php b/inc/ws/Controlleur/packager/class.ws.packager.php index 452707ec6..8cccff59b 100644 --- a/inc/ws/Controlleur/packager/class.ws.packager.php +++ b/inc/ws/Controlleur/packager/class.ws.packager.php @@ -11,6 +11,8 @@ class wsPackager { { if ($version == 'html') { $packager = new wsPackagerHTML($book_id); + } elseif ($version == 'win-exe') { + $packager = new wsPackagerWinEXE($book_id); } return $packager->makePackage(); @@ -34,11 +36,27 @@ class wsPackager { $this->theme = $daoTheme->getThemeOfBook($book_id, true); } - public function makePackage() + protected function preparePackage() { $this->initTempDir(); } + public function makePackage(){ + $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 @@ -51,8 +69,12 @@ class wsPackager { protected function copyOtherFiles($files) { - foreach($files as $f) { - copy(WS_COMPILE_ASSETS . '/' . $f, $this->vdir . $f); + foreach($files as $source => $dest) { + if (is_int($source)) { + $source = $dest; + } + + copy(WS_COMPILE_ASSETS . '/' . $source, $this->vdir . $dest); } } diff --git a/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php b/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php new file mode 100644 index 000000000..9ea107a49 --- /dev/null +++ b/inc/ws/Controlleur/packager/class.ws.packager.win.cd.php @@ -0,0 +1,26 @@ +version = 'win-cd'; + } + + public function preparePackage() + { + parent::preparePackage(); + + $this->copyOtherFiles(array('fluidbook.ico', 'autorun.inf')); + $this->replaceAutorun(); + } + + public function replaceAutorun() + { + $inf = file_get_contents($this->vdir . 'autorun.inf'); + $toReplace = array('title' => $this->book->parametres->title, 'exe' => $this->exeName); + $inf = $this->replaceContents($inf, $toReplace); + file_put_contents($this->vdir . 'autorun.inf', $inf); + } +} + +?> \ No newline at end of file diff --git a/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php b/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php new file mode 100644 index 000000000..fc63d067d --- /dev/null +++ b/inc/ws/Controlleur/packager/class.ws.packager.win.exe.php @@ -0,0 +1,27 @@ +version = 'win-exe'; + + $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 16)); + } + + public function preparePackage() + { + parent::preparePackage(); + + $this->copyFluidbookFiles(); + $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName)); + } + + public function makePackage() + { + return $this->zip(); + } +} + +?> \ No newline at end of file -- 2.39.5