Merge branch 'dev' into 12-dev

This commit is contained in:
Fred Tempez 2022-03-21 18:35:11 +01:00
commit 6a13590c9b
6 changed files with 139 additions and 112 deletions

View File

@ -180,19 +180,71 @@ class common {
]; ];
public static $fontsWebSafe = [ public static $fontsWebSafe = [
'arial' => 'Arial, Helvetica, sans-serif;', 'arial' => [
'arial-black' => '"Arial Black", Gadget, sans-serif;', 'name' => 'Arial',
'courrier' => 'Courier, "Liberation Mono", monospace;', 'font-family' => 'Arial, Helvetica, sans-serif',
'courrier-new' => '"Courier New", Courier, monospace', 'resource' => 'websafe'
'garamond' => 'Garamond, serif', ],
'georgia' => 'Georgia, serif;', 'arial-black' => [
'impact' => 'Impact, Charcoal, sans-serif;', 'name' => 'Arial Black',
'lucida' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif', 'font-family' => '\'Arial Black\', Gadget, sans-serif',
'tahoma' => 'Tahoma, Geneva, sans-serif;', 'resource' => 'websafe'
'times-new-roman' => '"Times New Roman", "Liberation Serif", serif;', ],
'trebuchet' => '"Trebuchet MS", Arial, Helvetica, sans-serif;', 'courrier' => [
'tahoma' => 'Tahoma, Geneva, sans-serif;', 'name' => 'Courier',
'verdana' => 'Verdana, Geneva, sans-serif;', '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'
]
]; ];
@ -403,48 +455,6 @@ class common {
} }
} }
/**
* Construit la liste des fontes dans un tableau
* @return array @fonts
*
*/
public function getFonts() {
// 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
];
}
// Ajoute les polices importées
$fontsImported = $this->getData(['fonts', 'imported']);
if (is_array($fontsImported)
) {
foreach ($fontsImported as $fontId => $fontValue) {
$f ['imported'] [$fontId] = [
'name' => $fontValue ['name'],
'font-family'=> $fontValue ['font-family'],
'resource' => $fontValue ['resource']
];
}
}
// Ajoute les polices locales
$fontsFiles = $this->getData(['fonts', 'files']);
if (is_array($fontsFiles)
) {
foreach ($fontsFiles as $fontId => $fontValue) {
$f ['files'] [$fontId] = [
'name' => $fontValue ['name'],
'font-family'=> $fontValue ['font-family'],
'resource' => $fontValue ['resource']
];
}
}
return $f;
}
/** /**
* Check du token CSRF (true = bo * Check du token CSRF (true = bo
*/ */
@ -2302,7 +2312,10 @@ class core extends common {
*/ */
// Fonts disponibles // Fonts disponibles
$fontsAvailable = $this->getFonts(); $fontsAvailable ['files'] = $this->getData(['fonts', 'files']);
$fontsAvailable ['imported'] = $this->getData(['fonts', 'imported']);
$fontsAvailable ['websafe'] = self::$fontsWebSafe;
// Fontes installées // Fontes installées
$fonts = [ $this->getData(['theme', 'text', 'font']), $fonts = [ $this->getData(['theme', 'text', 'font']),
$this->getData(['theme', 'title', 'font']), $this->getData(['theme', 'title', 'font']),

View File

@ -896,37 +896,37 @@ if ($this->getData(['core', 'dataVersion']) < 11400) {
], ],
'dancing-script' => [ 'dancing-script' => [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/dancing-script'
], ],
'droid-sans-2'=> [ 'droid-sans-2'=> [
'name' => 'Droid Sans', 'name' => 'Droid Sans',
'font-family' => '"Droid Sans", sans-serif', 'font-family' => '\'Droid Sans\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/droid-sans-2' 'resource' => 'https://fonts.cdnfonts.com/css/droid-sans-2'
], ],
'droid-serif-2'=> [ 'droid-serif-2'=> [
'name' => 'Droid Serif', 'name' => 'Droid Serif',
'font-family' => '"Droid Serif", serif', 'font-family' => '\'Droid Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/droid-serif-2' 'resource' => 'https://fonts.cdnfonts.com/css/droid-serif-2'
], ],
'indie-flower'=> [ 'indie-flower'=> [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/indie-flower'
], ],
'fira-sans' => [ 'fira-sans' => [
'name' => 'Fira Sans', 'name' => 'Fira Sans',
'font-family' => '"Fira Sans", sans-serif', 'font-family' => '\'Fira Sans\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/fira' 'resource' => 'https://fonts.cdnfonts.com/css/fira'
], ],
'liberation-sans'=> [ 'liberation-sans'=> [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/liberation-sans'
], ],
'liberation-serif'=> [ 'liberation-serif'=> [
'name' => 'Liberation Serif', 'name' => 'Liberation Serif',
'font-family' => '"Liberation Serif", serif', 'font-family' => '\'Liberation Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/liberation-serif' 'resource' => 'https://fonts.cdnfonts.com/css/liberation-serif'
], ],
'lobster-2'=> [ 'lobster-2'=> [
@ -946,12 +946,12 @@ if ($this->getData(['core', 'dataVersion']) < 11400) {
], ],
'old-standard-tt-3'=> [ 'old-standard-tt-3'=> [
'name' => 'Old Standard TT', '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' 'resource' => 'https://fonts.cdnfonts.com/css/old-standard-tt-3'
], ],
'open-sans' => [ 'open-sans' => [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/open-sans'
], ],
'oswald-4'=> [ 'oswald-4'=> [
@ -961,12 +961,12 @@ if ($this->getData(['core', 'dataVersion']) < 11400) {
], ],
'pt-mono'=> [ 'pt-mono'=> [
'name' => 'PT Mono', 'name' => 'PT Mono',
'font-family' => '"PT Mono", monospace', 'font-family' => '\'PT Mono\', monospace',
'resource' => 'https://fonts.cdnfonts.com/css/pt-mono' 'resource' => 'https://fonts.cdnfonts.com/css/pt-mono'
], ],
'pt-serif'=> [ 'pt-serif'=> [
'name' => "PR Serif", 'name' => 'PR Serif',
'font-family' => '"PT Serif", serif', 'font-family' => '\'PT Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/pt-serif' 'resource' => 'https://fonts.cdnfonts.com/css/pt-serif'
], ],
'rancho'=> [ 'rancho'=> [

View File

@ -100,32 +100,32 @@ class init extends common {
], ],
'dancing-script' => [ 'dancing-script' => [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/dancing-script'
], ],
'droid-sans-2'=> [ 'droid-sans-2'=> [
'name' => 'Droid Sans', 'name' => 'Droid Sans',
'font-family' => '"Droid Sans", sans-serif', 'font-family' => '\'Droid Sans\', sans-serif',
'resource' => 'https://fonts.cdnfonts.com/css/droid-sans-2' 'resource' => 'https://fonts.cdnfonts.com/css/droid-sans-2'
], ],
'droid-serif-2'=> [ 'droid-serif-2'=> [
'name' => 'Droid Serif', 'name' => 'Droid Serif',
'font-family' => '"Droid Serif", serif', 'font-family' => '\'Droid Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/droid-serif-2' 'resource' => 'https://fonts.cdnfonts.com/css/droid-serif-2'
], ],
'indie-flower'=> [ 'indie-flower'=> [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/indie-flower'
], ],
'liberation-sans'=> [ 'liberation-sans'=> [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/liberation-sans'
], ],
'liberation-serif'=> [ 'liberation-serif'=> [
'name' => 'Liberation Serif', 'name' => 'Liberation Serif',
'font-family' => '"Liberation Serif", serif', 'font-family' => '\'Liberation Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/liberation-serif' 'resource' => 'https://fonts.cdnfonts.com/css/liberation-serif'
], ],
'lobster-2'=> [ 'lobster-2'=> [
@ -145,12 +145,12 @@ class init extends common {
], ],
'old-standard-tt-3'=> [ 'old-standard-tt-3'=> [
'name' => 'Old Standard TT', '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' 'resource' => 'https://fonts.cdnfonts.com/css/old-standard-tt-3'
], ],
'open-sans' => [ 'open-sans' => [
'name' => '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' 'resource' => 'https://fonts.cdnfonts.com/css/open-sans'
], ],
'oswald-4'=> [ 'oswald-4'=> [
@ -160,12 +160,12 @@ class init extends common {
], ],
'pt-mono'=> [ 'pt-mono'=> [
'name' => 'PT Mono', 'name' => 'PT Mono',
'font-family' => '"PT Mono", monospace', 'font-family' => '\'PT Mono\', monospace',
'resource' => 'https://fonts.cdnfonts.com/css/pt-mono' 'resource' => 'https://fonts.cdnfonts.com/css/pt-mono'
], ],
'pt-serif'=> [ 'pt-serif'=> [
'name' => "PR Serif", 'name' => 'PR Serif',
'font-family' => '"PT Serif", serif', 'font-family' => '\'PT Serif\', serif',
'resource' => 'https://fonts.cdnfonts.com/css/pt-serif' 'resource' => 'https://fonts.cdnfonts.com/css/pt-serif'
], ],
'rancho'=> [ 'rancho'=> [

View File

@ -265,6 +265,8 @@ class theme extends common {
'state' => true 'state' => true
]); ]);
} }
// Lire les fontes installées
$this->enumFonts();
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Administration', 'title' => 'Administration',
@ -569,11 +571,14 @@ class theme extends common {
]; ];
// Récupérer le détail des fontes installées // Récupérer le détail des fontes installées
$f = $this->getFonts(); //$f = $this->getFonts();
$f ['files'] = $this->getData(['fonts', 'files']);
$f ['imported'] = $this->getData(['fonts', 'imported']);
$f ['websafe'] = self::$fontsWebSafe;
// Parcourir les fontes disponibles et construire le tableau pour le formulaire // Parcourir les fontes disponibles et construire le tableau pour le formulaire
foreach ($f as $type => $typeValue) { foreach ($f as $type => $typeValue) {
if (is_array($typeValue)) {
foreach ($typeValue as $fontId => $fontValue) { foreach ($typeValue as $fontId => $fontValue) {
// Fontes utilisées par les thèmes // Fontes utilisées par les thèmes
$fontUsed[$fontId] = ''; $fontUsed[$fontId] = '';
@ -605,6 +610,7 @@ class theme extends common {
]; ];
} }
} }
}
sort(self::$fontsDetail); sort(self::$fontsDetail);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -627,6 +633,9 @@ class theme extends common {
$fontName = $this->getInput('fontAddFontName', null, true); $fontName = $this->getInput('fontAddFontName', null, true);
$fontFamilyName = $this->getInput('fontAddFontFamilyName', null, true); $fontFamilyName = $this->getInput('fontAddFontFamilyName', null, true);
// Remplace les doubles quotes par des simples quotes
$fontFamilyName = str_replace('"', '\'', $fontFamilyName);
// Supprime la fonte si elle existe dans le type inverse // Supprime la fonte si elle existe dans le type inverse
if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) { if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) {
$this->deleteData(['fonts', $typeFlip, $fontId ]); $this->deleteData(['fonts', $typeFlip, $fontId ]);
@ -677,6 +686,9 @@ class theme extends common {
$fontName = $this->getInput('fontEditFontName', null , true); $fontName = $this->getInput('fontEditFontName', null , true);
$fontFamilyName = $this->getInput('fontEditFontFamilyName', null, true); $fontFamilyName = $this->getInput('fontEditFontFamilyName', null, true);
// Remplace les doubles quotes par des simples quotes
$fontFamilyName = str_replace('"', '\'', $fontFamilyName);
// Supprime la fonte si elle existe dans le type inverse // Supprime la fonte si elle existe dans le type inverse
if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) { if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) {
$this->deleteData(['fonts', $typeFlip, $fontId ]); $this->deleteData(['fonts', $typeFlip, $fontId ]);
@ -1115,7 +1127,9 @@ class theme extends common {
// Cette fonction est utile aux sélecteurs de fonts dans les formulaires. // Cette fonction est utile aux sélecteurs de fonts dans les formulaires.
public function enumFonts() { public function enumFonts() {
// Récupère la liste des fontes installées // Récupère la liste des fontes installées
$f = $this->getFonts(); $f ['files'] = $this->getData(['fonts', 'files']);
$f ['imported'] = $this->getData(['fonts', 'imported']);
$f ['websafe'] = self::$fontsWebSafe;
// Construit un tableau avec leur ID et leur famille // Construit un tableau avec leur ID et leur famille
foreach(['websafe', 'imported', 'files'] as $type) { foreach(['websafe', 'imported', 'files'] as $type) {
if(array_key_exists($type, $f)) { if(array_key_exists($type, $f)) {

View File

@ -128,7 +128,7 @@
<h4>Mise en forme du texte</h4> <h4>Mise en forme du texte</h4>
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::select('adminFontText', self::$fonts, [ <?php echo template::select('adminFontText', $module::$fontsList, [
'label' => 'Police du texte', 'label' => 'Police du texte',
'selected' => $this->getData(['admin', 'fontText']), 'selected' => $this->getData(['admin', 'fontText']),
'fonts' => true 'fonts' => true
@ -141,7 +141,7 @@
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('adminFontTitle', self::$fonts, [ <?php echo template::select('adminFontTitle', $module::$fontsList, [
'label' => 'Police des titres', 'label' => 'Police des titres',
'selected' => $this->getData(['admin', 'fontTitle']), 'selected' => $this->getData(['admin', 'fontTitle']),
'fonts' => true 'fonts' => true

View File

@ -61,7 +61,7 @@
<?php echo template::text('fontEditFontFamilyName', [ <?php echo template::text('fontEditFontFamilyName', [
'autocomplete' => 'off', 'autocomplete' => 'off',
'label' => 'Famille', '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']))
]); ?> ]); ?>
</div> </div>
</div> </div>