+++ /dev/null
-<?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
-$__autoload['wsPackagerMacEXE'] = dirname(__FILE__) . '/class.ws.packager.mac.exe.php';\r
-$__autoload['wsPackagerWinINST'] = dirname(__FILE__) . '/class.ws.packager.win.inst.php';\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsPackagerHTML extends wsPackager {\r
- protected $origHTML;\r
-\r
- public function __construct($book_id)\r
- {\r
- parent::__construct($book_id);\r
- $this->version = 'html';\r
- }\r
-\r
- protected function preparePackage()\r
- {\r
- parent::preparePackage();\r
-\r
- $this->copyFluidbookFiles();\r
- $this->mergeJavascript();\r
-\r
- $this->copyOtherFiles(array('fluidbook.js', 'getflash.gif', 'index.html', 'index.swf', 'player.swf', 'style.css'));\r
-\r
- mkdir($this->vdir . '/pages/', 0777, true);\r
-\r
- $ga = '';\r
- if ($this->book->parametres->googleAnalytics != '') {\r
- $variables = array('Language' => array('value' => 'getLang()', 'valueAsJS' => true, 'scope' => 2));\r
- $ga = cubePage::googleAnalytics(explode(',', $this->book->parametres->googleAnalytics), true, $variables);\r
- }\r
-\r
- $facebook = '';\r
- if ($this->book->parametres->facebook) {\r
- if ($this->book->parametres->facebook_title != '') {\r
- $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->facebook_title) . '" />';\r
- } else {\r
- $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->title) . '" />';\r
- }\r
- if ($this->book->parametres->facebook_description != '') {\r
- $facebook .= '<meta property="og:description" content="' . self::escape($this->book->parametres->facebook_description) . '" />';\r
- }\r
- $facebook .= '<meta property="og:image" content="http://dev.ws.fluidbook.com/services/facebook_thumbnail?id=' . $this->book->book_id . '" />';\r
- }\r
- // Stuffs to replace in html\r
- $toReplace = array('lang' => strtolower($this->book->lang), 'title' => self::escape($this->book->parametres->title), 'ga' => $ga, 'facebook' => $facebook, 'bgcolor' => $this->theme->parametres->loadingBackColor);\r
-\r
- $this->origHTML = file_get_contents($this->vdir . '/index.html');\r
- $this->origHTML = $this->replaceHTML($toReplace);\r
-\r
- $nav1 = $this->makeHTMLNav(true);\r
- $nav = $this->makeHTMLNav(false);\r
- $footer = $this->makeHTMLFooter();\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
- $htmlfile = WS_DOCS . '/' . $infos['document_id'] . '/h' . $infos['document_page'] . '.txt';\r
-\r
- if (file_exists($htmlfile)) {\r
- $html = file_get_contents($htmlfile);\r
- $alt .= "\n" . $html . "\n";\r
- }\r
-\r
- if ($page == 1) {\r
- $alt .= $nav1;\r
- } else {\r
- $alt .= $nav;\r
- }\r
- $alt .= $footer;\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
- parent::makePackage();\r
- return $this->zip();\r
- }\r
-\r
- protected function makeHTMLNav($root)\r
- {\r
- $res = '<ul id="nav">';\r
- foreach($this->pages as $page => $infos) {\r
- if ($page == 1) {\r
- if ($root) {\r
- $url = 'index.html';\r
- } else {\r
- $url = '../index.html';\r
- }\r
- } else {\r
- if ($root) {\r
- $url = 'pages/page' . $page . '.html';\r
- } else {\r
- $url = 'page' . $page . '.html';\r
- }\r
- }\r
- $res .= '<li><a href="' . $url . '">Page ' . $page . '</a></li>';\r
- }\r
- $res .= '</ul>';\r
- return $res;\r
- }\r
-\r
- protected function escape($txt)\r
- {\r
- return htmlentities($txt, ENT_COMPAT, 'UTF-8');\r
- }\r
-\r
- protected function makeHTMLFooter()\r
- {\r
- $res = '<div class="footer">';\r
- $res .= '<h2><a href="http://www.fluidbook.com">Fluidbook : Solution de catalogues interactifs et brochures en ligne</a></h2>';\r
- $res .= '</div>';\r
- return $res;\r
- }\r
-\r
- protected function replaceHTML($toReplace)\r
- {\r
- return $this->replaceContents($this->origHTML, $toReplace);\r
- }\r
-\r
- protected function mergeJavascript()\r
- {\r
- $dest = WS_COMPILE_ASSETS . '/fluidbook.js';\r
- $orig = WS_COMPILE_ASSETS . '/_js/';\r
- $files = array('swfobject.js' => false, 'swfaddress.js' => false, 'fluidbook.js' => true);\r
-\r
- $refresh = false;\r
- if (file_exists($dest)) {\r
- $mtime = filemtime($dest);\r
- foreach($files as $file => $min) {\r
- if (filemtime($orig . $file) > $mtime) {\r
- $refresh = true;\r
- break;\r
- }\r
- }\r
- } else {\r
- $refresh = true;\r
- }\r
- if (!$refresh) {\r
- return;\r
- }\r
-\r
- $minjs = "\n\n";\r
- foreach($files as $file => $min) {\r
- $c = file_get_contents($orig . $file);\r
- if ($min) {\r
- $c = JSMin::minify($c);\r
- }\r
-\r
- $minjs .= $c . "\n\n";\r
- }\r
- file_put_contents($dest, $minjs);\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsPackagerMacEXE extends wsPackager {\r
- protected $exeName;\r
-\r
- public function __construct($book_id)\r
- {\r
- parent::__construct($book_id);\r
- $this->version = 'mac-exe';\r
-\r
- $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 16));\r
- }\r
-\r
- protected function preparePackage()\r
- {\r
- parent::preparePackage();\r
-\r
- $this->copyFluidbookFiles();\r
- $this->copyOtherFiles(array('Fluidbook.app.zip'));\r
- }\r
-\r
- public function makePackage()\r
- {\r
- parent::makePackage();\r
- return $this->zip($this->vdir . 'Fluidbook.app.zip');\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsPackager {\r
- protected $dir;\r
- protected $vdir;\r
- protected $book;\r
- protected $pages;\r
- protected $theme;\r
- protected $version;\r
-\r
- public static function package($book_id, $version)\r
- {\r
- if ($version == 'html') {\r
- $packager = new wsPackagerHTML($book_id);\r
- } elseif ($version == 'win-exe') {\r
- $packager = new wsPackagerWinEXE($book_id);\r
- } elseif ($version == 'win-cd') {\r
- $packager = new wsPackagerWinCD($book_id);\r
- } elseif ($version == 'win-ins') {\r
- $packager = new wsPackagerWinINST($book_id);\r
- } elseif ($version == 'mac-exe') {\r
- $packager = new wsPackagerMacEXE($book_id);\r
- }\r
-\r
- return $packager->makePackage();\r
- }\r
-\r
- public function __construct($book_id)\r
- {\r
- global $core;\r
-\r
- $this->dir = WS_FILES . '/packager/' . $book_id . '/';\r
-\r
- if (!file_exists($this->dir)) {\r
- mkdir($this->dir, 0777, true);\r
- }\r
-\r
- $daoBook = new wsDAOBook($core->con);\r
- $this->book = $daoBook->selectById($book_id);\r
- $this->pages = $daoBook->getPagesOfBook($book_id);\r
-\r
- $daoTheme = new wsDAOTheme($core->con);\r
- $this->theme = $daoTheme->getThemeOfBook($book_id, true);\r
- }\r
-\r
- protected function preparePackage()\r
- {\r
- $this->initTempDir();\r
- }\r
-\r
- public function makePackage()\r
- {\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
- $cp = new cubeCommandLine('cp');\r
- $cp->setArg('R');\r
- $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*');\r
- $cp->setArg(null, $this->vdir);\r
- $cp->execute();\r
- }\r
-\r
- protected function copyOtherFiles($files)\r
- {\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
- protected function getBaseFile()\r
- {\r
- return $this->version . '-' . date('Ymdhis', TIME) . '-' . cubeText::str2URL($this->book->parametres->title);\r
- }\r
-\r
- protected function getRelativeBase()\r
- {\r
- return '/packager/download/' . $this->getBaseFile();\r
- }\r
-\r
- protected function getURLBase($ext = '')\r
- {\r
- $res = '/fluidbook' . $this->getRelativeBase() ;\r
- if ($ext != '') {\r
- $res .= '.' . $ext;\r
- }\r
- return $res;\r
- }\r
-\r
- protected function getPathBase($ext = '')\r
- {\r
- $res = WS_FILES . $this->getRelativeBase();\r
- if ($ext != '') {\r
- $res .= '.' . $ext;\r
- }\r
-\r
- return $res;\r
- }\r
-\r
- protected function zip($zipfile = null)\r
- {\r
- $url = $this->getURLBase('zip');\r
- $final = $this->getPathBase('zip');\r
- $rename = false;\r
- if (is_null($zipfile)) {\r
- $zipfile = $final;\r
- } else {\r
- $rename = true;\r
- }\r
-\r
- $zip = new cubeCommandLine('zip');\r
- $zip->cd($this->vdir);\r
- $zip->setArg(null, $zipfile);\r
- $zip->setArg('0');\r
- $zip->setArg('u');\r
- $zip->setArg('r');\r
- $zip->setArg('X');\r
- $zip->setArg(null, '.');\r
- $zip->execute();\r
-\r
- if ($rename) {\r
- rename($zipfile, $final);\r
- }\r
- return $url;\r
- }\r
-\r
- protected function initTempDir()\r
- {\r
- $this->vdir = $this->dir . $this->version . '/';\r
- $this->cleanVdir();\r
- mkdir($this->vdir, 0777, true);\r
- }\r
-\r
- protected function cleanVdir()\r
- {\r
- if (file_exists($this->vdir)) {\r
- // Suppression du répertoire si il existe\r
- $rm = new cubeCommandLine('rm');\r
- $rm->setArg('r');\r
- $rm->setArg('f');\r
- $rm->setArg(null, $this->vdir);\r
- $rm->execute();\r
- }\r
- }\r
-\r
- public function __destruct()\r
- {\r
- $this->cleanVdir();\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /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
- protected 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)).'.exe';\r
- }\r
-\r
- protected 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
- parent::makePackage();\r
- return $this->zip();\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsPackagerWinINST extends wsPackagerWinEXE {\r
- protected $nsi;\r
-\r
- public function __construct($book_id)\r
- {\r
- parent::__construct($book_id);\r
- $this->version = 'win-ins';\r
- }\r
-\r
- protected function preparePackage()\r
- {\r
- parent::preparePackage();\r
-\r
- $this->copyFluidbookFiles();\r
- $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName));\r
-\r
- $this->makeNSI();\r
- }\r
-\r
- protected function makeNSI()\r
- {\r
- global $core;\r
-\r
- $winvdir = trim($this->vdir, '/');\r
- $winvdir = str_replace('/', '\\' , $winvdir);\r
- $winvdir = "\\" . $winvdir;\r
-\r
- $daoLang = new wsDAOLang($core->con);\r
- $lang = $daoLang->selectById($this->book->lang);\r
-\r
- $nsi = file_get_contents(WS_COMPILE_ASSETS . '/script.nsi');\r
- $nsi = str_replace('$name', utf8_decode($this->book->parametres->title), $nsi);\r
- $nsi = str_replace('$htmldir', utf8_decode(WS_COMPILE_ASSETS), $nsi);\r
- $nsi = str_replace('$fname', str_replace('.exe', '', $this->exeName), $nsi);\r
- $nsi = str_replace('$fdir', $winvdir, $nsi);\r
- $nsi = str_replace('$titre', utf8_decode($this->book->parametres->title), $nsi);\r
- $nsi = str_replace('$lang', utf8_decode($lang->nsis), $nsi);\r
- $nsi = str_replace('$nsisdir', '/usr/local/nsis/nsis-2.46/share/nsis', $nsi);\r
- $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi);\r
-\r
- $this->nsi = $nsi;\r
- }\r
- public function makePackage()\r
- {\r
- $this->preparePackage();\r
- $url = 'http://installer.fluidbook.com/make.php?nsi=' . base64_encode($this->nsi) ;\r
- fb($url);\r
-\r
- file_get_contents('http://installer.fluidbook.com/make.php?nsi=' . base64_encode($this->nsi) . '&junk=' . TIME);\r
- return $this->getURLBase('exe');\r
- }\r
-\r
- public function __destruct()\r
- {\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
--- /dev/null
+<?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
+$__autoload['wsPackagerMacEXE'] = dirname(__FILE__) . '/class.ws.packager.mac.exe.php';\r
+$__autoload['wsPackagerWinINST'] = dirname(__FILE__) . '/class.ws.packager.win.inst.php';\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsPackagerHTML extends wsPackager {\r
+ protected $origHTML;\r
+\r
+ public function __construct($book_id)\r
+ {\r
+ parent::__construct($book_id);\r
+ $this->version = 'html';\r
+ }\r
+\r
+ protected function preparePackage()\r
+ {\r
+ parent::preparePackage();\r
+\r
+ $this->copyFluidbookFiles();\r
+ $this->mergeJavascript();\r
+\r
+ $this->copyOtherFiles(array('fluidbook.js', 'getflash.gif', 'index.html', 'index.swf', 'player.swf', 'style.css'));\r
+\r
+ mkdir($this->vdir . '/pages/', 0777, true);\r
+\r
+ $ga = '';\r
+ if ($this->book->parametres->googleAnalytics != '') {\r
+ $variables = array('Language' => array('value' => 'getLang()', 'valueAsJS' => true, 'scope' => 2));\r
+ $ga = cubePage::googleAnalytics(explode(',', $this->book->parametres->googleAnalytics), true, $variables);\r
+ }\r
+\r
+ $facebook = '';\r
+ if ($this->book->parametres->facebook) {\r
+ if ($this->book->parametres->facebook_title != '') {\r
+ $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->facebook_title) . '" />';\r
+ } else {\r
+ $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->title) . '" />';\r
+ }\r
+ if ($this->book->parametres->facebook_description != '') {\r
+ $facebook .= '<meta property="og:description" content="' . self::escape($this->book->parametres->facebook_description) . '" />';\r
+ }\r
+ $facebook .= '<meta property="og:image" content="http://dev.ws.fluidbook.com/services/facebook_thumbnail?id=' . $this->book->book_id . '" />';\r
+ }\r
+ // Stuffs to replace in html\r
+ $toReplace = array('lang' => strtolower($this->book->lang), 'title' => self::escape($this->book->parametres->title), 'ga' => $ga, 'facebook' => $facebook, 'bgcolor' => $this->theme->parametres->loadingBackColor);\r
+\r
+ $this->origHTML = file_get_contents($this->vdir . '/index.html');\r
+ $this->origHTML = $this->replaceHTML($toReplace);\r
+\r
+ $nav1 = $this->makeHTMLNav(true);\r
+ $nav = $this->makeHTMLNav(false);\r
+ $footer = $this->makeHTMLFooter();\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
+ $htmlfile = WS_DOCS . '/' . $infos['document_id'] . '/h' . $infos['document_page'] . '.txt';\r
+\r
+ if (file_exists($htmlfile)) {\r
+ $html = file_get_contents($htmlfile);\r
+ $alt .= "\n" . $html . "\n";\r
+ }\r
+\r
+ if ($page == 1) {\r
+ $alt .= $nav1;\r
+ } else {\r
+ $alt .= $nav;\r
+ }\r
+ $alt .= $footer;\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
+ parent::makePackage();\r
+ return $this->zip();\r
+ }\r
+\r
+ protected function makeHTMLNav($root)\r
+ {\r
+ $res = '<ul id="nav">';\r
+ foreach($this->pages as $page => $infos) {\r
+ if ($page == 1) {\r
+ if ($root) {\r
+ $url = 'index.html';\r
+ } else {\r
+ $url = '../index.html';\r
+ }\r
+ } else {\r
+ if ($root) {\r
+ $url = 'pages/page' . $page . '.html';\r
+ } else {\r
+ $url = 'page' . $page . '.html';\r
+ }\r
+ }\r
+ $res .= '<li><a href="' . $url . '">Page ' . $page . '</a></li>';\r
+ }\r
+ $res .= '</ul>';\r
+ return $res;\r
+ }\r
+\r
+ protected function escape($txt)\r
+ {\r
+ return htmlentities($txt, ENT_COMPAT, 'UTF-8');\r
+ }\r
+\r
+ protected function makeHTMLFooter()\r
+ {\r
+ $res = '<div class="footer">';\r
+ $res .= '<h2><a href="http://www.fluidbook.com">Fluidbook : Solution de catalogues interactifs et brochures en ligne</a></h2>';\r
+ $res .= '</div>';\r
+ return $res;\r
+ }\r
+\r
+ protected function replaceHTML($toReplace)\r
+ {\r
+ return $this->replaceContents($this->origHTML, $toReplace);\r
+ }\r
+\r
+ protected function mergeJavascript()\r
+ {\r
+ $dest = WS_COMPILE_ASSETS . '/fluidbook.js';\r
+ $orig = WS_COMPILE_ASSETS . '/_js/';\r
+ $files = array('swfobject.js' => false, 'swfaddress.js' => false, 'fluidbook.js' => true);\r
+\r
+ $refresh = false;\r
+ if (file_exists($dest)) {\r
+ $mtime = filemtime($dest);\r
+ foreach($files as $file => $min) {\r
+ if (filemtime($orig . $file) > $mtime) {\r
+ $refresh = true;\r
+ break;\r
+ }\r
+ }\r
+ } else {\r
+ $refresh = true;\r
+ }\r
+ if (!$refresh) {\r
+ return;\r
+ }\r
+\r
+ $minjs = "\n\n";\r
+ foreach($files as $file => $min) {\r
+ $c = file_get_contents($orig . $file);\r
+ if ($min) {\r
+ $c = JSMin::minify($c);\r
+ }\r
+\r
+ $minjs .= $c . "\n\n";\r
+ }\r
+ file_put_contents($dest, $minjs);\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsPackagerMacEXE extends wsPackager {\r
+ protected $exeName;\r
+\r
+ public function __construct($book_id)\r
+ {\r
+ parent::__construct($book_id);\r
+ $this->version = 'mac-exe';\r
+\r
+ $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 16));\r
+ }\r
+\r
+ protected function preparePackage()\r
+ {\r
+ parent::preparePackage();\r
+\r
+ $this->copyFluidbookFiles();\r
+ $this->copyOtherFiles(array('Fluidbook.app.zip'));\r
+ }\r
+\r
+ public function makePackage()\r
+ {\r
+ parent::makePackage();\r
+ return $this->zip($this->vdir . 'Fluidbook.app.zip');\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsPackager {\r
+ protected $dir;\r
+ protected $vdir;\r
+ protected $book;\r
+ protected $pages;\r
+ protected $theme;\r
+ protected $version;\r
+\r
+ public static function package($book_id, $version)\r
+ {\r
+ if ($version == 'html') {\r
+ $packager = new wsPackagerHTML($book_id);\r
+ } elseif ($version == 'win-exe') {\r
+ $packager = new wsPackagerWinEXE($book_id);\r
+ } elseif ($version == 'win-cd') {\r
+ $packager = new wsPackagerWinCD($book_id);\r
+ } elseif ($version == 'win-ins') {\r
+ $packager = new wsPackagerWinINST($book_id);\r
+ } elseif ($version == 'mac-exe') {\r
+ $packager = new wsPackagerMacEXE($book_id);\r
+ }\r
+\r
+ return $packager->makePackage();\r
+ }\r
+\r
+ public function __construct($book_id)\r
+ {\r
+ global $core;\r
+\r
+ $this->dir = WS_FILES . '/packager/' . $book_id . '/';\r
+\r
+ if (!file_exists($this->dir)) {\r
+ mkdir($this->dir, 0777, true);\r
+ }\r
+\r
+ $daoBook = new wsDAOBook($core->con);\r
+ $this->book = $daoBook->selectById($book_id);\r
+ $this->pages = $daoBook->getPagesOfBook($book_id);\r
+\r
+ $daoTheme = new wsDAOTheme($core->con);\r
+ $this->theme = $daoTheme->getThemeOfBook($book_id, true);\r
+ }\r
+\r
+ protected function preparePackage()\r
+ {\r
+ $this->initTempDir();\r
+ }\r
+\r
+ public function makePackage()\r
+ {\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
+ $cp = new cubeCommandLine('cp');\r
+ $cp->setArg('R');\r
+ $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*');\r
+ $cp->setArg(null, $this->vdir);\r
+ $cp->execute();\r
+ }\r
+\r
+ protected function copyOtherFiles($files)\r
+ {\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
+ protected function getBaseFile()\r
+ {\r
+ return $this->version . '-' . date('Ymdhis', TIME) . '-' . cubeText::str2URL($this->book->parametres->title);\r
+ }\r
+\r
+ protected function getRelativeBase()\r
+ {\r
+ return '/packager/download/' . $this->getBaseFile();\r
+ }\r
+\r
+ protected function getURLBase($ext = '')\r
+ {\r
+ $res = '/fluidbook' . $this->getRelativeBase() ;\r
+ if ($ext != '') {\r
+ $res .= '.' . $ext;\r
+ }\r
+ return $res;\r
+ }\r
+\r
+ protected function getPathBase($ext = '')\r
+ {\r
+ $res = WS_FILES . $this->getRelativeBase();\r
+ if ($ext != '') {\r
+ $res .= '.' . $ext;\r
+ }\r
+\r
+ return $res;\r
+ }\r
+\r
+ protected function zip($zipfile = null)\r
+ {\r
+ $url = $this->getURLBase('zip');\r
+ $final = $this->getPathBase('zip');\r
+ $rename = false;\r
+ if (is_null($zipfile)) {\r
+ $zipfile = $final;\r
+ } else {\r
+ $rename = true;\r
+ }\r
+\r
+ $zip = new cubeCommandLine('zip');\r
+ $zip->cd($this->vdir);\r
+ $zip->setArg(null, $zipfile);\r
+ $zip->setArg('0');\r
+ $zip->setArg('u');\r
+ $zip->setArg('r');\r
+ $zip->setArg('X');\r
+ $zip->setArg(null, '.');\r
+ $zip->execute();\r
+\r
+ if ($rename) {\r
+ rename($zipfile, $final);\r
+ }\r
+ return $url;\r
+ }\r
+\r
+ protected function initTempDir()\r
+ {\r
+ $this->vdir = $this->dir . $this->version . '/';\r
+ $this->cleanVdir();\r
+ mkdir($this->vdir, 0777, true);\r
+ }\r
+\r
+ protected function cleanVdir()\r
+ {\r
+ if (file_exists($this->vdir)) {\r
+ // Suppression du répertoire si il existe\r
+ $rm = new cubeCommandLine('rm');\r
+ $rm->setArg('r');\r
+ $rm->setArg('f');\r
+ $rm->setArg(null, $this->vdir);\r
+ $rm->execute();\r
+ }\r
+ }\r
+\r
+ public function __destruct()\r
+ {\r
+ $this->cleanVdir();\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /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
+ protected 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)).'.exe';\r
+ }\r
+\r
+ protected 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
+ parent::makePackage();\r
+ return $this->zip();\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsPackagerWinINST extends wsPackagerWinEXE {\r
+ protected $nsi;\r
+\r
+ public function __construct($book_id)\r
+ {\r
+ parent::__construct($book_id);\r
+ $this->version = 'win-ins';\r
+ }\r
+\r
+ protected function preparePackage()\r
+ {\r
+ parent::preparePackage();\r
+\r
+ $this->copyFluidbookFiles();\r
+ $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName));\r
+\r
+ $this->makeNSI();\r
+ }\r
+\r
+ protected function makeNSI()\r
+ {\r
+ global $core;\r
+\r
+ $winvdir = trim($this->vdir, '/');\r
+ $winvdir = str_replace('/', '\\' , $winvdir);\r
+ $winvdir = "\\" . $winvdir;\r
+\r
+ $daoLang = new wsDAOLang($core->con);\r
+ $lang = $daoLang->selectById($this->book->lang);\r
+\r
+ $nsi = file_get_contents(WS_COMPILE_ASSETS . '/script.nsi');\r
+ $nsi = str_replace('$name', utf8_decode($this->book->parametres->title), $nsi);\r
+ $nsi = str_replace('$htmldir', utf8_decode(WS_COMPILE_ASSETS), $nsi);\r
+ $nsi = str_replace('$fname', str_replace('.exe', '', $this->exeName), $nsi);\r
+ $nsi = str_replace('$fdir', $winvdir, $nsi);\r
+ $nsi = str_replace('$titre', utf8_decode($this->book->parametres->title), $nsi);\r
+ $nsi = str_replace('$lang', utf8_decode($lang->nsis), $nsi);\r
+ $nsi = str_replace('$nsisdir', '/usr/local/nsis/nsis-2.46/share/nsis', $nsi);\r
+ $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi);\r
+\r
+ $this->nsi = $nsi;\r
+ }\r
+ public function makePackage()\r
+ {\r
+ $this->preparePackage();\r
+ $url = 'http://installer.fluidbook.com/make.php?nsi=' . base64_encode($this->nsi) ;\r
+ fb($url);\r
+\r
+ file_get_contents('http://installer.fluidbook.com/make.php?nsi=' . base64_encode($this->nsi) . '&junk=' . TIME);\r
+ return $this->getURLBase('exe');\r
+ }\r
+\r
+ public function __destruct()\r
+ {\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file