From: vincent@cubedesigners.com Date: Wed, 17 Sep 2014 09:53:42 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=2c8124372e982c525e7b7252ffb2f542f9285881;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index ea80a1e61..6c7b86acc 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -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() { diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 36cb61ae6..09daf58e1 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -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';