From: vincent@cubedesigners.com Date: Tue, 14 Dec 2010 10:51:33 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9c093cd168e9437c3438b91e589b23705150ce4f;p=cubeextranet.git --- diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index d83c7f487..3ed63bdd5 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -30,7 +30,8 @@ class wsDocument extends cubeMetier { protected $in; protected $uncompressed; protected $log; - protected $log_pointer; + protected $common_log_pointer; + protected $pages_log_pointers; protected $infos; protected $cropped; protected $uncropped; @@ -54,17 +55,19 @@ class wsDocument extends cubeMetier { public function init() { - $this->out = WS_DOCS. '/' . $this->document_id . '/'; - $this->log = $this->out . 'log.txt'; + $this->out = WS_DOCS . '/' . $this->document_id . '/'; + $this->log = $this->out . '/logs/'; $this->in = $this->out . 'original.pdf'; $this->uncompressed = $this->out . 'uncompressed.pdf'; $this->infos = $this->out . 'infos.txt'; if (!file_exists($this->out)) { mkdir($this->out, 0755, true); + mkdir($this->out . '/logs/'); } $this->cropped = $this->out . 'crop.pdf'; $this->uncropped = $this->out . 'uncrop.pdf'; - $this->log_pointer = fopen($this->log, 'a'); + $this->common_log_pointer = fopen($this->log . '/commons.log', 'a'); + $this->pages_log_pointers = array(); } public function copyOriginal($tmp_file) @@ -331,7 +334,7 @@ class wsDocument extends cubeMetier { public function makeMiniShot($page) { - $this->makeShotFixedWidth($page, 'p', 100, 90, 4, 'GS'); + $this->makeShotFixedWidth($page, 'p', 200, 90, 4, 'GS'); } public function makeRealShot($page) @@ -417,7 +420,7 @@ class wsDocument extends cubeMetier { $gs->setArg(null, $in); $gs->execute(); - $this->addToLog($gs); + $this->addToLog($gs,true,$page); } protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null) @@ -444,7 +447,7 @@ class wsDocument extends cubeMetier { $pdftoppm->setArg(null, $in); $pdftoppm->setArg(null, $this->out . 'ppm'); $pdftoppm->execute(); - $this->addToLog($pdftoppm); + $this->addToLog($pdftoppm,true,$page); $startpage = is_null($page)?1:$page; @@ -461,7 +464,7 @@ class wsDocument extends cubeMetier { $pnmtojpeg->setManualArg($ppmfile); $pnmtojpeg->execute(); - $this->addToLog($pnmtojpeg, false); + $this->addToLog($pnmtojpeg, false,$i); unlink($ppmfile); } } @@ -508,7 +511,7 @@ 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); + $overflowObjects = $this->checkObjectsNumber($this->out . 'p' . $page . '.swf', $maxObjects,$page); } if (!$written || $overflow || $overflowObjects) { @@ -517,7 +520,7 @@ class wsDocument extends cubeMetier { } } - protected function checkObjectsNumber($file, $maxObjects) + protected function checkObjectsNumber($file, $maxObjects,$page) { $swfdump = new cubeCommandLine('swfdump', null, true); $swfdump->setPath(CONVERTER_PATH); @@ -667,7 +670,7 @@ disablelinks Disable links. $pdf2swf->setArg('output', $this->out . 'p%.swf'); $pdf2swf->execute(); - $this->addToLog($pdf2swf, true); + $this->addToLog($pdf2swf, true,$page); } else { $this->pdf2swfBarbare($page, $resolution, $quality, $method); } @@ -687,7 +690,7 @@ disablelinks Disable links. $swfcombine->setArg(null, ROOT . '/swf/as3Container.swf'); $swfcombine->setManualArg('content=' . $swffile); $swfcombine->execute(); - $this->addToLog($swfcombine); + $this->addToLog($swfcombine,true,$page); } protected function pdf2swfBarbare($page, $resolution = 150, $quality = 85, $method = 4) @@ -708,12 +711,12 @@ disablelinks Disable links. $jpeg2swf->execute(); $this->addToLog($jpeg2swf); // Suppression du jpeg - @unlink($this->out . '/barbare' . $page . '.jpg') ; + @unlink($this->out . '/barbare' . $page . '.jpg',true,$page) ; return ''; } - public function addToLog($cl, $output = true) + public function addToLog($cl, $output = true, $page = null) { if ($cl instanceof cubeCommandLine) { $c = '--- Exécuté en ' . $cl->execTime . " s\n" . $cl->commande . "\n\n"; @@ -724,13 +727,31 @@ disablelinks Disable links. $c = '--- ' . "\n\n"; $c .= $cl . "\n\n"; } - fwrite($this->log_pointer, $c); + + if (is_null($page)) { + $pointer = $this->common_log_pointer; + } else { + if (isset($this->pages_log_pointers[$page])) { + $pointer = $this->pages_log_pointers; + } else { + $pointer = fopen($this->log . '/p' . $page . '.log', 'a'); + $this->pages_log_pointers[$page] = $pointer; + } + } + + fwrite($pointer, $c); } public function __destruct() { - if (isset($this->log_pointer) && is_resource($this->log_pointer)) { - fclose($this->log_pointer); + if (isset($this->common_log_pointer) && is_resource($this->common_log_pointer)) { + fclose($this->common_log_pointer); + } + + foreach($this->pages_log_pointers as $p) { + if (!is_null($p) && is_resource($p)) { + fclose($p); + } } } }