forked from ZwiiCMS-Team/ZwiiCMS
Chargement localisé des polices de carcatères
This commit is contained in:
parent
4f64de7aa3
commit
b31159513c
@ -2267,49 +2267,52 @@ class core extends common {
|
|||||||
$css = '/*' . md5(json_encode($this->getData(['theme']))) . '*/';
|
$css = '/*' . md5(json_encode($this->getData(['theme']))) . '*/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import des polices de caractères à partir du CDN
|
* Import des polices de caractères
|
||||||
|
* A partir du CDN ou dans le dossier site/file/source/fonts
|
||||||
*/
|
*/
|
||||||
$importFonts = [$this->getData(['theme', 'text', 'font']),
|
$cdnFonts = [ $this->getData(['theme', 'text', 'font']),
|
||||||
$this->getData(['theme', 'title', 'font']),
|
$this->getData(['theme', 'title', 'font']),
|
||||||
$this->getData(['theme', 'header', 'font']),
|
$this->getData(['theme', 'header', 'font']),
|
||||||
$this->getData(['theme', 'menu', 'font']),
|
$this->getData(['theme', 'menu', 'font']),
|
||||||
$this->getData(['theme', 'footer', 'font'])
|
$this->getData(['theme', 'footer', 'font'])
|
||||||
];
|
];
|
||||||
// Suppression des polices identiques
|
// Suppression des polices identiques
|
||||||
$importFonts = array_unique($importFonts);
|
$cdnFonts = array_unique($cdnFonts);
|
||||||
|
|
||||||
// Un fichier local de configuration existe
|
// Un fichier local de configuration existe
|
||||||
/*
|
|
||||||
if ( file_exists(self::FILE_DIR . 'source/fonts/fonts.json') )
|
if ( file_exists(self::FILE_DIR . 'source/fonts/fonts.json') )
|
||||||
{
|
{
|
||||||
// Lire le fichier et check l'existence des fichiers locaux
|
// Lire le fichier et check l'existence des fichiers locaux
|
||||||
$fontList = json_decode(file_get_contents (self::FILE_DIR . "source/fonts/fonts.json"), true);
|
$localFonts = json_decode(file_get_contents (self::FILE_DIR . "source/fonts/fonts.json"), true);
|
||||||
// Validité du format
|
// Validité du format
|
||||||
if (is_array($fontList) ) {
|
if (is_array($localFonts) ) {
|
||||||
foreach ($fontList as $fontId => $fontName) {
|
foreach ($localFonts as $fontId => $fontName) {
|
||||||
|
|
||||||
// Validité du tableau :
|
// Validité du tableau :
|
||||||
// L'id de la police est présent dans la liste interne
|
// L'id de la police est présent dans la liste interne
|
||||||
// Le nom de la police fournie correspond à un fichier existant
|
// Le nom de la police fournie correspond à un fichier existant
|
||||||
//
|
|
||||||
if ( array_key_exists($fontId, self::$fonts) &&
|
if ( array_key_exists($fontId, self::$fonts) &&
|
||||||
file_exists(self::FILE_DIR . 'source/fonts/' . $fontName) ) {
|
file_exists(self::FILE_DIR . 'source/fonts/' . $fontName) ) {
|
||||||
// Chargement de la police
|
// La police locale est-elle invoquée ?
|
||||||
|
$d = array_search($fontId, $cdnFonts);
|
||||||
|
if ($d) {
|
||||||
|
// Chargement de la police demandée dans le thème
|
||||||
$formatFont = explode('.', self::FILE_DIR . 'source/fonts/' . $fontName);
|
$formatFont = explode('.', self::FILE_DIR . 'source/fonts/' . $fontName);
|
||||||
$css .= '@import url("' . helper::baseUrl(false) . self::FILE_DIR . 'source/fonts/' . $fontName . '");';
|
$css .= '@font-face { font-family:"' . self::$fonts[$fontId] . '";';
|
||||||
// Déchargement l'élément des fonts en ligne
|
$css .= 'src: url("' . helper::baseUrl(false) . self::FILE_DIR . 'source/fonts/' . $fontName . '");}';
|
||||||
unset($importFonts[$fontId]);
|
// Supprimer l'élément des fontes chargées en ligne
|
||||||
|
unset($cdnFonts[$d]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
}
|
||||||
// Chargement en ligne des polices
|
}
|
||||||
foreach ($importFonts as $fontId) {
|
}
|
||||||
|
// Chargement des polices en ligne
|
||||||
|
if ($cdnFonts) {
|
||||||
|
foreach ($cdnFonts as $fontId) {
|
||||||
$css .= '@import url("http://fonts.cdnfonts.com/css/' . $fontId . '");';
|
$css .= '@import url("http://fonts.cdnfonts.com/css/' . $fontId . '");';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fond du body
|
// Fond du body
|
||||||
$colors = helper::colorVariants($this->getData(['theme', 'body', 'backgroundColor']));
|
$colors = helper::colorVariants($this->getData(['theme', 'body', 'backgroundColor']));
|
||||||
@ -2487,15 +2490,61 @@ class core extends common {
|
|||||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||||
header("Pragma: no-cache");
|
header("Pragma: no-cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check la version rafraichissement du theme admin
|
// Check la version rafraichissement du theme admin
|
||||||
$cssVersion = preg_split('/\*+/', file_get_contents(self::DATA_DIR.'admin.css'));
|
$cssVersion = preg_split('/\*+/', file_get_contents(self::DATA_DIR.'admin.css'));
|
||||||
if(empty($cssVersion[1]) OR $cssVersion[1] !== md5(json_encode($this->getData(['admin'])))) {
|
if(empty($cssVersion[1]) OR $cssVersion[1] !== md5(json_encode($this->getData(['admin'])))) {
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
$css = '/*' . md5(json_encode($this->getData(['admin']))) . '*/';
|
$css = '/*' . md5(json_encode($this->getData(['admin']))) . '*/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import des polices de caractères
|
||||||
|
* A partir du CDN ou dans le dossier site/file/source/fonts
|
||||||
|
*/
|
||||||
|
$cdnFonts = [ $this->getData(['admin', 'fontText']),
|
||||||
|
$this->getData(['admin', 'fontTitle']),
|
||||||
|
];
|
||||||
|
// Suppression des polices identiques
|
||||||
|
$cdnFonts = array_unique($cdnFonts);
|
||||||
|
// Un fichier local de configuration existe
|
||||||
|
if ( file_exists(self::FILE_DIR . 'source/fonts/fonts.json') )
|
||||||
|
{
|
||||||
|
// Lire le fichier et check l'existence des fichiers locaux
|
||||||
|
$localFonts = json_decode(file_get_contents (self::FILE_DIR . "source/fonts/fonts.json"), true);
|
||||||
|
// Validité du format
|
||||||
|
if (is_array($localFonts) ) {
|
||||||
|
foreach ($localFonts as $fontId => $fontName) {
|
||||||
|
// Validité du tableau :
|
||||||
|
// L'id de la police est présent dans la liste des polcies locales
|
||||||
|
// Le nom de la police fournie correspond à un fichier existant
|
||||||
|
if ( array_key_exists($fontId, self::$fonts) &&
|
||||||
|
file_exists(self::FILE_DIR . 'source/fonts/' . $fontName) ) {
|
||||||
|
// La police locale est-elle invoquée ?
|
||||||
|
$d = array_search($fontId, $cdnFonts);
|
||||||
|
if ($d) {
|
||||||
|
// Chargement de la police demandée dans le thème
|
||||||
|
$formatFont = explode('.', self::FILE_DIR . 'source/fonts/' . $fontName);
|
||||||
|
$css .= '@font-face { font-family:"' . self::$fonts[$fontId] . '";';
|
||||||
|
$css .= 'src: url("' . helper::baseUrl(false) . self::FILE_DIR . 'source/fonts/' . $fontName . '");}';
|
||||||
|
// Supprimer l'élément des fontes chargées en ligne
|
||||||
|
unset($cdnFonts[$d]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Chargement des polices en ligne
|
||||||
|
if ($cdnFonts) {
|
||||||
|
foreach ($cdnFonts as $fontId) {
|
||||||
|
$css .= '@import url("http://fonts.cdnfonts.com/css/' . $fontId . '");';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$colors = helper::colorVariants($this->getData(['admin','backgroundColor']));
|
$colors = helper::colorVariants($this->getData(['admin','backgroundColor']));
|
||||||
$css .= '#site{background-color:' . $colors['normal']. ';}';
|
$css .= '#site{background-color:' . $colors['normal']. ';}';
|
||||||
$css .= '.row > div {font:' . $this->getData(['admin','fontSize']) . ' "' . $this->getData(['admin','fontText']) . '", sans-serif;}';
|
$css .= '.row > div {font:' . $this->getData(['admin','fontSize']) . ' "' . self::$fonts[$this->getData(['admin','fontText'])] . '", sans-serif;}';
|
||||||
$css .= 'body h1, h2, h3, h4 a, h5, h6 {font-family:' . $this->getData(['admin','fontTitle' ]) . ', sans-serif;color:' . $this->getData(['admin','colorTitle' ]) . ';}';
|
$css .= 'body h1, h2, h3, h4 a, h5, h6 {font-family:' . self::$fonts[$this->getData(['admin','fontTitle'])] . ', sans-serif;color:' . $this->getData(['admin','colorTitle' ]) . ';}';
|
||||||
|
|
||||||
// TinyMCE
|
// TinyMCE
|
||||||
$css .= 'body:not(.editorWysiwyg),span .zwiico-help {color:' . $this->getData(['admin','colorText']) . ';}';
|
$css .= 'body:not(.editorWysiwyg),span .zwiico-help {color:' . $this->getData(['admin','colorText']) . ';}';
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user