From: vincent@cubedesigners.com Date: Tue, 2 May 2023 17:58:51 +0000 (+0000) Subject: wait #5703 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b61ca73c7d21b3376daf52c16d8a4abcd45c9d5b;p=cubeextranet.git wait #5703 @2 --- diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index ba8edd4d6..df2ff098d 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -743,33 +743,51 @@ class wsHTML5Compiler } $this->config->product_zoom_references = []; - $files = ['360°', 'Image supplémentaire', 'Fiche technique']; + $fileCols = ['360°', 'Image supplémentaire', 'Fiche technique']; foreach ($this->config->basketReferences as $ref => $data) { $r = []; - foreach ($files as $file) { - if (!isset($data[$file])) { - $data[$file] = ''; - } - $fname = trim($data[$file]); - if ($fname !== '') { - $fname = str_replace(' ', '-', $fname); - $wfile = $this->wdir . 'commerce/' . $fname; + foreach ($fileCols as $col) { + $slides = []; + $button = ''; + if (!isset($data[$col]) || !trim($data[$col])) { + $files = []; + $this->config->basketReferences[$ref][$col] = ''; + } else { + $files = explode(',', $data[$col]); - if (file_exists($wfile)) { + $files = array_map(function ($v) { + return str_replace([' ', '(', ')'], ['-', '', ''], trim($v)); + }, $files); + + $files = array_filter($files, function ($v) { + if (!$v) { + return false; + } + return file_exists($this->wdir . 'commerce/' . $v); + }); + + foreach ($files as $fname) { + $wfile = $this->wdir . 'commerce/' . $fname; if (stristr($wfile, '.png') || stristr($wfile, '.jpg')) { $s = CubeIT_Image::getimagesize($wfile); - $html = ''; + if (count($files) <= 1) { + $button .= ''; + } else { + $slides[] = ['path' => 'data/commerce/' . $fname, 'absolute_path' => $wfile]; + } } else { - $html = 'data/commerce/' . $fname; + $button = 'data/commerce/' . $fname; } $this->vdir->copy($wfile, 'data/commerce/' . $fname); - $fname = $html; - } else { - $fname = ''; } } - $r[] = $fname; + if (count($files) > 1) { + $button = slideshowLink::generateSlideshowHtml($slides, [], ['type' => 'loop']); + $this->addSlideshowLibrary(false); + } + $r[] = $button; } + $this->config->product_zoom_references[$ref] = $r; } @@ -2432,7 +2450,6 @@ height="0" width="0" style="display:none;visibility:hidden"> } } - $this->config->pagesOfCustomLinks = $pagesOfCustomLinks; $i = 1; @@ -2444,12 +2461,10 @@ height="0" width="0" style="display:none;visibility:hidden"> $allLinksData = []; $gamifyCoins = []; - usort($links, array($this, '_sortLinks')); - $this->log('Links 3.5'); - foreach ($links as $linkData) { + if (in_array($linkData['type'], $ignore)) { continue; } @@ -2481,6 +2496,7 @@ height="0" width="0" style="display:none;visibility:hidden"> $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 @@ -2529,7 +2545,6 @@ height="0" width="0" style="display:none;visibility:hidden"> if ($link->keep()) { $this->hiddenContents[] = $link->getHTMLContainer(); } - $this->log('Links 4 :: ' . $link->to); } $this->log('Links 4'); diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index d25fa138d..e565160ff 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -3092,10 +3092,6 @@ class slideshowLink extends normalLink return 'data-slideshow="' . rawurlencode($this->generateSlideshow('popup')) . '" '; } -// public function keep() { -// return true; -// } - public function getDefaultTooltip() { return 'view slideshow'; @@ -3112,13 +3108,6 @@ class slideshowLink extends normalLink $slideshowID = 'slideshow_' . $this->uid; $XML_path = $this->path_absolute . '/slideshow.xml'; // Optional file so it may not exist - // Default Slick settings (can be overridden by slideshow.xml) - $slideshow_settings = [ - 'autoplay' => false, - 'fade' => false, - ]; - - $slides = []; $slides_options = []; @@ -3165,16 +3154,47 @@ class slideshowLink extends normalLink $thumbnails = (count($slides) > 1); } + $options = ['openIndex' => $this->extra, + 'thumbnails' => $thumbnails, + 'thumbnail_height' => $this->thumbnail_height, + 'id' => $slideshowID, + 'library' => ($context === 'popup' ? $this->compiler->book->parametres->popupSlideshowLibrary : $this->compiler->book->parametres->inlineSlideshowLibrary) + ]; + + return self::generateSlideshowHtml($slides, $options, $slideshow_settings, $slides_options); + + } + + + public static function generateSlideshowHtml($slides, $options = [], $slideshowSettings = [], $slidesOptions = []) + { + // Default Slick settings (can be overridden by slideshow.xml) + $slideshowDefaultSettings = [ + 'autoplay' => false, + 'fade' => false, + 'type' => 'slide', + 'rewind' => false, + ]; + + $defaultOptions = [ + 'library' => 'splide', + 'openIndex' => 0, + 'thumbnails' => false, + 'id' => 'slideshow_' . rand(1000, 1000000), + 'context' => 'popup', + 'thumbnail_height' => 80, + ]; + $options = array_merge($defaultOptions, $options); + $slideshowSettings = array_merge($slideshowDefaultSettings, $slideshowSettings); + // Main slider - $res = '
' . $this->_slides($slides, $slides_options) . '
'; + $res = '
' . self::_slides($slides, $slidesOptions) . '
'; // Thumbnails slider - if ($thumbnails) { - $res .= '
' . $this->_slides($slides, ['show_captions' => false, 'max_height' => $this->thumbnail_height]) . '
'; + if ($options['thumbnails']) { + $res .= '
' . self::_slides($slides, ['show_captions' => false, 'max_height' => $options['thumbnail_height']]) . '
'; } - - $lib = $context === 'popup' ? $this->compiler->book->parametres->popupSlideshowLibrary : $this->compiler->book->parametres->inlineSlideshowLibrary; - return '
' . $res . '
'; + return '
' . $res . '
'; } protected function _getSlidesFromDirectory($path) @@ -3195,14 +3215,14 @@ class slideshowLink extends normalLink if (!in_array($ext, $this->allowed_extensions)) { continue; } - $slides[] = ['path' => $this->path . '/' . $file->getFilename(), 'absolute_path' => $file->getPathname(), 'caption' => null]; + $slides[] = ['path' => $this->path . '/' . $file->getFilename(), 'absolute_path' => $file->getPathname(), 'caption' => null]; uasort($slides, [$this, '_orderSlidesByFilename']); } return $slides; } - protected function _slides($slides, $options = []) + protected static function _slides($slides, $options = []) { $default_options = [ 'show_captions' => true, @@ -3212,10 +3232,13 @@ class slideshowLink extends normalLink $options = array_merge($default_options, $options); + $defaultSlide = ['caption' => null]; + $res = '
'; $res .= '