From 8d8d35a5407ce46ddad047a366c4824e6855641a Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 4 Apr 2023 18:56:41 +0200 Subject: [PATCH] Fonts pluriel --- core/class/layout.class.php | 4 +-- core/class/router.class.php | 14 ++++---- core/module/theme/theme.php | 34 +++++++++---------- .../view/{fonts/fonts.css => font/font.css} | 0 .../{fonts/fonts.js.php => font/font.js.php} | 0 .../view/{fonts/fonts.php => font/font.php} | 0 core/module/theme/view/index/index.php | 4 +-- core/module/translate/translate.php | 9 ++--- 8 files changed, 30 insertions(+), 35 deletions(-) rename core/module/theme/view/{fonts/fonts.css => font/font.css} (100%) rename core/module/theme/view/{fonts/fonts.js.php => font/font.js.php} (100%) rename core/module/theme/view/{fonts/fonts.php => font/font.php} (100%) diff --git a/core/class/layout.class.php b/core/class/layout.class.php index b429f25e..3faa191f 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -1100,8 +1100,8 @@ class layout extends common public function showFonts() { // Import des fontes liées au thème - if (file_exists(self::DATA_DIR . 'fonts/font.html')) { - include_once(self::DATA_DIR . 'fonts/font.html'); + if (file_exists(self::DATA_DIR . 'font/font.html')) { + include_once(self::DATA_DIR . 'font/font.html'); } } diff --git a/core/class/router.class.php b/core/class/router.class.php index 3ffaeb1b..1a8f4a68 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -142,7 +142,7 @@ class core extends common if (!is_dir(self::DATA_DIR . 'font')) { mkdir(self::DATA_DIR . 'font'); } - file_put_contents(self::DATA_DIR . 'fonts/font.html', $fontFile); + file_put_contents(self::DATA_DIR . 'font/font.html', $fontFile); /** * Fontes installées localement @@ -150,10 +150,10 @@ class core extends common foreach ($fonts as $fontId) { // Validité du tableau : if (isset($fontsAvailable['files'][$fontId])) { - if (file_exists(self::DATA_DIR . 'fonts/' . $fontId)) { + if (file_exists(self::DATA_DIR . 'font/' . $fontId)) { // Chargement de la police $css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";'; - $css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontsAvailable['files'][$fontId]['resource'] . '");}'; + $css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'font/' . $fontsAvailable['files'][$fontId]['resource'] . '");}'; // Tableau pour la construction de la feuille de style $fonts[$fontId] = $fontsAvailable['files'][$fontId]['font-family']; } else { @@ -322,7 +322,7 @@ class core extends common if (!is_dir(self::DATA_DIR . 'font')) { mkdir(self::DATA_DIR . 'font'); } - file_put_contents(self::DATA_DIR . 'fonts/font.html', $fontFile); + file_put_contents(self::DATA_DIR . 'font/font.html', $fontFile); // Enregistre la personnalisation file_put_contents(self::DATA_DIR . 'theme.css', $css); @@ -380,7 +380,7 @@ class core extends common } } // Enregistre la personnalisation - file_put_contents(self::DATA_DIR . 'fonts/font.html', $fontFile); + file_put_contents(self::DATA_DIR . 'font/font.html', $fontFile); /** * Fontes installées localement @@ -388,10 +388,10 @@ class core extends common foreach ($fonts as $fontId) { // Validité du tableau : if (isset($fontsAvailable['files'][$fontId])) { - if (file_exists(self::DATA_DIR . 'fonts/' . $fontId)) { + if (file_exists(self::DATA_DIR . 'font/' . $fontId)) { // Chargement de la police $css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";'; - $css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontsAvailable['files'][$fontId]['resource'] . '");}'; + $css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'font/' . $fontsAvailable['files'][$fontId]['resource'] . '");}'; // Tableau pour la construction de la feuille de style $fonts[$fontId] = $fontsAvailable['files'][$fontId]['font-family']; } else { diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 5bbcb4a0..5c6d7cfb 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -583,7 +583,7 @@ class theme extends common /** * Options des fontes */ - public function fonts() + public function font() { // Toutes les fontes installées sont chargées @@ -689,7 +689,7 @@ class theme extends common $type === 'files' && file_exists(self::FILE_DIR . 'source/' . $ressource) ) { - copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource); + copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'font/' . $ressource); } // Valeurs en sortie @@ -752,7 +752,7 @@ class theme extends common $type === 'files' && file_exists(self::FILE_DIR . 'source/' . $ressource) ) { - copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource); + copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'font/' . $ressource); } // Valeurs en sortie @@ -979,7 +979,7 @@ class theme extends common // Substitution des fontes Google if ($modele = 'theme') { - $c = $this->subFonts(self::DATA_DIR . 'theme.json'); + $c = $this->subFont(self::DATA_DIR . 'theme.json'); // Un remplacement nécessite la régénération de la feuille de style if ( $c > 0 @@ -989,7 +989,7 @@ class theme extends common } } if ($modele = 'admin') { - $c = $this->subFonts(self::DATA_DIR . 'admin.json'); + $c = $this->subFont(self::DATA_DIR . 'admin.json'); // Un remplacement nécessite la régénération de la feuille de style if ( $c > 0 @@ -1081,11 +1081,11 @@ class theme extends common $zip->addEmptyDir(self::DATA_DIR . 'font'); $fonts = $this->getData(['font', 'files']); foreach ($fonts as $fontId => $fontName) { - $zip->addFile(self::DATA_DIR . 'fonts/' . $fontName, self::DATA_DIR . 'fonts/' . $fontName); + $zip->addFile(self::DATA_DIR . 'font/' . $fontName, self::DATA_DIR . 'font/' . $fontName); } - if (file_exists(self::DATA_DIR . 'fonts/font.html')) { + if (file_exists(self::DATA_DIR . 'font/font.html')) { - $zip->addFile(self::DATA_DIR . 'fonts/font.html', self::DATA_DIR . 'fonts/font.html'); + $zip->addFile(self::DATA_DIR . 'font/font.html', self::DATA_DIR . 'font/font.html'); } break; case 'theme': @@ -1119,11 +1119,11 @@ class theme extends common $zip->addEmptyDir(self::DATA_DIR . 'font'); $fonts = $this->getData(['font', 'files']); foreach ($fonts as $fontId => $fontName) { - $zip->addFile(self::DATA_DIR . 'fonts/' . $fontName, self::DATA_DIR . 'fonts/' . $fontName); + $zip->addFile(self::DATA_DIR . 'font/' . $fontName, self::DATA_DIR . 'font/' . $fontName); } - if (file_exists(self::DATA_DIR . 'fonts/font.html')) { + if (file_exists(self::DATA_DIR . 'font/font.html')) { - $zip->addFile(self::DATA_DIR . 'fonts/font.html', self::DATA_DIR . 'fonts/font.html'); + $zip->addFile(self::DATA_DIR . 'font/font.html', self::DATA_DIR . 'font/font.html'); } break; } @@ -1138,7 +1138,7 @@ class theme extends common * @param string $file, nom du fichier json à convertir * @return int nombre de substitution effectuées */ - private function subFonts($file) + private function subFont($file) { // Tableau de substitution des fontes $fonts = [ @@ -1271,24 +1271,24 @@ class theme extends common ($scope === 'user' && in_array($fontId, $fontsInstalled)) || $scope === 'all' ) { - if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource'])) { + if (file_exists(self::DATA_DIR . 'font/' . $fontValue['resource'])) { // Extension - $path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']); + $path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'font/' . $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 = '' . $fileContent; } } } } // Enregistre la personnalisation - file_put_contents(self::DATA_DIR . 'fonts/font.html', $fileContent); + file_put_contents(self::DATA_DIR . 'font/font.html', $fileContent); // Enregistre la personnalisation - file_put_contents(self::DATA_DIR . 'fonts/fonts.css', $fileContentCss); + file_put_contents(self::DATA_DIR . 'font/font.css', $fileContentCss); } } diff --git a/core/module/theme/view/fonts/fonts.css b/core/module/theme/view/font/font.css similarity index 100% rename from core/module/theme/view/fonts/fonts.css rename to core/module/theme/view/font/font.css diff --git a/core/module/theme/view/fonts/fonts.js.php b/core/module/theme/view/font/font.js.php similarity index 100% rename from core/module/theme/view/fonts/fonts.js.php rename to core/module/theme/view/font/font.js.php diff --git a/core/module/theme/view/fonts/fonts.php b/core/module/theme/view/font/font.php similarity index 100% rename from core/module/theme/view/fonts/fonts.php rename to core/module/theme/view/font/font.php diff --git a/core/module/theme/view/index/index.php b/core/module/theme/view/index/index.php index 6115be7c..e709d47c 100644 --- a/core/module/theme/view/index/index.php +++ b/core/module/theme/view/index/index.php @@ -17,7 +17,7 @@
'font', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/fonts', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/font', 'value' => 'Fontes' ]); ?>
@@ -68,7 +68,7 @@
'font', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/fonts', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/font', 'value' => 'Fontes' ]); ?>
diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index 4e0baab5..0ba5b6a2 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -184,13 +184,8 @@ class translate extends common } // Langues disponibles avec la mise à jour - $store = json_decode(file_get_contents('core/module/install/ressource/i18n/language.json'), true); - if (array_key_exists('languages', $store )) { - $store = $store['languages']; - } - if (array_key_exists('language', $store )) { - $store = $store['language']; - } + $store = $this->getData(['language']); + if ($installedUI) { foreach($installedUI as $key => $value) { if (isset($store[$key]) && $store[$key]['version'] > $value['version']) {