From: vincent@cubedesigners.com Date: Fri, 25 Nov 2016 11:06:37 +0000 (+0000) Subject: done #741 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=5b05d17f6b8ff3c9c59ed06c5df7436cbed6bce2;p=cubeextranet.git done #741 @1 --- diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 723bbb882..557d8f9e2 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -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)) { diff --git a/inc/ws/Util/class.ws.pdf.convert.php b/inc/ws/Util/class.ws.pdf.convert.php index 49e9f5bbb..387c2e2b7 100644 --- a/inc/ws/Util/class.ws.pdf.convert.php +++ b/inc/ws/Util/class.ws.pdf.convert.php @@ -117,6 +117,22 @@ class wsPDFConvert { unlink($tmp); } } + public static 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; + } } \ No newline at end of file diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index acd65765e..535967bb0 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -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');