theme liste des polices ok

This commit is contained in:
fredtempez 2022-03-11 09:17:13 +01:00
parent 142611e69d
commit bafb7b3bc3
7 changed files with 47 additions and 41 deletions

View File

@ -618,13 +618,6 @@ class template {
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['selected'] = common::$inputBefore[$attributes['id']];
}
// Liste des polices à intégrer
//var_dump(core::$fonts);
if ($attributes['fonts'] === true) {
foreach (core::$fonts as $fontId => $font) {
echo "<link href='https://fonts.cdnfonts.com/css/" . $fontId . "' rel='stylesheet' type='text/css'>\n";
}
}
// Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label

View File

@ -183,10 +183,6 @@ class common {
];
// Fontes
public static $fonts = [
];
public static $fontsWebSafe = [
'arial' => 'Arial, Helvetica, sans-serif;',
'arial-black' => 'Arial Black, Gadget, sans-serif;',
@ -422,7 +418,7 @@ class common {
foreach (self::$fontsWebSafe as $fontId => $fontValue) {
$fontName = explode (',', $fontValue);
$f ['websafe'] [$fontId] = [
'name' => $fontName[0],
'name' => str_replace('"', '', $fontName[0]),
'font-family'=> $fontValue
];
}
@ -433,7 +429,7 @@ class common {
foreach ($fontsImported as $fontId => $fontValue) {
$fontName = explode (',', $fontValue);
$f ['imported'] [$fontId] = [
'name' => $fontName[0],
'name' => str_replace('"', '', $fontName[0]),
'font-family'=> $fontValue
//'ressource'
];
@ -446,7 +442,8 @@ class common {
foreach ($fontsFiles as $fontId => $fontValue) {
$f ['files'] [$fontId] = [
'font-family'=> $fontValue ['font-family'],
'ressource'=> $fontValue ['ressource']
'ressource'=> $fontValue ['ressource'],
'name' => ucfirst($fontId) // A créer
];
}
}
@ -2355,7 +2352,7 @@ class core extends common {
$fontFile = '';
foreach ($fonts as $fontId) {
if ( isset($fontsAvailable['websafe'][$fontId])) {
self::$fonts [$fontId] = $fontsAvailable['websafe'][$fontId]['font-family'];
$fonts [$fontId] = $fontsAvailable['websafe'][$fontId]['font-family'];
}
}
@ -2367,7 +2364,7 @@ class core extends common {
if ( isset($fontsAvailable['imported'][$fontId])) {
$fontFile .= '<link href="https://fonts.cdnfonts.com/css/' . $fontId .'" rel="stylesheet">';
// Tableau pour la construction de la feuille de style
self::$fonts [$fontId] = $fontsAvailable['imported'][$fontId]['font-family'];
$fonts [$fontId] = $fontsAvailable['imported'][$fontId]['font-family'];
}
}
// Enregistre la personnalisation
@ -2385,7 +2382,7 @@ class core extends common {
$css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";';
$css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontName . '");}';
// Tableau pour la construction de la feuille de style
self::$fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family'];
$fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family'];
}
}
@ -2393,7 +2390,7 @@ class core extends common {
// Fond du body
$colors = helper::colorVariants($this->getData(['theme', 'body', 'backgroundColor']));
// Body
$css .= 'body{font-family:' . self::$fonts[$this->getData(['theme', 'text', 'font'])] . ';}';
$css .= 'body{font-family:' . $fonts[$this->getData(['theme', 'text', 'font'])] . ';}';
if($themeBodyImage = $this->getData(['theme', 'body', 'image'])) {
// Image dans html pour éviter les déformations.
$css .= 'html {background-image:url("../file/source/' . $themeBodyImage . '");background-position:' . $this->getData(['theme', 'body', 'imagePosition']) . ';background-attachment:' . $this->getData(['theme', 'body', 'imageAttachment']) . ';background-size:' . $this->getData(['theme', 'body', 'imageSize']) . ';background-repeat:' . $this->getData(['theme', 'body', 'imageRepeat']) . '}';
@ -2411,7 +2408,7 @@ class core extends common {
$colors = helper::colorVariants($this->getData(['theme', 'text', 'linkColor']));
$css .= 'a{color:' . $colors['normal'] . '}';
// Couleurs de site dans TinyMCe
$css .= 'div.mce-edit-area {font-family:' . self::$fonts[$this->getData(['theme', 'text', 'font'])] . ';}';
$css .= 'div.mce-edit-area {font-family:' . $fonts[$this->getData(['theme', 'text', 'font'])] . ';}';
// Site dans TinyMCE
$css .= '.editorWysiwyg {background-color:' . $this->getData(['theme', 'site', 'backgroundColor']) . ';}';
$css .= 'span.mce-text{background-color: unset !important;}';
@ -2452,7 +2449,7 @@ class core extends common {
$css .= '.helpButton span:hover{color:' . $colors['darken'] . '}';
$css .= '.button:active,button[type=\'submit\']:active,.pagination a:active{background-color:' . $colors['veryDarken'] . '}';
$colors = helper::colorVariants($this->getData(['theme', 'title', 'textColor']));
$css .= 'h1,h2,h3,h4,h5,h6,h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color:' . $colors['normal'] . ';font-family:' . self::$fonts[$this->getData(['theme', 'title', 'font'])] . ';font-weight:' . $this->getData(['theme', 'title', 'fontWeight']) . ';text-transform:' . $this->getData(['theme', 'title', 'textTransform']) . '}';
$css .= 'h1,h2,h3,h4,h5,h6,h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color:' . $colors['normal'] . ';font-family:' . $fonts[$this->getData(['theme', 'title', 'font'])] . ';font-weight:' . $this->getData(['theme', 'title', 'fontWeight']) . ';text-transform:' . $this->getData(['theme', 'title', 'textTransform']) . '}';
$css .= 'h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{color:' . $colors['darken'] . '}';
// Les blocs
$colors = helper::colorVariants($this->getData(['theme', 'block', 'backgroundColor']));
@ -2486,7 +2483,7 @@ class core extends common {
$css .= 'header{background-image:url("../file/source/' . $themeHeaderImage . '");background-position:' . $this->getData(['theme', 'header', 'imagePosition']) . ';background-repeat:' . $this->getData(['theme', 'header', 'imageRepeat']) . '}';
}
$colors = helper::colorVariants($this->getData(['theme', 'header', 'textColor']));
$css .= 'header span{color:' . $colors['normal'] . ';font-family:' . self::$fonts[$this->getData(['theme', 'header', 'font'])] . ';font-weight:' . $this->getData(['theme', 'header', 'fontWeight']) . ';font-size:' . $this->getData(['theme', 'header', 'fontSize']) . ';text-transform:' . $this->getData(['theme', 'header', 'textTransform']) . '}';
$css .= 'header span{color:' . $colors['normal'] . ';font-family:' . $fonts[$this->getData(['theme', 'header', 'font'])] . ';font-weight:' . $this->getData(['theme', 'header', 'fontWeight']) . ';font-size:' . $this->getData(['theme', 'header', 'fontSize']) . ';text-transform:' . $this->getData(['theme', 'header', 'textTransform']) . '}';
}
// Bannière au contenu personnalisé
@ -2535,7 +2532,7 @@ class core extends common {
$css .= 'nav{padding:0 10px;}';
}
$css .= '#toggle span,#menu a{padding:' . $this->getData(['theme', 'menu', 'height']) .';font-family:' . self::$fonts[$this->getData(['theme', 'menu', 'font'])] . ';font-weight:' . $this->getData(['theme', 'menu', 'fontWeight']) . ';font-size:' . $this->getData(['theme', 'menu', 'fontSize']) . ';text-transform:' . $this->getData(['theme', 'menu', 'textTransform']) . '}';
$css .= '#toggle span,#menu a{padding:' . $this->getData(['theme', 'menu', 'height']) .';font-family:' . $fonts[$this->getData(['theme', 'menu', 'font'])] . ';font-weight:' . $this->getData(['theme', 'menu', 'fontWeight']) . ';font-size:' . $this->getData(['theme', 'menu', 'fontSize']) . ';text-transform:' . $this->getData(['theme', 'menu', 'textTransform']) . '}';
// Pied de page
$colors = helper::colorVariants($this->getData(['theme', 'footer', 'backgroundColor']));
@ -2545,7 +2542,7 @@ class core extends common {
$css .= 'footer{padding:0}';
}
$css .= 'footer span, #footerText > p {color:' . $this->getData(['theme', 'footer', 'textColor']) . ';font-family:' . self::$fonts[$this->getData(['theme', 'footer', 'font'])] . ';font-weight:' . $this->getData(['theme', 'footer', 'fontWeight']) . ';font-size:' . $this->getData(['theme', 'footer', 'fontSize']) . ';text-transform:' . $this->getData(['theme', 'footer', 'textTransform']) . '}';
$css .= 'footer span, #footerText > p {color:' . $this->getData(['theme', 'footer', 'textColor']) . ';font-family:' . $fonts[$this->getData(['theme', 'footer', 'font'])] . ';font-weight:' . $this->getData(['theme', 'footer', 'fontWeight']) . ';font-size:' . $this->getData(['theme', 'footer', 'fontSize']) . ';text-transform:' . $this->getData(['theme', 'footer', 'textTransform']) . '}';
$css .= 'footer {background-color:' . $colors['normal'] . ';color:' . $this->getData(['theme', 'footer', 'textColor']) . '}';
$css .= 'footer a{color:' . $this->getData(['theme', 'footer', 'textColor']) . '}';
$css .= 'footer #footersite > div {margin:' . $this->getData(['theme', 'footer', 'height']) . ' 0}';
@ -2589,7 +2586,7 @@ class core extends common {
$fontFile = '';
foreach ($fonts as $fontId) {
if ( isset($fontsAvailable['websafe'][$fontId])) {
self::$fonts [$fontId] = $fontsAvailable['websafe'][$fontId]['font-family'];
$fonts [$fontId] = $fontsAvailable['websafe'][$fontId]['font-family'];
}
}
@ -2601,7 +2598,7 @@ class core extends common {
if ( isset($fontsAvailable['imported'][$fontId])) {
$fontFile .= '<link href="https://fonts.cdnfonts.com/css/' . $fontId .'" rel="stylesheet">';
// Tableau pour la construction de la feuille de style
self::$fonts [$fontId] = $fontsAvailable['imported'][$fontId]['font-family'];
$fonts [$fontId] = $fontsAvailable['imported'][$fontId]['font-family'];
}
}
// Enregistre la personnalisation
@ -2619,7 +2616,7 @@ class core extends common {
$css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";';
$css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontName . '");}';
// Tableau pour la construction de la feuille de style
self::$fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family'];
$fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family'];
}
}
@ -2627,8 +2624,8 @@ class core extends common {
// Thème Administration
$colors = helper::colorVariants($this->getData(['admin','backgroundColor']));
$css .= '#site{background-color:' . $colors['normal']. ';}';
$css .= '.row > div {font:' . self::$fonts[$this->getData(['admin','fontText'])] . ';font-size:' . $this->getData(['admin','fontSize']) .'}';
$css .= 'body h1, h2, h3, h4 a, h5, h6 {font-family:' . self::$fonts[$this->getData(['admin','fontTitle'])] . ';color:' . $this->getData(['admin','colorTitle' ]) . ';}';
$css .= '.row > div {font:' . $fonts[$this->getData(['admin','fontText'])] . ';font-size:' . $this->getData(['admin','fontSize']) .'}';
$css .= 'body h1, h2, h3, h4 a, h5, h6 {font-family:' . $fonts[$this->getData(['admin','fontTitle'])] . ';color:' . $this->getData(['admin','colorTitle' ]) . ';}';
// TinyMCE
$css .= 'body:not(.editorWysiwyg),span .zwiico-help {color:' . $this->getData(['admin','colorText']) . ';}';

View File

@ -396,7 +396,8 @@ class theme extends common {
unset(self::$pagesList[$page]);
}
}
// Lire les fontes installées
$this->enumFonts();
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation du pied de page',
@ -475,6 +476,8 @@ class theme extends common {
'state' => true
]);
}
// Lire les fontes installées
$this->enumFonts();
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation de la bannière',
@ -534,6 +537,8 @@ class theme extends common {
'state' => true
]);
}
// Lire les fontes installées
$this->enumFonts();
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation du menu',
@ -549,10 +554,14 @@ class theme extends common {
*/
public function fonts() {
$this->listFonts();
// Peuple la variable de module fontsList de la liste des fonts disponibles clé : fontid - valeur nom de la fonte
$this->enumFonts();
//echo "<pre>";
// Polices liées au thème
$used = [
'Bannière' => $this->getData (['theme', 'header', 'font']),
@ -564,16 +573,18 @@ class theme extends common {
'Admin (texte)' => $this->getData (['admin', 'fontText' ])
];
// Parcourir les fontes installées et construire le tableau pour le formulaire
foreach (self::$fonts as $fontId => $fontName) {
// Parcourir les fontes disponibles et construire le tableau pour le formulaire
foreach ($fonts as $fontId => $fontName) {
// Fontes utilisées par le thème
// Fontes utilisées par les thèmes
$fontUsed[$fontId] = '';
foreach ($used as $key => $value) {
if ( $value === $fontId) {
$fontUsed[$fontId] .= $key . '<br/>';
}
}
self::$fontsList [] = [
'<span style="font-family:' . $fontName . '">' . $fontName . '</span>' ,
$fontId,
@ -787,6 +798,8 @@ class theme extends common {
'state' => true
]);
}
// Lire les fontes installées
$this->enumFonts();
// Valeurs en sortie
$this->addOutput([
'title' => 'Personnalisation du site',
@ -1048,16 +1061,19 @@ class theme extends common {
return ($count);
}
// Peule la variable self:$fonts avec les fontes disponibles.
public function listFonts() {
// Retourne un tableau simple des fonts installées idfont avec le nom
// Cette fonction est utile aux sélecteurs de fonts dans les formulaires.
public function enumFonts() {
// Récupère la liste des fontes installées
$f = $this->getFonts();
// Construit un tableau avec leur ID et leur famille
foreach(['websafe', 'imported', 'files'] as $type) {
foreach ($f[$type] as $fontId => $fontValue ) {
self::$fonts [$fontId] = $fontValue['name'];
$fonts [$fontId] = $fontValue['name'];
}
}
ksort($fonts);
self::$fontsList = $fonts;
}
}

View File

@ -171,7 +171,7 @@
<h4>Mise en forme du texte</h4>
<div class="row">
<div class="col3">
<?php echo template::select('themeFooterFont', self::$fonts, [
<?php echo template::select('themeFooterFont', $module::$fontsList, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'footer', 'font']),
'fonts' => true

View File

@ -106,7 +106,7 @@
]); ?>
</div>
<div class="col4">
<?php echo template::select('themeHeaderFont', self::$fonts, [
<?php echo template::select('themeHeaderFont', $module::$fontsList, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'header', 'font']),
'fonts' => true

View File

@ -183,7 +183,7 @@
<h4>Mise en forme du texte</h4>
<div class="row">
<div class="col6">
<?php echo template::select('themeMenuFont', self::$fonts, [
<?php echo template::select('themeMenuFont', $module::$fontsList, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'menu', 'font']),
'fonts' => true

View File

@ -158,7 +158,7 @@
<h4>Mise en forme du texte</h4>
<div class="row">
<div class="col6">
<?php echo template::select('themeTextFont', self::$fonts, [
<?php echo template::select('themeTextFont', $module::$fontsList, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'text', 'font']),
'fonts' => true
@ -179,7 +179,7 @@
<h4>Mise en forme des titres</h4>
<div class="row">
<div class="col4">
<?php echo template::select('themeTitleFont', self::$fonts, [
<?php echo template::select('themeTitleFont', $module::$fontsList, [
'label' => 'Police',
'selected' => $this->getData(['theme', 'title', 'font']),
'fonts' => true