]> _ Git - cubeextranet.git/commitdiff
wait #4463 @6
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 14 Jun 2021 14:35:32 +0000 (14:35 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 14 Jun 2021 14:35:32 +0000 (14:35 +0000)
inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php
inc/ws/Util/html5/twofaces/class.ws.html5.links.php

index b384ee93cd1a621019ca9654af10a032b50e5862..92b3f0df7552560e54b4186300cc89cc99cd68f9 100644 (file)
@@ -518,6 +518,34 @@ class wsHTML5Compiler
         return false;
     }
 
+    public function writeFlexipanCart()
+    {
+        $this->lessVariables['import-cart-styles'] = 'flexipan';
+
+        $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js');
+        $this->addJsLib('flexipan', 'js/libs/fluidbook/cart/fluidbook.cart.flexipan.js');
+        $this->addJsLib('html2pdf', 'js/libs/html2pdf/html2pdf.min.js');
+
+        $cdir = $this->wdir . '/commerce/';
+
+
+        $file = $cdir . $this->book->parametres->basketReferences;
+        $this->config->basketReferences = wsUtil::excelToArrayKeyVars($file);
+
+        wsLinks::getLinksAndRulersFromFile($this->book_id, $links, $rulers);
+
+        foreach ($links as $link) {
+            if ($link['type'] == '12') {
+
+            }
+        }
+
+        $this->config->product_zoom_references = [];
+        foreach ($this->config->basketReferences as $ref => $data){
+            $this->config->product_zoom_references[$ref] = [$ref];
+        }
+    }
+
     public function writeMIFCart()
     {
         $this->lessVariables['import-cart-styles'] = 'mif';
@@ -618,6 +646,8 @@ class wsHTML5Compiler
         if ($this->config->basket) {
             $this->addJsLib('cart', 'js/libs/fluidbook/fluidbook.cart.js');
             switch ($this->config->basketManager) {
+                case 'Flexipan';
+                    return $this->writeFlexipanCart();
                 case 'Puma':
                     return $this->writePumaCart();
                 case 'MIF':
@@ -865,6 +895,20 @@ class wsHTML5Compiler
                 $this->config->tagcommander_plan = $fixedplan;
             }
         }
+        if (isset($this->book->parametres->googleTagManager) && $this->book->parametres->googleTagManager) {
+            $this->book->parametres->googleAnalyticsCustom .= "<!-- Google Tag Manager -->
+<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
+new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
+j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
+'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
+})(window,document,'script','dataLayer','" . $this->book->parametres->googleTagManager . "');</script>
+<!-- End Google Tag Manager -->
+";
+            $this->book->parametres->statsCustom = '<!-- Google Tag Manager (noscript) -->
+<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=' . $this->book->parametres->googleTagManager . '"
+height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
+<!-- End Google Tag Manager (noscript) -->';
+        }
     }
 
     protected function writeSecure()
@@ -1211,15 +1255,15 @@ class wsHTML5Compiler
 
             $favicon = '';
             $hasIos = false;
-            if ($this->theme->parametres->iosicon != '') {
+            if ($iosico = $this->checkThemeImage($this->theme->parametres->iosicon)) {
                 $hasIos = true;
-                $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->iosicon, 'data/apple-touch-icon.png');
+                $this->vdir->copy($iosico, 'data/apple-touch-icon.png');
                 $favicon .= '<link rel="apple-touch-icon" href="data/apple-touch-icon.png" />' . "\n\t";
             }
             if ($this->theme->parametres->favicon != '') {
 
-                $pngFile = $this->themeRoot . '/' . $this->theme->parametres->favicon;
-                $icoFile = $this->themeRoot . '/favicon.ico';
+                $pngFile = $this->checkThemeImage($this->theme->parametres->favicon);
+                $icoFile = $this->checkThemeImage('favicon.ico');
 
                 if (!file_exists($icoFile) || filemtime($icoFile) < filemtime($pngFile) || filemtime(__FILE__) > filemtime($icoFile)) {
                     $tmp = CubeIT_Files::tempnam() . '.png';
@@ -1258,10 +1302,10 @@ class wsHTML5Compiler
                 if ($this->book->parametres->splashURL !== '') {
                     $splash = '<a href="' . $this->book->parametres->splashURL . '" target="' . $this->book->parametres->splashTarget . '" style="display:block;position:absolute;top:0;left;0;width:100%;height:100%"></a>';
                 }
-            } else if ($this->theme->parametres->logoLoader && file_exists($this->themeRoot . $this->theme->parametres->logoLoader)) {
-                $dim = CubeIT_Image::getimagesize($this->themeRoot . $this->theme->parametres->logoLoader);
+            } else if ($ll = $this->checkThemeImage($this->theme->parametres->logoLoader)) {
+                $dim = CubeIT_Image::getimagesize($ll);
                 if ($dim !== false) {
-                    $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->logoLoader, 'data/images/' . $this->theme->parametres->logoLoader);
+                    $this->vdir->copy($ll, 'data/images/' . $this->theme->parametres->logoLoader);
                     $splash .= '<div class="logo"><img src="data/images/' . $this->theme->parametres->logoLoader . '" width="' . $dim[0] . '" height="' . $dim[1] . '" alt="" /></div>';
                 }
             }
