From 8b06c8052a867bcfac104130906bd134af3243d0 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Sat, 24 Feb 2024 14:10:55 +0100 Subject: [PATCH] wait #6750 @1 --- app/Fluidbook/Compiler/Compiler.php | 12 +-- app/Fluidbook/Compiler/Links.php | 42 +---------- app/Fluidbook/Compiler/Tabs.php | 105 +++++++++++++++++++++++++++ app/Models/FluidbookHealthIssues.php | 11 ++- composer.lock | 95 ++++++++++++------------ 5 files changed, 166 insertions(+), 99 deletions(-) create mode 100644 app/Fluidbook/Compiler/Tabs.php diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index d931efe98..6fc5a6f27 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -51,6 +51,7 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError use Cache; use Search; use Accessibility; + use Tabs; /** @var Lock */ protected $lock; @@ -506,17 +507,8 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError $this->config->vectorPages = array_diff(ArrayUtil::parseRange($this->config->vectorPages), $this->config->rasterizePages); $this->numerotation = $this->config->numerotation = explode(',', $this->getFluidbook()->page_numbers); - $hideOnPages = ArrayUtil::parseRange($this->config->tabsHideOnPages); - $this->config->tabsDisabledOnPages = ArrayUtil::parseRange($this->config->tabsDisabledOnPages); + $this->initTabsConfig(); - if ($this->config->tabsHideOnCover) { - $hideOnPages[] = 0; - $hideOnPages[] = 1; - } - if ($this->config->tabsHideOnLastPage) { - $hideOnPages[] = count($this->pages); - } - $this->config->tabsHideOnPages = $hideOnPages; $this->config->triggersLinks = []; $this->config->hasContentLock = false; } diff --git a/app/Fluidbook/Compiler/Links.php b/app/Fluidbook/Compiler/Links.php index cb21d421d..55cd4560b 100644 --- a/app/Fluidbook/Compiler/Links.php +++ b/app/Fluidbook/Compiler/Links.php @@ -84,47 +84,7 @@ trait Links $this->vdir->copyDirectory($d['dir'], $d['fdir']); } - if ($this->fluidbookSettings->tabsHTML5 != '' && file_exists($this->wdir . '/' . $this->fluidbookSettings->tabsHTML5)) { - $ext = Files::getExtension($this->fluidbookSettings->tabsHTML5); - if ($ext === 'zip') { - $links['tabs'] = [ - 'page' => 'background', - 'top' => 0, - 'left' => 0, - 'width' => 100, - 'height' => 100, - 'type' => Link::MULTIMEDIA, - 'to' => $this->fluidbookSettings->tabsHTML5, - 'image' => '', - 'inline' => 1, - 'interactive' => 1, - 'class' => 'tabslink', - 'uid' => 'tabs', - ]; - } else if ($ext === 'svg') { - $this->vdir->copy($this->wdir . '/' . $this->fluidbookSettings->tabsHTML5, 'data/tabs.svg'); - $this->config->svgTabs = true; - $pagesLists = ['tabsPages', 'tabsSections']; - - foreach ($pagesLists as $pagesList) { - $e = explode(',', $this->fluidbookSettings->$pagesList); - $list = []; - foreach ($e as $k => $v) { - $v = trim($v); - if ($v === '') { - continue; - } - if ($v !== '-') { - if ($this->fluidbookSettings->tabsPagesNumbers === 'virtual') { - $v = $this->virtualToPhysical($v); - } - } - $list[] = $v; - } - $this->config->$pagesList = $list; - } - } - } + $this->writeTabs(); $pagesOfCustomLinks = []; $hiddenLinks = []; diff --git a/app/Fluidbook/Compiler/Tabs.php b/app/Fluidbook/Compiler/Tabs.php new file mode 100644 index 000000000..4be7cf026 --- /dev/null +++ b/app/Fluidbook/Compiler/Tabs.php @@ -0,0 +1,105 @@ +config->tabsHideOnPages); + $this->config->tabsDisabledOnPages = ArrayUtil::parseRange($this->config->tabsDisabledOnPages); + + if ($this->config->tabsHideOnCover) { + $hideOnPages[] = 0; + $hideOnPages[] = 1; + } + if ($this->config->tabsHideOnLastPage) { + $hideOnPages[] = count($this->pages); + } + $this->config->tabsHideOnPages = $hideOnPages; + } + + protected function writeTabs() + { + if (!$this->fluidbookSettings->tabsHTML5 || !file_exists($this->wdir . '/' . $this->fluidbookSettings->tabsHTML5)) { + return; + } + + $ext = Files::getExtension($this->fluidbookSettings->tabsHTML5); + if ($ext === 'zip') { + $links['tabs'] = [ + 'page' => 'background', + 'top' => 0, + 'left' => 0, + 'width' => 100, + 'height' => 100, + 'type' => Link::MULTIMEDIA, + 'to' => $this->fluidbookSettings->tabsHTML5, + 'image' => '', + 'inline' => 1, + 'interactive' => 1, + 'class' => 'tabslink', + 'uid' => 'tabs', + ]; + return; + } + + + $svg = $this->wdir . '/' . $this->fluidbookSettings->tabsHTML5; + $opt = SVGTools::optimizeSVG($svg, null, '--trim-ids no --remove-unreferenced-ids no --ungroup-groups no --group-by-style no', true); + + $svgContent = file_get_contents($opt); + $svgContent = str_replace('_1_', '', $svgContent, $count); + if ($count) { + file_put_contents($opt, $svgContent); + } + + + $this->vdir->copy($opt, 'data/tabs.svg'); + $this->config->svgTabs = true; + $pagesLists = ['tabsPages', 'tabsSections']; + + foreach ($pagesLists as $pagesList) { + $e = explode(',', $this->fluidbookSettings->$pagesList); + $list = []; + foreach ($e as $k => $v) { + $v = trim($v); + if ($v === '') { + continue; + } + if ($v !== '-') { + if ($this->fluidbookSettings->tabsPagesNumbers === 'virtual') { + $v = $this->virtualToPhysical($v); + } + } + $list[] = $v; + } + $this->config->$pagesList = $list; + } + + $this->checkTabsSVG($opt); + } + + 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; + } + } + + if (count($missing)) { + $this->addIssue(FluidbookHealthIssues::TYPE_TABS_MISSING_TAB_ID, ['missing_tabs' => implode(', ', $missing)]); + } + + } +} diff --git a/app/Models/FluidbookHealthIssues.php b/app/Models/FluidbookHealthIssues.php index 8b3fb46c4..fcccec5a0 100644 --- a/app/Models/FluidbookHealthIssues.php +++ b/app/Models/FluidbookHealthIssues.php @@ -16,7 +16,8 @@ class FluidbookHealthIssues extends ToolboxModel const TYPE_MOBILEFIRST_CONFIG = 3; const TYPE_TTS_VOICE_INVALID = 4; const TYPE_COMPILE_FILES = 5; - const TYPE_CHAPTER_PAGE_NOT_EXIST=6; + const TYPE_CHAPTER_PAGE_NOT_EXIST = 6; + const TYPE_TABS_MISSING_TAB_ID = 7; const CRIT_ERROR = 5; const CRIT_WARNING = 3; @@ -117,6 +118,14 @@ class FluidbookHealthIssues extends ToolboxModel 'fixText' => __('Editer le sommaire'), 'fixURL' => route('fluidbook-publication.edit', ['id' => $fluidbookId]) . '#s_section_chapters', ], + static::TYPE_TABS_MISSING_TAB_ID => + [ + 'summary' => __('Identifiant des onglets non définis'), + 'criticality' => self::CRIT_WARNING, + 'text' => 'Le SVG des onglets devraient contenir des calques portant les identifiants suivants : :missing_tabs.', + 'fixText' => __('Lire la documentation'), + 'fixURL' => 'https://docs.google.com/document/d/1iq4o9V3h74QCMxAymGbSmCkYZWjzK81FskDWKTxejFg/edit', + ] ]; } diff --git a/composer.lock b/composer.lock index d80a1c12e..2a1626fae 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a2c4e7e7e43bf89fa3a5c783830cb261", + "content-hash": "8c149e34e8566615c51e387244172414", "packages": [ { "name": "archtechx/enums", @@ -1584,22 +1584,23 @@ }, { "name": "cubedesigners/userdatabase", - "version": "dev-backpack5", + "version": "dev-master", "source": { "type": "git", "url": "git://git.cubedesigners.com/cubedesigners_userdatabase.git", - "reference": "4373255749acbad60ac7957943406d3d0ddc851d" + "reference": "104abada3256ab6df09320052854c665792f8f58" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubedesigners/userdatabase/cubedesigners-userdatabase-dev-backpack5-eb743b.tar", - "reference": "4373255749acbad60ac7957943406d3d0ddc851d", - "shasum": "e456325d86dd8dd4e607201a49197d128c5d0e5e" + "url": "https://composer.cubedesigners.com/dist/cubedesigners/userdatabase/cubedesigners-userdatabase-dev-master-f99793.tar", + "reference": "104abada3256ab6df09320052854c665792f8f58", + "shasum": "a13fb014f7a9b17949437e19f27a1421645d3017" }, "require": { "cubist/cms-back": "dev-backpack5", "php": ">=8.2" }, + "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1626,7 +1627,7 @@ } ], "description": "Cubedesigners common users database", - "time": "2023-10-18T07:47:08+00:00" + "time": "2024-02-23T11:33:37+00:00" }, { "name": "cubist/azuretts", @@ -2060,13 +2061,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_net.git", - "reference": "2ce0039849af4c8a877c81e57f5fb7568541bf8e" + "reference": "5679d21834ca61f6ca55f94fa9a7ffdf933f6cd4" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-6477e3.tar", - "reference": "2ce0039849af4c8a877c81e57f5fb7568541bf8e", - "shasum": "cb8e5f0cf2782715f29152b4704767f9ab943b8e" + "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-5cf72a.tar", + "reference": "5679d21834ca61f6ca55f94fa9a7ffdf933f6cd4", + "shasum": "e492c3876a059b659cbf106aa2c174d04112ee01" }, "require": { "cubist/util": "dev-master", @@ -2091,7 +2092,7 @@ } ], "description": "net cubist composer package", - "time": "2024-02-01T15:16:16+00:00" + "time": "2024-02-22T15:26:55+00:00" }, { "name": "cubist/pdf", @@ -3830,13 +3831,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/fluidbook_tools.git", - "reference": "0a53a4c867caab1fb9a4cc7d72fb29a824bd00ca" + "reference": "97d54a44641d98b15ebaa798fc3c053092f47756" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-6971c7.tar", - "reference": "0a53a4c867caab1fb9a4cc7d72fb29a824bd00ca", - "shasum": "04f779c4390d723229ba3f2bc0b7c6182c371637" + "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-f8e490.tar", + "reference": "97d54a44641d98b15ebaa798fc3c053092f47756", + "shasum": "1cedc9849713364a0d3cb35ea9a9f62494308b97" }, "require": { "barryvdh/laravel-debugbar": "*", @@ -3872,7 +3873,7 @@ } ], "description": "Fluidbook Tools", - "time": "2024-02-21T16:08:21+00:00" + "time": "2024-02-23T16:44:02+00:00" }, { "name": "fruitcake/php-cors", @@ -10190,28 +10191,28 @@ }, { "name": "spatie/laravel-translatable", - "version": "6.5.5", + "version": "6.6.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-translatable.git", - "reference": "d6dc7c9fe3c678ce50b2d6a4a7434fcbcfc3df4c" + "reference": "11f0b548dd43b846a5bdca1431de173ac77ed349" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-translatable/zipball/d6dc7c9fe3c678ce50b2d6a4a7434fcbcfc3df4c", - "reference": "d6dc7c9fe3c678ce50b2d6a4a7434fcbcfc3df4c", + "url": "https://api.github.com/repos/spatie/laravel-translatable/zipball/11f0b548dd43b846a5bdca1431de173ac77ed349", + "reference": "11f0b548dd43b846a5bdca1431de173ac77ed349", "shasum": "" }, "require": { - "illuminate/database": "^9.0|^10.0", - "illuminate/support": "^9.0|^10.0", + "illuminate/database": "^9.0|^10.0|^11.0", + "illuminate/support": "^9.0|^10.0|^11.0", "php": "^8.0", "spatie/laravel-package-tools": "^1.11" }, "require-dev": { "mockery/mockery": "^1.4", - "orchestra/testbench": "^7.0|^8.0", - "pestphp/pest": "^1.20" + "orchestra/testbench": "^7.0|^8.0|^9.0", + "pestphp/pest": "^1.20|^2.0" }, "type": "library", "extra": { @@ -10260,7 +10261,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-translatable/issues", - "source": "https://github.com/spatie/laravel-translatable/tree/6.5.5" + "source": "https://github.com/spatie/laravel-translatable/tree/6.6.0" }, "funding": [ { @@ -10268,7 +10269,7 @@ "type": "github" } ], - "time": "2023-12-06T10:56:22+00:00" + "time": "2024-02-23T13:52:34+00:00" }, { "name": "spatie/pdf-to-image", @@ -15618,21 +15619,21 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.8.1", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "bc3dc91a5e9b14aa06d1d9e90647c5c5a2cc5353" + "reference": "153ae662783729388a584b4361f2545e4d841e3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/bc3dc91a5e9b14aa06d1d9e90647c5c5a2cc5353", - "reference": "bc3dc91a5e9b14aa06d1d9e90647c5c5a2cc5353", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", + "reference": "153ae662783729388a584b4361f2545e4d841e3c", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", - "php": "^7.4 || ^8.0", + "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", "phpstan/phpdoc-parser": "^1.13" }, @@ -15670,22 +15671,22 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2" }, - "time": "2024-01-18T19:15:27+00:00" + "time": "2024-02-23T11:10:43+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.25.0", + "version": "1.26.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240" + "reference": "231e3186624c03d7e7c890ec662b81e6b0405227" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240", - "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/231e3186624c03d7e7c890ec662b81e6b0405227", + "reference": "231e3186624c03d7e7c890ec662b81e6b0405227", "shasum": "" }, "require": { @@ -15717,9 +15718,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.26.0" }, - "time": "2024-01-04T17:06:16+00:00" + "time": "2024-02-23T16:05:55+00:00" }, { "name": "phpunit/php-code-coverage", @@ -16042,16 +16043,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.16", + "version": "9.6.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f" + "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f", - "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1a156980d78a6666721b7e8e8502fe210b587fcd", + "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd", "shasum": "" }, "require": { @@ -16125,7 +16126,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.17" }, "funding": [ { @@ -16141,7 +16142,7 @@ "type": "tidelift" } ], - "time": "2024-01-19T07:03:14+00:00" + "time": "2024-02-23T13:14:51+00:00" }, { "name": "psy/psysh", @@ -17571,5 +17572,5 @@ "ext-zlib": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.1.0" } -- 2.39.5