From c825ca1f1c9ed5f83d0619f85cdf2c5a6632bd81 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 17 Jul 2013 15:45:49 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.url.php | 22 ++++ inc/ws/Util/html5/class.ws.html5.compiler.php | 58 ++++----- inc/ws/Util/html5/class.ws.html5.links.php | 116 +++++++++++------- 3 files changed, 126 insertions(+), 70 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 290ca4c68..63faf1ae2 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -967,6 +967,16 @@ html{height:100%}' . "\n"; commonDroits::error(); } + if (!wsDroits::admin()) { + if ($book->parametres->redirectDemo != '') { + http::redirect($book->parametres->redirectDemo); + exit; + } + if ($book->parametres->disableDemo) { + commonDroits::error(); + } + } + $dao->compile($book_id, 'html5'); $time = self::getHTML5CacheTime($book_id); @@ -1074,6 +1084,18 @@ html{height:100%}' . "\n"; if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) { commonDroits::error(); } + + if (!wsDroits::admin()) { + if ($book->parametres->redirectDemo != '') { + http::redirect($book->parametres->redirectDemo); + exit; + } + if ($book->parametres->disableDemo) { + commonDroits::error(); + } + } + + echo file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html'); exit; } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 6244f5c87..9c9176c9b 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -930,26 +930,26 @@ class wsHTML5Compiler { $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.doublePage._3d{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}'; $res[] = '.doublePage,#pages,#links,.landscape #shadow.double{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}'; - $res[] = '.landscape .doublePage._2d.axis_x.next{' . $this->writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}'; - $res[] = '.landscape .doublePage._2d.axis_x.prev{' . $this->writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}'; - $res[] = '.portrait .doublePage._2d.axis_x.next{' . $this->writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}'; - $res[] = '.portrait .doublePage._2d.axis_x.prev{' . $this->writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}'; - $res[] = '.doublePage._2d.axis_y.next{' . $this->writeCSSUA('transform', 'translate3d(0,' . $h . ',0)') . '}'; - $res[] = '.doublePage._2d.axis_y.prev{' . $this->writeCSSUA('transform', 'translate3d(0,-' . $h . ',0)') . '}'; - - /* $res[] = '.dev .landscape .doublePage._2d.axis_x.next{left:' . $w2 . ';' . $this->writeCSSUA('transform', 'none') . '}'; - $res[] = '.dev .landscape .doublePage._2d.axis_x.prev{left:-' . $w2 . ';' . $this->writeCSSUA('transform', 'none') . '}'; - $res[] = '.dev .portrait .doublePage._2d.axis_x.next{left:' . $w . ';' . $this->writeCSSUA('transform', 'none') . '}'; - $res[] = '.dev .portrait .doublePage._2d.axis_x.prev{left:-' . $w . ';' . $this->writeCSSUA('transform', 'none') . '}'; - $res[] = '.dev .doublePage._2d.axis_y.next{top:' . $h . ';' . $this->writeCSSUA('transform', 'none') . '}'; - $res[] = '.dev .doublePage._2d.axis_y.prev{top:-' . $h . ';' . $this->writeCSSUA('transform', 'none') . '}'; - - $res[] = '.dev .landscape .doublePage._2d.axis_x.next{' . $this->writeCSSUA('transform', 'translate(' . $w2 . ',0)') . '}'; - $res[] = '.dev .landscape .doublePage._2d.axis_x.prev{' . $this->writeCSSUA('transform', 'translate(-' . $w2 . ',0)') . '}'; - $res[] = '.dev .portrait .doublePage._2d.axis_x.next{' . $this->writeCSSUA('transform', 'translate(' . $w . ',0)') . '}'; - $res[] = '.dev .portrait .doublePage._2d.axis_x.prev{' . $this->writeCSSUA('transform', 'translate(-' . $w . ',0)') . '}'; - $res[] = '.dev .doublePage._2d.axis_y.next{' . $this->writeCSSUA('transform', 'translate(0,' . $h . ')') . '}'; - $res[] = '.dev .doublePage._2d.axis_y.prev{' . $this->writeCSSUA('transform', 'translate(0,-' . $h . ')') . '}'; */ + $res[] = '.landscape .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}'; + $res[] = '.landscape .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}'; + $res[] = '.portrait .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}'; + $res[] = '.portrait .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}'; + $res[] = '.doublePage._2d.axis_y.next{' . self::writeCSSUA('transform', 'translate3d(0,' . $h . ',0)') . '}'; + $res[] = '.doublePage._2d.axis_y.prev{' . self::writeCSSUA('transform', 'translate3d(0,-' . $h . ',0)') . '}'; + + /* $res[] = '.dev .landscape .doublePage._2d.axis_x.next{left:' . $w2 . ';' . self::writeCSSUA('transform', 'none') . '}'; + $res[] = '.dev .landscape .doublePage._2d.axis_x.prev{left:-' . $w2 . ';' . self::writeCSSUA('transform', 'none') . '}'; + $res[] = '.dev .portrait .doublePage._2d.axis_x.next{left:' . $w . ';' . self::writeCSSUA('transform', 'none') . '}'; + $res[] = '.dev .portrait .doublePage._2d.axis_x.prev{left:-' . $w . ';' . self::writeCSSUA('transform', 'none') . '}'; + $res[] = '.dev .doublePage._2d.axis_y.next{top:' . $h . ';' . self::writeCSSUA('transform', 'none') . '}'; + $res[] = '.dev .doublePage._2d.axis_y.prev{top:-' . $h . ';' . self::writeCSSUA('transform', 'none') . '}'; + + $res[] = '.dev .landscape .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate(' . $w2 . ',0)') . '}'; + $res[] = '.dev .landscape .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate(-' . $w2 . ',0)') . '}'; + $res[] = '.dev .portrait .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate(' . $w . ',0)') . '}'; + $res[] = '.dev .portrait .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate(-' . $w . ',0)') . '}'; + $res[] = '.dev .doublePage._2d.axis_y.next{' . self::writeCSSUA('transform', 'translate(0,' . $h . ')') . '}'; + $res[] = '.dev .doublePage._2d.axis_y.prev{' . self::writeCSSUA('transform', 'translate(0,-' . $h . ')') . '}'; */ $res[] = '.doublePage._3d{left:' . $w . ';}'; $res[] = '#links.right{left:-' . $w . ';}'; @@ -962,9 +962,9 @@ class wsHTML5Compiler { } else { $res[] = '#pagesnumbers{display:none;}'; } - $res[] = '.doublePage._2d,.doublePage._3d{' . $this->writeCSSUA('transition', 'all ' . $this->book->parametres->mobileTransitionDuration . 's ease-in-out') . '}'; + $res[] = '.doublePage._2d,.doublePage._3d{' . self::writeCSSUA('transition', 'all ' . $this->book->parametres->mobileTransitionDuration . 's ease-in-out') . '}'; - $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}'; + $res[] = '.background{' . self::writeCSSUA('transform-origin', 'top left') . ';}'; foreach (self::$resolutions as $r) { $ratio = round(72 / $r, 3) * $cssScale; @@ -973,13 +973,13 @@ class wsHTML5Compiler { $br = '.background.r' . $r . '{'; if ($ratio != 1) { - $br.=$this->writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; + $br.=self::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 = '.texts{' . self::writeCSSUA('transform-origin', 'top left') . ';'; + $texts.=self::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.='}'; @@ -996,7 +996,7 @@ class wsHTML5Compiler { $search.='color:' . self::colorToCSS($this->theme->parametres->couleurS) . ';'; $search.='background-color:' . self::colorToCSS($this->theme->parametres->searchFieldColor) . ';'; if ($this->theme->parametres->searchShadeAlpha > 0) { - $search.=$this->writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;'; + $search.=self::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;'; } $search.='}'; $res[] = $search; @@ -1042,7 +1042,7 @@ class wsHTML5Compiler { // Book shadow $shadowColor = self::colorToCSS($this->theme->parametres->bookShadeColor); if ($shadowColor != 'transparent') { - $res[] = '#shadow{' . $this->writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}'; + $res[] = '#shadow{' . self::writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}'; } // Links Styles @@ -1114,7 +1114,7 @@ class wsHTML5Compiler { $ratio = $this->width / $this->height; $thumbh = round(100 / $ratio); $res[] = '#indexView .thumb img{width:100px;height:' . $thumbh . 'px;}'; - $res[] = '#indexView .doubleThumb{height:' . $thumbh . 'px;' . $this->writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}'; + $res[] = '#indexView .doubleThumb{height:' . $thumbh . 'px;' . self::writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}'; $res[] = '#indexView .doubleThumb .overlay{height:' . $thumbh . 'px;}'; $res[] = '#indexView .doubleThumb .hits.yes{background-color:' . self::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextSelectColor) . '}'; @@ -1186,7 +1186,7 @@ class wsHTML5Compiler { return $body; } - protected function writeCSSUA($property, $value) { + public static function writeCSSUA($property, $value) { $res = array(); foreach (self::$uaPrefixes as $prefix) { $res[] = $prefix . $property . ':' . $value; diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php index da42a9d3b..4972423d2 100644 --- a/inc/ws/Util/html5/class.ws.html5.links.php +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -52,8 +52,7 @@ class wsHTML5Link { } else { return new videoPopupLink($id, $init, $compiler); } - case 6: - return new multimediaLink($id, $init, $compiler); + case 7: if ($compiler->book->parametres->customLinkClass == 'WescoLink') { return new wescoLink($id, $init, $compiler); @@ -94,16 +93,42 @@ class wsHTML5Link { $compiler->addBookmarkGroup($init); break; case 21: - return new htmlMultimediaLink($id, $init, $compiler); + case 6: + return self::getMultimediaInstance($id, $init, $compiler); + break; default: return null; } } + public static function getMultimediaInstance($id, $init, &$compiler) { + if ($init['alternative'] == '') { + return null; + } + + $ext = mb_strtolower(files::getExtension($init['alternative'])); + + if ($ext == 'oam') { + if ($init['inline']) { + return new htmlMultimediaLink($id, $init, $compiler); + } else { + return new htmlMultimediaPopupLink($id, $init, $compiler); + } + } else if (in_array($ext, array('gif', 'jpeg', 'jpg', 'png', 'svg'))) { + if ($init['inline']) { + return new htmlMultimediaImage($id, $init, $compiler); + } else { + return new htmlMultimediaPopupImage($id, $init, $compiler); + } + } + return null; + } + public function __construct($id, $init, &$compiler) { foreach ($init as $k => $v) { $this->$k = $v; } + $this->wdir = WS_BOOKS . '/working/' . $compiler->book_id . '/'; $this->id = $id; $this->compiler = $compiler; } @@ -229,6 +254,41 @@ class normalLink extends wsHTML5Link { } +class htmlMultimediaImage extends wsHTML5Link { + + public function getHTMLContainerClass() { + return 'link multimedia'; + } + + public function getHTMLContent() { + $w = $this->width * $this->getCssScale(); + $h = $this->height * $this->getCssScale(); + $this->copyExternalFile($this->alternative); + $alt = ''; + return $alt; + } + +} + +class htmlMultimediaPopupImage extends normalLink { + + public function getURL() { + $this->copyExternalFile($this->alternative); + return '#/multimedia/' . $this->alternative; + } + + public function getAdditionnalContent() { + $dim = getimagesize($this->wdir . '/' . $this->alternative); + $markup = '
'; + return ' data-multimedia="' . rawurlencode($markup) . '" '; + } + + public function keep() { + return true; + } + +} + class contentLink extends wsHTML5Link { public function getHTMLContainerClass() { @@ -420,25 +480,6 @@ class fileLink extends normalLink { } -class multimediaLink extends wsHTML5Link { - - public function getHTMLContainerClass() { - return 'link multimedia'; - } - - public function getHTMLContent() { - //$this->copyExternalFile($this->to); - $w = $this->width * $this->getCssScale(); - $h = $this->height * $this->getCssScale(); - if ($this->alternative != '') { - $this->copyExternalFile($this->alternative); - } - $alt = $this->alternative == '' ? '' : ''; - return $alt; - } - -} - class htmlMultimediaLink extends wsHTML5Link { protected $_config = null; @@ -446,19 +487,17 @@ class htmlMultimediaLink extends wsHTML5Link { public function getHTMLContent() { if ($this->_content == '') { - $d = $this->unzipFile($this->to, true); + $d = $this->unzipFile($this->alternative, true); $this->_config = $this->getConfig($d['dir']); - - $this->_correctFiles($d['dir']); - $w = $this->width * $this->getCssScale(); $h = $this->height * $this->getCssScale(); - $res = ''; - $res.=$this->_config['content']; + $iw = $this->_config['width'] * $this->getCssScale(); + $ih = $this->_config['height'] * $this->getCssScale(); + $res = ''; $this->copyExternalDir($d['dir']); $this->_content = $res; } @@ -475,18 +514,13 @@ class htmlMultimediaLink extends wsHTML5Link { } } - /** - * - * @param SplFileInfo $file - */ - protected function _correctFile($file) { - $d = 'data/links/' . $this->to . '/'; - $content = file_get_contents($file); - foreach ($this->_config['assets'] as $a) { - $content = str_replace($a, $d . $a, $content); - } - $content = str_replace("='images/';", "='$d"."images/';",$content); - file_put_contents($file, $content); + public function getCSS() { + $sx = $this->width / ($this->_config['width'] * $this->getCssScale()); + $sy = $this->height / ($this->_config['height'] * $this->getCssScale()); + + $res = wsHTML5Compiler::writeCSSUA('transform', 'scale(' . $sx . ',' . $sy . ')'); + $res.= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); + return $res; } public function getConfig($d) { @@ -496,7 +530,7 @@ class htmlMultimediaLink extends wsHTML5Link { $x = simplexml_load_file($config, 'SimpleXMLElement', LIBXML_NOCDATA); $c = CubeIT_Util_Xml::toObject($x); - $props = array('default-width' => 'width', 'default-height' => 'height'); + $props = array('default-width' => 'width', 'default-height' => 'height', 'html-page' => 'html'); $res = array('content' => trim($c->content), 'name' => $c->_name, 'assets' => array()); -- 2.39.5