]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6554 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Dec 2023 10:17:06 +0000 (11:17 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 19 Dec 2023 10:17:06 +0000 (11:17 +0100)
app/Fluidbook/Compiler/Cart.php
app/Fluidbook/Compiler/Compiler.php

index 5d3c14f393eb76b3edd8be01561b2f00ab92fb1b..6ebd0f7c90d006f0c05c73eff84e35aa0dfa237c 100644 (file)
@@ -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
index 0a5c1603a58e9f77929d061b764dfba9c8da356a..c34a0b78c2a5e455d6c8a031be6cdc6f4e70f3af 100644 (file)
@@ -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();