From: vincent@cubedesigners.com Date: Tue, 23 Feb 2010 16:34:27 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a55b1bfb3eda2cda74c82591f43f3d661bab09fa;p=cubeextranet.git --- 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 a68c7eb6e..217b4a784 100644 Binary files a/swf/_src/wsComposer.fla and b/swf/_src/wsComposer.fla differ