From bd1a1742725496dad5332b3f416e0ecda59fbdd4 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 9 May 2022 17:25:59 +0200 Subject: [PATCH] =?UTF-8?q?Validit=C3=A9=20des=20fontes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 4 +++ core/module/theme/theme.php | 59 +++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 89b5e03c..b710a58d 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## Version 11.4.02 +### Modifications : +- Liste des aperçus de fontes, contrôle de validité amélioré. + ## Version 11.4.01 ### Corrections : - Défaut de chargement des fontes locales (ex: fichiers woff). diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index a0c344c0..dc6f16a7 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -1190,16 +1190,19 @@ class theme extends common { */ $gf = false; $fileContent = ''; - foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) { - if ( - ( $scope === 'user' && in_array($fontId, $fontsInstalled) ) - || $scope === 'all' - ) { - //Pré chargement à revoir - //$fileContent .= ''; - $fileContent .= ''; - // Pré connect pour api.google - $gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true; + if ( is_array($this->getData(['fonts', 'imported'])) && + !empty($this->getData(['fonts', 'imported'])) ) { + foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) { + if ( + ( $scope === 'user' && in_array($fontId, $fontsInstalled) ) + || $scope === 'all' + ) { + //Pré chargement à revoir + //$fileContent .= ''; + $fileContent .= ''; + // Pré connect pour api.google + $gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true; + } } } @@ -1213,22 +1216,26 @@ class theme extends common { * Fontes installées localement */ $fileContentCss = ''; - foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) { - if ( - ( $scope === 'user' && in_array($fontId, $fontsInstalled) ) - || $scope === 'all' - ) { - if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource']) ) { - // Extension - $path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']); - // Chargement de la police - $fileContentCss .= '@font-face {' ; - $fileContentCss .= 'font-family:"' . $fontValue['name'] . '";'; - $fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");'; - $fileContentCss .= '}' ; - // Préchargement - //$fileContent = '' . $fileContent; - } + $fileContent = ''; + if ( is_array($this->getData(['fonts', 'files'])) && + !empty($this->getData(['fonts', 'files'])) ) { + foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) { + if ( + ( $scope === 'user' && in_array($fontId, $fontsInstalled) ) + || $scope === 'all' + ) { + if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource']) ) { + // Extension + $path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']); + // Chargement de la police + $fileContentCss .= '@font-face {' ; + $fileContentCss .= 'font-family:"' . $fontValue['name'] . '";'; + $fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");'; + $fileContentCss .= '}' ; + // Préchargement + //$fileContent = '' . $fileContent; + } + } } }