]> _ Git - cubeextranet.git/commitdiff
wip #4240 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 20 Feb 2021 18:12:43 +0000 (18:12 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 20 Feb 2021 18:12:43 +0000 (18:12 +0000)
inc/ws/Util/class.ws.util.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 443e3bb69fbc8354d63b3036df33b124db5cb2ba..e01544bfb22a5e8bc79196082ec6f9fbf92d86c5 100644 (file)
@@ -78,7 +78,7 @@ class wsUtil
         return $res;\r
     }\r
 \r
-    public static function excelToArrayKeyVars($excelFile, $reader = 'Excel2007')\r
+    public static function excelToArrayKeyVars($excelFile, $reader = 'Excel2007', $skipEmptyId = false)\r
     {\r
         $worksheets = self::excelToArray($excelFile, false, $reader);\r
         $res = [];\r
@@ -99,6 +99,9 @@ class wsUtil
                     }\r
                     $id = trim($line[0]);\r
                     if ($id === '') {\r
+                        if ($skipEmptyId) {\r
+                            continue;\r
+                        }\r
                         $id = $i;\r
                     }\r
                     $res[$id] = $r;\r
index b5eefec41934e196aec08e8cacd466bed6c1ddb4..58434ea768142b009e00231859125b859a187013 100644 (file)
@@ -431,7 +431,7 @@ class wsHTML5Compiler
 
         $cdir = $this->wdir . '/commerce/';
         $file = $cdir . $this->book->parametres->basketReferences;
-        $this->config->basketReferences = wsUtil::excelToArrayKeyVars($file);
+        $this->config->basketReferences = wsUtil::excelToArrayKeyVars($file, 'Excel2007', true);
 
         $odir = $cdir . '/opt/';
         if (!file_exists($odir)) {
@@ -456,12 +456,16 @@ class wsHTML5Compiler
             if (!$ean) {
                 continue;
             }
+            if (!isset($this->config->basketReferences[$ean])) {
+                continue;
+            }
 
             $f = $file->getPathname();
 
             if ($ext === 'mp4') {
+                $n = $ean . '-360.mp4';
                 $this->config->basketReferences[$ean]['360'] = true;
-                $opt = $odir . '/' . $ean . '-360.mp4';
+                $opt = $odir . '/' . $n;
                 if (!file_exists($opt) || !filesize($opt) || filemtime($opt) < filemtime($f)) {
                     // Optimize original video
                     `ffmpeg -i $f -filter:v scale=360:-2 -vcodec libx264 -an $opt`;
@@ -472,18 +476,18 @@ class wsHTML5Compiler
                 } else if (in_array('angle', $e)) {
                     $type = 'angle';
                 }
+                $n = $ean . '-' . $type . '.jpg';
                 $this->config->basketReferences[$ean][$type] = true;
-                $opt = $odir . '/' . $ean . '-' . $type . '.jpg';
+                $opt = $odir . '/' . $n;
                 if (!file_exists($opt) || !filesize($opt) || filemtime($opt) < filemtime($f)) {
                     // Optimize original image
                     $convert = new CubeIT_Image_Resizer_ImageMagick();
                     $convert->loadImage($f);
-                    $convert->resize(1080, null, 'ratio', false, 'C', 'M', 'ffffff');
-                    $convert->output('jpg', $f, 75);
+                    $convert->resize(1080, null, 'ratio', false, 'C', 'M', 'white');
+                    $convert->output('jpg', $opt, 75);
                 }
             }
-
-
+            $this->vdir->copy($opt, 'data/commerce/' . $n);
         }
 
     }