11505 bug catégorie de fonte vide + warning sur variable non initialisée

This commit is contained in:
Fred Tempez 2022-06-20 15:01:12 +02:00
parent 98bddca72a
commit af49819e37
1 changed files with 33 additions and 34 deletions

View File

@ -430,6 +430,7 @@ class theme extends common {
/**
* Stocker les images incluses dans la bannière perso dans un tableau
*/
$files = [];
preg_match_all('/<img[^>]+>/i',$featureContent, $results);
foreach($results[0] as $value) {
// Lire le contenu XML
@ -460,7 +461,7 @@ class theme extends common {
'tinyHidden' => $this->getInput('themeHeaderTinyHidden', helper::FILTER_BOOLEAN),
'feature' => $this->getInput('themeHeaderFeature'),
'featureContent' => $featureContent,
'featureFiles' => $files
'featureFiles' => $files
]]);
// Modification de la position du menu selon la position de la bannière
if ( $this->getData(['theme','header','position']) == 'site' )
@ -1188,21 +1189,20 @@ class theme extends common {
*/
$gf = false;
$fileContent = '<!-- Fontes personnalisées -->';
//if ( is_array($this->getData(['fonts', 'imported'])) &&
// !empty($this->getData(['fonts', 'imported'])) ) {
foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) {
if (
( $scope === 'user' && in_array($fontId, $fontsInstalled) )
|| $scope === 'all'
) {
//Pré chargement à revoir
//$fileContent .= '<link rel="preload" href="' . $fontValue['resource'] . '" crossorigin="anonymous" as="style">';
$fileContent .= '<link href="' . $fontValue['resource'] .'" rel="stylesheet">';
// Pré connect pour api.google
$gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true;
}
if ( !empty($this->getData(['fonts', 'imported'])) ) {
foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) {
if (
( $scope === 'user' && in_array($fontId, $fontsInstalled) )
|| $scope === 'all'
) {
//Pré chargement à revoir
//$fileContent .= '<link rel="preload" href="' . $fontValue['resource'] . '" crossorigin="anonymous" as="style">';
$fileContent .= '<link href="' . $fontValue['resource'] .'" rel="stylesheet">';
// Pré connect pour api.google
$gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true;
}
}
//}
}
// Ajoute le préconnect des fontes Googles.
$fileContent = $gf ? '<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' . $fileContent
@ -1214,27 +1214,26 @@ class theme extends common {
* Fontes installées localement
*/
$fileContentCss = '';
//if ( is_array($this->getData(['fonts', 'files'])) &&
// !empty($this->getData(['fonts', 'files'])) ) {
foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) {
if (
if ( !empty($this->getData(['fonts', 'files'])) ) {
foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) {
if (
( $scope === 'user' && in_array($fontId, $fontsInstalled) )
|| $scope === 'all'
) {
if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource']) ) {
// Extension
$path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']);
// Chargement de la police
$fileContentCss .= '@font-face {' ;
$fileContentCss .= 'font-family:"' . $fontValue['name'] . '";';
$fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");';
$fileContentCss .= '}' ;
// Préchargement
//$fileContent = '<link rel="preload" href="' . self::DATA_DIR . 'fonts/' . $fontValue['resource'] . '" type="font/woff" crossorigin="anonymous" as="font">' . $fileContent;
}
|| $scope === 'all'
) {
if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource']) ) {
// Extension
$path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']);
// Chargement de la police
$fileContentCss .= '@font-face {' ;
$fileContentCss .= 'font-family:"' . $fontValue['name'] . '";';
$fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");';
$fileContentCss .= '}' ;
// Préchargement
//$fileContent = '<link rel="preload" href="' . self::DATA_DIR . 'fonts/' . $fontValue['resource'] . '" type="font/woff" crossorigin="anonymous" as="font">' . $fileContent;
}
}
}
}
//}
}
// Enregistre la personnalisation
file_put_contents(self::DATA_DIR.'fonts/fonts.html', $fileContent);