From 38b132961f7e3920ba245d38176be05bd1e17c6f Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 14 Jun 2021 14:35:32 +0000 Subject: [PATCH] wait #4463 @6 --- .../twofaces/class.ws.html5.compiler.php | 106 ++++++++++++++---- .../html5/twofaces/class.ws.html5.links.php | 80 +++++++------ 2 files changed, 130 insertions(+), 56 deletions(-) diff --git a/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php b/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php index b384ee93c..92b3f0df7 100644 --- a/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php @@ -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 .= " + + +"; + $this->book->parametres->statsCustom = ' + +'; + } } 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 .= '' . "\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 = ''; } - } 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 .= ''; } } @@ -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:'; diff --git a/inc/ws/Util/html5/twofaces/class.ws.html5.links.php b/inc/ws/Util/html5/twofaces/class.ws.html5.links.php index 18f89fcd4..f7778a5d3 100644 --- a/inc/ws/Util/html5/twofaces/class.ws.html5.links.php +++ b/inc/ws/Util/html5/twofaces/class.ws.html5.links.php @@ -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, '
')) { -// 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 '
'; - } - - 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 '
'; +// } +// +// 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;'; -- 2.39.5