]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 17 Jul 2013 15:45:49 +0000 (15:45 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 17 Jul 2013 15:45:49 +0000 (15:45 +0000)
inc/ws/Controlleur/class.ws.url.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/html5/class.ws.html5.links.php

index 290ca4c6856e37107f88cd69fe8c00a5646d59e0..63faf1ae296cfa40136ded78043f680218564db7 100644 (file)
@@ -967,6 +967,16 @@ html{height:100%}' . "\n";
                        commonDroits::error();\r
                }\r
 \r
+               if (!wsDroits::admin()) {\r
+                       if ($book->parametres->redirectDemo != '') {\r
+                               http::redirect($book->parametres->redirectDemo);\r
+                               exit;\r
+                       }\r
+                       if ($book->parametres->disableDemo) {\r
+                               commonDroits::error();\r
+                       }\r
+               }\r
+\r
                $dao->compile($book_id, 'html5');\r
                $time = self::getHTML5CacheTime($book_id);\r
 \r
@@ -1074,6 +1084,18 @@ html{height:100%}' . "\n";
                if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
                        commonDroits::error();\r
                }\r
+\r
+               if (!wsDroits::admin()) {\r
+                       if ($book->parametres->redirectDemo != '') {\r
+                               http::redirect($book->parametres->redirectDemo);\r
+                               exit;\r
+                       }\r
+                       if ($book->parametres->disableDemo) {\r
+                               commonDroits::error();\r
+                       }\r
+               }\r
+\r
+\r
                echo file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html');\r
                exit;\r
        }\r
index 6244f5c878dc9790e9830a18d419bf2599335399..9c9176c9b8ce24f1935dd64606ee9ae118f4c4b4 100644 (file)
@@ -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;
index da42a9d3b05e5cdf032dfde7611c37b6df4f8529..4972423d205cf1a78f3b3fb6f25f0a620ee71a50 100644 (file)
@@ -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 = '<img src="' . wsHTML5Link::getUniversalLocation($this->alternative) . '" width="' . $w . '" height="' . $h . '" />';
+               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 = '<div class="multimediaContainer"><img src="' . wsHTML5Link::getUniversalLocation($this->alternative) . '" width="' . $dim[0] . '" height="' . $dim[1] . '" class="multimedia" /></div>';
+               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 == '' ? '' : '<img src="' . wsHTML5Link::getUniversalLocation($this->alternative) . '" width="' . $w . '" height="' . $h . '" />';
-               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 = '<script type="text/javascript" src="' . $d['fdir'] . '/' . $this->_config['name'] . '_edgePreload.js"></script>';
-                       $res.=$this->_config['content'];
+                       $iw = $this->_config['width'] * $this->getCssScale();
+                       $ih = $this->_config['height'] * $this->getCssScale();
 
+                       $res = '<iframe width="' . $iw . '" height="' . $ih . '" src="' . $d['fdir'] . '/' . $this->_config['html'] . '" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
                        $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());