From f005512786df9e545094659f9458e2c88a558930 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 13 Apr 2012 09:37:41 +0000 Subject: [PATCH] --- inc/commons/class.common.core.php | 2 + inc/ws/Controlleur/class.ws.flash.php | 10 +- inc/ws/Controlleur/class.ws.url.php | 30 ++--- inc/ws/DAO/class.ws.dao.book.php | 104 +++++++++--------- inc/ws/Metier/class.ws.book.php | 2 + .../Util/packager/class.ws.packager.html.php | 3 + inc/ws/Util/packager/class.ws.packager.php | 4 +- inc/ws/Util/packager/class.ws.packager.v1.php | 2 +- 8 files changed, 75 insertions(+), 82 deletions(-) diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 2b5a76e5b..d5e2c5a5f 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -373,6 +373,8 @@ class commonCore extends cubeCore { $db->books->numerotation('text', 0, false); $db->books->changedate('integer', 0, false); $db->books->compiledate('integer', 0, false); + $db->books->compile1date('integer', 0, false); + $db->books->compilehtml5date('integer', 0, false); $db->books->version('integer', 0, false, 2); $db->books->composition_update('integer', 0, false); $db->books->dir_references('varchar', 256, false); diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 6e5b5f5fb..7931d5934 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -679,12 +679,10 @@ class wsFlash extends cubeFlashGateway { global $core; wsSecureSWF::checkProtectedSWF(); $dao = new wsDAOBook($core->con); - if (!$dao->isUpToDate($this->args['book_id'])) { - $log = $dao->compile($this->args['book_id'], 3); - $log = str_replace('&', '&', $log); - $log = str_replace('&', '&', $log); - // $this->xml->addChild('log', $log); - } + + $log = $dao->compile($this->args['book_id'], '2'); + + $book = $dao->selectById($this->args['book_id']); $viewer = 'viewer'; if (wsDroits::admin()) { diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 63de0c21e..ab550bd2d 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -557,7 +557,7 @@ html{height:100%}' . "\n"; global $core; cubePHP::neverStop(); - + $book_id = $args[1]; $time = $args[2]; @@ -647,15 +647,7 @@ html{height:100%}' . "\n"; commonDroits::error(); } - if (!$dao->isUpToDate($book_id)) { - if (isset($version) && ($version == 'u' || $version == 't')) { - $dao->compileHTML5($book_id); - } else { - $dao->compile($book_id); - $dao->touchCompile($book_id); - } - } - + $dao->compile($book_id, 'html5'); $time = self::getHTML5CacheTime($book_id); if (count($e) == 2 || $e[2] != $time) { @@ -681,7 +673,9 @@ html{height:100%}' . "\n"; commonDroits::min(5); $args = cubePage::getArgs($args); + $e = explode('_', $args[0]); + $dao->compile($e[0], 'html5'); $time = self::getHTML5CacheTime($e[0]); if (count($e) == 2 || $e[2] != $time) { @@ -700,6 +694,7 @@ html{height:100%}' . "\n"; $args = cubePage::getArgs($args); $e = explode('_', $args[0]); + $dao->compile($e[0], 'html5'); $time = self::getHTML5CacheTime($e[0]); if (count($e) == 2 || $e[2] != $time) { @@ -724,15 +719,6 @@ html{height:100%}' . "\n"; commonDroits::error(); } - if (!$dao->isUpToDate($book_id)) { - if ($version == 'u' || $version == 't') { - $dao->compileHTML5($book_id); - } else { - $dao->compile($book_id); - $dao->touchCompile($book_id); - } - } - echo file_get_contents(WS_BOOKS . '/html5/' . $book_id . '/index' . $version . '.html'); exit; } @@ -824,10 +810,8 @@ html{height:100%}' . "\n"; commonDroits::error(); } - if (!$dao->isUpToDate($book_id)) { - $dao->compile($book_id); - $dao->touchCompile($book_id); - } + fb($version); + $dao->compile($book_id, (string)$version); $daoTheme = new wsDAOTheme($core->con); $theme = $daoTheme->selectById($book->theme, 'themes'); diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 2f8fc18ac..f8591ca8b 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -32,6 +32,8 @@ class wsDAOBook extends commonDAO { $book->numerotation = $r->numerotation; $book->changedate = $r->changedate; $book->compiledate = $r->compiledate; + $book->compile1date = $r->compile1date; + $book->compilehtml5date = $r->compilehtml5date; $book->facturable = $r->facturable; $book->facturable_id = $r->facturable_id; $book->tache = $r->tache; @@ -194,7 +196,7 @@ class wsDAOBook extends commonDAO { $c->theme = 1; $c->lang = $lang; $c->changedate = TIME; - $c->compiledate = TIME; + $c->compiledate = 0; $c->version = 2; $c->composition_update = TIME; $book_id = $c->book_id = $this->getNextId(); @@ -577,9 +579,19 @@ class wsDAOBook extends commonDAO { $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } - public function touchCompile($book_id) { + public function touchCompile($book_id, $version = 'all') { $c = $this->con->openCursor('books'); - $c->compiledate = TIME; + if ($version == '2') { + $c->compiledate = TIME; + } elseif ($version == '1') { + $c->compile1date = TIME; + } elseif ($version == 'html5') { + $c->compilehtml5date = TIME; + } else { + $c->compiledate = TIME; + $c->compile1date = TIME; + $c->compilehtml5date = TIME; + } $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } @@ -776,30 +788,59 @@ class wsDAOBook extends commonDAO { $pages = $this->getPagesOfBook($book_id); } - public function compile($book_id, $version = 3, $complete = false) { + public function compile($book_id, $version = 'all', $complete = false) { if (is_null($book_id) || !$book_id) { return; } - fb(time(), 'Start compile 3'); - $res = $this->compile3($book_id, $complete, $book); - fb(time(), 'Start compile 1'); - if ($book->parametres->version == 1) { - $this->compile1($book_id); + $v1 = $v2 = $html5 = false; + + if ($version == 'all') { + $v1 = $v2 = $html5 = true; + } else if ($version == '1') { + $v1 = true; + } else if ($version == '2') { + $v2 = true; + } elseif ($version == 'html5') { + $html5 = true; + } + + + $book = $this->selectById($book_id); + $pages = $this->getPagesOfBook($book_id); + + $v1 = $v1 && $book->compile1date < $book->changedate; + $v2 = $v2 && $book->compiledate < $book->changedate; + $html5 = $html5 && $book->compilehtml5date < $book->changedate; + + + if ($v1 || $v2) { + $this->compilePDF($book, $pages); + $this->compileWidget($book, $pages); + } + $res = ''; + if ($v1) { + $res.=$this->compile1($book_id, $book, $pages); + $this->touchCompile($book_id, '1'); + } + if ($v2) { + $res .= $this->compile3($book_id, $complete, $book, $pages); + $this->touchCompile($book_id, '2'); + } + if ($html5) { + $res.=$this->compileHTML5($book_id); + $this->touchCompile($book_id, 'html5'); } - $this->touchCompile($book_id); - fb(time(), 'End compile'); return $res; } - public function compile1($book_id) { - + public function compile1($book_id, $book, $pages) { $finalDir = WS_BOOKS . '/finalv1/' . $book_id . '/'; $packager = new wsPackagerV1($book_id, $finalDir, false); $packager->makePackage(false); } - public function compile3($book_id, $complete, &$book) { + public function compile3($book_id, $complete, $book, $pages) { $res = ''; $compilerDir = WS_BOOKS . '/datasCompiler/' . $book_id . '/'; @@ -812,19 +853,12 @@ class wsDAOBook extends commonDAO { $rm->execute(); mkdir($finalDir, 0777, true); - $book = $this->selectById($book_id); - $pages = $this->getPagesOfBook($book_id); - - fb(time(), 'prepare flex'); - $flex = new cubeFlexCompiler('FluidbookDatas', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH, 10); $flexLight = new cubeFlexCompiler('FluidbookDatasLight', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH, 10); $filesToCopy = array(); $this->compileFlex($book_id, $complete, $compilerDir, $finalDir, $filesToCopy, $book, $pages, $flex, $flexLight); - fb(time(), 'compile flex'); - $res .= $flex->compile() . "\n\n-------------------\n\n"; $flexLight->addVariable('datasSize', filesize($compilerDir . '/FluidbookDatas.swf')); $res .= $flexLight->compile(); @@ -832,16 +866,12 @@ class wsDAOBook extends commonDAO { $filesToCopy['data/fd.swf'] = $compilerDir . '/FluidbookDatas.swf'; $filesToCopy['data/fdl.swf'] = $compilerDir . '/FluidbookDatasLight.swf'; - fb(time(), 'flex compiled'); - // Copy of files // Check if dest dir exists if (!file_exists($finalDir . 'data')) { mkdir($finalDir . 'data', 0777, true); } - fb(time(), 'copy files'); - foreach ($filesToCopy as $local => $source) { $localPath = $finalDir . $local; if (!file_exists($localPath) || filemtime($localPath) < filemtime($source) || filesize($localPath) != filesize($source) || filemtime($localPath) < $book->composition_update) { @@ -851,18 +881,6 @@ class wsDAOBook extends commonDAO { copy($source, $localPath); } } - - fb(time(), 'Compile PDF'); - - $this->compilePDF($book, $pages); - if ($book->parametres->mobileVersion != 'pdf') { - fb(time(), 'Compile HTML5'); - $this->compileHTML5($book_id); - } - fb(time(), 'Compile widget'); - $this->compileWidget($book, $pages); - $this->touchCompile($book_id); - return $res; } @@ -938,12 +956,8 @@ class wsDAOBook extends commonDAO { $hash .= round($size[0], 4); $hash = sha1($hash); - fb(time(), 'texts and indexes'); - $this->makeTextsIndexes($book, $pages, $index, $textes); - fb(time(), 'texts and links'); - $daoDoc->getLinksAndRulers($book_id, $links, $rulers); $imagesassets = array(); @@ -1204,13 +1218,8 @@ class wsDAOBook extends commonDAO { $it->resize($book->parametres->widgetSize, 10000); $it->output('jpeg', $tempimage[$i], 100); } catch (Exception $e) { - fb($e->getMessage()); $tempimage[$i] = $image; } - - - - $jpg2swf = new cubeCommandLine('jpeg2swf'); $jpg2swf->setEnv('PATH', '/bin:/usr/bin:/usr/local/bin'); $jpg2swf->setArg('q', $book->parametres->widgetQuality); @@ -1218,8 +1227,6 @@ class wsDAOBook extends commonDAO { $jpg2swf->setArg(null, $tempimage[$i]); $jpg2swf->execute(); - fb($jpg2swf); - $swfcombine->setArg(null, $tempswf[$i]); } $swfcombine->execute(); @@ -1267,7 +1274,6 @@ class wsDAOBook extends commonDAO { $pdfName = $book->parametres->pdfName; } - $finalPDF = WS_BOOKS . '/final/' . $book->book_id . '/data/' . $pdfName; if (!$book->parametres->pdf && $book->parametres->mobileVersion != 'pdf') { diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index bf14ca7c6..110eb45a1 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -28,6 +28,8 @@ class wsBook extends cubeMetier { protected $specialRulers; protected $changedate; protected $compiledate; + protected $compile1date; + protected $compilehtml5date; protected $composition_update; protected $version; protected $dir_references; diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 17e1abac4..24760edb4 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -171,6 +171,9 @@ class wsPackagerHTML extends wsPackager { if (!$this->whole) { return; } + + $this->daoBook->compile($this->book_id, 'html5'); + $dest = $this->vdir . 'm'; mkdir($dest, 0777, true); diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index 21ade5981..96903bff1 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -63,9 +63,7 @@ class wsPackager { } protected function compile() { - if (!$this->daoBook->isUpToDate($this->book_id)) { - $this->daoBook->compile($this->book_id); - } + $this->daoBook->compile($this->book_id, '2'); } protected function preparePackage() { diff --git a/inc/ws/Util/packager/class.ws.packager.v1.php b/inc/ws/Util/packager/class.ws.packager.v1.php index a0a98a95e..c3788bf06 100644 --- a/inc/ws/Util/packager/class.ws.packager.v1.php +++ b/inc/ws/Util/packager/class.ws.packager.v1.php @@ -24,7 +24,7 @@ class wsPackagerV1 extends wsPackagerHTML { } protected function compile() { - + } protected function copyFluidbookFiles() { -- 2.39.5