From: vincent@cubedesigners.com Date: Wed, 11 Jul 2012 12:24:30 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=437115d168bfbc73b287b874a7d22b934e57a49a;p=cubeextranet.git --- diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index d02170c33..99681573b 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1264,7 +1264,7 @@ class wsDAOBook extends commonDAO { } public function compileHTML5($book_id,$book) { - $htmlCompiler = new wsHTML5Compiler($book_id,$book->parametres->mobileLVersion); + $htmlCompiler = wsHTML5Compiler::factory($book_id,$book->parametres->mobileLVersion); $htmlCompiler->compile(); } diff --git a/inc/ws/Util/_common.php b/inc/ws/Util/_common.php index 45a1b6dd8..eb6cca453 100644 --- a/inc/ws/Util/_common.php +++ b/inc/ws/Util/_common.php @@ -10,6 +10,7 @@ $__autoload['wsSWF2HTMLMatrix'] = dirname(__FILE__) . '/class.ws.swf2html.php'; $__autoload['wsSecureSWF'] = dirname(__FILE__) . '/class.ws.secure.swf.php'; $__autoload['wsTools'] = dirname(__FILE__) . '/class.ws.tools.php'; $__autoload['wsHTML5Compiler'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php'; +$__autoload['wsHTML5CompilerDev'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php'; $__autoload['wsHTML5Link'] = dirname(__FILE__) . '/html5/class.ws.html5.links.php'; $__autoload['wsPDFFontExtractor'] = dirname(__FILE__) . '/fontextractor/class.ws.pdf.fontextractor.php'; $__autoload['wsPDFFont'] = dirname(__FILE__) . '/fontextractor/class.ws.pdf.font.php'; diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 948a4f786..76d27677f 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -2,6 +2,14 @@ class wsHTML5Compiler { + public static function factory($book_id, $version = 'stable') { + if ($version == 'stable') { + return new wsHTML5Compiler($book_id, $version); + } else { + return new wsHTML5CompilerDev($book_id, $version); + } + } + protected static $resolutions = array(150, 36); protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', ''); protected static $jsFiles = array( @@ -294,7 +302,7 @@ class wsHTML5Compiler { protected function writeIndex($numCSS) { global $core; - + $html = file_get_contents($this->assets . '/_index.html'); $uhtml = $html; @@ -504,7 +512,7 @@ class wsHTML5Compiler { $this->config->height = $this->cssHeight; $this->config->optimalWidth = $this->optimalWidth; $this->config->optimalHeight = $this->optimalHeight; - $this->config->chapters=$this->book->chapters; + $this->config->chapters = $this->book->chapters; foreach ($this->additionalConfig as $k => $v) { $this->config->$k = $v; } @@ -857,4 +865,184 @@ class wsHTML5Compiler { } +class wsHTML5CompilerDev extends wsHTML5Compiler { + + protected function writeCSS($file, $links) { + $res = array(); + + // General theme + $cssWidth = $this->cssWidth; + $cssHeight = $this->cssHeight; + $cssScale = $this->cssScale; + $w2 = ($cssWidth * 2) . 'px'; + + + $h = $cssHeight . 'px'; + + $wm = ($this->width * $this->multiply) . 'px'; + $hm = ($this->height * $this->multiply) . 'px'; + $w = $cssWidth . 'px'; + $offsetLeft = round(($this->optimalWidth - $cssWidth) / 2, 3); + $offsetLeft2 = $offsetLeft * 2; + $offsetTop = round(($this->optimalHeight - $cssHeight) / 2, 3); + $navTop = ($cssHeight - 40 - 100) / 2; + + + $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links,.doublePage._3d{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}'; + $res[] = '.doublePage,#pages,.landscape #shadow.double{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}'; + $res[] = '.landscape .doublePage._2d.next{' . $this->writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}'; + $res[] = '.landscape .doublePage._2d.prev{' . $this->writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}'; + $res[] = '.portrait .doublePage._2d.next{' . $this->writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}'; + $res[] = '.portrait .doublePage._2d.prev{' . $this->writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}'; + $res[] = '.doublePage._3d{left:' . $w . ';}'; + $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}'; + $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}'; + $res[] = '.landscape .page.right{left:' . $w . '}'; + if ($this->theme->parametres->displayPageNumber) { + $res[] = '#pagesnumbers{top:' . $h . ';color:' . self::colorToCSS($this->theme->parametres->colorPageNumber) . '}'; + $res[] = '#pagesnumbers div{width:' . $w . '}'; + } else { + $res[] = '#pagesnumbers{display:none;}'; + } + + + $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}'; + foreach (self::$resolutions as $r) { + $ratio = round(72 / $r, 3) * $cssScale; + + $wr = $cssWidth / $ratio; + $hr = $cssHeight / $ratio; + + $br = '.background.r' . $r . '{'; + if ($ratio != 1) { + $br.=$this->writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; + } + $br.='width:' . $wr . 'px;height:' . $hr . 'px;}'; + $res[] = $br; + } + $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';'; + $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; + + // Theme + // Background + $body = '#main{'; + $body.='background-color:#' . $this->theme->parametres->backgroundColor . ';'; + switch ($this->theme->parametres->repeat) { + case wsTheme::REPEAT: + $body.='background-repeat:repeat;'; + break; + case wsTheme::NONE: + $body.='background-repeat:no-repeat;'; + break; + case wsTheme::RATIO: + $body.='background-repeat:no-repeat;'; + $body.='background-size:cover;'; + break; + case wsTheme::STRETCH: + $body.='background-repeat:no-repeat;'; + $body.='background-size:100% 100%;'; + break; + } + if ($this->theme->parametres->backgroundImage != '') { + copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); + $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; + $body.='background-position:'; + + switch ($this->theme->parametres->backgroundVAlign) { + case wsTheme::TOP: + $body.='top'; + break; + case wsTheme::MIDDLE: + $body.='center'; + break; + case wsTheme::BOTTOM: + $body.='bottom'; + break; + } + $body.=' '; + switch ($this->theme->parametres->backgroundHAlign) { + case wsTheme::LEFT: + $body.='left'; + break; + case wsTheme::CENTER: + $body.='center'; + break; + case wsTheme::RIGHT: + $body.='right'; + break; + } + $body.=';'; + } + + $body.='}'; + $res[] = $body; + + // Header + $header = '#header{'; + $header.='height:' . $this->theme->parametres->menuHeight . 'px;'; + $header.='background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; + if ($this->theme->parametres->menuImage != '') { + copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); + $header.='background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; + $header.='background-repeat:no-repeat;'; + $header.='background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; + } + $header.='}'; + $res[] = $header; + + //Icons + $res = array_merge($res, $this->writeIcons()); + + // Logo + $logo = '#logo{'; + if ($this->theme->parametres->logo) { + copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); + $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo); + $logo.='background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; + } + $logo.='}'; + $res[] = $logo; + + // Credits + $res[] = '#credits,#credits a{color:' . self::colorToCSS($this->theme->parametres->creditsColor) . ';}'; + + // Arrows + $res[] = '#next,#previous{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}'; + // Book shadow + $shadowColor = self::colorToCSS($this->theme->parametres->bookShadeColor); + if ($shadowColor != 'transparent') { + $res[] = '#shadow{' . $this->writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}'; + } + + // Links Styles + $res = array_merge($res, $links); + $res[] = '.link a.displayArea:hover,.link a.displayArea.animating{background-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';}'; + $res[] = '.link a.displayArea{-webkit-tap-highlight-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';background-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.0001) . ';}'; + + // Menus + # View + $res[] = '.portrait #view{width:' . $w . ';min-height:' . $h . '}'; + $res[] = '.landscape #view{width:' . $w2 . ';min-height:' . $h . '}'; + $res[] = '#view{background-color:' . self::colorToCSS($this->theme->parametres->couleurB) . ';color:' . self::colorToCSS($this->theme->parametres->subTextColor) . ';}'; + # Index + $ratio = $this->width / $this->height; + $thumbh = round(100 / $ratio); + $res[] = '#index .thumb img{width:100px;height:' . $thumbh . 'px;}'; + $res[] = '#index .doubleThumb{height:' . $thumbh . 'px;' . $this->writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}'; + $res[] = '#index .doubleThumb .overlay{height:' . $thumbh . 'px;}'; + $res[] = '#index .doubleThumb .hits.yes{background-color:' . self::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextSelectColor) . '}'; + + $res = array_chunk($res, 3500); + foreach ($res as $k => $css) { + file_put_contents(sprintf($file, $k), implode("\n", $css)); + } + return count($res); + } + +} + ?> \ No newline at end of file diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 4e19b2e8e..538694e4b 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -132,7 +132,7 @@ class wsPackagerHTML extends wsPackager { } else { $label = $this->_getLabelOfPage($page); $title = $label . ' - ' . $this->book->parametres->title; - $dest = 'pages/' . $page . '-' . cubeText::str2URL($label) . '.html'; + $dest = 'pages/' . $page . '-' . mb_strtolower(cubeText::str2URL($label)) . '.html'; $pathToIndex = '../index.swf'; $pathToGetflash = '../getflash.gif'; $redirectScript = ''; @@ -227,7 +227,7 @@ class wsPackagerHTML extends wsPackager { } protected function makeHTMLNav($root) { - $res = ''; + $res .= ''; return $res; } @@ -310,9 +310,9 @@ class wsPackagerHTML extends wsPackager { } protected function makeHTMLFooter() { - $res = ''; + $res .= ''; return $res; }