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