]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Feb 2010 16:34:27 +0000 (16:34 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Feb 2010 16:34:27 +0000 (16:34 +0000)
inc/ws/Metier/class.ws.document.php
swf/_src/wsComposer.fla

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