<?php\r
$__autoload['wsPackager'] = dirname(__FILE__) . '/class.ws.packager.php';\r
$__autoload['wsPackagerHTML'] = dirname(__FILE__) . '/class.ws.packager.html.php';\r
+$__autoload['wsPackagerWinEXE'] = dirname(__FILE__) . '/class.ws.packager.win.exe.php';\r
+$__autoload['wsPackagerWinCD'] = dirname(__FILE__) . '/class.ws.packager.win.cd.php';\r
\r
?>
\ No newline at end of file
$this->version = 'html';\r
}\r
\r
- public function makePackage()\r
+ protected function preparePackage()\r
{\r
- parent::makePackage();\r
+ parent::preparePackage();\r
\r
$this->copyFluidbookFiles();\r
$this->copyOtherFiles(array('fluidbook.js', 'getflash.gif', 'index.html', 'index.swf', 'player.swf', 'style.css'));\r
\r
foreach($this->pages as $page => $infos) {\r
$pathToIndex = 'index.swf';\r
+ $pathToGetflash = 'getflash.gif';\r
$redirectScript = '';\r
if ($page == 1) {\r
$dest = 'index.html';\r
} else {\r
$dest = 'pages/page' . $page . '.html';\r
$pathToIndex = '../index.swf';\r
+ $pathToGetflash = '../getflash.gif';\r
$redirectScript = '<script type="text/javascript">window.location=\'../index.html#/' . $page . '\';</script>';\r
}\r
$alt = '';\r
\r
$data = str_replace('$alt', $alt , $this->origHTML);\r
$data = str_replace('$pathToIndex', $pathToIndex, $data);\r
+ $data = str_replace('$pathToGetflash', $pathToGetflash, $data);\r
$data = str_replace('$redirectScript', $redirectScript, $data);\r
\r
file_put_contents($this->vdir . $dest, $data);\r
}\r
+ }\r
\r
+ public function makePackage()\r
+ {\r
return $this->zip();\r
}\r
\r
\r
protected function replaceHTML($toReplace)\r
{\r
- $res = $this->origHTML;\r
- foreach($toReplace as $k => $v) {\r
- if (is_null($v)) {\r
- return;\r
- }\r
- $res = str_replace('$' . $k, $v, $res);\r
- }\r
- return $res;\r
+ return $this->replaceContents($this->origHTML, $toReplace);\r
}\r
}\r
\r
{\r
if ($version == 'html') {\r
$packager = new wsPackagerHTML($book_id);\r
+ } elseif ($version == 'win-exe') {\r
+ $packager = new wsPackagerWinEXE($book_id);\r
}\r
\r
return $packager->makePackage();\r
$this->theme = $daoTheme->getThemeOfBook($book_id, true);\r
}\r
\r
- public function makePackage()\r
+ protected function preparePackage()\r
{\r
$this->initTempDir();\r
}\r
\r
+ public function makePackage(){\r
+ $this->preparePackage();\r
+ }\r
+\r
+ protected function replaceContents($str, $toReplace)\r
+ {\r
+ $res = $str;\r
+ foreach($toReplace as $k => $v) {\r
+ if (is_null($v)) {\r
+ return;\r
+ }\r
+ $res = str_replace('$' . $k, $v, $res);\r
+ }\r
+ return $res;\r
+ }\r
+\r
protected function copyFluidbookFiles()\r
{\r
// Copie du FB vers un répertoire temporaire\r
\r
protected function copyOtherFiles($files)\r
{\r
- foreach($files as $f) {\r
- copy(WS_COMPILE_ASSETS . '/' . $f, $this->vdir . $f);\r
+ foreach($files as $source => $dest) {\r
+ if (is_int($source)) {\r
+ $source = $dest;\r
+ }\r
+\r
+ copy(WS_COMPILE_ASSETS . '/' . $source, $this->vdir . $dest);\r
}\r
}\r
\r
--- /dev/null
+<?php\r
+class wsPackagerWinCD extends wsPackagerWinEXE {\r
+ public function __construct($book_id)\r
+ {\r
+ parent::__construct($book_id);\r
+ $this->version = 'win-cd';\r
+ }\r
+\r
+ public function preparePackage()\r
+ {\r
+ parent::preparePackage();\r
+\r
+ $this->copyOtherFiles(array('fluidbook.ico', 'autorun.inf'));\r
+ $this->replaceAutorun();\r
+ }\r
+\r
+ public function replaceAutorun()\r
+ {\r
+ $inf = file_get_contents($this->vdir . 'autorun.inf');\r
+ $toReplace = array('title' => $this->book->parametres->title, 'exe' => $this->exeName);\r
+ $inf = $this->replaceContents($inf, $toReplace);\r
+ file_put_contents($this->vdir . 'autorun.inf', $inf);\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsPackagerWinEXE extends wsPackager {\r
+ protected $exeName;\r
+\r
+ public function __construct($book_id)\r
+ {\r
+ parent::__construct($book_id);\r
+ $this->version = 'win-exe';\r
+\r
+ $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 16));\r
+ }\r
+\r
+ public function preparePackage()\r
+ {\r
+ parent::preparePackage();\r
+\r
+ $this->copyFluidbookFiles();\r
+ $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName));\r
+ }\r
+\r
+ public function makePackage()\r
+ {\r
+ return $this->zip();\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file