]> _ Git - cubeextranet.git/commitdiff
wait #4550 @5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 21 Jun 2021 16:53:06 +0000 (16:53 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 21 Jun 2021 16:53:06 +0000 (16:53 +0000)
inc/ws/Util/html5/blendmode/class.ws.html5.compiler.php
inc/ws/Util/html5/blendmode/class.ws.html5.links.php
inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php
inc/ws/Util/html5/twofaces/class.ws.html5.links.php

index 8b1cb5c85fc732dcce63ca67538dcceccd006933..8779e3073b2eb69056271791d6ba3d7dce0cef7a 100644 (file)
@@ -1794,7 +1794,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 
         $this->config->pagesOfCustomLinks = $pagesOfCustomLinks;
 
-        $i = 0;
+        $i = 1;
         $pages = array();
         $cpages = array();
         $ctpages = array();
@@ -1826,7 +1826,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             }
 
             foreach ($linksToAdd as $lta) {
-                $c = $lta->getHTMLContainer();
+
                 $css[] = $lta->getCSSContainer();
                 if (!isset($pages[$lta->page])) {
                     $pages[$lta->page] = [];
@@ -1843,11 +1843,13 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                     $v = 'pages';
                 }
 
+                $lta->setInitialOrder($i);
                 if (!isset($$v[$lta->page][$lta->blendmode])) {
                     $$v[$lta->page][$lta->blendmode] = [];
                 }
 
-                array_push($$v[$lta->page][$lta->blendmode], $c);
+                array_push($$v[$lta->page][$lta->blendmode], $lta);
+                $i++;
             }
             // Make old "aftersearch" link compatible with new "extra" menu option by extracting link URL
             if ($link->page == 'aftersearch') {
@@ -1866,9 +1868,8 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             $allLinksData[$linkData['uid']] = $linkData;
 
             if ($link->keep()) {
-                $this->hiddenContents[] = $c;
+                $this->hiddenContents[] = $link->getHTMLContainer();
             }
-            $i++;
         }
 
         $allpages = range(0, $this->book->parametres->pages + 1);
@@ -1882,22 +1883,9 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         }
 
         foreach ($allpages as $i) {
-
-            $c = [];
-            $cc = [];
-            $ct = [];
-            if (isset($pages[$i])) {
-                $c = $pages[$i];
-            }
-            if (isset($cpages[$i])) {
-                $cc = $cpages[$i];
-            }
-            if (isset($ctpages[$i])) {
-                $ct = $ctpages[$i];
-            }
-            $this->config->links[$i] = $c;
-            $this->config->clinks[$i] = $cc;
-            $this->config->ctlinks[$i] = $ct;
+            $this->config->links[$i] = $this->_htmlLinkList($pages[$i]['normal'] ?? []);
+            $this->config->clinks[$i] = $this->_htmlLinkList($cpages[$i] ?? []);
+            $this->config->ctlinks[$i] = $this->_htmlLinkList($ctpages[$i] ?? []);
         }
 
         if ($this->writeLinksData) {
@@ -1908,6 +1896,28 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         return $css;
     }
 
+    protected function _htmlLinkList($list)
+    {
+        if (!count($list)) {
+            return '';
+        }
+        usort($list, [$this, '_sortLinksByDepth']);
+        $res = '';
+        foreach ($list as $item) {
+            $res .= $item->getHTMLContainer();
+        }
+        return $res;
+    }
+
+    protected function _sortLinksByDepth($a, $b)
+    {
+        $c = $a->getDepth() - $b->getDepth();
+        if ($c === 0) {
+            return $a->getInitialOrder() - $b->getInitialOrder();
+        }
+        return $c;
+    }
+
     public function addSlideshowLibrary($inline = true)
     {
         $l = ($inline ? $this->config->inlineSlideshowLibrary : $this->config->popupSlideshowLibrary);
index 865878c438c9c42526bdf987923be51221fc8df8..448ee3bf7cef7001858fd63d60e036260b8af947 100644 (file)
@@ -954,10 +954,24 @@ class contentLink extends wsHTML5Link
         if ($this->_isHiddenFirst($animations)) {
             $res .= ' data-animation-hide ';
         }
+        if ($this->_isFinallyHidden($animations)) {
+            $res .= ' data-animation-hide-on-leave ';
+        }
 
         return $res;
     }
 
