]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 27 Aug 2011 11:54:35 +0000 (11:54 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 27 Aug 2011 11:54:35 +0000 (11:54 +0000)
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index 8deb027eed5d5ed54cc48a7413f3021aefc0779c..b9d50160f9d766796d674a6e4a9b09c4d4b131ae 100644 (file)
@@ -536,7 +536,7 @@ class wsDAOBook extends commonDAO {
                        return false;\r
                }\r
 \r
-               $checks = array($r->changedate, cubeFiles::filemtimeRecursive(WS_COMPILE_ASSETS . '/_html5'));\r
+               $checks = array($r->changedate, cubeFiles::filemtimeRecursive(WS_COMPILE_ASSETS . '/_html5'),  cubeFiles::filemtimeRecursive(ROOT.'/inc/ws/Util/html5'));\r
                $reffile = WS_BOOKS . '/html5/' . $book_id;\r
 \r
                if (!file_exists($reffile)) {\r
index f1c9835c7a7b5be688a23c3ab800c1e7a4078f06..7e4e4a82a8615cd9d2316c6c2d7d2eaee9bed9b5 100644 (file)
@@ -632,11 +632,13 @@ class wsDocument extends cubeMetier {
 \r
        public function makeHTML5Files($page) {\r
                // Then make HD background shots\r
-               $resolutions = array(36 => 80, 72 => 70, 150 => 50);\r
+               $resolutions = array(36 => 90, 72 => 80, 150 => 75);\r
                foreach ($resolutions as $r => $q) {\r
                        $texts = false;\r
                        $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, $texts);\r
                }\r
+               // Then get layout infos from swf\r
+               file_put_contents($this->out . '/html/s' . $page . '.layout', $this->dumpSWF($page));\r
        }\r
 \r
        protected function checkObjectsNumber($file, $maxObjects, $page) {\r
@@ -793,7 +795,7 @@ class wsDocument extends cubeMetier {
                        $pdf2swf->setArg('set jpegquality', $quality);\r
                        $pdf2swf->setArg('set disablelinks');\r
                        $pdf2swf->setArg('set dots');\r
-                       // $pdf2swf->setManualArg('-vvv');\r
+                       $pdf2swf->setManualArg('-vvv');\r
                        $pdf2swf->setArg(null, $this->cropped);\r
                        $pdf2swf->setArg('output', $this->out . $prefix . '%.swf');\r
                        $pdf2swf->execute();\r
index 5eac661385c34e51c139203c868dc965fcf7061a..49a8c184dbd7b65724a3ac808cf9451f8ecc54db 100644 (file)
@@ -104,7 +104,7 @@ class wsHTML5Compiler {
                $this->cssWidth = $this->width * $this->cssScale;
                $this->cssHeight = $this->height * $this->cssScale;
 
-               $this->scale = 4;
+               $this->scale = 10;
                $this->multiply = $this->pdf2htmlRatio * $this->scale * $this->cssScale;
                $this->numerotation = explode(',', $this->book->numerotation);
        }
@@ -333,8 +333,6 @@ class wsHTML5Compiler {
                                $fontforge->setArg(null, '-');
                                $fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format);
                                $fontforge->execute();
-
-                               fb($fontforge->commande);
                        }
                }
        }
@@ -453,6 +451,7 @@ class wsHTML5Compiler {
                $wm = ($this->width * $this->multiply) . 'px';
                $hm = ($this->height * $this->multiply) . 'px';
                $offsetLeft = round(($this->optimalWidth - $this->cssWidth) / 2, 2);
+               $offsetLeft2 = $offsetLeft * 2;
                $offsetTop = round(($this->optimalHeight - $this->cssHeight) / 2, 2);
 
                $navTop = ($this->cssHeight - 40 - 100) / 2;
@@ -460,6 +459,7 @@ class wsHTML5Compiler {
 
 
                $res[] = '#fluidbook{left:' . $offsetLeft . 'px;top:' . $offsetTop . 'px;}';
+               $res[] = '.landscape #fluidbook{left:' . $offsetLeft2 . 'px;}';
                $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';
                $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}';
                foreach (self::$resolutions as $r) {
@@ -515,11 +515,11 @@ class wsHTML5Compiler {
                        $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');';
                        $body.='background-position:';
 
-                       if(file_exists($this->themeRoot . '/' . $this->theme->parametres->backgroundImage)){
-                               $dim=getimagesize($this->themeRoot . '/' . $this->theme->parametres->backgroundImage);
-                               $this->additionalConfig['backgroundRatio']=$dim[0]/$dim[1];
-                       }else{
-                               $this->additionalConfig['backgroundRatio']=1;
+                       if (file_exists($this->themeRoot . '/' . $this->theme->parametres->backgroundImage)) {
+                               $dim = getimagesize($this->themeRoot . '/' . $this->theme->parametres->backgroundImage);
+                               $this->additionalConfig['backgroundRatio'] = $dim[0] / $dim[1];
+                       } else {
+                               $this->additionalConfig['backgroundRatio'] = 1;
                        }
 
                        switch ($this->theme->parametres->backgroundVAlign) {
@@ -668,6 +668,9 @@ class wsHTML5Compiler {
 
        protected function addLine($line, $document_id) {
                $res = array();
+               if (count($line->a) > 1) {
+                       $line = $this->sortLine($line);
+               }
                foreach ($line->a as $group) {
                        $res = array_merge($res, $this->addGroup($group, $document_id));
                }
@@ -677,6 +680,71 @@ class wsHTML5Compiler {
                        "groups" => $res);
        }
 
+       protected function sortLine($line) {
+               $debug = rand(1, 20) == 5;
+
+
+               // Copy the current line to a new one
+               $l = simplexml_load_string('<l />');
+               foreach ($line->attributes() as $k => $v) {
+                       $l->addAttribute($k, $v);
+               }
+
+               // Get the s elements and sort them by x
+               $tab = array();
+               $allSpans = $line->xpath("a/s");
+               foreach ($allSpans as $span) {
+                       $tab[] = $span;
+               }
+
+               usort($tab, array('wsHTML5Compiler', 'sortSpans'));
+               if ($debug) {
+                       //fb($tab);
+               }
+
+               $currentGroup = null;
+               $lastParent = null;
+               foreach ($tab as $span) {
+                       $parents = $span->xpath("..");
+                       $parent = array_pop($parents);
+                       if ($parent == $lastParent) {
+                               cubeXML::append($currentGroup, $span);
+                               continue;
+                       }
+                       if (!is_null($currentGroup)) {
+                               cubeXML::append($l, $currentGroup);
+                       }
+
+                       $lastParent = $parent;
+                       $currentGroup = simplexml_load_string('<a />');
+                       foreach ($parent->attributes() as $k => $v) {
+                               $currentGroup->addAttribute($k, $v);
+                       }
+                       cubeXML::append($currentGroup, $span);
+               }
+
+               if (!is_null($currentGroup)) {
+                       cubeXML::append($l, $currentGroup);
+               }
+
+               if ($debug) {
+                       fb($l);
+               }
+               return $l;
+       }
+
+       protected static function sortSpans($a, $b) {
+               $xa = floatval((string) $a['x']);
+               $xb = floatval((string) $b['x']);
+
+               if ($xa > $xb) {
+                       return 1;
+               } else if ($xa < $xb) {
+                       return -1;
+               }
+               return 0;
+       }
+
        protected function addGroup($group, $document_id) {
                $alpha = intval(substr($group['color'], 1, 2), 16);
                if ($alpha == 0) {