]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 4 Jan 2011 18:37:45 +0000 (18:37 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 4 Jan 2011 18:37:45 +0000 (18:37 +0000)
inc/ws/Controlleur/class.ws.conversion.session.php
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Metier/class.ws.document.conversioninfos.php
inc/ws/Metier/class.ws.document.php

index a62c8d7c36501d287d94e0810b9adde5030aca15..de01833668d60d00163d1373120e2e5dc58c994e 100644 (file)
@@ -2,6 +2,7 @@
 \r
 class wsConversionSession {\r
        protected $documentsId = array();\r
+       protected $documentsPages = array();\r
        protected $documents = array();\r
        protected $guid;\r
        protected $progress = 0;\r
@@ -16,6 +17,7 @@ class wsConversionSession {
        protected $processedPages = 0;\r
        protected $processedDoc = 0;\r
        protected $bookId = null;\r
+       public $reload = false;\r
 \r
        public function __construct($guid)\r
        {\r
@@ -24,7 +26,8 @@ class wsConversionSession {
 \r
        public function setDocuments($documents)\r
        {\r
-               $this->documentsId = $documents;\r
+               $this->documentsId = array_keys($documents);\r
+               $this->documentsPages = $documents;\r
        }\r
 \r
        public function setBook($book_id)\r
@@ -42,6 +45,15 @@ class wsConversionSession {
                $inited = true;\r
        }\r
 \r
+       public function getDocumentById($id)\r
+       {\r
+               foreach($this->documents as $doc) {\r
+                       if ($doc->document_id == $id) {\r
+                               return $doc;\r
+                       }\r
+               }\r
+       }\r
+\r
        public function process()\r
        {\r
                global $core;\r
@@ -66,7 +78,10 @@ class wsConversionSession {
                                $this->processedPages++;\r
                        }\r
                        $doc = $dao->updateFromObject($doc);\r
-                       $daobook->appendDocument($this->bookId, $doc->document_id);\r
+                       if (!$this->reload) {\r
+                               // On n'ajoute les fichiers à la fin du fluidbook que si l'on n'est pas en train de recharger le fluidbook\r
+                               $daobook->appendDocument($this->bookId, $doc->document_id);\r
+                       }\r
                        $this->processedDoc++;\r
                }\r
 \r
@@ -78,8 +93,13 @@ class wsConversionSession {
        public function updateCountPages()\r
        {\r
                $this->totalPages = 0;\r
-               foreach($this->documents as $doc) {\r
-                       $this->totalPages += $doc->generalInfos['pages'];\r
+               foreach($this->documentsPages as $id => $pages) {\r
+                       if ($pages == 'all') {\r
+                               $doc = $this->getDocumentById($id);\r
+                               $this->totalPages += $doc->generalInfos['pages'];\r
+                       } else {\r
+                               $this->totalPages += count($pages);\r
+                       }\r
                }\r
                $this->totalDoc = count($this->documents);\r
        }\r
index 386504b66ac98d98f280f5ea0e3ba5cfba40e59e..0253a3914b6057b3b958e4cd09f649bf36b4af94 100644 (file)
@@ -32,12 +32,44 @@ class wsFlash extends cubeFlashGateway {
                        $li->creationDate = $this->args['creationDate'];\r
                        $li->modificationDate = $this->args['modificationDate'];\r
                        $data['localInfos'] = $li;\r
-                       $data['conversionInfos'] = new wsDocumentConversionInfos($this->args['resolution'], $this->args['method'], $this->args['quality']);\r
+                       $data['conversionInfos'] = new wsDocumentConversionInfos($this->args['resolution'], $this->args['method'], $this->args['quality'], $this->args['objects']);\r
                        $document = $dao->sauve($data);\r
                        $document->copyOriginal($infos['tmp_name']);\r
+                       $this->xml->addChild('document_id', $document->document_id);\r
+                       $_SESSION['conversionSession'][$document->document_id] = 'all';\r
+               }\r
+       }\r
+\r
+       public function reload()\r
+       {\r
+               global $core;\r
+\r
+               $dao = new wsDAODocument($core->con);\r
+               $_SESSION['conversionSession'] = $this->args['documents'];\r
+               foreach($this->args['documents'] as $id => $pages) {\r
+                       $doc = $dao->selectById($id);\r
+                       $doc->conversionInfos->updatePages($pages, $this->args['resolution'], $this->args['quality'], $this->args['method'], $this->args['objects']);\r
+                       $dao->updateFromObject($doc);\r
+               }\r
+       }\r
+\r
+       public function processConversionSession()\r
+       {\r
+               $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
+               $session = new wsConversionSession($sessionConversionGUID);\r
+               $session->reload = false;\r
+               $session->setDocuments($_SESSION['conversionSession']);\r
+               $session->setBook($this->args['book_id']);\r
+               unset($_SESSION['conversionSession']);\r
+               $session->serialize();\r
+\r
+               $http = new cubeHTTP($_SERVER['HTTP_HOST']);\r
+               $http->setDataTimeout(1);\r
+               try {\r
+                       $http->post('/flash/processConversionSessionAsync', array('user_email' => $_SESSION['user_email'], 'user_password' => $_SESSION['user_password'], 'sessionConversionGUID' => $sessionConversionGUID));\r
+               }\r
+               catch(Exception $e) {\r
                }\r
-               $this->xml->addChild('document_id', $document->document_id);\r
-               $_SESSION['conversionSession'][] = $document->document_id;\r
        }\r
 \r
        public function uploadThemeFile()\r
@@ -117,24 +149,6 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       public function processConversionSession()\r
-       {\r
-               $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
-               $session = new wsConversionSession($sessionConversionGUID);\r
-               $session->setDocuments($_SESSION['conversionSession']);\r
-               $session->setBook($this->args['book_id']);\r
-               unset($_SESSION['conversionSession']);\r
-               $session->serialize();\r
-\r
-               $http = new cubeHTTP($_SERVER['HTTP_HOST']);\r
-               $http->setDataTimeout(1);\r
-               try {\r
-                       $http->post('/flash/processConversionSessionAsync', array('user_email' => $_SESSION['user_email'], 'user_password' => $_SESSION['user_password'], 'sessionConversionGUID' => $sessionConversionGUID));\r
-               }\r
-               catch(Exception $e) {\r
-               }\r
-       }\r
-\r
        public function processConversionSessionAsync()\r
        {\r
                cubePHP::neverStop();\r
index c6411edd0dc64009b34b98b0c446e92262587f5d..717a4ae19dc329e7ff4c543b81c52f70556374b0 100644 (file)
@@ -4,23 +4,53 @@ class wsDocumentConversionInfos {
        public $resolution;\r
        public $method;\r
        public $quality;\r
+       public $objects;\r
+\r
        public $pages;\r
 \r
-       public function __construct($resolution = 150, $method = 0, $quality = 85)\r
+       public function __construct($resolution = 150, $method = 0, $quality = 85, $objects = 1800)\r
        {\r
                $this->resolution = $resolution;\r
                $this->method = $method;\r
                $this->quality = $quality;\r
+               $this->objects = $objects;\r
 \r
                $this->pages = array();\r
        }\r
 \r
-       public function setPagesNumber($n)\r
+       public function setPageNumber($n)\r
        {\r
                // Set defaults\r
                for($i = 1;$i <= $n;$n++) {\r
                        if (!isset($this->pages[$i])) {\r
-                               $this->pages[$i] = new wsDocumentConversionInfos($this->resolution, $this->method, $this->quality);\r
+                               $this->pages[$i] = new wsDocumentConversionInfos($this->resolution, $this->method, $this->quality, $this->objects);\r
+                       }\r
+               }\r
+       }\r
+\r
+       public function updatePages($pages, $resolution, $quality, $method, $objects)\r
+       {\r
+               foreach($pages as $page) {\r
+                       $this->updatePage($page, $resolution, $quality, $method, $objcts);\r
+               }\r
+       }\r
+\r
+       public function updatePage($page, $resolution, $quality, $method, $objects)\r
+       {\r
+               if (!isset($this->pages[$page])) {\r
+                       $this->pages[$page] = new wsDocumentConversionInfos($resolution, $quality, $method, $objects);\r
+               } else {\r
+                       if ($resolution != 'default') {\r
+                               $this->pages[$page]->resolution = $resolution;\r
+                       }\r
+                       if ($quality != 'default') {\r
+                               $this->pages[$page]->quality = $quality;\r
+                       }\r
+                       if ($method != 'default') {\r
+                               $this->pages[$page]->method = $method;\r
+                       }\r
+                       if ($objects != 'default') {\r
+                               $this->pages[$page]->objects = $objects;\r
                        }\r
                }\r
        }\r
index 74bbb0e62f833a351c10b649b8a44f173991b47a..5d025bc6873c9e0d86123fe1e9831a8c2e59265b 100644 (file)
@@ -60,7 +60,7 @@ class wsDocument extends cubeMetier {
                $this->infos = $this->out . 'infos.txt';\r
                if (!file_exists($this->out)) {\r
                        mkdir($this->out, 0755, true);\r
-                       mkdir($this->log,0755);\r
+                       mkdir($this->log, 0755);\r
                }\r
                $this->cropped = $this->out . 'crop.pdf';\r
                $this->uncropped = $this->out . 'uncrop.pdf';\r
@@ -88,6 +88,8 @@ class wsDocument extends cubeMetier {
                $this->addToLog($fwstk);\r
                $this->parseInfos($fwstk->output);\r
 \r
+               $this->conversionInfos->setPageNumber($this->generalInfos['pages']);\r
+\r
                file_put_contents($this->infos, $fwstk->output);\r
                $this->findCutDisposition();\r
        }\r
@@ -277,8 +279,7 @@ class wsDocument extends cubeMetier {
                // $this->makeRealShot($page);\r
                if ($force || $this) {\r
                        $this->makeMiniShot($page);\r
-                       $this->makeSWFFiles($page, 150, 90, true, 1800, 1);\r
-                       // $this->makeAS3($page);\r
+                       $this->makeSWFFiles($page);\r
                }\r
        }\r
 \r
@@ -418,7 +419,7 @@ class wsDocument extends cubeMetier {
 \r
                $gs->setArg(null, $in);\r
                $gs->execute();\r
-               $this->addToLog($gs,true,$page);\r
+               $this->addToLog($gs, true, $page);\r
        }\r
 \r
        protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null)\r
@@ -445,7 +446,7 @@ class wsDocument extends cubeMetier {
                $pdftoppm->setArg(null, $in);\r
                $pdftoppm->setArg(null, $this->out . 'ppm');\r
                $pdftoppm->execute();\r
-               $this->addToLog($pdftoppm,true,$page);\r
+               $this->addToLog($pdftoppm, true, $page);\r
 \r
                $startpage = is_null($page)?1:$page;\r
 \r
@@ -462,7 +463,7 @@ class wsDocument extends cubeMetier {
                        $pnmtojpeg->setManualArg($ppmfile);\r
                        $pnmtojpeg->execute();\r
 \r
-                       $this->addToLog($pnmtojpeg, false,$i);\r
+                       $this->addToLog($pnmtojpeg, false, $i);\r
                        unlink($ppmfile);\r
                }\r
        }\r
@@ -472,8 +473,25 @@ class wsDocument extends cubeMetier {
                return $this->autocrop || $this->manualcrop || $this->autocut || $this->manualcut;\r
        }\r
 \r
-       public function makeSWFFiles($page , $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0)\r
+       public function makeSWFFiles($page, $resolution = null, $quality = null, $storeAllChars = null, $maxObjects = 1800, $method = null)\r
        {\r
+               $conversionSettings = $this->conversionInfos[$page];\r
+               if (is_null($storeAllChars)) {\r
+                       $storeAllChars = true;\r
+               }\r
+               if (is_null($resolution)) {\r
+                       $resolution = $conversionSettings->resolution;\r
+               }\r
+               if (is_null($method)) {\r
+                       $method = $conversionSettings->method;\r
+               }\r
+               if (is_null($quality)) {\r
+                       $quality = $conversionSettings->quality;\r
+               }\r
+               if (is_null($maxObjects)) {\r
+                       $maxObjects = $conversionSettings->objects;\r
+               }\r
+\r
                if ($maxObjects <= 1) {\r
                        $method = self::POLY2BITMAP;\r
                }\r
@@ -509,23 +527,23 @@ class wsDocument extends cubeMetier {
                        }\r
                        // On teste si le fichier est écrit et qu'il a été généré par le premier niveau\r
                        if ($method < self::POLY2BITMAP && $written) {\r
-                               $overflowObjects = $this->checkObjectsNumber($this->out . 'p' . $page . '.swf', $maxObjects,$page);\r
+                               $overflowObjects = $this->checkObjectsNumber($this->out . 'p' . $page . '.swf', $maxObjects, $page);\r
                        }\r
 \r
                        if (!$written || $overflow || $overflowObjects) {\r
-                               $this->makeSWFFiles($page, $resolution, $quality, $storeAllChars, $maxObjects, $method + 1);\r
+                               return $this->makeSWFFiles($page, $resolution, $quality, $storeAllChars, $maxObjects, $method + 1);\r
                        }\r
                }\r
        }\r
 \r
-       protected function checkObjectsNumber($file, $maxObjects,$page)\r
+       protected function checkObjectsNumber($file, $maxObjects, $page)\r
        {\r
                $swfdump = new cubeCommandLine('swfdump', null, true);\r
                $swfdump->setPath(CONVERTER_PATH);\r
                $swfdump->setArg('t');\r
                $swfdump->setArg(null, $file);\r
                $swfdump->execute();\r
-               $this->addToLog($swfdump,true,$page);\r
+               $this->addToLog($swfdump, true, $page);\r
 \r
                str_replace('[01a]', '', $swfdump->output, $nbObjects);\r
                if ($nbObjects > $maxObjects) {\r
@@ -668,7 +686,7 @@ disablelinks                Disable links.
                        $pdf2swf->setArg('output', $this->out . 'p%.swf');\r
                        $pdf2swf->execute();\r
 \r
-                       $this->addToLog($pdf2swf, true,$page);\r
+                       $this->addToLog($pdf2swf, true, $page);\r
                } else {\r
                        $this->pdf2swfBarbare($page, $resolution, $quality, $method);\r
                }\r
@@ -688,7 +706,7 @@ disablelinks                Disable links.
                $swfcombine->setArg(null, ROOT . '/swf/as3Container.swf');\r
                $swfcombine->setManualArg('content=' . $swffile);\r
                $swfcombine->execute();\r
-               $this->addToLog($swfcombine,true,$page);\r
+               $this->addToLog($swfcombine, true, $page);\r
        }\r
 \r
        protected function pdf2swfBarbare($page, $resolution = 150, $quality = 85, $method = 4)\r
@@ -707,9 +725,9 @@ disablelinks                Disable links.
                $jpeg2swf->setArg('f');\r
                $jpeg2swf->setArg(null, $this->out . 'barbare' . $page . '.jpg');\r
                $jpeg2swf->execute();\r
-               $this->addToLog($jpeg2swf,true,$page);\r
+               $this->addToLog($jpeg2swf, true, $page);\r
                // Suppression du jpeg\r
-               @unlink($this->out . '/barbare' . $page . '.jpg',true,$page) ;\r
+               @unlink($this->out . '/barbare' . $page . '.jpg', true, $page) ;\r
 \r
                return '';\r
        }\r