From: Vincent Vanwaelscappel Date: Tue, 3 Sep 2024 10:56:48 +0000 (+0200) Subject: wip #6998 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ba50e0d375389ac4779c487007cc7be148f1e431;p=fluidbook-toolbox.git wip #6998 @0.5 --- diff --git a/app/Fluidbook/Compiler/Cart.php b/app/Fluidbook/Compiler/Cart.php index ec4f0ba09..05227b843 100644 --- a/app/Fluidbook/Compiler/Cart.php +++ b/app/Fluidbook/Compiler/Cart.php @@ -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/'; diff --git a/app/Fluidbook/Compiler/Tabs.php b/app/Fluidbook/Compiler/Tabs.php index 2947bc5af..95b50badf 100644 --- a/app/Fluidbook/Compiler/Tabs.php +++ b/app/Fluidbook/Compiler/Tabs.php @@ -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; } } diff --git a/app/Models/FluidbookHealthIssues.php b/app/Models/FluidbookHealthIssues.php index 81234e0de..9bab3e746 100644 --- a/app/Models/FluidbookHealthIssues.php +++ b/app/Models/FluidbookHealthIssues.php @@ -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 = '' . $data['fixText'] . ''; } diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 9f4b3e1f7..e4595cf70 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -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;