@@ -1519,8 +1563,8 @@ class wsHTML5Compiler
 
     protected function writeExtras()
     {
-        if ($this->theme->parametres->afterSearch != '') {
-            $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->afterSearch, 'data/images/' . $this->theme->parametres->afterSearch);
+        if ($as = $this->checkThemeImage($this->theme->parametres->afterSearch)) {
+            $this->vdir->copy($as, 'data/images/' . $this->theme->parametres->afterSearch);
         }
         if ($this->book->parametres->externalArchives != '') {
             $this->addFilesInfos('archives', $this->wdir . '/' . $this->book->parametres->externalArchives);
@@ -1750,7 +1794,7 @@ class wsHTML5Compiler
 
         $this->config->pagesOfCustomLinks = $pagesOfCustomLinks;
 
-        $i = 0;
+        $i = 1;
         $pages = array();
         $cpages = array();
         $ctpages = array();
@@ -1863,8 +1907,8 @@ class wsHTML5Compiler
     protected function _sortLinksByDepth($a, $b)
     {
         $c = $a->getDepth() - $b->getDepth();
-        if($c===0){
-            return $a->getInitialOrder()-$b->getInitialOrder();
+        if ($c === 0) {
+            return $a->getInitialOrder() - $b->getInitialOrder();
         }
         return $c;
     }
@@ -2290,8 +2334,8 @@ class wsHTML5Compiler
         // Header
         $header = 'header{';
         $header .= 'height:' . $this->theme->parametres->menuHeight . 'px;';
-        if ($this->theme->parametres->menuImage != '') {
-            $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, 'data/images/' . $this->theme->parametres->menuImage);
+        if ($mi = $this->checkThemeImage($this->theme->parametres->menuImage)) {
+            $this->vdir->copy($mi, '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;';
@@ -2304,9 +2348,9 @@ class wsHTML5Compiler
 
         // Logo
         $logo = '#logo{';
-        if ($this->theme->parametres->logo) {
-            $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->logo, 'data/images/' . $this->theme->parametres->logo);
-            $dim = CubeIT_Image::getimagesize($this->themeRoot . '/' . $this->theme->parametres->logo);
+        if ($l = $this->checkThemeImage($this->theme->parametres->logo)) {
+            $this->vdir->copy($l, 'data/images/' . $this->theme->parametres->logo);
+            $dim = CubeIT_Image::getimagesize($l);
             $logo .= 'background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;';
         }
         $logo .= '}';
@@ -2430,6 +2474,25 @@ class wsHTML5Compiler
         $this->log('Write CSS');
     }
 
+    protected function checkThemeImage($path)
+    {
+        $path = trim($path);
+        $path = trim($path, '/');
+        if (!$path) {
+            return false;
+        }
+        $p = $this->themeRoot . '/' . $path;
+        if (file_exists($p)) {
+            return $p;
+        }
+        $po = str_replace('.svg', '.o.svg', $p);
+        if (file_exists($po)) {
+            copy($po, $p);
+            return $p;
+        }
+        return false;
+    }
+
     protected function _writeLess($variables, $lessContents = '')
     {
         if ($this->widget) {
@@ -2519,14 +2582,13 @@ class wsHTML5Compiler
                 $body .= 'background-size:100% 100%;';
                 break;
         }
-        if ($this->theme->parametres->backgroundImage != '') {
-            $bi = $this->themeRoot . '/' . $this->theme->parametres->backgroundImage;
-            if (file_exists($bi)) {
+        if ($bi = $this->checkThemeImage($this->theme->parametres->backgroundImage)) {
+
                 $dbi = CubeIT_Image::getimagesize($bi);
                 $this->config->backgroundImageDimensions = array('width' => $dbi[0], 'height' => $dbi[1]);
-            }
 
-            $this->vdir->copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, 'data/images/' . $this->theme->parametres->backgroundImage);
+
+            $this->vdir->copy($bi, 'data/images/' . $this->theme->parametres->backgroundImage);
             $body .= 'background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');';
             $body .= 'background-position:';
 
index 18f89fcd4d0fa2ec8cf56f8855ca691374b09fee..f7778a5d3fcebb92d35f3a4b921a674df20d773e 100644 (file)
@@ -45,6 +45,9 @@ class wsHTML5Link
     public $maxWidth = 0;
     public $wdir;
     public $initialOrder = 0;
+    public $gamifyCoins = 0;
+    public $tooltipColor = null;
+    public $tooltipBackgroundColor = null;
     protected $role = 'button';
 
     protected $_init;
@@ -132,7 +135,7 @@ class wsHTML5Link
                 return new actionLink($id, $init, $compiler);
             case 12:
 
-                if ($compiler->book->parametres->basketManager === 'Puma' || $compiler->book->parametres->basketManager === 'MIF') {
+                if ($compiler->book->parametres->basketManager === 'Puma' || $compiler->book->parametres->basketManager === 'MIF' || $compiler->book->parametres->basketManager === 'Flexipan') {
                     return new zoomProductLink($id, $init, $compiler);
                 }
                 if ($compiler->book->parametres->product_zoom_references !== '') {
@@ -540,10 +543,15 @@ class wsHTML5Link
 
     public function getCSSZIndex()
     {
-        $zindex = (($this->getDepth() + 1) * 1000) - min(999, round(($this->width * $this->height) / 300));
+        $zindex = $this->getAddZIndex() + (($this->getDepth() + 1) * 1000) - min(999, round(($this->width * $this->height) / 300));
         return 'z-index:' . $zindex . ';';
     }
 
+    public function getAddZIndex()
+    {
+        return 0;
+    }
+
     public function moveOnEvenPage()
     {
         return false;
@@ -920,6 +928,7 @@ class htmlMultimediaPopupImage extends normalLink
 class contentLink extends wsHTML5Link
 {
     public $defaultZIndex = 30;
+    public $animZindex = 0;
 
     public function getHTMLContainerClass()
     {
@@ -931,9 +940,9 @@ class contentLink extends wsHTML5Link
         $res = parent::getAdditionnalContent();
         $animations = self::parseAnimations($this->image_rollover);
         foreach ($animations as $animation) {
-//            if (isset($animation['zindex'])) {
-//                $this->defaultZIndex = $animation['zindex'];
-//            }
+            if (isset($animation['zindex'])) {
+                $this->animZindex = $animation['zindex'];
+            }
         }
         $res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" ';
         if ($this->_isHiddenFirst($animations)) {
@@ -967,6 +976,11 @@ class contentLink extends wsHTML5Link
         }
         return false;
     }
+
+    public function getAddZIndex()
+    {
+        return parent::getAddZIndex() + $this->animZindex;
+    }
 }
 
 class eventOverlayLink extends wsHTML5Link
@@ -1749,13 +1763,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']);
@@ -1771,10 +1785,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);
@@ -1843,28 +1853,28 @@ class htmlMultimediaLink extends wsHTML5Link
         return $this->_content;
     }
 
-    public function getLottieContent($c, $width, $height)
-    {
-        $this->_config = ['width' => $this->width * $this->getCssScale(), 'height' => $this->height * $this->getCssScale()];
-        $parsedLottie = self::_parseLottieContent($c);
-
-        $lottieID = $this->compiler->addLottie($parsedLottie['animation'], $parsedLottie['params'], $parsedLottie['hash']);
-        return '<div class="lottie" data-lottie-id="' . $lottieID . '"></div>';
-    }
-
-    public static function _parseLottieContent($c)
-    {
-        $hash = hash('sha256', $c);
-        $start = mb_strpos($c, 'var animationData = {') + 20;
-        $end = mb_strpos($c, '};', $start) + 1;
-        $ad = mb_substr($c, $start, $end - $start);
-        $animationData = json_decode($ad);
-        preg_match('/var params = (\{.*\});/sU', $c, $matches);
-        $matches[1] = str_replace('container: document.getElementById(\'lottie\'),', '', $matches[1]);
-        $matches[1] = str_replace('animationData: animationData', '', $matches[1]);
-        $params = CJSON::decode($matches[1]);
-        return ['animation' => $animationData, 'params' => $params, 'hash' => $hash];
-    }
+//    public function getLottieContent($c, $width, $height)
+//    {
+//        $this->_config = ['width' => $this->width * $this->getCssScale(), 'height' => $this->height * $this->getCssScale()];
+//        $parsedLottie = self::_parseLottieContent($c);
+//
+//        $lottieID = $this->compiler->addLottie($parsedLottie['animation'], $parsedLottie['params'], $parsedLottie['hash']);
+//        return '<div class="lottie" data-lottie-id="' . $lottieID . '"></div>';
+//    }
+//
+//    public static function _parseLottieContent($c)
+//    {
+//        $hash = hash('sha256', $c);
+//        $start = mb_strpos($c, 'var animationData = {') + 20;
+//        $end = mb_strpos($c, '};', $start) + 1;
+//        $ad = mb_substr($c, $start, $end - $start);
+//        $animationData = json_decode($ad);
+//        preg_match('/var params = (\{.*\});/sU', $c, $matches);
+//        $matches[1] = str_replace('container: document.getElementById(\'lottie\'),', '', $matches[1]);
+//        $matches[1] = str_replace('animationData: animationData', '', $matches[1]);
+//        $params = CJSON::decode($matches[1]);
+//        return ['animation' => $animationData, 'params' => $params, 'hash' => $hash];
+//    }
 
     public function getHTMLContainerClass()
     {
@@ -1893,6 +1903,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;';