From: vincent@cubedesigners.com Date: Wed, 14 Jun 2017 15:55:09 +0000 (+0000) Subject: Gain extraordinaire de 4 minutes sur un fluidbook de 500 pages | Fix #1475 @0:40 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=60e6dea368053e4dbec7920cb484d0f9a42289d4;p=cubeextranet.git Gain extraordinaire de 4 minutes sur un fluidbook de 500 pages | Fix #1475 @0:40 --- diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 5b5312d3d..942a855d0 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -2,6 +2,8 @@ class wsDAOBook extends commonDAO { + public static $pagesOfBookCache = array(); + /** * wsDAOBook::singleton() * @@ -208,6 +210,10 @@ class wsDAOBook extends commonDAO { $c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\''); } + if (isset(self::$pagesOfBookCache[$book_id])) { + unset(self::$pagesOfBookCache[$book_id]); + } + return $this->selectById($book_id); } @@ -346,40 +352,46 @@ class wsDAOBook extends commonDAO { } public function getPagesOfBook($book_id, $conversion = true) { - $pages = array(); + if (!isset(self::$pagesOfBookCache[$book_id])) { - $sql = 'SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page'; - $r = $this->con->select($sql); - while ($r->fetch()) { - $n = explode(',', $r->num); + $pages = array(); - if (isset($n[$r->document_page - 1])) { - $num = $n[$r->document_page - 1]; - } else { - $num = ''; - } - $pages[$r->book_page] = array('document_id' => $r->document_id, - 'document_page' => $r->document_page, - 'version' => $r->version, - 'defaultNum' => $num, - 'nb_pages' => $r->doc_pages - ); - - if ($conversion) { - if ($r->conversion != '') { - $c = unserialize($r->conversion); - $c = $c->pages[$r->document_page]; + $sql = 'SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page'; + + $r = $this->con->select($sql); + while ($r->fetch()) { + $n = explode(',', $r->num); + + if (isset($n[$r->document_page - 1])) { + $num = $n[$r->document_page - 1]; + } else { + $num = ''; } - $qp = array('resolution', 'method', 'quality', 'objects'); - foreach ($qp as $p) { - if (isset($c) && isset($c->$p)) { - $pages[$r->book_page][$p] = $c->$p; + $pages[$r->book_page] = array('document_id' => $r->document_id, + 'document_page' => $r->document_page, + 'version' => $r->version, + 'defaultNum' => $num, + 'nb_pages' => $r->doc_pages + ); + + if ($conversion) { + if ($r->conversion != '') { + $c = unserialize($r->conversion); + $c = $c->pages[$r->document_page]; + } + $qp = array('resolution', 'method', 'quality', 'objects'); + foreach ($qp as $p) { + if (isset($c) && isset($c->$p)) { + $pages[$r->book_page][$p] = $c->$p; + } } } } + + self::$pagesOfBookCache[$book_id] = $pages; } - return $pages; + return self::$pagesOfBookCache[$book_id]; } public function appendDocument($book_id, $document_id) { diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 0533bf4f5..e80560888 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -830,6 +830,8 @@ class wsHTML5Compiler { $this->hiddenContents[] = $c; } $i++; + + $this->log('Link ' . $link->type . ' written'); } $allpages = range(0, $this->book->parametres->pages + 1); diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index 15a8bdf56..f251fb3d8 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -993,16 +993,16 @@ class webVideoPopupLink extends videoPopupLink { public function getURL() { - switch($this->video_service) { - case 1: // Dailymotion - return '#/webvideo/dailymotion/' . $this->to; - break; - case 2: // Vimeo - return '#/webvideo/vimeo/' . $this->to; - break; - default: - return '#/video/' . $this->to; - } + switch ($this->video_service) { + case 1: // Dailymotion + return '#/webvideo/dailymotion/' . $this->to; + break; + case 2: // Vimeo + return '#/webvideo/vimeo/' . $this->to; + break; + default: + return '#/video/' . $this->to; + } } public function getAdditionnalContent() { @@ -1228,16 +1228,21 @@ class zoomLink extends normalLink { } public function generateImage() { + $this->compiler->log('Before generating image'); + $left = CubeIT_Files::tempnam(); $p = wsDAOBook::getDocumentPage($this->compiler->book_id, $this->page); + $this->compiler->log('Got document page'); $pdfpath = wsDocument::getDir($p['document_id']) . 'original.pdf'; - + $this->compiler->log('Got pdf original'); $leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath, $p['document_page'], array('x' => $this->left, 'y' => $this->top, 'width' => $this->width, 'height' => $this->height), $left, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/'); + $this->compiler->log('Left file generated'); + $bookwidth = $this->compiler->book->parametres->width; if (($this->left + $this->width) > $bookwidth) { @@ -1250,13 +1255,18 @@ class zoomLink extends normalLink { array('x' => 0, 'y' => $this->top, 'width' => $diff, 'height' => $this->height), $right, array(), WS_CACHE . '/zoomarea/' . $this->compiler->book_id . '/'); + $this->compiler->log('Left file generated'); + $both = CubeIT_Files::tempnam() . '.jpg'; CubeIT_CommandLine_Imagemagick::append(array($leftfile, $rightfile), $both, 'horizontal'); + + $this->compiler->log('Both files assembled'); } else { $both = $leftfile; } $this->compiler->simpleCopyLinkFile($both, 'data/links/zoom_' . $this->id . '.jpg'); + $this->compiler->log('Files copied'); // Perform tidy up and delete temporary files if they exist $files_to_delete = ['left', 'leftfile', 'right', 'rightfile', 'both']; @@ -1265,6 +1275,7 @@ class zoomLink extends normalLink { unlink($$file); } } + $this->compiler->log('Files cleaned up'); }