]> _ Git - cubeextranet.git/commitdiff
wip #5138 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 2 Mar 2022 12:44:26 +0000 (12:44 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 2 Mar 2022 12:44:26 +0000 (12:44 +0000)
inc/ws/Controlleur/class.ws.url.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index b069676d06dea35d48660329f972c6a6a550b12b..5d8a1b38b5d3c98a21f4cd0580d327acf6c1e13e 100644 (file)
@@ -2046,7 +2046,7 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
         self::_relay($file, $ok);
     }
 
-    protected function _relay($file, $ok = 'auto')
+    protected static function _relay($file, $ok = 'auto')
     {
         global $core;
 
@@ -2094,7 +2094,7 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
         return true;
     }
 
-    public function relayfb($args)
+    public static function relayfb($args)
     {
         global $core;
         array_shift($args);
index 9f321b5942b10cf48b0a090a13aa2ac3c3f16f4e..2aed7f2dd1cf5478be65987a4a01cfd4b1f68ba6 100644 (file)
@@ -31,6 +31,7 @@ class wsHTML5Link
     public $infobulle;
     public $blendmode = "normal";
     public $extra;
+    public $extraraw;
     public $id;
     public $rot;
     public $class;
@@ -52,7 +53,8 @@ class wsHTML5Link
     public $tooltipBackgroundColor = null;
     public $parallax = 0;
     public $attachLeft = false;
-    public $allowsAnimation = false;
+    public $allowsAnimation = true;
+    public $forceTexture = false;
 
     protected $role = 'button';
 
@@ -324,15 +326,33 @@ class wsHTML5Link
                 $v = $matches[1];
             }
             $k = trim($e[0]);
+
             if ($normalizeKey) {
                 $k = mb_strtolower($k);
             }
+            if ($k === 'animationtype') {
+                break;
+            }
             $res[$k] = $v;
         }
 
         return $res;
     }
 
+    public static function parseAnimationsInExtra($extra)
+    {
+        if (!$extra) {
+            return [];
+        }
+
+        $e = explode('animationtype=', $extra, 2);
+        if (count($e) === 1) {
+            return [];
+        }
+
+        return self::parseAnimations('type=' . $e[1]);
+    }
+
     public static function parseAnimations($animations)
     {
         $anims = explode('---', $animations);
@@ -423,8 +443,10 @@ class wsHTML5Link
     public function __construct($id, $init, &$compiler)
     {
         $this->_init = $init;
+        $this->extraraw = '';
         foreach ($init as $k => $v) {
             if ($k == 'extra') {
+                $this->extraraw = $v;
                 if (CubeIT_Util_Json::isJson($v)) {
                     $v = CubeIT_Util_Json::decode($v);
                 } else if (strpos($v, '=') !== false && strpos($v, '&') !== false) {
@@ -567,6 +589,57 @@ class wsHTML5Link
     public function getAdditionnalContent()
     {
         $res = '';
+
+//        if ($this->uid == '831d0b8600') {
+//            die($this->allowsAnimation . '/' . $this->image_rollover . '/' . $this->extraraw);
+//        }
+
+        if ($this->allowsAnimation) {
+            if (stristr($this->image_rollover, 'type=') && $this instanceof contentLink) {
+                $animations = self::parseAnimations($this->image_rollover);
+            } else {
+                $animations = self::parseAnimationsInExtra($this->extraraw);
+            }
+            if (count($animations)) {
+                foreach ($animations as $animation) {
+                    if (isset($animation['blendmode'])) {
+                        $this->blendmode = $animation['blendmode'];
+                        unset($animation['blendmode']);
+                    }
+                    if (isset($animation['zindex'])) {
+                        if ($animation['zindex'] >= 10) {
+                            $this->zindex = $animation['zindex'];
+                        } else {
+                            $this->zindex += $animation['zindex'];
+                        }
+                    }
+                    if (isset($animation['addzindex'])) {
+                        $this->addzindex = $animation['addzindex'];
+                    }
+                    if (isset($animation['parallax'])) {
+                        $this->parallax = $animation['parallax'];
+                        unlink($animation['parallax']);
+                    }
+                    if ($animation['type'] === 'draggable') {
+                        $this->defaultZIndex = 70;
+                        $this->interactive = true;
+                    }
+                }
+
+                $res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" ';
+                if ($this->_isHiddenFirst($animations)) {
+                    $res .= ' data-animation-hide ';
+                }
+                if ($this->_isFinallyHidden($animations)) {
+                    $res .= ' data-animation-hide-on-leave ';
+                }
+            }
+        }
+        if ($this->forceTexture && $this->getDepth() >= 40) {
+            $res .= ' data-force-texture="1" ';
+        }
+
+
         if ($this->role !== '') {
             $res .= ' role="' . $this->role . '"';
         }
@@ -588,10 +661,33 @@ class wsHTML5Link
             $res .= ' data-parallax="' . $this->parallax . '"';
         }
 
+
         return $res;
 
     }
 
+    protected function _isFinallyHidden($animations)
+    {
+        $hiddenAnimations = ['fadeout', 'unmask'];
+        foreach ($animations as $animation) {
+            if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    protected function _isHiddenFirst($animations)
+    {
+        $hiddenAnimations = ['reveal', 'fadein', 'translatefrom'];
+        foreach ($animations as $animation) {
+            if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public function getClasses()
     {
 
@@ -1057,71 +1153,7 @@ class contentLink extends wsHTML5Link
         return $res;
     }
 
-    public function getAdditionnalContent()
-    {
-        $res = parent::getAdditionnalContent();
-        if ($this->allowsAnimation) {
-            $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'])) {
-                    if ($animation['zindex'] >= 10) {
-                        $this->zindex = $animation['zindex'];
-                    } else {
-                        $this->zindex += $animation['zindex'];
-                    }
-                }
-                if (isset($animation['addzindex'])) {
-                    $this->addzindex = $animation['addzindex'];
-                }
-                if (isset($animation['parallax'])) {
-                    $this->parallax = $animation['parallax'];
-                    unlink($animation['parallax']);
-                }
-                if ($animation['type'] === 'draggable') {
-                    $this->defaultZIndex = 70;
-                    $this->interactive = true;
-                }
-            }
-            $res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" ';
-            if ($this->_isHiddenFirst($animations)) {
-                $res .= ' data-animation-hide ';
-            }
-            if ($this->_isFinallyHidden($animations)) {
-                $res .= ' data-animation-hide-on-leave ';
-            }
-        }
-        if ($this->forceTexture && $this->getDepth() >= 40) {
-            $res .= ' data-force-texture="1" ';
-        }
 
-        return $res;
-    }
-
-    protected function _isFinallyHidden($animations)
-    {
-        $hiddenAnimations = ['fadeout', 'unmask'];
-        foreach ($animations as $animation) {
-            if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    protected function _isHiddenFirst($animations)
-    {
-        $hiddenAnimations = ['reveal', 'fadein', 'translatefrom'];
-        foreach ($animations as $animation) {
-            if (isset($animation['type']) && in_array($animation['type'], $hiddenAnimations)) {
-                return true;
-            }
-        }
-        return false;
-    }
 }
 
 class eventOverlayLink extends wsHTML5Link
@@ -1799,7 +1831,6 @@ class imageLink extends contentLink
 
     public function getBackgroundSize()
     {
-
         $size = '100%';
         $animations = self::parseAnimations($this->image_rollover);
         foreach ($animations as $animation) {