global $core;\r
\r
cubePHP::neverStop();\r
- \r
+\r
$book_id = $args[1];\r
$time = $args[2];\r
\r
commonDroits::error();\r
}\r
\r
- if (!$dao->isUpToDate($book_id)) {\r
- if (isset($version) && ($version == 'u' || $version == 't')) {\r
- $dao->compileHTML5($book_id);\r
- } else {\r
- $dao->compile($book_id);\r
- $dao->touchCompile($book_id);\r
- }\r
- }\r
-\r
+ $dao->compile($book_id, 'html5');\r
$time = self::getHTML5CacheTime($book_id);\r
\r
if (count($e) == 2 || $e[2] != $time) {\r
commonDroits::min(5);\r
$args = cubePage::getArgs($args);\r
\r
+ \r
$e = explode('_', $args[0]);\r
+ $dao->compile($e[0], 'html5');\r
$time = self::getHTML5CacheTime($e[0]);\r
\r
if (count($e) == 2 || $e[2] != $time) {\r
$args = cubePage::getArgs($args);\r
\r
$e = explode('_', $args[0]);\r
+ $dao->compile($e[0], 'html5');\r
$time = self::getHTML5CacheTime($e[0]);\r
\r
if (count($e) == 2 || $e[2] != $time) {\r
commonDroits::error();\r
}\r
\r
- if (!$dao->isUpToDate($book_id)) {\r
- if ($version == 'u' || $version == 't') {\r
- $dao->compileHTML5($book_id);\r
- } else {\r
- $dao->compile($book_id);\r
- $dao->touchCompile($book_id);\r
- }\r
- }\r
-\r
echo file_get_contents(WS_BOOKS . '/html5/' . $book_id . '/index' . $version . '.html');\r
exit;\r
}\r
commonDroits::error();\r
}\r
\r
- if (!$dao->isUpToDate($book_id)) {\r
- $dao->compile($book_id);\r
- $dao->touchCompile($book_id);\r
- }\r
+ fb($version);\r
+ $dao->compile($book_id, (string)$version);\r
\r
$daoTheme = new wsDAOTheme($core->con);\r
$theme = $daoTheme->selectById($book->theme, 'themes');\r
$book->numerotation = $r->numerotation;\r
$book->changedate = $r->changedate;\r
$book->compiledate = $r->compiledate;\r
+ $book->compile1date = $r->compile1date;\r
+ $book->compilehtml5date = $r->compilehtml5date;\r
$book->facturable = $r->facturable;\r
$book->facturable_id = $r->facturable_id;\r
$book->tache = $r->tache;\r
$c->theme = 1;\r
$c->lang = $lang;\r
$c->changedate = TIME;\r
- $c->compiledate = TIME;\r
+ $c->compiledate = 0;\r
$c->version = 2;\r
$c->composition_update = TIME;\r
$book_id = $c->book_id = $this->getNextId();\r
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
}\r
\r
- public function touchCompile($book_id) {\r
+ public function touchCompile($book_id, $version = 'all') {\r
$c = $this->con->openCursor('books');\r
- $c->compiledate = TIME;\r
+ if ($version == '2') {\r
+ $c->compiledate = TIME;\r
+ } elseif ($version == '1') {\r
+ $c->compile1date = TIME;\r
+ } elseif ($version == 'html5') {\r
+ $c->compilehtml5date = TIME;\r
+ } else {\r
+ $c->compiledate = TIME;\r
+ $c->compile1date = TIME;\r
+ $c->compilehtml5date = TIME;\r
+ }\r
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
}\r
\r
$pages = $this->getPagesOfBook($book_id);\r
}\r
\r
- public function compile($book_id, $version = 3, $complete = false) {\r
+ public function compile($book_id, $version = 'all', $complete = false) {\r
if (is_null($book_id) || !$book_id) {\r
return;\r
}\r
\r
- fb(time(), 'Start compile 3');\r
- $res = $this->compile3($book_id, $complete, $book);\r
- fb(time(), 'Start compile 1');\r
- if ($book->parametres->version == 1) {\r
- $this->compile1($book_id);\r
+ $v1 = $v2 = $html5 = false;\r
+\r
+ if ($version == 'all') {\r
+ $v1 = $v2 = $html5 = true;\r
+ } else if ($version == '1') {\r
+ $v1 = true;\r
+ } else if ($version == '2') {\r
+ $v2 = true;\r
+ } elseif ($version == 'html5') {\r
+ $html5 = true;\r
+ }\r
+\r
+\r
+ $book = $this->selectById($book_id);\r
+ $pages = $this->getPagesOfBook($book_id);\r
+\r
+ $v1 = $v1 && $book->compile1date < $book->changedate;\r
+ $v2 = $v2 && $book->compiledate < $book->changedate;\r
+ $html5 = $html5 && $book->compilehtml5date < $book->changedate;\r
+\r
+\r
+ if ($v1 || $v2) {\r
+ $this->compilePDF($book, $pages);\r
+ $this->compileWidget($book, $pages);\r
+ }\r
+ $res = '';\r
+ if ($v1) {\r
+ $res.=$this->compile1($book_id, $book, $pages);\r
+ $this->touchCompile($book_id, '1');\r
+ }\r
+ if ($v2) {\r
+ $res .= $this->compile3($book_id, $complete, $book, $pages);\r
+ $this->touchCompile($book_id, '2');\r
+ }\r
+ if ($html5) {\r
+ $res.=$this->compileHTML5($book_id);\r
+ $this->touchCompile($book_id, 'html5');\r
}\r
- $this->touchCompile($book_id);\r
- fb(time(), 'End compile');\r
return $res;\r
}\r
\r
- public function compile1($book_id) {\r
-\r
+ public function compile1($book_id, $book, $pages) {\r
$finalDir = WS_BOOKS . '/finalv1/' . $book_id . '/';\r
$packager = new wsPackagerV1($book_id, $finalDir, false);\r
$packager->makePackage(false);\r
}\r
\r
- public function compile3($book_id, $complete, &$book) {\r
+ public function compile3($book_id, $complete, $book, $pages) {\r
$res = '';\r
\r
$compilerDir = WS_BOOKS . '/datasCompiler/' . $book_id . '/';\r
$rm->execute();\r
mkdir($finalDir, 0777, true);\r
\r
- $book = $this->selectById($book_id);\r
- $pages = $this->getPagesOfBook($book_id);\r
-\r
- fb(time(), 'prepare flex');\r
-\r
$flex = new cubeFlexCompiler('FluidbookDatas', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH, 10);\r
$flexLight = new cubeFlexCompiler('FluidbookDatasLight', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH, 10);\r
\r
$filesToCopy = array();\r
$this->compileFlex($book_id, $complete, $compilerDir, $finalDir, $filesToCopy, $book, $pages, $flex, $flexLight);\r
\r
- fb(time(), 'compile flex');\r
-\r
$res .= $flex->compile() . "\n\n-------------------\n\n";\r
$flexLight->addVariable('datasSize', filesize($compilerDir . '/FluidbookDatas.swf'));\r
$res .= $flexLight->compile();\r
$filesToCopy['data/fd.swf'] = $compilerDir . '/FluidbookDatas.swf';\r
$filesToCopy['data/fdl.swf'] = $compilerDir . '/FluidbookDatasLight.swf';\r
\r
- fb(time(), 'flex compiled');\r
-\r
// Copy of files\r
// Check if dest dir exists\r
if (!file_exists($finalDir . 'data')) {\r
mkdir($finalDir . 'data', 0777, true);\r
}\r
\r
- fb(time(), 'copy files');\r
-\r
foreach ($filesToCopy as $local => $source) {\r
$localPath = $finalDir . $local;\r
if (!file_exists($localPath) || filemtime($localPath) < filemtime($source) || filesize($localPath) != filesize($source) || filemtime($localPath) < $book->composition_update) {\r
copy($source, $localPath);\r
}\r
}\r
-\r
- fb(time(), 'Compile PDF');\r
-\r
- $this->compilePDF($book, $pages);\r
- if ($book->parametres->mobileVersion != 'pdf') {\r
- fb(time(), 'Compile HTML5');\r
- $this->compileHTML5($book_id);\r
- }\r
- fb(time(), 'Compile widget');\r
- $this->compileWidget($book, $pages);\r
- $this->touchCompile($book_id);\r
-\r
return $res;\r
}\r
\r
$hash .= round($size[0], 4);\r
$hash = sha1($hash);\r
\r
- fb(time(), 'texts and indexes');\r
-\r
$this->makeTextsIndexes($book, $pages, $index, $textes);\r
\r
- fb(time(), 'texts and links');\r
-\r
$daoDoc->getLinksAndRulers($book_id, $links, $rulers);\r
\r
$imagesassets = array();\r
$it->resize($book->parametres->widgetSize, 10000);\r
$it->output('jpeg', $tempimage[$i], 100);\r
} catch (Exception $e) {\r
- fb($e->getMessage());\r
$tempimage[$i] = $image;\r
}\r
-\r
-\r
-\r
-\r
$jpg2swf = new cubeCommandLine('jpeg2swf');\r
$jpg2swf->setEnv('PATH', '/bin:/usr/bin:/usr/local/bin');\r
$jpg2swf->setArg('q', $book->parametres->widgetQuality);\r
$jpg2swf->setArg(null, $tempimage[$i]);\r
$jpg2swf->execute();\r
\r
- fb($jpg2swf);\r
-\r
$swfcombine->setArg(null, $tempswf[$i]);\r
}\r
$swfcombine->execute();\r
$pdfName = $book->parametres->pdfName;\r
}\r
\r
-\r
$finalPDF = WS_BOOKS . '/final/' . $book->book_id . '/data/' . $pdfName;\r
\r
if (!$book->parametres->pdf && $book->parametres->mobileVersion != 'pdf') {\r