]> _ Git - cubeextranet.git/commitdiff
done #741 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 25 Nov 2016 11:06:37 +0000 (11:06 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 25 Nov 2016 11:06:37 +0000 (11:06 +0000)
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Util/class.ws.pdf.convert.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index 723bbb88216608213ebaf3ebd42f4ce43ea8c21c..557d8f9e2da4e01f0f567a6985da8febb61dda6e 100644 (file)
@@ -1313,7 +1313,7 @@ class wsDAOBook extends commonDAO {
 
                        $thumb = false;
                        if ($book->parametres->pdfThumbnails) {
-                               $thumb = $this->getThumbFromPDF($workingDir . '/' . $book->parametres->pdfThumbnails, $i);
+                               $thumb = wsPDFConvert::getThumbFromPDF($workingDir . '/' . $book->parametres->pdfThumbnails, $i);
                        }
                        if (!$thumb) {
                                $thumb = $base . '.jpg';
@@ -1483,23 +1483,7 @@ class wsDAOBook extends commonDAO {
                $flexLight->addVariable('checksum', $hash, false, true, 'String');
        }
 
-       public function getThumbFromPDF($pdf, $page) {
-               if (!file_exists($pdf)) {
-                       return false;
-               }
-               $dir = WS_CACHE . '/thumbs/' . sha1($pdf) . '/';
-               if (!file_exists($dir)) {
-                       mkdir($dir, 0777, true);
-               }
-               $jpeg = $dir . '/p' . $page . '.jpg';
-               $mtime = filemtime($jpeg);
-
-               if (!file_exists($jpeg) || $mtime < filemtime(__FILE__) || $mtime < filemtime($pdf)) {
-                       wsPDFConvert::makeMiniShot($pdf, $jpeg, $page);
-               }
 
-               return $jpeg;
-       }
 
        public static function getWorkingFile($path, $book_id, $dir = "") {
                if (substr($path, 0, 1) == '/' && file_exists($path)) {
index 49e9f5bbb672c62738994ea3addc7538b21f3dab..387c2e2b78bcb3a76d4b6f950e2649e93a90f587 100644 (file)
@@ -117,6 +117,22 @@ class wsPDFConvert {
                        unlink($tmp);\r
                }\r
        }\r
+       public static function getThumbFromPDF($pdf, $page) {\r
+               if (!file_exists($pdf)) {\r
+                       return false;\r
+               }\r
+               $dir = WS_CACHE . '/thumbs/' . sha1($pdf) . '/';\r
+               if (!file_exists($dir)) {\r
+                       mkdir($dir, 0777, true);\r
+               }\r
+               $jpeg = $dir . '/p' . $page . '.jpg';\r
+               $mtime = filemtime($jpeg);\r
 \r
+               if (!file_exists($jpeg) || $mtime < filemtime(__FILE__) || $mtime < filemtime($pdf)) {\r
+                       wsPDFConvert::makeMiniShot($pdf, $jpeg, $page);\r
+               }\r
+\r
+               return $jpeg;\r
+       }\r
 \r
 }
\ No newline at end of file
index acd65765eefc17c5737f2954b3c8db31f91d6780..535967bb0b55a1f50eabf560e2d22ecd65303b9c 100644 (file)
@@ -975,7 +975,17 @@ class wsHTML5Compiler {
                                        $this->maxRes = 150;
                                }
                        }
-                       $this->copy(wsDocument::getDir($infos['document_id']) . 'p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
+
+                       $thumb = false;
+                       if ($this->book->parametres->pdfThumbnails) {
+                               $thumb = wsPDFConvert::getThumbFromPDF(WS_BOOKS . '/working/' . $this->book->book_id . '/' . $this->book->parametres->pdfThumbnails, $page);
+                       }
+                       if (!$thumb) {
+                               $thumb = wsDocument::getDir($infos['document_id']) . 'p' . $infos['document_page'] . '.jpg';
+                       }
+
+
+                       $this->copy($thumb, $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
 
                        if ($page == 1) {
                                $this->_makeCover(wsDocument::getDir($infos['document_id']) . 'html/t36-' . $infos['document_page'] . '.jpg');