Thème fonte Améliore le code discrimant les fontes utilisées et prend en compte le thème admin

This commit is contained in:
Fred Tempez 2024-01-17 18:27:21 +01:00
parent 5a5e9dc72c
commit 3bfcaa4187
1 changed files with 16 additions and 17 deletions

View File

@ -628,16 +628,16 @@ class theme extends common
// Toutes les fontes installées sont chargées // Toutes les fontes installées sont chargées
$this->setFonts('all'); $this->setFonts('all');
// Polices liées au thème admin
$fonts['Titre (admin)'] = $this->getData(['admin', 'fontTitle']);
$fonts['Texte (admin)'] = $this->getData(['admin', 'fontText']);
// Polices liées au thème // Polices liées au thème
$used = [ $fonts['Bannière'] = $this->getData(['theme', 'header', 'font']);
'Bannière' => $this->getData(['theme', 'header', 'font']), $fonts['Menu'] = $this->getData(['theme', 'menu', 'font']);
'Menu' => $this->getData(['theme', 'menu', 'font']), $fonts['Titre'] = $this->getData(['theme', 'title', 'font']);
'Titre ' => $this->getData(['theme', 'title', 'font']), $fonts['Texte'] = $this->getData(['theme', 'text', 'font']);
'Texte' => $this->getData(['theme', 'text', 'font']), $fonts['Pied de page'] = $this->getData(['theme', 'footer', 'font']);
'Pied de page' => $this->getData(['theme', 'footer', 'font']),
'Titre (admin)' => $this->getData(['admin', 'fontTitle']),
'Admin (texte)' => $this->getData(['admin', 'fontText'])
];
// 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();
@ -649,18 +649,17 @@ class theme extends common
foreach ($f as $type => $typeValue) { foreach ($f as $type => $typeValue) {
if (is_array($typeValue)) { if (is_array($typeValue)) {
foreach ($typeValue as $fontId => $fontValue) { foreach ($typeValue as $fontId => $fontValue) {
// Fontes utilisées par les thèmes // Recherche les correspondances
$fontUsed[$fontId] = ''; $result = array_filter($fonts, function($value) use ($fontId) {
foreach ($used as $key => $value) { return $value == $fontId;
if ($value === $fontId) { });
$fontUsed[$fontId] .= $key . '<br/>'; $keyResults = array_keys($result);
} // Préparation du tableau
}
self::$fontsDetail[] = [ self::$fontsDetail[] = [
$fontId, $fontId,
'<span style="font-family:' . $f[$type][$fontId]['font-family'] . '">' . $f[$type][$fontId]['name'] . '</span>', '<span style="font-family:' . $f[$type][$fontId]['font-family'] . '">' . $f[$type][$fontId]['name'] . '</span>',
$f[$type][$fontId]['font-family'], $f[$type][$fontId]['font-family'],
$fontUsed[$fontId], empty($keyResults) ? '' : '<span class="fontsList">' . implode('<br />', $keyResults) . '</span>',
$type, $type,
$type !== 'websafe' ? template::button('themeFontEdit' . $fontId, [ $type !== 'websafe' ? template::button('themeFontEdit' . $fontId, [
'class' => 'themeFontEdit', 'class' => 'themeFontEdit',