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

@ -2374,16 +2374,19 @@ class core extends common {
*/
foreach ($fonts as $fontId) {
// Validité du tableau :
if ( isset($fontsAvailable['files'][$fontId]) &&
file_exists(self::DATA_DIR . 'fonts/' . $f) ) {
if ( isset($fontsAvailable['files'][$fontId]) ) {
if (file_exists(self::DATA_DIR . 'fonts/' . $fontId) ) {
// 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]['resource'] . '");}';
// Tableau pour la construction de la feuille de style
$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

View File

@ -621,37 +621,31 @@ class theme extends common {
if ($this->isPost()) {
// Type d'import en ligne ou local
$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);
$fontName = $this->getInput('fontAddFontName', 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
// Charger les données des fontes
$fonts = $this->getData(['fonts']);
// Concaténation dans les tableaux existants
$t = [ $fontId => [
// 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
]];
]]);
// 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
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
@ -677,37 +671,29 @@ class theme extends common {
if ($this->isPost()) {
// Type d'import en ligne ou local
$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);
$fontName = $this->getInput('fontEditFontName', 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
// 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
]];
// Supprime la fonte si elle existe dans le type inverse
if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) {
$this->deleteData(['fonts', $typeFlip, $fontId ]);
}
// Stocker les fontes
$this->setData(['fonts', $type, [ $fontId =>
[
$this->setData(['fonts',
$type,
$fontId, [
'name' => $fontName,
'font-family' => $fontFamilyName,
'resource' => $ressource
]]
]);
]]);
// Copier la fonte si le nom du fichier est fourni
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