+    protected function _isFinallyHidden($animations)
+    {
+        $hiddenAnimations = ['fadeout', 'unmask'];
+        foreach ($animations as $animation) {
+            if (in_array($animation['type'], $hiddenAnimations)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     protected function _isHiddenFirst($animations)
     {
         $hiddenAnimations = ['reveal', 'fadein', 'translatefrom'];
@@ -1785,13 +1799,13 @@ class htmlMultimediaLink extends wsHTML5Link
     public function getHTMLContent()
     {
         if ($this->_content == '') {
-            $type = $ext = files::getExtension($this->alternative);
+            $ext = files::getExtension($this->alternative);
 
-            if ($ext == 'oam') {
+            if ($ext === 'oam') {
                 $d = $this->unzipFile($this->alternative, true);
                 $this->_config = $this->getConfigOAM($d['dir']);
                 $this->copyExternalDir($d['dir'], $d['fdir']);
-            } elseif ($ext == 'zip') {
+            } elseif ($ext === 'zip') {
                 $d = $this->unzipFile($this->alternative, false);
                 $this->_config = $this->getConfigZIP($d['dir']);
                 $this->copyExternalDir($d['dir'], $d['fdir']);
@@ -1807,10 +1821,6 @@ class htmlMultimediaLink extends wsHTML5Link
 
                 $d = array('fdir' => $fdir, 'dir' => $dir);
                 $file = $this->compiler->wdir . '/' . $this->alternative;
-                $content = file_get_contents($file);
-//                if (false && strpos($content, '<div id="lottie"></div>')) {
-//                    return $this->getLottieContent($content, $this->width, $this->height);
-//                }
                 $this->compiler->vdir->copy($this->compiler->wdir . '/' . $this->alternative, $d['dir'] . '/' . $this->alternative);
                 $this->_config = $this->getConfigHTML($d['dir'], $this->alternative);
                 $this->copyExternalFile($d['dir'] . '/' . $this->alternative);
@@ -1929,6 +1939,8 @@ class htmlMultimediaLink extends wsHTML5Link
             $this->left += $this->compiler->width;
         }
 
+        $this->getHTMLContent();
+
         $css = '#l_' . $this->id . '{';
         $css .= 'left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;';
         $css .= 'width:' . $this->_config['width'] . 'px;height:' . $this->_config['height'] . 'px;';
index 92b3f0df7552560e54b4186300cc89cc99cd68f9..23f38b0d9ab9cd6a0acfaa6f38c18e0163b4062a 100644 (file)
@@ -541,7 +541,7 @@ class wsHTML5Compiler
         }
 
         $this->config->product_zoom_references = [];
-        foreach ($this->config->basketReferences as $ref => $data){
+        foreach ($this->config->basketReferences as $ref => $data) {
             $this->config->product_zoom_references[$ref] = [$ref];
         }
     }
@@ -1825,12 +1825,15 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 $linksToAdd[] = $link->getRightClone();
             }
             foreach ($linksToAdd as $lta) {
+                /** @var $lta wsLink */
+                // Keep this line because some properties of the link (like blend mode) are parsed with this function
+                $c = $lta->getHTMLContainer();
 
                 $css[] = $lta->getCSSContainer();
                 if (!isset($pages[$lta->page])) {
-                    $pages[$lta->page] = [];
-                    $cpages[$lta->page] = [];
-                    $ctpages[$lta->page] = [];
+                    $pages[$lta->page] = ['normal' => []];
+                    $cpages[$lta->page] = ['normal' => []];
+                    $ctpages[$lta->page] = ['normal' => []];
                 }
 
                 $d = $lta->getDepth();
@@ -1843,7 +1846,11 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
                 }
 
                 $lta->setInitialOrder($i);
-                array_push($$v[$lta->page], $lta);
+                if (!isset($$v[$lta->page][$lta->blendmode])) {
+                    $$v[$lta->page][$lta->blendmode] = [];
+                }
+
+                array_push($$v[$lta->page][$lta->blendmode], $lta);
                 $i++;
             }
             // Make old "aftersearch" link compatible with new "extra" menu option by extracting link URL
@@ -1894,14 +1901,19 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
     protected function _htmlLinkList($list)
     {
         if (!count($list)) {
-            return '';
+            return [];
         }
-        usort($list, [$this, '_sortLinksByDepth']);
-        $res = '';
-        foreach ($list as $item) {
-            $res .= $item->getHTMLContainer();
+        $res = [];
+        foreach ($list as $blendmode => $l) {
+            usort($l, [$this, '_sortLinksByDepth']);
+            $res[$blendmode] = [];
+            foreach ($l as $item) {
+                $res[$blendmode][] = $item->getHTMLContainer();
+            }
+
         }
         return $res;
+
     }
 
     protected function _sortLinksByDepth($a, $b)
@@ -2584,8 +2596,8 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         }
         if ($bi = $this->checkThemeImage($this->theme->parametres->backgroundImage)) {
 
-                $dbi = CubeIT_Image::getimagesize($bi);
-                $this->config->backgroundImageDimensions = array('width' => $dbi[0], 'height' => $dbi[1]);
+            $dbi = CubeIT_Image::getimagesize($bi);
+            $this->config->backgroundImageDimensions = array('width' => $dbi[0], 'height' => $dbi[1]);
 
 
             $this->vdir->copy($bi, 'data/images/' . $this->theme->parametres->backgroundImage);
index f7778a5d3fcebb92d35f3a4b921a674df20d773e..ff2cb86e1f00b813cc9d7511a19f919642bac52c 100644 (file)
@@ -29,6 +29,7 @@ class wsHTML5Link
     public $read_mode;
     public $group;
     public $infobulle;
+    public $blendmode = "normal";
     public $extra;
     public $id;
     public $rot;
@@ -462,7 +463,8 @@ class wsHTML5Link
 
     public function getHTMLContainer()
     {
-        return '<div class="' . $this->getHTMLContainerClass() . '" data-hidden="' . $this->hidden . '" data-scorm="' . $this->scorm . '" data-id="' . $this->uid . '" id="l_' . $this->id . '"' . $this->getAdditionnalContent() . '>' . $this->getHTMLContent() . '</div>';
+        $addContent=$this->getAdditionnalContent();
+        return '<div class="' . $this->getHTMLContainerClass() . '" data-blendmode="' . $this->blendmode . '" data-hidden="' . $this->hidden . '" data-scorm="' . $this->scorm . '" data-id="' . $this->uid . '" id="l_' . $this->id . '"' . $addContent . '>' . $this->getHTMLContent() . '</div>';
     }
 
     public function getHTMLContainerClass()
@@ -940,6 +942,10 @@ class contentLink extends wsHTML5Link
         $res = parent::getAdditionnalContent();
         $animations = self::parseAnimations($this->image_rollover);
         foreach ($animations as $animation) {
+            if (isset($animation['blendmode'])) {
+                $this->blendmode = $animation['blendmode'];
+                unset($animation['blendmode']);
+            }
             if (isset($animation['zindex'])) {
                 $this->animZindex = $animation['zindex'];
             }
@@ -1541,7 +1547,7 @@ class layerLink extends imageLink
         if (!$this->rightClone) {
             zoomLink::generateImage($attributes, $this->compiler, 'layerlink', 'layer');
         }
-        return 'background-image:url(' . $this->getImageUrl() . ');background-size:100% 100%;background-repeat:no-repeat;';
+        return 'background-image:url(' . $this->getImageUrl() . ');background-size:' . $this->getBackgroundSize() . ';background-position:' . $this->getBackgroundPosition() . ';background-repeat:no-repeat;';
     }
 
     public function getImageUrl()
@@ -1569,7 +1575,9 @@ class colorLink extends contentLink
 
     public function getCSS()
     {
-        return 'background-color:' . wsHTML5::colorToCSS($this->to, 1) . ';';
+        $res = parent::getCSS();
+        $res .= 'background-color:' . wsHTML5::colorToCSS($this->to, 1) . ';';
+        return $res;
     }
 
     public function getAdditionnalContent()
@@ -1590,7 +1598,9 @@ class textLink extends contentLink
         }
         $fz = $this->height * $this->getCssScale();
         $fz = round($fz / $font['capHeight'], 2);
-        return 'line-height:' . $font['capHeight'] . ';font-size:' . $fz . 'px;font-family:' . $font['family'] . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';';
+        $res = parent::getCSS();
+        $res .= 'line-height:' . $font['capHeight'] . ';font-size:' . $fz . 'px;font-family:' . $font['family'] . ';color:' . wsHTML5::colorToCSS($this->extra, 1) . ';';
+        return $res;
     }
 
     public function getHTMLContainerClass()
@@ -1622,8 +1632,34 @@ class imageLink extends contentLink
 
     public function getCSS()
     {
+        $res = parent::getCSS();
         $this->copyExternalFile($this->to);
-        return 'background-image:url(' . $this->getImageUrl() . ');background-size:100% 100%;background-repeat:no-repeat;';
+        $res .= 'background-image:url(' . $this->getImageUrl() . ');background-size:' . $this->getBackgroundSize() . ';background-position:' . $this->getBackgroundPosition() . ';background-repeat:no-repeat;';
+        return $res;
+    }
+
+    public function getBackgroundPosition()
+    {
+        $animations = self::parseAnimations($this->image_rollover);
+        foreach ($animations as $animation) {
+            if (($animation['type'] === 'zoomout' || $animation['type'] === 'zoomin') && isset($animation['transformorigin'])) {
+                return $animation['transformorigin'];
+            }
+        }
+        return '50% 50%';
+    }
+
+    public function getBackgroundSize()
+    {
+
+        $size = '100%';
+        $animations = self::parseAnimations($this->image_rollover);
+        foreach ($animations as $animation) {
+            if ($animation['type'] === 'zoomout') {
+                $size = round($animation['scale'] * 100) . '%';
+            }
+        }
+        return $size . ' ' . $size;
     }
 
     public function getAdditionnalContent()