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
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
}\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
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
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
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
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
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
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
$in = htmlentities($in, ENT_NOQUOTES, "UTF-8");\r
$in = str_replace(' ', '', $in);\r
\r
-\r
return $in;\r
}\r
\r