@ -179,22 +179,18 @@ class common {
];
// Fontes
public static $fonts = [
];
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',
'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',
'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;',
'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;',
];
@ -294,7 +290,7 @@ class common {
// Construit la liste des pages parents/enfants
if($this->hierarchy['all'] === []) {
$pages = helper::arrayColl umn($this->getData(['page']), 'position', 'SORT_ASC');
$pages = helper::arrayColumn($this->getData(['page']), 'position', 'SORT_ASC');
// Parents
foreach($pages as $pageId => $pagePosition) {
if(
@ -407,6 +403,48 @@ 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'],
'ressource' => $fontValue ['ressource']
];
}
}
// 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'],
'ressource' => $fontValue ['ressource']
];
}
}
return $f;
}
/**
* Check du token CSRF (true = bo
*/
@ -2232,27 +2270,6 @@ class core extends common {
}
}
/**
* Traitement des polices de caractères
*/
// Fusionne la liste des fontes avec les webSafe
foreach (self::$fontsWebSafe as $fontId => $fontValue) {
$fontName = explode (',', $fontValue);
self::$fonts [$fontId] = $fontName[0];
}
// Importe les polices personnalisées
$fontsImported = $this->getData(['fonts', 'imported']);
if (is_array($fontsImported) & &
!empty ($fontsImported)
) {
// Fusionner avec les fontes installées
self::$fonts = array_merge(self::$fonts, $fontsImported);
}
// Tri Alphabétique
asort(self::$fonts);
// Crée le fichier de personnalisation avancée
if(file_exists(self::DATA_DIR.'custom.css') === false) {
file_put_contents(self::DATA_DIR.'custom.css', file_get_contents('core/module/theme/resource/custom.css'));
@ -2268,18 +2285,24 @@ class core extends common {
file_put_contents(self::DATA_DIR.'admin.css', '');
chmod(self::DATA_DIR.'admin.css', 0755);
}
// Check la version rafraichissement du theme
$cssVersion = preg_split('/\*+/', file_get_contents(self::DATA_DIR.'theme.css'));
if(empty($cssVersion[1]) OR $cssVersion[1] !== md5(json_encode($this->getData(['theme'])))) {
// Version
$css = '/*' . md5(json_encode($this->getData(['theme']))) . '*/';
/**
* Import des polices de caractères
* A partir du CDN
* ou dans le dossier site/file/source/fonts
* ou pas du tout si fonte webSafe
*/
// Fonts disponibles
$fontsAvailable = $this->getFonts();
// Fontes installées
$fonts = [ $this->getData(['theme', 'text', 'font']),
$this->getData(['theme', 'title', 'font']),
$this->getData(['theme', 'header', 'font']),
@ -2290,51 +2313,50 @@ class core extends common {
$fonts = array_unique($fonts);
/**
* Fontes Web Safe, ne sont pas chargées.
* Charge les fontes websafe
*/
$fontFile = '';
foreach ($fonts as $fontId) {
if (array_key_exists($fontId, self::$fontsWebSafe) ) {
unset($fonts[$fontId]) ;
if ( isset($fontsAvailable['websafe'][$fontId]) ) {
$fonts [$fontId] = $fontsAvailable['websafe'][$fontId]['font-family'] ;
}
}
/**
* Chargement des polices en ligne dans un fichier séparé
* Chargement des polices en ligne dans un fichier fonts.html inclus dans main.php
*/
// Lire le fichier des fontes locales
$localFonts = $this->getData(['fonts', 'files']);
$fontFile = '';
foreach ($fonts as $fontId) {
if (!array_key_exists($fontId, $localFonts) ) {
$fontFile .= '< link href = " https://fonts.cdnfonts.com/css/' . $fontId .'" rel = "stylesheet" > ';
// Supprimer l'élément des fontes chargées en lign e
unset($fonts[$fontId]) ;
if ( isset($fontsAvailable['imported'][$fontId]) ) {
$fontFile .= '< link href = " ' . $fontsAvailable['imported'][$fontId]['ressource'] .'" rel = "stylesheet" > ';
// Tableau pour la construction de la feuille de styl e
$fonts [$fontId] = $fontsAvailable['imported'][$fontId]['font-family'] ;
}
}
// Enregistre la personnalisation
file_put_contents(self::DATA_DIR.'fonts/fonts.html', $fontFile);
/**
* Fontes installées localement
*/
// Validité du format
if ( !empty($localFonts)
) {
foreach ($localFonts as $fontId => $fontName) {
// Validité du tableau :
if ( array_key_exists($fontId, self::$fonts) & &
file_exists(self::DATA_DIR . 'fonts/' . $fontName) ) {
// Chargement de la police
//$formatFont = explode('.', self::DATA_DIR . 'fonts/' . $fontName);
$css .= '@font-face {font-family:"' . self::$fonts[$fontId] . '";';
$css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontName . '");}';
}
foreach ($fonts as $fontId) {
// Validité du tableau :
if ( isset($fontsAvailable['files'][$fontId]) & &
file_exists(self::DATA_DIR . 'fonts/' . $f) ) {
// Chargement de la police
//$formatFont = explode('.', self::DATA_DIR . 'fonts/' . $fontName);
$css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";';
$css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' .$fontsAvailable['files'][$fontId]['ressource'] . '");}';
// Tableau pour la construction de la feuille de style
$fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family'];
}
}
// Fond du body
$colors = helper::colorVariants($this->getData(['theme', 'body', 'backgroundColor']));
// Body
$css .= 'body{font-family:" ' . self:: $fonts[$this->getData(['theme', 'text', 'font'])] . '",sans-serif }';
$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']) . '}';
@ -2352,7 +2374,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'])] . '",sans-serif }';
$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;}';
@ -2393,7 +2415,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'])] . '",sans-serif ;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']));
@ -2427,7 +2449,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'])] . '",sans-serif ;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é
@ -2476,7 +2498,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'])] . '",sans-serif ;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']));
@ -2486,7 +2508,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'])] . '",sans-serif ;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}';
@ -2497,10 +2519,8 @@ class core extends common {
$css .= '#footerText > p {text-align:' . $this->getData(['theme', 'footer', 'textAlign']) . '}';
$css .= '#footerCopyright{text-align:' . $this->getData(['theme', 'footer', 'copyrightAlign']) . '}';
// Enregistre la personnalisation
file_put_contents(self::DATA_DIR.'theme.css', $css);
file_put_contents(self::DATA_DIR.'fonts/fonts.html', $fontFile);
// Effacer le cache pour tenir compte de la couleur de fond TinyMCE
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@ -2527,52 +2547,51 @@ class core extends common {
$fonts = array_unique($fonts);
/**
* Fontes Web Safe, ne sont pas chargées.
* Charge les fontes websafe
*/
$fontFile = '';
foreach ($fonts as $fontId) {
if (array_key_exists($fontId, self::$fontsWebSafe) ) {
unset($fonts[$fontId]) ;
if ( isset($fontsAvailable['websafe'][$fontId]) ) {
$fonts [$fontId] = $fontsAvailable['websafe'][$fontId]['font-family'] ;
}
}
// Lire le fichier des fontes locales
$localFonts = $this->getData(['fonts', 'files']);
/**
* Chargement des polices en ligne
* Chargement des polices en ligne dans un fichier fonts.html inclus dans main.php
*/
$fontFile = '';
foreach ($fonts as $fontId) {
if (!array_key_exists($fontId, $localFonts) ) {
$css .= '@import url("http://fonts.cdnfonts.com/css/' . $fontId . '"); ';
// Supprimer l'élément des fontes chargées en lign e
unset($fonts[$fontId]) ;
if ( isset($fontsAvailable['imported'][$fontId]) ) {
$fontFile .= '< link href = "' . $fontsAvailable['imported'][$fontId]['ressource'] .'" rel = "stylesheet" > ';
// Tableau pour la construction de la feuille de styl e
$fonts [$fontId] = $fontsAvailable['imported'][$fontId]['font-family'] ;
}
}
// Enregistre la personnalisation
file_put_contents(self::DATA_DIR.'fonts/fonts.html', $fontFile);
/**
* Fontes installées localement
*/
// Validité du format
if ( !empty($localFonts)
) {
foreach ($localFonts as $fontId => $fontName) {
// Validité du tableau :
if ( array_key_exists($fontId, self::$fonts) & &
file_exists(self::DATA_DIR . 'fonts/' . $fontName) ) {
// Chargement de la police
//$formatFont = explode('.', self::DATA_DIR . 'fonts/' . $fontName);
$css .= '@font-face {font-family:"' . self::$fonts[$fontId] . '";';
$css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontName . '");}';
}
foreach ($fonts as $fontId) {
// Validité du tableau :
if ( isset($fontsAvailable['files'][$fontId]) & &
file_exists(self::DATA_DIR . 'fonts/' . $f) ) {
// Chargement de la police
//$formatFont = explode('.', self::DATA_DIR . 'fonts/' . $fontName);
$css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";';
$css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' .$fontsAvailable['files'][$fontId]['ressource'] . '");}';
// Tableau pour la construction de la feuille de style
$fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family'];
}
}
// Thème Administration
$colors = helper::colorVariants($this->getData(['admin','backgroundColor']));
$css .= '#site{background-color:' . $colors['normal']. ';}';
$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:" ' . self:: $fonts[$this->getData(['admin','fontTitle'])] . '", sans-serif ;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']) . ';}';