bug de fontes

This commit is contained in:
fredtempez 2022-03-18 16:12:30 +01:00
parent 8c9f3d0bd5
commit 82b3c27b8b
3 changed files with 40 additions and 51 deletions

View File

@ -216,7 +216,7 @@ core.start = function() {
var getUrl = window.location; var getUrl = window.location;
var domain = "domain=" + getUrl.host + ";"; var domain = "domain=" + getUrl.host + ";";
var path = "path=" + getUrl.pathname.split('/')[1] + ";"; var path = "path=" + getUrl.pathname.split('/')[1] + ";";
var e = new Date(); var e = new Date();
e.setFullYear(e.getFullYear() + 1); e.setFullYear(e.getFullYear() + 1);
var expires = "expires=" + e.toUTCString(); var expires = "expires=" + e.toUTCString();
@ -225,7 +225,7 @@ core.start = function() {
var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>"; var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>";
// l'Id GA est défini dans la configuration, afficher la checkbox d'acceptation // l'Id GA est défini dans la configuration, afficher la checkbox d'acceptation
if( analytics.length > 0){ if( analytics.length > 0){
// Traitement du retour de la checkbox // Traitement du retour de la checkbox
if ($("#googleAnalytics").is(":checked")) { if ($("#googleAnalytics").is(":checked")) {
// L'URL du serveur faut TRUE // L'URL du serveur faut TRUE

View File

@ -410,7 +410,7 @@ class common {
/** /**
* Construit la liste des fontes dans un tableau * Construit la liste des fontes dans un tableau
* @return array @fonts * @return array @fonts
* *
*/ */
public function getFonts() { public function getFonts() {
@ -2374,16 +2374,19 @@ class core extends common {
*/ */
foreach ($fonts as $fontId) { foreach ($fonts as $fontId) {
// Validité du tableau : // Validité du tableau :
if ( isset($fontsAvailable['files'][$fontId]) && if ( isset($fontsAvailable['files'][$fontId]) ) {
file_exists(self::DATA_DIR . 'fonts/' . $f) ) { if (file_exists(self::DATA_DIR . 'fonts/' . $fontId) ) {
// Chargement de la police // Chargement de la police
//$formatFont = explode('.', self::DATA_DIR . 'fonts/' . $fontName); //$formatFont = explode('.', self::DATA_DIR . 'fonts/' . $fontName);
$css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";'; $css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";';
$css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' .$fontsAvailable['files'][$fontId]['resource'] . '");}'; $css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'fonts/' .$fontsAvailable['files'][$fontId]['resource'] . '");}';
// Tableau pour la construction de la feuille de style // Tableau pour la construction de la feuille de style
$fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family']; $fonts [$fontId] = $fontsAvailable['files'][$fontId]['font-family'];
} else {
// Le fichier de font n'est pas disponible, fonte par défaut
$fonts [$fontId] = 'verdana';
}
} }
} }
// Fond du body // Fond du body

View File

@ -621,37 +621,31 @@ class theme extends common {
if ($this->isPost()) { if ($this->isPost()) {
// Type d'import en ligne ou local // Type d'import en ligne ou local
$type = $this->getInput('fontAddFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; $type = $this->getInput('fontAddFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files';
$ressource = $type === 'imported' ? $this->getInput('fontAddUrl', helper::FILTER_STRING_SHORT) : $this->getInput('fontAddFile', helper::FILTER__SHORT_STRING); $typeFlip = $type === 'files' ? 'imported' : 'files';
$ressource = $type === 'imported' ? $this->getInput('fontAddUrl', helper::FILTER_STRING_SHORT) : $this->getInput('fontAddFile', helper::FILTER_STRING_SHORT);
$fontId = $this->getInput('fontAddFontId', helper::FILTER_STRING_SHORT, true); $fontId = $this->getInput('fontAddFontId', helper::FILTER_STRING_SHORT, true);
$fontName = $this->getInput('fontAddFontName', helper::FILTER_STRING_SHORT, true); $fontName = $this->getInput('fontAddFontName', helper::FILTER_STRING_SHORT, true);
$fontFamilyName = $this->getInput('fontAddFontFamilyName', helper::FILTER_STRING_SHORT, true); $fontFamilyName = $this->getInput('fontAddFontFamilyName', helper::FILTER_STRING_SHORT, true);
// Vérifier l'existence de fontId et validité de family name si usage en ligne de cdnFonts // Supprime la fonte si elle existe dans le type inverse
if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) {
$this->deleteData(['fonts', $typeFlip, $fontId ]);
}
// Stocker la fonte
$this->setData(['fonts',
$type,
$fontId, [
'name' => $fontName,
'font-family' => $fontFamilyName,
'resource' => $ressource
]]);
// Charger les données des fontes
$fonts = $this->getData(['fonts']);
// Concaténation dans les tableaux existants
$t = [ $fontId => [
'name' => $fontName,
'font-family' => $fontFamilyName,
'resource' => $ressource
]];
// Stocker les fontes
$this->setData(['fonts', $type, [ $fontId =>
[
'name' => $fontName,
'font-family' => $fontFamilyName,
'resource' => $ressource
]]
]);
// Copier la fonte si le nom du fichier est fourni // Copier la fonte si le nom du fichier est fourni
if ( $type === 'files' && if ( $type === 'files' &&
is_file(self::FILE_DIR . 'source/' . $ressource) file_exists(self::FILE_DIR . 'source/' . $ressource)
) { ) {
copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource ); copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . $ressource );
} }
// Valeurs en sortie // Valeurs en sortie
@ -677,37 +671,29 @@ class theme extends common {
if ($this->isPost()) { if ($this->isPost()) {
// Type d'import en ligne ou local // Type d'import en ligne ou local
$type = $this->getInput('fontEditFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; $type = $this->getInput('fontEditFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files';
$ressource = $type === 'imported' ? $this->getInput('fontEditUrl', helper::FILTER_STRING_SHORT) : $this->getInput('fontEditFile', helper::FILTER__SHORT_STRING); $typeFlip = $type === 'files' ? 'imported' : 'files';
$ressource = $type === 'imported' ? $this->getInput('fontEditUrl', helper::FILTER_STRING_SHORT) : $this->getInput('fontEditFile', helper::FILTER_STRING_SHORT);
$fontId = $this->getInput('fontEditFontId', helper::FILTER_STRING_SHORT, true); $fontId = $this->getInput('fontEditFontId', helper::FILTER_STRING_SHORT, true);
$fontName = $this->getInput('fontEditFontName', helper::FILTER_STRING_SHORT, true); $fontName = $this->getInput('fontEditFontName', helper::FILTER_STRING_SHORT, true);
$fontFamilyName = $this->getInput('fontEditFontFamilyName', helper::FILTER_STRING_SHORT, true); $fontFamilyName = $this->getInput('fontEditFontFamilyName', helper::FILTER_STRING_SHORT, true);
// Vérifier l'existence de fontId et validité de family name si usage en ligne de cdnFonts // Supprime la fonte si elle existe dans le type inverse
if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) {
// Charger les données des fontes $this->deleteData(['fonts', $typeFlip, $fontId ]);
$fonts = $this->getData(['fonts']); }
// Concaténation dans les tableaux existants
$t = [ $fontId => [
'name' => $fontName,
'font-family' => $fontFamilyName,
'resource' => $ressource
]];
// Stocker les fontes // Stocker les fontes
$this->setData(['fonts', $type, [ $fontId => $this->setData(['fonts',
[ $type,
'name' => $fontName, $fontId, [
'font-family' => $fontFamilyName, 'name' => $fontName,
'resource' => $ressource 'font-family' => $fontFamilyName,
]] 'resource' => $ressource
]); ]]);
// Copier la fonte si le nom du fichier est fourni // Copier la fonte si le nom du fichier est fourni
if ( $type === 'files' && if ( $type === 'files' &&
is_file(self::FILE_DIR . 'source/' . $ressource) file_exists(self::FILE_DIR . 'source/' . $ressource)
) { ) {
copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource ); copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . $ressource );
} }
// Valeurs en sortie // Valeurs en sortie