]> _ Git - cubeextranet.git/commitdiff
Gain extraordinaire de 4 minutes sur un fluidbook de 500 pages | Fix #1475 @0:40
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 14 Jun 2017 15:55:09 +0000 (15:55 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 14 Jun 2017 15:55:09 +0000 (15:55 +0000)
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index 5b5312d3d242e5b96125bc153da61291f14fbd1f..942a855d0677fbe291c91576145d0a35af9c418c 100644 (file)
@@ -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) {
index 0533bf4f5c8c79d64aba7a85ac99934147d0dcf4..e8056088812b9c64268a7361bb635af4d497edb1 100644 (file)
@@ -830,6 +830,8 @@ class wsHTML5Compiler {
                                $this->hiddenContents[] = $c;
                        }
                        $i++;
+
+                       $this->log('Link ' . $link->type . ' written');
                }
 
                $allpages = range(0, $this->book->parametres->pages + 1);
index 15a8bdf56beea74e67607361135465e36c24ccee..f251fb3d8814c88e88550b8cc1c274a049b7041f 100644 (file)
@@ -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');
        }