From 8fc7ea86de28dba62dd1d033f70afcf451df16d0 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 21 Mar 2022 15:35:05 +0100 Subject: [PATCH] gestion des fontes : Simplifier getfonts --- core/core.php | 84 +++++++++++++++---- core/module/install/ressource/defaultdata.php | 22 ++--- core/module/theme/theme.php | 2 + core/module/theme/view/fontEdit/fontEdit.php | 2 +- 4 files changed, 82 insertions(+), 28 deletions(-) diff --git a/core/core.php b/core/core.php index 7281a481..dea0589a 100644 --- a/core/core.php +++ b/core/core.php @@ -184,19 +184,71 @@ class common { ]; public static $fontsWebSafe = [ - 'arial' => 'Arial, Helvetica, sans-serif;', - 'arial-black' => '"Arial Black", Gadget, sans-serif;', - 'courrier' => 'Courier, "Liberation Mono", monospace;', - 'courrier-new' => '"Courier New", Courier, monospace', - 'garamond' => 'Garamond, serif', - 'georgia' => 'Georgia, serif;', - 'impact' => 'Impact, Charcoal, sans-serif;', - 'lucida' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif', - 'tahoma' => 'Tahoma, Geneva, sans-serif;', - 'times-new-roman' => '"Times New Roman", "Liberation Serif", serif;', - 'trebuchet' => '"Trebuchet MS", Arial, Helvetica, sans-serif;', - 'tahoma' => 'Tahoma, Geneva, sans-serif;', - 'verdana' => 'Verdana, Geneva, sans-serif;', + 'arial' => [ + 'name' => 'Arial', + 'font-family' => 'Arial, Helvetica, sans-serif', + 'resource' => 'websafe' + ], + 'arial-black' => [ + 'name' => 'Arial Black', + 'font-family' => '\'Arial Black\', Gadget, sans-serif', + 'resource' => 'websafe' + ], + 'courrier' => [ + 'name' => 'Courier', + 'font-family' => 'Courier, \'Liberation Mono\', monospace', + 'resource' => 'websafe' + ], + 'courrier-new' => [ + 'name' => 'Courier New', + 'font-family' => '\'Courier New\', Courier, monospace', + 'resource' => 'websafe' + ], + 'garamond' => [ + 'name' => 'Garamond', + 'font-family' => 'Garamond, serif', + 'resource' => 'websafe' + ], + 'georgia' => [ + 'name' => 'Geogia', + 'font-family' => 'Georgia, serif', + 'resource' => 'websafe' + ], + 'impact' => [ + 'name' => 'Impact', + 'font-family' => 'Impact, Charcoal, sans-serif', + 'resource' => 'websafe' + ], + 'lucida' => [ + 'name' => 'Lucida', + 'font-family' => '\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif', + 'resource' => 'websafe' + ], + 'tahoma' => [ + 'name' => 'Tahoma', + 'font-family' => 'Tahoma, Geneva, sans-serif', + 'resource' => 'websafe' + ], + 'times-new-roman' => [ + 'name' => 'Times New Roman', + 'font-family' => '\'Times New Roman\', \'Liberation Serif\', serif', + 'resource' => 'websafe' + ], + 'trebuchet' => [ + 'name' => 'Trebuchet', + 'font-family' => '\'Trebuchet MS\', Arial, Helvetica, sans-serif', + 'resource' => 'websafe' + ], + 'tahoma' => [ + 'name' => 'Tahoma', + 'font-family' => 'Tahoma, Geneva, sans-serif', + 'resource' => 'websafe' + ], + 'verdana' => [ + 'name' => 'Verdana', + 'font-family' => 'Verdana, Geneva, sans-serif;', + 'resource' => 'websafe' + ] ]; @@ -416,10 +468,10 @@ class common { // Fusionne la liste des fontes avec les webSafe foreach (self::$fontsWebSafe as $fontId => $fontValue) { - $fontName = explode (',', $fontValue); $f ['websafe'] [$fontId] = [ - 'name' => str_replace('"', '', $fontName[0]), - 'font-family'=> $fontValue + 'name' => $fontValue ['name'], + 'font-family'=> $fontValue ['font-family'], + 'resource' => $fontValue ['resource'] ]; } // Ajoute les polices importées diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 62cb4560..29a397ba 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -100,32 +100,32 @@ class init extends common { ], 'dancing-script' => [ 'name' => 'Dancing Script', - 'font-family' => '"Dancing Script", sans-serif', + 'font-family' => '\'Dancing Script\', sans-serif', 'resource' => 'https://fonts.cdnfonts.com/css/dancing-script' ], 'droid-sans-2'=> [ 'name' => 'Droid Sans', - 'font-family' => '"Droid Sans", sans-serif', + 'font-family' => '\'Droid Sans\', sans-serif', 'resource' => 'https://fonts.cdnfonts.com/css/droid-sans-2' ], 'droid-serif-2'=> [ 'name' => 'Droid Serif', - 'font-family' => '"Droid Serif", serif', + 'font-family' => '\'Droid Serif\', serif', 'resource' => 'https://fonts.cdnfonts.com/css/droid-serif-2' ], 'indie-flower'=> [ 'name' => 'Indie Flower', - 'font-family' => '"Indie Flower", sans-serif', + 'font-family' => '\'Indie Flower\', sans-serif', 'resource' => 'https://fonts.cdnfonts.com/css/indie-flower' ], 'liberation-sans'=> [ 'name' => 'Liberation Sans', - 'font-family' => '"Liberation Sans", sans-serif', + 'font-family' => '\'Liberation Sans\', sans-serif', 'resource' => 'https://fonts.cdnfonts.com/css/liberation-sans' ], 'liberation-serif'=> [ 'name' => 'Liberation Serif', - 'font-family' => '"Liberation Serif", serif', + 'font-family' => '\'Liberation Serif\', serif', 'resource' => 'https://fonts.cdnfonts.com/css/liberation-serif' ], 'lobster-2'=> [ @@ -145,12 +145,12 @@ class init extends common { ], 'old-standard-tt-3'=> [ 'name' => 'Old Standard TT', - 'font-family' => '"Old Standard TT", serif', + 'font-family' => '\'Old Standard TT\', serif', 'resource' => 'https://fonts.cdnfonts.com/css/old-standard-tt-3' ], 'open-sans' => [ 'name' => 'Open Sans', - 'font-family' => '"Open Sans", sans-serif', + 'font-family' => '\'Open Sans\', sans-serif', 'resource' => 'https://fonts.cdnfonts.com/css/open-sans' ], 'oswald-4'=> [ @@ -160,12 +160,12 @@ class init extends common { ], 'pt-mono'=> [ 'name' => 'PT Mono', - 'font-family' => '"PT Mono", monospace', + 'font-family' => '\'PT Mono\', monospace', 'resource' => 'https://fonts.cdnfonts.com/css/pt-mono' ], 'pt-serif'=> [ - 'name' => "PR Serif", - 'font-family' => '"PT Serif", serif', + 'name' => 'PR Serif', + 'font-family' => '\'PT Serif\', serif', 'resource' => 'https://fonts.cdnfonts.com/css/pt-serif' ], 'rancho'=> [ diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index bb68422a..7d6b7031 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -265,6 +265,8 @@ class theme extends common { 'state' => true ]); } + // Lire les fontes installées + $this->enumFonts(); // Valeurs en sortie $this->addOutput([ 'title' => 'Administration', diff --git a/core/module/theme/view/fontEdit/fontEdit.php b/core/module/theme/view/fontEdit/fontEdit.php index 17a9596b..21bf456c 100644 --- a/core/module/theme/view/fontEdit/fontEdit.php +++ b/core/module/theme/view/fontEdit/fontEdit.php @@ -61,7 +61,7 @@ 'off', 'label' => 'Famille', - 'value' => $this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'font-family']) + 'value' => stripslashes($this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'font-family'])) ]); ?>