From: Vincent Vanwaelscappel Date: Tue, 19 Dec 2023 10:17:06 +0000 (+0100) Subject: wip #6554 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=54ad9ada2c352e81719a493403dc5b497cfbdc17;p=fluidbook-toolbox.git wip #6554 @1 --- diff --git a/app/Fluidbook/Compiler/Cart.php b/app/Fluidbook/Compiler/Cart.php index 5d3c14f39..6ebd0f7c9 100644 --- a/app/Fluidbook/Compiler/Cart.php +++ b/app/Fluidbook/Compiler/Cart.php @@ -8,6 +8,7 @@ use Cubist\Util\Files\Files; use Cubist\Util\Graphics\Resizer; use Cubist\Util\Text; use Cubist\Util\Url; +use Fluidbook\Tools\Links\ZoomLink; use SplFileInfo; trait Cart @@ -259,6 +260,9 @@ trait Cart } + /** + * @throws \Exception + */ public function writePumaCart() { $this->lessVariables['import-cart-styles'] = 'puma'; @@ -270,24 +274,34 @@ trait Cart $this->addJsLib('exceljs', 'js/libs/exceljs.min.js'); $this->addVideoJs(); - $this->config->basketReferences = ExcelToArray::excelToArrayKeyVars($this->wdir . 'commerce/' . $this->fluidbookSettings->basketReferences); + $this->log('Puma libs inited'); + + $cartReferences = ExcelToArray::excelToArrayKeyVars($this->wdir . 'commerce/' . $this->fluidbookSettings->basketReferences); + $this->log('Puma excel file parsed'); $eanFile = $this->wdir . 'commerce/ean.xlsx'; if (file_exists($eanFile)) { - $this->config->eanReferences = ExcelToArray::excelToArrayIndexKeyVars($eanFile); + $eanReferences = ExcelToArray::excelToArrayIndexKeyVars($eanFile); + $this->log('Puma ean file parsed'); + $this->config->setRaw('eanReferences', $eanReferences); + $this->log('Puma ean data set'); } + $this->getLinksAndRulers($links, $rulers); foreach ($links as $link) { - if ($link['type'] == '12' && isset($this->config->basketReferences[$link['to']])) { - $this->config->basketReferences[$link['to']]['zoom_image'] = 'data/links/zoom_' . $link['uid'] . '.jpg'; - $this->config->basketReferences[$link['to']]['zoom_url'] = base64_encode(file_get_contents($this->dir . '/data/links/zoom_' . $link['uid'] . '.jpg')); - $this->config->basketReferences[$link['to']]['zoom_image_ratio'] = $link['width'] / $link['height']; + if ($link['type'] == '12' && isset($cartReferences[$link['to']])) { + ; + $cartReferences[$link['to']]['zoom_image'] = 'data/links/zoom_' . $link['uid'] . '.jpg'; + //$cartReferences[$link['to']]['zoom_url'] = base64_encode(file_get_contents($this->dir . '/data/links/zoom_' . $link['uid'] . '.jpg')); + $cartReferences[$link['to']]['zoom_image_ratio'] = $link['width'] / $link['height']; } } - $this->config->product_zoom_references = []; + $this->log('Puma cart completed'); + + $productZoomReferences = []; $files = ['360°', 'Image supplémentaire', 'Fiche technique']; - foreach ($this->config->basketReferences as $ref => $data) { + foreach ($cartReferences as $ref => $data) { $r = []; foreach ($files as $file) { if (!isset($data[$file])) { @@ -306,8 +320,14 @@ trait Cart } $r[] = $fname; } - $this->config->product_zoom_references[$ref] = $r; + $productZoomReferences[$ref] = $r; } + $this->log('Puma product zoom done'); + + $this->config->setRaw('product_zoom_references', $productZoomReferences); + $this->config->setRaw('basketReferences', $cartReferences); + + $this->log('Puma cart written'); } @@ -338,7 +358,6 @@ trait Cart if (file_exists($referencesFile) || Url::isDistant($referencesFile)) { $rows = ExcelToArray::excelToArrayFirstSheet($referencesFile); - // Expected headings are: EXCLU, LIGNE, EAN, REF, DESIGNATION, COULEUR, QTE MINI, PRIX TTC $column_headings = array_shift($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 diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index 0a5c1603a..c34a0b78c 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -602,7 +602,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError if (null === $this->logtime) { $this->logtime = $currenttime; } - $time = $currenttime - $this->logtime; + $time = max(0.0001, $currenttime - $this->logtime); $log = $step . ' | ' . round($time, 4) . 's' . "\n"; fwrite($this->logfp, $log); fflush($this->logfp); @@ -716,6 +716,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError $this->writeImages(); $this->log('Images written'); $this->writeCartConfig(); + $this->log('Cart written'); $this->writeXMLArticles(); $this->log('XML Articles written'); $this->writeSlider();