From: vincent@cubedesigners.com Date: Tue, 7 Jun 2022 19:52:24 +0000 (+0000) Subject: wait #5307 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=36b13c6af6968578773af5c25733af380f0f4bfd;p=cubeextranet.git wait #5307 --- diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index bd2aa0132..57701cfbc 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -82,10 +82,16 @@ class wsTools $svg = file_get_contents($in); } $svg = self::_disablePreserveRatio($svg); + $svg = self::_removeForeignObjects($svg); file_put_contents($out, $svg); return $out; } + protected static function _removeForeignObjects($svg) + { + return preg_replace('//U', '', $svg); + } + protected static function _disablePreserveRatio($in) { $str = 'preserveAspectRatio="none"'; 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 f3d829951..1058b78ae 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -756,6 +756,68 @@ class wsHTML5Compiler $this->addJsLib('thiriet', 'js/libs/fluidbook/cart/fluidbook.cart.thiriet.js'); } + public function writeCFOCCart() + { + + $this->lessVariables['import-cart-styles'] = 'cfoc'; + + $this->addJsLib('cfoc', 'js/libs/fluidbook/cart/fluidbook.cart.cfoc.js'); + + // NOTE: $this->config->basketReferences initially contains the uploaded filename and if we don't + // modify it, the writeCartConfig() function will replace it with the extracted data from the spreadsheet 🤐 + // It would be much better if the extracted data had its own variable but it would break too many things to + // change it now, so we'll follow the same approach. + + if (!empty($this->config->basketReferences)) { + if (file_exists($this->config->basketReferences) || CubeIT_Util_Url::isDistant($this->config->basketReferences)) { + $referencesFile = $this->config->basketReferences; + } else { + $referencesFile = $this->wdir . 'commerce/' . $this->config->basketReferences; + } + } + + $references = []; + + if (file_exists($referencesFile) || CubeIT_Util_Url::isDistant($referencesFile)) { + $raw_data = wsUtil::excelToArray($referencesFile); + $first_sheet_rows = reset($raw_data); // First sheet's data will be returned since it's the first array element + + // Expected headings are: EXCLU, LIGNE, EAN, REF, DESIGNATION, COULEUR, QTE MINI, PRIX TTC + $column_headings = array_shift($first_sheet_rows); // We assume the first row will be the headings, so we slice it off + $column_headings = array_map(function ($heading) { // Clean the headings a bit + return trim(strtoupper($heading)); + }, $column_headings); + + foreach ($first_sheet_rows as $row) { + + // First, trim values in case there are any stray spaces + $row = array_map('trim', $row); + + // Next, set the headings as keys to make it easier to refer to the row values by name + $row = array_combine($column_headings, $row); + + // For the 'EXCLU' field, this should be converted to a boolean + $row['EXCLU'] = ('exclu boutique' === $row['EXCLU']); + + // The EAN and REF are required, so if they don't exist, we can assume it's not a valid row + if (empty($row['EAN']) || empty($row['REF'])) { + continue; + } + + $references[$row['REF']][$row['EAN']] = $row; + } + + } + + $this->config->basketReferences = $references; + + // It's possible to use the cartExtraSettings field in the parameters to define publication specific settings, + // such as the subject line used in the e-mail that is sent from the cart validation + $extra = wsHTML5Link::parseExtras($this->book->parametres->cartExtraSettings, true); + + $this->config->cartEmailSubject = $extra['email_subject'] ?? 'Récapitulatif de votre commande CFOC'; + } + public function writeCartConfig() { if ($this->book->parametres->cartLinkAppearance == 'overlay') { @@ -789,6 +851,9 @@ class wsHTML5Compiler $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js'); $this->addJsLib('mopec', 'js/libs/fluidbook/cart/fluidbook.cart.mopec.js'); break; + case 'CFOC': + $this->writeCFOCCart(); + break; default: break; } @@ -2091,7 +2156,7 @@ height="0" width="0" style="display:none;visibility:hidden"> $dupData = $linkData; $dupData['image'] = ''; $dupData['animation'] = ''; - $dupData['to'] = $linkData['image']; + $dupData['to'] = self::_SVGCleanAsset($linkData['image']); if ($dupData['image_rollover'] != 'none' && !stristr($dupData['image_rollover'], '=')) { $dupData['rollover'] = $dupData['image_rollover']; } @@ -2623,6 +2688,22 @@ height="0" width="0" style="display:none;visibility:hidden"> } } + protected function _SVGCleanAsset($a) + { + if (!stristr($a, '.svg')) { + return $a; + } + $clean = str_replace('.svg', '.o.svg', $a); + $path = $this->wdir . '/' . $a; + $opt = $this->wdir . '/' . $clean; + + if (!file_exists($opt) || !filesize($opt) || filemtime($path) > filemtime($opt)) { + wsTools::_optimizeSVG($path, $opt); + } + return $clean; + + } + public function supportSVG() { if (!$this->phonegap) { 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 710f1326d..0b79db4ef 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -177,14 +177,13 @@ class wsHTML5Link return new webVideoLink($id, $init, $compiler); case 11: return new actionLink($id, $init, $compiler); - case 12: - if ($compiler->book->parametres->basketManager === 'Puma' || $compiler->book->parametres->basketManager === 'MIF' || $compiler->book->parametres->basketManager === 'Flexipan') { - return new zoomProductLink($id, $init, $compiler); - } + case 12: // Basket / Cart links if ($compiler->book->parametres->product_zoom_references !== '') { return new zoomProductLink($id, $init, $compiler); } switch ($compiler->book->parametres->basketManager) { + case 'CFOC': + return new CFOCCartLink($id, $init, $compiler); case 'GrandVision': return new grandVisionCartLink($id, $init, $compiler); case 'GrandPavois': @@ -196,6 +195,9 @@ class wsHTML5Link case 'Remarkable': return new remarkableCartLink($id, $init, $compiler); case 'ZoomProductLink': + case 'Flexipan': + case 'Puma': + case 'MIF': return new zoomProductLink($id, $init, $compiler); default : return new cartLink($id, $init, $compiler); @@ -1737,6 +1739,24 @@ class cartLink extends normalLink } } +class CFOCCartLink extends normalLink +{ + public function getUrl() + { + return '#/cart/add/' . $this->to; + } + + // public function getAdditionnalContent() + // { + // return parent::getAdditionnalContent() . ' data-cfoc-ref="' . $this->to . '" '; + // } + + public function getTooltip() + { + return 'Ajouter à ma sélection'; + } +} + class remarkableCartLink extends cartLink { @@ -1744,7 +1764,7 @@ class remarkableCartLink extends cartLink class layerLink extends imageLink { - protected $maxzoom_default = 2; + protected $maxzoom_default = 1; public $defaultZIndex = 31; public function ignore()