]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 13 Jun 2011 15:11:03 +0000 (15:11 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 13 Jun 2011 15:11:03 +0000 (15:11 +0000)
inc/ws/Util/packager/class.ws.packager.html5.php

index e07046ce3e4ccad96b8f027c63338b5f0747218f..d4c5f00f4722af14c8471000fbe10653e8f5a14c 100644 (file)
@@ -16,6 +16,8 @@ class wsPackagerHTML5 extends wsPackager {
        protected $scale;\r
        protected $multiply;\r
        protected $div = array();\r
+       protected static $resolutions = array(36, 72, 150);\r
+       protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');\r
 \r
        public function __construct($book_id) {\r
                parent::__construct($book_id);\r
@@ -71,6 +73,7 @@ class wsPackagerHTML5 extends wsPackager {
        protected function writeConfig() {\r
                $res = 'DATAS=' . json_encode($this->book->parametres->toStandardObject()) . ';' . "\n";\r
                $res.= 'THEME=' . json_encode($this->theme->parametres->toStandardObject()) . ';' . "\n";\r
+               $res.= 'ID=' . $this->book->book_id . ';' . "\n";\r
 \r
                return $res;\r
        }\r
@@ -86,8 +89,8 @@ class wsPackagerHTML5 extends wsPackager {
        }\r
 \r
        protected function writeImages() {\r
-               $resolutions = array(36, 72, 150);\r
-               foreach ($resolutions as $r) {\r
+\r
+               foreach (self::$resolutions as $r) {\r
                        mkdir($this->vdir . '/images/' . $r, 0777);\r
                }\r
                foreach ($this->pages as $page => $infos) {\r
@@ -171,29 +174,35 @@ class wsPackagerHTML5 extends wsPackager {
                        return '';\r
                }\r
 \r
-               $class = array();\r
+               return self::escapeHTML($span['text']);\r
+       }\r
 \r
-               $span['x'] = $this->getCSSX($span['x'] * $this->multiply);\r
+       protected function writeCSS() {\r
+               $res = array();\r
 \r
-               if (!is_null($span['x'])) {\r
-                       $class[] = 'x' . $span['x'];\r
-               }\r
+               $h = $this->book->parametres->height . 'px';\r
+               $w2 = ($this->book->parametres->width * 2) . 'px';\r
+               $w = $this->book->parametres->width . 'px';\r
 \r
-               if (count($class)) {\r
-                       $class = ' class="' . implode(' ', $class) . '"';\r
-               } else {\r
-                       $class = "";\r
-               }\r
+               $navTop = ($this->book->parametres->height - 40 - 100) / 2;\r
+               $res[] = '#next,#previous{top:' . $navTop . 'px}';\r
+               $res[] = '.page,.background{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';\r
+               $res[] = '.doublePage,#pages{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}';\r
+               $res[] = '.page.right{left:' . $w . '}';\r
 \r
-               $res = '<p' . $class . '>';\r
-               $res .= self::escapeHTML($span['text']);\r
-               $res .= '</p>';\r
-               return $res;\r
-       }\r
+               foreach (self::$resolutions as $r) {\r
+                       $wb = ($this->book->parametres->width * $r) / 72;\r
+                       $hb = ($this->book->parametres->height * $r) / 72;\r
+                       $s = 72 / $r;\r
+\r
+                       $scale = '';\r
+                       if ($s != 1) {\r
+                               $scale = self::writeCSSUA('transform', 'scale(' . $s . ')');\r
+                       }\r
+\r
+                       $res[] = '.background .r' . $r . '{width:' . $wb . ';height:' . $hb . ';' . $scale . '}';\r
+               }\r
 \r
-       protected function writeCSS() {\r
-               $res = array();\r
-               $res[] = '.page,.background{width:' . $this->book->parametres->width . 'px;height:' . $this->book->parametres->height . 'px;}';\r
                foreach ($this->cssColor as $color => $index) {\r
                        $res[] = '.c' . $index . '{color:#' . $color . '}';\r
                }\r
@@ -221,14 +230,12 @@ class wsPackagerHTML5 extends wsPackager {
                foreach ($this->cssRotation as $rotation => $index) {\r
                        $rotation*= - 1;\r
 \r
-                       $navigators = array('-moz-', '-webkit-', '-ms-', '-o-', '');\r
-                       $t = 'transform:rotate(' . $rotation . 'deg);';\r
+\r
                        $to = 'transform-origin:left top;';\r
 \r
                        $css = '.r' . $index . '{';\r
-                       foreach ($navigators as $n) {\r
-                               $css.=$n . $t . $n . $to;\r
-                       }\r
+                       $css.=self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';';\r
+                       $css.=self::writeCSSUA('transform-origin', 'left top');\r
                        $css.='}';\r
                        $res[] = $css;\r
                }\r
@@ -241,6 +248,14 @@ class wsPackagerHTML5 extends wsPackager {
                return implode("\n", $res);\r
        }\r
 \r
+       protected function writeCSSUA($property, $value) {\r
+               $res = array();\r
+               foreach (self::$uaPrefixes as $prefix) {\r
+                       $res[] = $prefix . $property . ':' . $value;\r
+               }\r
+               return implode(';', $res);\r
+       }\r
+\r
        protected function addLine($line, $document_id) {\r
                $res = array();\r
                foreach ($line->a as $group) {\r
@@ -282,9 +297,7 @@ class wsPackagerHTML5 extends wsPackager {
                if ($text == '') {\r
                        return false;\r
                }\r
-               return array('text' => $text,\r
-                       'x' => $this->normalizeFloatValue($span['x']),\r
-                       'width' => $this->normalizeFloatValue($span['width']));\r
+               return array('text' => $text);\r
        }\r
 \r
        protected function getCSSSize(&$size) {\r
@@ -356,7 +369,7 @@ class wsPackagerHTML5 extends wsPackager {
                if (isset($tab[$value])) {\r
                        return $tab[$value];\r
                }\r
-               $res = $this->base36(count($tab));\r
+               $res = $this->base62(count($tab));\r
                $tab[$value] = $res;\r
                return $res;\r
        }\r
@@ -368,9 +381,9 @@ class wsPackagerHTML5 extends wsPackager {
                return $value;\r
        }\r
 \r
-       protected function base36($val) {\r
-               $base = 36;\r
-               $chars = '0123456789abcdefghijklmnopqrstuvwxyz';\r
+       protected function base62($val) {\r
+               $base = 62;\r
+               $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\r
                $str = '';\r
                do {\r
                        $i = $val % $base;\r
@@ -384,7 +397,6 @@ class wsPackagerHTML5 extends wsPackager {
                $in = htmlentities($in, ENT_NOQUOTES, "UTF-8");\r
                $in = str_replace('&thinsp;', '', $in);\r
 \r
-\r
                return $in;\r
        }\r
 \r