From a55b1bfb3eda2cda74c82591f43f3d661bab09fa Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 23 Feb 2010 16:34:27 +0000 Subject: [PATCH] --- inc/ws/Metier/class.ws.document.php | 116 +++++++++++----------------- swf/_src/wsComposer.fla | Bin 65536 -> 65536 bytes 2 files changed, 47 insertions(+), 69 deletions(-) diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 47211fa17..85a8055ab 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -27,10 +27,12 @@ class wsDocument extends cubeMetier { protected $log_pointer; protected $infos; protected $textes; + protected $phperrors; private $_basicInfos = null; private $_advancedInfos = null; private $_links = array(); + private $_memoErrorLog; const NORMAL = 0; const FLATTEN = 1; @@ -46,10 +48,13 @@ class wsDocument extends cubeMetier { $this->in = $this->out . 'original.pdf'; $this->infos = $this->out . 'infos.txt'; $this->textes = $this->out . 'textes.txt'; + $this->phperrors = $this->out . 'php.err'; if (!file_exists($this->out)) { mkdir($this->out, 0755, true); } $this->log_pointer = fopen($this->log, 'a'); + $this->_memoErrorLog = ini_get('error_log'); + ini_set('error_log', $this->phperrors); } public function copyOriginal($tmp_file) @@ -159,6 +164,7 @@ class wsDocument extends cubeMetier { $this->makeMiniShot($page); $this->makeRealShot($page); $this->makeSWFFiles($page); + $this->makeAS3($page); } public function processAllPages() @@ -175,37 +181,32 @@ class wsDocument extends cubeMetier { } } - public function getTexts($page = null) + public function getTexts($page) { $pdftotext = new cubeCommandLine('pdftotext', null, true); $pdftotext->setPath(CONVERTER_PATH); $pdftotext->setArg('q'); - if (is_null($page)) { - $pdftotext->setArg('f', 1); - $pdftotext->setArg('l', 10000); - } else { - $pdftotext->setArg('f', $page); - $pdftotext->setArg('l', $page); - } + $pdftotext->setArg('f', $page); + $pdftotext->setArg('l', $page); $pdftotext->setArg('-eol', 'unix'); $pdftotext->setArg('-enc', 'UTF-8'); $pdftotext->setArg(null, $this->in); - $pdftotext->setArg(null, $this->textes); + $pdftotext->setArg(null, $this->out . 'p' . $page . '.txt'); $pdftotext->execute(); $this->addToLog($pdftotext); } - public function makeMiniShot($page = null) + public function makeMiniShot($page) { $this->makeShotFixedWidth($page, 'p', 100, 70, 4, 'GS'); } - public function makeRealShot($page = null) + public function makeRealShot($page) { $this->makeShot($page, 'te', 72); } - public function makeShotFixedWidth($page = null, $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'GS') + public function makeShotFixedWidth($page , $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'GS') { // Make thumbs of $w width // resolution 72 make 1pt=1px @@ -214,7 +215,7 @@ class wsDocument extends cubeMetier { $this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method); } - public function makeShotFixedHeight($page = null, $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'GS') + public function makeShotFixedHeight($page , $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'GS') { // Make thumbs of $w height // resolution 72 make 1pt=1px @@ -223,29 +224,17 @@ class wsDocument extends cubeMetier { $this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method); } - public function makeShot($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'GS') + public function makeShot($page , $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'GS') { // Delete all old files - for($i = 1;$i <= $this->generalInfos['pages'];$i++) { - if (file_exists($this->out . $prefix . $i . '.jpg')) { - @unlink($this->out . $prefix . $i . '.jpg'); - } - } if ($method == 'GS') { $this->makeShotGS($page, $prefix, $resolution, $quality, $antialiasing); } elseif ($method == 'PNM') { $this->makeShotPNM($page, $prefix, $resolution, $quality, $antialiasing); } // Test the result by checking all files - $error = false; - $startpage = is_null($page)?1:$page; - $endpage = is_null($page)?$this->generalInfos['pages']:$page; - - for($i = $startpage;$i <= $endpage;$i++) { - if (!file_exists($this->out . $prefix . $i . '.jpg')) { - $error = true; - break; - } + if (!file_exists($this->out . $prefix . $page . '.jpg')) { + $error = true; } // If error, we try to make thumbs with other method if ($error) { @@ -257,7 +246,7 @@ class wsDocument extends cubeMetier { } } - protected function makeShotGS($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4) + protected function makeShotGS($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4) { // Fabrication des thumbanails avec ghostscript $gs = new cubeCommandLine('gs', null, true); @@ -273,10 +262,8 @@ class wsDocument extends cubeMetier { $gs->setArg('-dTextAlphaBits=' . $antialiasing); $gs->setArg('-dGraphicsAlphaBits=' . $antialiasing); // $gs->setArg('-dUseCropBox'); - if (!is_null($page)) { - $gs->setArg('-dStartPage=' . $page); - $gs->setArg('-dEndPage=' . $page); - } + $gs->setArg('-dFirstPage=' . $page); + $gs->setArg('-dLastPage=' . $page); $gs->setArg('-sOutputFile=' . $this->out . '/' . $prefix . '%d.jpg'); $gs->setArg('-dAutoRotatePages=/None'); $gs->setArg(null, $this->in); @@ -284,20 +271,16 @@ class wsDocument extends cubeMetier { $this->addToLog($gs); } - protected function makeShotPNM($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4) + protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4) { $antialiasing = $antialiasing?'yes':'no'; $resolution = round($resolution); // Exporte les fichiers $pdftoppm = new cubeCommandLine('pdftoppm', null, true); $pdftoppm->setPath(CONVERTER_PATH); - if (is_null($page)) { - $pdftoppm->setArg('f', 1); - $pdftoppm->setArg('l', 10000); - } else { - $pdftoppm->setArg('f', $page); - $pdftoppm->setArg('l', $page); - } + + $pdftoppm->setArg('f', $page); + $pdftoppm->setArg('l', $page); $pdftoppm->setArg('-freetype yes'); $pdftoppm->setArg('-aa ' . $antialiasing); @@ -331,7 +314,7 @@ class wsDocument extends cubeMetier { } } - public function makeSWFFiles($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0, &$muliply = 1) + public function makeSWFFiles($page , $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0, &$muliply = 1) { if ($maxObjects <= 1) { $method = self::POLY2BITMAP; @@ -362,7 +345,6 @@ class wsDocument extends cubeMetier { $written = true; } if ($written && $method < self::BITMAP && !isset($this->_links[$page])) { - file_put_contents(ROOT . '/test.txt', print_r($out, true)); $this->_links[$page] = $this->extractLinks($page, $out['outputfile'], $out['multiply']); } // On teste si le fichier est écrit et qu'il a été généré par le premier niveau @@ -394,7 +376,7 @@ class wsDocument extends cubeMetier { return false; } - protected function pdf2swf($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0) + protected function pdf2swf($page , $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0) { /* -h , --help Print short help message and exit @@ -468,7 +450,7 @@ splinequality= Set the quality of spline convertion to value (0-100 disablelinks Disable links. */ - if (!is_null($page) && file_exists($this->out . 'p' . $page . '.swf')) { + if (file_exists($this->out . 'p' . $page . '.swf')) { unlink($this->out . 'p' . $page . '.swf'); } @@ -477,9 +459,9 @@ disablelinks Disable links. $pdf2swf = new cubeCommandLine('pdf2swf', null, true); $pdf2swf->setPath(CONVERTER_PATH); - if (!is_null($page)) { - $pdf2swf->setArg('p', $page); - } + + $pdf2swf->setArg('p', $page); + if ($method == self::NORMAL) { // Default $multiply = 1; @@ -525,8 +507,10 @@ disablelinks Disable links. } } - protected function makeAS3($swffile) + protected function makeAS3($page) { + $swffile = $this->out . 'p' . $page . '.swf'; + $swfcombine = new cubeCommandLine('swfcombine'); $swfcombine->setPath(CONVERTER_PATH); $swfcombine->setArg('merge'); @@ -540,7 +524,7 @@ disablelinks Disable links. $this->addToLog($swfcombine); } - protected function pdf2swfBarbare($page = null, $resolution = 150, $quality = 85, $method = 4) + protected function pdf2swfBarbare($page, $resolution = 150, $quality = 85, $method = 4) { // Fabrique les images if ($method == BARBARE_PNM) { @@ -549,25 +533,17 @@ disablelinks Disable links. $this->makeShot($page, 'barbare', $resolution, $quality, 4, 'GS'); } // A partir des images, on crée les swf - if (is_null($page)) { - $startpage = 1; - $endpage = $this->generalInfos['pages']; - } else { - $startpage = $endpage = $page; - } + $jpeg2swf = new cubeCommandLine('jpeg2swf'); + $jpeg2swf->setPath(CONVERTER_PATH); + $jpeg2swf->setArg('q', $quality); + $jpeg2swf->setArg('o', $this->out . 'p' . $page . '.swf'); + $jpeg2swf->setArg('f'); + $jpeg2swf->setArg(null, $this->out . 'barbare' . $page . '.jpg'); + $jpeg2swf->execute(); + $this->addToLog($jpeg2swf); + // Suppression du jpeg + @unlink($this->out . '/barbare' . $page . '.jpg') ; - for($i = $startpage;$i <= $endpage;$i++) { - $jpeg2swf = new cubeCommandLine('jpeg2swf'); - $jpeg2swf->setPath(CONVERTER_PATH); - $jpeg2swf->setArg('q', $quality); - $jpeg2swf->setArg('o', $this->out . 'p' . $i . '.swf'); - $jpeg2swf->setArg('f'); - $jpeg2swf->setArg(null, $this->out . 'barbare' . $i . '.jpg'); - $jpeg2swf->execute(); - $this->addToLog($jpeg2swf); - // Suppression du jpeg - @unlink($this->out . '/barbare' . $i . '.jpg') ; - } return ''; } @@ -579,7 +555,8 @@ disablelinks Disable links. $c .= $cl->output . "\n\n"; } } elseif (is_string($cl)) { - $c = $cl; + $c = '--- ' . "\n\n"; + $c .= $cl . "\n\n"; } fwrite($this->log_pointer, $c); } @@ -642,6 +619,7 @@ TRACE drawlink s=http://www.ladocumentationfrancaise.fr/ if (isset($this->log_pointer) && is_resource($this->log_pointer)) { fclose($this->log_pointer); } + ini_set('error_log', $this->_memoErrorLog); } } diff --git a/swf/_src/wsComposer.fla b/swf/_src/wsComposer.fla index a68c7eb6edcdcffaee0b15139d04f04a85ea8649..217b4a78454602bf4b838a1be9e22ebeffefcca9 100644 GIT binary patch delta 1843 zcmYLJYiN^K819!QF|BEmuUQwYX>@un`R6tqd1(C4PkDhn@%X*eu#6ToghP$X74%a+y@`$oR{-n z&htF)o6E^_Ir&roxuo?P@ttmz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