]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 21 Mar 2012 16:46:51 +0000 (16:46 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 21 Mar 2012 16:46:51 +0000 (16:46 +0000)
inc/config.inc.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index ad7916d0b7bfc921655613be1d50a6cba1c404af..f953cc4533dbb85338d4a6312c850371be57083c 100644 (file)
@@ -10,7 +10,7 @@ define('SITE_PATH', WEBROOT . '/');
 define('FONT_PATH', ROOT . '/fluidbook/fonts/');\r
 define('FTPROOT', '/home/extranet/ftp/');\r
 define('WINDOWS', false);\r
-define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/www/fluidbook/tools:/usr/local/flex:/usr/local/secureSWF');\r
+define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/www/fluidbook/tools:/usr/local/flex:/usr/local/secureSWF:/usr/local/scour');\r
 define('MXMLC_PATH', '/usr/local/flex/bin/mxmlc');\r
 define('MXMLC_PATH_3', '/usr/local/flex_sdk_3.6/bin/mxmlc');\r
 define('AS3_SOURCES', '/home/ws/sources/as3');\r
index 3705613fc119a019bc42352f87b3d0a011522159..376aacb20f77ff4229537099664d2b159ed6ddfc 100644 (file)
@@ -548,7 +548,7 @@ class wsDocument extends cubeMetier {
 \r
        public function makeSVGFile($page) {\r
                $svgFile = $this->out . '/html/p' . $page . '.svg';\r
-               $svgzFile = $this->out . '/html/p' . $page . '.svgz';\r
+               $svgOpt = $this->out . '/html/o' . $page . '.svg';\r
 \r
                $pdf2svg = new cubeCommandLine('pdf2svg');\r
                $pdf2svg->setPath(CONVERTER_PATH);\r
@@ -559,7 +559,7 @@ class wsDocument extends cubeMetier {
                $this->addToLog($pdf2svg, true, $page);\r
 \r
                $svg = new DOMDocument();\r
-               $svg->preserveWhiteSpace=false;\r
+               $svg->preserveWhiteSpace = false;\r
                $svg->load($svgFile);\r
 \r
                // Operations to delete \r
@@ -572,7 +572,8 @@ class wsDocument extends cubeMetier {
                        '//svg:defs/svg:image',\r
                        '//svg:defs/svg:pattern',\r
                        '/svg:svg/svg:g/svg:g[not(svg:use[@xlink:href])]',\r
-                       '/svg:svg/svg:g/svg:path'\r
+                       '/svg:svg/svg:g/svg:path',\r
+                       '/svg:svg/svg:g/rect:path',\r
                );\r
 \r
                global $svglog;\r
@@ -592,6 +593,16 @@ class wsDocument extends cubeMetier {
 \r
                $this->addToLog(implode("\n", $svglog), false, $page);\r
                file_put_contents($svgFile, $svg->saveXML());\r
+\r
+               $scour = new cubeCommandLine('scour.py');\r
+               $scour->setArg('shorten-ids');\r
+               $scour->setArg('set-precision', '3');\r
+               $scour->setArg('indent', 'none');\r
+               $scour->setArg('create-groups');\r
+               $scour->setArg('i', $svgFile);\r
+               $scour->setArg('o', $svgOpt);\r
+               $scour->setNohup(true);\r
+               $scour->execute();\r
        }\r
 \r
        protected function checkObjectsNumber($file, $maxObjects, $page) {\r
index 755ad37ad2ecfb1348d520cb43fad7e4c0c82003..a0741877ccb3e03cb759b72f45cb982189791c92 100644 (file)
@@ -58,7 +58,7 @@ class wsHTML5Compiler {
        protected $cssOneWidth;
        protected $cssOneHeight;
        protected $cssScale;
-       protected $cssSVGScale = 0.75;
+       protected $cssSVGScale;
        protected $optimalWidth = 567;
        protected $optimalHeight = 709;
        protected $additionalConfig = array();
@@ -102,12 +102,12 @@ class wsHTML5Compiler {
                $firstDoc = $daoDoc->selectById($this->pages[1]['document_id']);
                $size = $firstDoc->generalInfos['size'];
 
-               $this->width = round($size[0], 2);
-               $this->height = round($size[1], 2);
+               $this->width = round($size[0], 3);
+               $this->height = round($size[1], 3);
 
 
                $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h150-' . $this->pages[1]['document_page'] . '.jpg');
-               $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 2);
+               $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 3);
 
                $this->cssScale = min($this->optimalWidth / $this->width, $this->optimalHeight / $this->height);
                $this->cssOneScale = min(($this->optimalWidth * 2) / $this->width, $this->optimalHeight / $this->height);
@@ -117,6 +117,8 @@ class wsHTML5Compiler {
 
                $this->cssOneWidth = $this->width * $this->cssOneScale;
                $this->cssOneHeight = $this->height * $this->cssOneScale;
+               
+               $this->cssSVGScale=0.75/2;
 
                $this->scale = 1;
                if ($this->book->parametres->zoomMode == 1) {
@@ -454,13 +456,21 @@ class wsHTML5Compiler {
                foreach (self::$resolutions as $r) {
                        mkdir($this->vdir . '/data/background/' . $r, 0777, true);
                }
-               $srcPrefix=$this->backgroundsPrefix;
+               $srcPrefix = $this->backgroundsPrefix;
                if ($this->backgroundsPrefix == 'p') {
                        $srcPrefix = 'h';
                }
                foreach ($this->pages as $page => $infos) {
                        if ($this->svg) {
-                               $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.svg', $this->vdir . '/data/contents/p' . $page . '.svg');
+                               $orig = WS_DOCS . '/' . $infos['document_id'] . '/html/p' . $infos['document_page'] . '.svg';
+                               $opt = WS_DOCS . '/' . $infos['document_id'] . '/html/o' . $infos['document_page'] . '.svg';
+
+                               $svg = $orig;
+                               if (file_exists($opt) && filesize($opt) > 0) {
+                                       $svg = $opt;
+                               }
+
+                               $this->copy($svg, $this->vdir . '/data/contents/p' . $page . '.svg');
                        }
                        foreach (self::$resolutions as $r) {
                                $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg');
@@ -496,9 +506,9 @@ class wsHTML5Compiler {
                $wm = ($this->width * $this->multiply) . 'px';
                $hm = ($this->height * $this->multiply) . 'px';
                $w = $cssWidth . 'px';
-               $offsetLeft = round(($this->optimalWidth - $cssWidth) / 2, 2);
+               $offsetLeft = round(($this->optimalWidth - $cssWidth) / 2, 3);
                $offsetLeft2 = $offsetLeft * 2;
-               $offsetTop = round(($this->optimalHeight - $cssHeight) / 2, 2);
+               $offsetTop = round(($this->optimalHeight - $cssHeight) / 2, 3);
                $navTop = ($cssHeight - 40 - 100) / 2;
 
                $res[] = '#fluidbook{left:' . $offsetLeft . 'px;top:' . $offsetTop . 'px;}';
@@ -517,7 +527,7 @@ class wsHTML5Compiler {
 
                $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}';
                foreach (self::$resolutions as $r) {
-                       $ratio = round(72 / $r, 2) * $cssScale;
+                       $ratio = round(72 / $r, 3) * $cssScale;
 
                        $wr = $cssWidth / $ratio;
                        $hr = $cssHeight / $ratio;
@@ -530,9 +540,9 @@ class wsHTML5Compiler {
                        $res[] = $br;
                }
                $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';';
-               $texts.=$this->writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 2) . ')') . ';';
-               $texts.='width:' . ($wm/$this->cssSVGScale) . '; max-width:' . ($wm/$this->cssSVGScale). ';';
-               $texts.='height:' . ($hm/$this->cssSVGScale) . '; max-height:' . ($hm/$this->cssSVGScale) . ';';
+               $texts.=$this->writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';';
+               $texts.='width:' . ($wm / $this->cssSVGScale) . '; max-width:' . ($wm / $this->cssSVGScale) . ';';
+               $texts.='height:' . ($hm / $this->cssSVGScale) . '; max-height:' . ($hm / $this->cssSVGScale) . ';';
                $texts.='}';
                $res[] = $texts;