From: vincent@cubedesigners.com Date: Mon, 13 Jun 2011 15:11:03 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e1819837b044f0ebaad3f14af56dd2f59f5189af;p=cubeextranet.git --- diff --git a/inc/ws/Util/packager/class.ws.packager.html5.php b/inc/ws/Util/packager/class.ws.packager.html5.php index e07046ce3..d4c5f00f4 100644 --- a/inc/ws/Util/packager/class.ws.packager.html5.php +++ b/inc/ws/Util/packager/class.ws.packager.html5.php @@ -16,6 +16,8 @@ class wsPackagerHTML5 extends wsPackager { protected $scale; protected $multiply; protected $div = array(); + protected static $resolutions = array(36, 72, 150); + protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', ''); public function __construct($book_id) { parent::__construct($book_id); @@ -71,6 +73,7 @@ class wsPackagerHTML5 extends wsPackager { protected function writeConfig() { $res = 'DATAS=' . json_encode($this->book->parametres->toStandardObject()) . ';' . "\n"; $res.= 'THEME=' . json_encode($this->theme->parametres->toStandardObject()) . ';' . "\n"; + $res.= 'ID=' . $this->book->book_id . ';' . "\n"; return $res; } @@ -86,8 +89,8 @@ class wsPackagerHTML5 extends wsPackager { } protected function writeImages() { - $resolutions = array(36, 72, 150); - foreach ($resolutions as $r) { + + foreach (self::$resolutions as $r) { mkdir($this->vdir . '/images/' . $r, 0777); } foreach ($this->pages as $page => $infos) { @@ -171,29 +174,35 @@ class wsPackagerHTML5 extends wsPackager { return ''; } - $class = array(); + return self::escapeHTML($span['text']); + } - $span['x'] = $this->getCSSX($span['x'] * $this->multiply); + protected function writeCSS() { + $res = array(); - if (!is_null($span['x'])) { - $class[] = 'x' . $span['x']; - } + $h = $this->book->parametres->height . 'px'; + $w2 = ($this->book->parametres->width * 2) . 'px'; + $w = $this->book->parametres->width . 'px'; - if (count($class)) { - $class = ' class="' . implode(' ', $class) . '"'; - } else { - $class = ""; - } + $navTop = ($this->book->parametres->height - 40 - 100) / 2; + $res[] = '#next,#previous{top:' . $navTop . 'px}'; + $res[] = '.page,.background{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}'; + $res[] = '.doublePage,#pages{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}'; + $res[] = '.page.right{left:' . $w . '}'; - $res = ''; - $res .= self::escapeHTML($span['text']); - $res .= '

'; - return $res; - } + foreach (self::$resolutions as $r) { + $wb = ($this->book->parametres->width * $r) / 72; + $hb = ($this->book->parametres->height * $r) / 72; + $s = 72 / $r; + + $scale = ''; + if ($s != 1) { + $scale = self::writeCSSUA('transform', 'scale(' . $s . ')'); + } + + $res[] = '.background .r' . $r . '{width:' . $wb . ';height:' . $hb . ';' . $scale . '}'; + } - protected function writeCSS() { - $res = array(); - $res[] = '.page,.background{width:' . $this->book->parametres->width . 'px;height:' . $this->book->parametres->height . 'px;}'; foreach ($this->cssColor as $color => $index) { $res[] = '.c' . $index . '{color:#' . $color . '}'; } @@ -221,14 +230,12 @@ class wsPackagerHTML5 extends wsPackager { foreach ($this->cssRotation as $rotation => $index) { $rotation*= - 1; - $navigators = array('-moz-', '-webkit-', '-ms-', '-o-', ''); - $t = 'transform:rotate(' . $rotation . 'deg);'; + $to = 'transform-origin:left top;'; $css = '.r' . $index . '{'; - foreach ($navigators as $n) { - $css.=$n . $t . $n . $to; - } + $css.=self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';'; + $css.=self::writeCSSUA('transform-origin', 'left top'); $css.='}'; $res[] = $css; } @@ -241,6 +248,14 @@ class wsPackagerHTML5 extends wsPackager { return implode("\n", $res); } + protected function writeCSSUA($property, $value) { + $res = array(); + foreach (self::$uaPrefixes as $prefix) { + $res[] = $prefix . $property . ':' . $value; + } + return implode(';', $res); + } + protected function addLine($line, $document_id) { $res = array(); foreach ($line->a as $group) { @@ -282,9 +297,7 @@ class wsPackagerHTML5 extends wsPackager { if ($text == '') { return false; } - return array('text' => $text, - 'x' => $this->normalizeFloatValue($span['x']), - 'width' => $this->normalizeFloatValue($span['width'])); + return array('text' => $text); } protected function getCSSSize(&$size) { @@ -356,7 +369,7 @@ class wsPackagerHTML5 extends wsPackager { if (isset($tab[$value])) { return $tab[$value]; } - $res = $this->base36(count($tab)); + $res = $this->base62(count($tab)); $tab[$value] = $res; return $res; } @@ -368,9 +381,9 @@ class wsPackagerHTML5 extends wsPackager { return $value; } - protected function base36($val) { - $base = 36; - $chars = '0123456789abcdefghijklmnopqrstuvwxyz'; + protected function base62($val) { + $base = 62; + $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $str = ''; do { $i = $val % $base; @@ -384,7 +397,6 @@ class wsPackagerHTML5 extends wsPackager { $in = htmlentities($in, ENT_NOQUOTES, "UTF-8"); $in = str_replace(' ', '', $in); - return $in; }