]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 17 Sep 2014 09:53:42 +0000 (09:53 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 17 Sep 2014 09:53:42 +0000 (09:53 +0000)
inc/ws/Controlleur/class.ws.services.php
inc/ws/DAO/class.ws.dao.book.php

index ea80a1e61790c37a80d4350a3670adafd00ceab1..6c7b86acc236817bb3d304ddc939e0602d7f96ea 100644 (file)
@@ -56,6 +56,10 @@ class wsServices extends cubeFlashGateway {
                        return;
                }
 
+               global $core;
+               $dao = new wsDAOBook($core->con);
+               $book = $dao->selectById($this->args['id']);
+
                $bookmarks = json_decode(base64_decode($this->args['bookmarks']), true);
                $files = array();
                foreach ($bookmarks as $b) {
@@ -312,8 +316,9 @@ class wsServices extends cubeFlashGateway {
                }
                // Paths init
                $baseDocument = $this->getPDFComplexBaseDocument($book);
-               fb($baseDocument);
+               fb($baseDocument, '!!');
                if (!file_exists($baseDocument)) {
+                       fb('not exists');
                        return;
                }
                $destDir = WS_CACHE . '/exportpdf/' . $book->cid;
@@ -321,11 +326,14 @@ class wsServices extends cubeFlashGateway {
                        mkdir($destDir, 0777, true);
                }
                $fname = md5(implode(',%ù', $range)) . '.pdf';
+               fb($fname);
                $destFile = $destDir . '/' . $fname;
                $destURL = '/fluidbook/cache/exportpdf/' . $book->cid . '/' . $fname;
+               fb($destFile);
+
                // If result exists, don't make the pdf again
                if (file_exists($destFile) && filemtime($destFile) > filemtime($baseDocument)) {
-
+                       fb('already exists');
                } else {
                        // Prepare the command line
                        $l = array('A="' . $baseDocument . '"', 'cat');
@@ -344,19 +352,31 @@ class wsServices extends cubeFlashGateway {
                        $pdftk->setPath(CONVERTER_PATH);
                        $pdftk->setManualArg($args);
                        $pdftk->execute();
+                       fb($pdftk->commande);
+                       fb($pdftk->output);
                }
 
                return array('url' => $destURL, 'file' => $destFile);
        }
 
        public function getPDFComplexBaseDocument($book) {
+               global $core;
                $normal = WS_BOOKS . '/pdf/' . $book->book_id . '/original.pdf';
+               if (!file_exists($normal)) {
+                       $daoBook = new wsDAOBook($core->con);
+                       $pages = $daoBook->getPagesOfBook($book->book_id);
+                       $daoBook->compilePDF($book, $pages);
+               }
 
                if ($book->parametres->pdfReplace != '' && file_exists($normal)) {
                        $this->xml->addChild('normal', $normal);
                        return $normal;
                }
-               return WS_BOOKS . '/final/' . $book->book_id . '/data/' . $book->parametres->pdfName;
+               $res = WS_BOOKS . '/final/' . $book->book_id . '/data/' . $book->parametres->pdfName;
+               if (!file_exists($res)) {
+                       return $normal;
+               }
+               return $normal;
        }
 
        public function e() {
index 36cb61ae62549ec1f368b4a62f2ec728b12cbda7..09daf58e137dba5caad02b14f7bb6656d9f86c53 100644 (file)
@@ -1520,7 +1520,7 @@ class wsDAOBook extends commonDAO {
 
                $cacheDir = WS_BOOKS . '/pdf/' . $book->book_id;
                if (!file_exists($cacheDir)) {
-                       mkdir($cacheDir);
+                       mkdir($cacheDir, 0777, true);
                }
 
                $normalPDF = $cacheDir . '/normal.pdf';