]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6998 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 3 Sep 2024 10:56:48 +0000 (12:56 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 3 Sep 2024 10:56:48 +0000 (12:56 +0200)
app/Fluidbook/Compiler/Cart.php
app/Fluidbook/Compiler/Tabs.php
app/Models/FluidbookHealthIssues.php
app/Models/FluidbookPublication.php

index ec4f0ba099983ff2c38981ce12d8fb912510e6d0..05227b843dc303b63e2f6cab18b6ad1e4eeb8cfb 100644 (file)
@@ -29,11 +29,14 @@ trait Cart
 
         $cdir = $this->wdir . '/commerce/';
         $file = $cdir . $this->fluidbookSettings->basketReferences;
-        $refs = ExcelToArray::excelToArrayKeyVars($file, 'Excel2007', true);
+        $refs = ExcelToArray::excelToArrayKeyVars($file, null, true);
         $this->config->basketReferences = [];
         foreach ($refs as $ean => $ref) {
-            $this->config->basketReferences[$ean] = $ref;
-            $this->config->basketReferences[$ean]['angle_url'] = base64_encode(file_get_contents($this->wdir . '/commerce/opt/' . $ean . '-angle.jpg'));
+            $this->config->set('basketReferences.' . $ean, $ref);
+            $f = $this->wdir . '/commerce/opt/' . $ean . '-angle.jpg';
+            if (file_exists($f)) {
+                $this->config->set('basketReferences.' . $ean . '.angle_url', base64_encode(file_get_contents($f)));
+            }
         }
 
         $odir = $cdir . '/opt/';
index 2947bc5af3537ca3e6231d9f3e4f2848dd66d4d4..95b50badfd029c232be4532edf4943ba6a43590a 100644 (file)
@@ -84,23 +84,32 @@ trait Tabs
             $this->config->$pagesList = $list;
         }
 
-        $this->checkTabsSVG($opt);
+        if (!$this->checkTabsSVG($opt)) {
+            $this->config->svgTabs = false;
+            $this->config->tabsHTML5 = '';
+        }
     }
 
     protected function checkTabsSVG($svg)
     {
-        $xmlsvg = simplexml_load_string(file_get_contents($svg));
-        $xmlsvg->registerXPathNamespace('svg', 'http://www.w3.org/2000/svg');
-        $missing = [];
-        for ($i = 1; $i <= count($this->config->tabsPages); $i++) {
-            if (!$xmlsvg->xpath('//svg:g[@id="o' . $i . '"]')) {
-                $missing[] = 'o' . $i;
+        try {
+            $xmlsvg = simplexml_load_string(file_get_contents($svg));
+            $xmlsvg->registerXPathNamespace('svg', 'http://www.w3.org/2000/svg');
+            $missing = [];
+            for ($i = 1; $i <= count($this->config->tabsPages); $i++) {
+                if (!$xmlsvg->xpath('//svg:g[@id="o' . $i . '"]')) {
+                    $missing[] = 'o' . $i;
+                }
             }
-        }
 
-        if (count($missing)) {
-            $this->addIssue(FluidbookHealthIssues::TYPE_TABS_MISSING_TAB_ID, ['missing_tabs' => implode(', ', $missing)]);
+            if (count($missing)) {
+                $this->addIssue(FluidbookHealthIssues::TYPE_TABS_MISSING_TAB_ID, ['missing_tabs' => implode(', ', $missing)]);
+            }
+        } catch (\Exception $e) {
+            $this->addIssue(FluidbookHealthIssues::TYPE_TABS_INVALID_SVG, ['error' => $e->getMessage()]);
+            return false;
         }
+        return true;
 
     }
 }
index 81234e0de7046f356c6a2dc4e5d3e80d852fb1f7..9bab3e746c99d5d8e147996916623adaea964099 100644 (file)
@@ -21,6 +21,7 @@ class FluidbookHealthIssues extends ToolboxModel
     const TYPE_THUMBS_PDF_MISSING = 8;
     const TYPE_TIMEOUT_MAKE_SVG = 9;
     const TYPE_NOT_VALID_IMAGE_IN_LINK = 10;
+    const TYPE_TABS_INVALID_SVG = 11;
 
     const CRIT_ERROR = 5;
     const CRIT_WARNING = 3;
@@ -157,6 +158,13 @@ class FluidbookHealthIssues extends ToolboxModel
                     'fixText' => __('Aller sur l\'éditeur de liens'),
                     'fixURL' => $linkeditorURL,
                 ],
+            static::TYPE_TABS_INVALID_SVG =>
+                [
+                    'summary' => __('Fichier SVG des onglets non valide'),
+                    'criticality' => self::CRIT_ERROR,
+                    'text' => 'Le format du SVG des onglets est invalide. L\'erreur suivante est retournée : :error',
+                    'fixText' => __('Corriger le SVG'),
+                ],
         ];
     }
 
@@ -177,6 +185,8 @@ class FluidbookHealthIssues extends ToolboxModel
 
             if (!isset($data['fixText'])) {
                 $fix = '';
+            } else if (!isset($data['fixURL'])) {
+                $fix = $data['fixText'];
             } else {
                 $fix = '<a class="btn-link" target="_blank" href="' . __($data['fixURL'], $replaceRaw) . '">' . $data['fixText'] . '</a>';
             }
index 9f4b3e1f7eb7114e61ad724909a2a3bf4938967b..e4595cf702b0b654b05e500bdee4bebd5e69f670 100644 (file)
@@ -46,6 +46,7 @@ use App\Models\Traits\PublicationSettings;
 use App\Models\Traits\PublicationTags;
 use App\Models\Traits\SCORMVersionTrait;
 use App\Models\Traits\ToolboxSettings;
+use App\Slack\Mattermost;
 use App\Slack\Slack;
 use App\SubForms\Link\Base;
 use Cubedesigners\UserDatabase\Permissions;