diff --git a/core/core.php b/core/core.php index cff3145f..40ba2a8b 100644 --- a/core/core.php +++ b/core/core.php @@ -184,7 +184,7 @@ class common { ]; public static $fontsWebSafe = [ - 'arial' => [ + 'arial' => [ 'name' => 'Arial', 'font-family' => 'Arial, Helvetica, sans-serif', 'resource' => 'websafe' @@ -1377,9 +1377,6 @@ class common { */ echo '
'; $this->showContent(); - if (file_exists(self::DATA_DIR . 'body.inc.html')) { - include(self::DATA_DIR . 'body.inc.html'); - } echo '
'; /** * Barre droite @@ -2162,6 +2159,14 @@ class common { } echo ''; } + // Import des fontes en ligne + if ( file_exists(self::DATA_DIR.'fonts/fonts.html') ){ + include_once(self::DATA_DIR . 'fonts/fonts.html'); + } + // Import des fontes locales + if (file_exists(self::DATA_DIR.'fonts/fonts.css')) { + echo ''; + } } /** diff --git a/core/layout/blank.php b/core/layout/blank.php index db6b8727..6e2d1852 100644 --- a/core/layout/blank.php +++ b/core/layout/blank.php @@ -13,17 +13,8 @@ - - - - - - - + + showContent(); ?> showScript(); ?> diff --git a/core/layout/light.php b/core/layout/light.php index e8de5ea5..833cb19d 100644 --- a/core/layout/light.php +++ b/core/layout/light.php @@ -14,16 +14,6 @@ - - - - - - showNotification(); ?> diff --git a/core/layout/main.php b/core/layout/main.php index 1f19c331..f1c2fbbc 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -13,16 +13,7 @@ - - - - - - + getData(['page', $this->getUrl(0), 'moduleId']) === 'blog' OR $this->getData(['page', $this->getUrl(0), 'moduleId']) === 'news' ) @@ -30,6 +21,7 @@ showStyle(); ?> + @@ -196,6 +188,10 @@ showCookies(); ?> showScript();?> - + + diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index a88e0252..4dad9850 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -499,6 +499,9 @@ class theme extends common { * Accueil de la personnalisation */ public function index() { + // Restaurer les fontes utilisateurs + $this->setFonts('user'); + // Valeurs en sortie $this->addOutput([ 'title' => 'Personnalisation des thèmes', @@ -560,6 +563,9 @@ class theme extends common { */ public function fonts() { + // Toutes les fontes installées + $this->setFonts('all'); + // Polices liées au thème $used = [ 'Bannière' => $this->getData (['theme', 'header', 'font']), @@ -657,8 +663,7 @@ class theme extends common { ) { copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource ); } - // Met à jour les fichiers d'appel des fontes utilisés par les layouts - $this->setFonts(); + // Valeurs en sortie $this->addOutput([ 'notification' => 'La fonte a été créée', @@ -710,9 +715,6 @@ class theme extends common { copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource ); } - // Met à jour les fichiers d'appel des fontes utilisés par les layouts - $this->setFonts(); - // Valeurs en sortie $this->addOutput([ 'notification' => 'La fonte a été actualisée', @@ -751,9 +753,6 @@ class theme extends common { unlink(self::DATA_DIR . $this->getUrl(2)); } - // Met à jour les fichiers d'appel des fontes utilisés par les layouts - $this->setFonts(); - // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . 'theme/fonts', @@ -1158,8 +1157,22 @@ class theme extends common { /** * Création d'un fichier de liens d'appel des fontes + * @param string $scope vaut all pour toutes les fontes ; 'user' pour les fontes utilisateurs */ - private function setFonts() { + private function setFonts($scope = 'all') { + + // Filtrage par fontes installées + $fontsInstalled = [ $this->getData(['theme', 'text', 'font']), + $this->getData(['theme', 'title', 'font']), + $this->getData(['theme', 'header', 'font']), + $this->getData(['theme', 'menu', 'font']), + $this->getData(['theme', 'footer', 'font']), + $this->getData(['admin', 'fontText']), + $this->getData(['admin', 'fontTitle']), + ]; + + // Compression + $fontsInstalled = array_unique($fontsInstalled); /** * Chargement des polices en ligne dans un fichier fonts.html inclus dans main.php @@ -1167,16 +1180,21 @@ class theme extends common { $gf = false; $fileContent = ''; foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) { - $fileContent .= ''; - // Pré connect pour api.google - $gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true; + if ( + ( $scope === 'user' && array_key_exists($fontId, $fontsInstalled) ) + || $scope === 'all' + ) { + $fileContent .= ''; + // Pré connect pour api.google + $gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true; + } } // Ajoute le préconnect des fontes Googles. $fileContent = $gf ? '' . $fileContent : $fileContent; - // Enregistre la personnalisation + // Enregistre la personnalisation file_put_contents(self::DATA_DIR.'fonts/fonts.html', $fileContent); /** @@ -1184,12 +1202,17 @@ class theme extends common { */ $fileContent = ''; foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) { - if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource']) ) { - // Chargement de la police - $fileContent .= '@font-face {' ; - $fileContent .= 'font-family:"' . $fontValue['font-family'] . '";'; - $fileContent .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource'] . '");'; - $fileContent .= '}' ; + if ( + ( $scope === 'user' && array_key_exists($fontId, $fontsInstalled) ) + || $scope === 'all' + ) { + if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource']) ) { + // Chargement de la police + $fileContent .= '@font-face {' ; + $fileContent .= 'font-family:"' . $fontValue['font-family'] . '";'; + $fileContent .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource'] . '");'; + $fileContent .= '}' ; + } } } // Enregistre la personnalisation