From e00d421848a052209ce49ee30aef441e53d83ede Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 23 Oct 2020 19:37:27 +0000 Subject: [PATCH] wip #3961 @1 --- inc/ws/Metier/class.ws.book.parametres.php | 29 +++++++++++++-- .../html5/master/class.ws.html5.compiler.php | 37 +++++++++++++++++-- .../html5/master/class.ws.html5.links.php | 6 +++ 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index f4014ce1d..eb186ae65 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -515,8 +515,31 @@ class wsBookParametres extends wsParametres $this->fields['product_zoom_references'] = array('type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Références produits'), 'grade' => 3, 'fileFilter' => $basketFilter, 'hint' => __('Fichier contenant les références produits'), 'dir' => 'commerce'); $this->fields['product_zoom_buttons_order'] = ['type' => 'combo', 'datas' => [__('De la droite vers la gauche') => 'right', __('De la gauche vers la droite') => 'left'], 'editable' => true, 'grade' => 3, 'default' => 'right', 'label' => __('Order des boutons')]; - $icons = [__('Aucune') => 'none', __('Partage') => 'nav-share', __('Ecran') => 'icon-site', __('Télécharger') => 'nav-download', 'PDF' => 'icon-pdf', 'Video' => 'icon-video', __('Lien') => 'icon-link', __('Code') => 'icon-code', __('QR code') => 'icon-qr', __('Article') => 'icon-article', __('Panier (sac)') => 'nav-basket', __('Panier (caddie)') => 'nav-cart-caddie']; - $actions = [__('Ouvrir un lien') => 'link', __('Ouvrir en iframe') => 'iframe', __('Copier un contenu') => 'copy', __('Vidéo') => 'video', __('Ajouter au panier') => 'addtocart']; + $icons = [ + __('Aucune') => 'none', + __('Partage') => 'nav-share', + __('Ecran') => 'icon-site', + __('Télécharger') => 'nav-download', + 'PDF' => 'icon-pdf', + 'Video' => 'icon-video', + __('Lien') => 'icon-link', + __('Code') => 'icon-code', + __('QR code') => 'icon-qr', + __('Article') => 'icon-article', + __('Panier (sac)') => 'nav-basket', + __('Panier (caddie)') => 'nav-cart-caddie', + __('360°') => 'icon-360', + __('Photo') => 'icon-photo']; + $actions = [ + __('Ouvrir un lien') => 'link', + __('Ouvrir en iframe') => 'iframe', + __('Copier un contenu') => 'copy', + __('Web Vidéo') => 'video', + __('Vidéo') => 'videofile', + __('Vidéo (boucle, sans contrôle)') => 'videogif', + __('Voir une image') => 'image', + __('Ajouter au panier') => 'addtocart' + ]; $f = []; for ($i = 1; $i <= 3; $i++) { $this->fields['product_zoom_label_' . $i] = ['type' => 'text', 'label' => __('Label du bouton') . ' ' . $i, 'default' => '', 'editable' => true, 'grade' => 3]; @@ -615,7 +638,7 @@ class wsBookParametres extends wsParametres $this->fields['basketReferences'] = array('type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Références produits'), 'grade' => 3, 'fileFilter' => $basketFilter, 'hint' => __('Fichier contenant les références produits'), 'dir' => 'commerce'); $this->fields['basketImages'] = array('type' => 'freefile', 'default' => '', 'editable' => true, - 'label' => __('Images des produits'), 'grade' => 5, 'fileFilter' => $imageFilter, 'hint' => __('Chaque image doit avoir pour nom exact la référence du produit'), + 'label' => __('Images des produits'), 'grade' => 3, 'multiple' => true, 'dir' => 'commerce'); $this->fields['basketPDFBackground'] = array('type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Fond du PDF (bon de commande)'), 'grade' => 5, 'fileFilter' => $epsFilter, 'hint' => __('Fond du bon de commande'), 'dir' => 'commerce'); 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 1b55fceac..196cadb56 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -410,10 +410,43 @@ class wsHTML5Compiler $this->config->seoArticles = $this->seoArticles; } + public function writePumaCart() + { + $this->addJsLib('parsley', 'js/libs/parsley.min.js'); + $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js'); + $this->addJsLib('puma', 'js/libs/fluidbook/cart/fluidbook.cart.puma.js'); + $this->addVideoJs(); + + $this->config->basketReferences = wsUtil::excelToArrayKeyVars($this->wdir . '/commerce/' . $this->book->parametres->basketReferences); + $this->config->product_zoom_references = []; + $files = ['360°', 'Image supplémentaire', 'Fiche technique']; + foreach ($this->config->basketReferences as $ref => $data) { + $r = []; + foreach ($files as $file) { + $fname = trim($data[$file]); + if ($fname !== '') { + $fname = str_replace(' ', '-', $fname); + $wfile = $this->wdir . '/commerce/' . $fname; + if (file_exists($wfile)) { + $fname = 'data/commerce/' . $fname; + $this->vdir->copy($wfile, $fname); + } else { + $fname = ''; + } + } + $r[] = $fname; + } + $this->config->product_zoom_references[$ref] = $r; + } + } + public function writeCartConfig() { if ($this->config->basket) { $this->addJsLib('cart', 'js/libs/fluidbook/fluidbook.cart.js'); + if ($this->config->basketManager === 'Puma') { + return $this->writePumaCart(); + } switch ($this->config->basketManager) { case 'Remarkable': $this->addJsLib('parsley', 'js/libs/parsley.min.js'); @@ -425,10 +458,6 @@ class wsHTML5Compiler $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js'); $this->addJsLib('mopec', 'js/libs/fluidbook/cart/fluidbook.cart.mopec.js'); break; - case 'Puma': - $this->addJsLib('parsley', 'js/libs/parsley.min.js'); - $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js'); - $this->addJsLib('puma', 'js/libs/fluidbook/cart/fluidbook.cart.puma.js'); default: break; } 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 73a87b45f..24cca7d65 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -80,6 +80,9 @@ class wsHTML5Link } return new videoPopupLink($id, $init, $compiler); case 7: + if ($compiler->book->parametres->basketManager === 'Puma') { + return new cartLink($id, $init, $compiler); + } switch ($compiler->book->parametres->customLinkClass) { case 'WescoLink': return new wescoLink($id, $init, $compiler); @@ -109,6 +112,9 @@ class wsHTML5Link case 11: return new actionLink($id, $init, $compiler); case 12: + if ($compiler->book->parametres->basketManager === 'Puma') { + return new zoomProductLink($id, $init, $compiler); + } if ($compiler->book->parametres->product_zoom_references !== '') { return new zoomProductLink($id, $init, $compiler); } -- 2.39.5