Merge branch '12204' into 12300

This commit is contained in:
Fred Tempez 2023-02-16 14:01:20 +01:00
commit 42ec86a189
6 changed files with 86 additions and 43 deletions

View File

@ -15,6 +15,8 @@
- Correction de petits bugs. - Correction de petits bugs.
### Nouveautés : ### Nouveautés :
- Paramétrage du délai de recherche automatique d'une mise à jour, tous les jours, deux jours, quatre jours, toutes les semaines, tous les mois. - Paramétrage du délai de recherche automatique d'une mise à jour, tous les jours, deux jours, quatre jours, toutes les semaines, tous les mois.
### Corrections :
- Mauvais affichage du script ou du CSS déclaré dans une page.
## Version 12.2.03 ## Version 12.2.03
- Corrections de bugs consécutifs au changement de format de languages.json - Corrections de bugs consécutifs au changement de format de languages.json

View File

@ -117,6 +117,8 @@ class common
'showPageContent' => false, 'showPageContent' => false,
'state' => false, 'state' => false,
'style' => '', 'style' => '',
'inlineStyle' => [],
'inlineScript' => [],
'title' => null, 'title' => null,
// Null car un titre peut être vide // Null car un titre peut être vide
// Trié par ordre d'exécution // Trié par ordre d'exécution
@ -350,9 +352,9 @@ class common
self::$i18nUI = $this->getData(['user', $this->getUser('id'), 'language']); self::$i18nUI = $this->getData(['user', $this->getUser('id'), 'language']);
// Validation de la langue // Validation de la langue
self::$i18nUI = (empty(self::$i18nUI) || is_null(self::$i18nUI)) self::$i18nUI = (empty(self::$i18nUI) || is_null(self::$i18nUI))
&& !file_exists(self::I18N_DIR . self::$i18nUI . '.json') && !file_exists(self::I18N_DIR . self::$i18nUI . '.json')
? 'fr_FR' ? 'fr_FR'
: self::$i18nUI; : self::$i18nUI;
} }
// Stocker le cookie de langue pour l'éditeur de texte // Stocker le cookie de langue pour l'éditeur de texte
@ -1076,16 +1078,12 @@ class common
case 'image/jpeg': case 'image/jpeg':
case 'image/jpg': case 'image/jpg':
return (imagejpeg($virtual_image, $dest)); return (imagejpeg($virtual_image, $dest));
break;
case 'image/png': case 'image/png':
return (imagepng($virtual_image, $dest)); return (imagepng($virtual_image, $dest));
break;
case 'image/gif': case 'image/gif':
return (imagegif($virtual_image, $dest)); return (imagegif($virtual_image, $dest));
break;
case 'webp': case 'webp':
$source_image = imagecreatefromwebp($src); $source_image = imagecreatefromwebp($src);
break;
} }
} else { } else {
return (false); return (false);
@ -2288,11 +2286,14 @@ class common
* Affiche le script * Affiche le script
*/ */
public function showScript() public function showScript()
{ {
ob_start(); ob_start();
require 'core/core.js.php'; require 'core/core.js.php';
$coreScript = ob_get_clean(); $coreScript = ob_get_clean();
echo '<script>' . helper::minifyJs($coreScript . $this->output['script']) . '</script>'; if ($this->output['inlineScript']) {
$inlineScript = implode($this->output['inlineScript']);
}
echo '<script>' . helper::minifyJs( $coreScript . $this->output['script'] . htmlspecialchars_decode($inlineScript) ) . '</script>';
} }
/** /**
@ -2308,6 +2309,29 @@ class common
} }
echo '<style type="text/css">' . helper::minifyCss($this->output['style']) . '</style>'; echo '<style type="text/css">' . helper::minifyCss($this->output['style']) . '</style>';
} }
}
/**
* Affiche le style interne des pages
*/
public function showInlineStyle()
{
// Import des styles liés à la page
if ($this->output['inlineStyle']) {
foreach ($this->output['inlineStyle'] as $style) {
if ($style) {
echo '<style type="text/css">' . helper::minifyCss($style) . '</style>';
}
}
}
}
/**
* Importe les polices de caractères
*/
public function showFonts()
{
// Import des fontes liées au thème // Import des fontes liées au thème
if (file_exists(self::DATA_DIR . 'fonts/fonts.html')) { if (file_exists(self::DATA_DIR . 'fonts/fonts.html')) {
include_once(self::DATA_DIR . 'fonts/fonts.html'); include_once(self::DATA_DIR . 'fonts/fonts.html');
@ -2966,6 +2990,22 @@ class core extends common
'</a> &#8250; ' . '</a> &#8250; ' .
$this->getData(['page', $this->getUrl(0), 'title']); $this->getData(['page', $this->getUrl(0), 'title']);
} }
// Importe le style de la page principale
$inlineStyle[] = $this->getData(['page', $this->getUrl(0), 'css']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'css']);
// Importe le script de la page principale
$inlineScript[] = $this->getData(['page', $this->getUrl(0), 'js']) === null ? '' : $this->getData(['page', $this->getUrl(0), 'js']);
// Importe le contenu, le CSS et le script des barres
$contentRight = $this->getData(['page', $this->getUrl(0), 'barRight']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) : '';
$inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']);
$inlineScript[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']);
$contentLeft = $this->getData(['page', $this->getUrl(0), 'barLeft']) ? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) : '';
$inlineStyle[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']);
$inlineScript[] = $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js']) === null ? '' : $this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js']);
// Importe la page simple sans module ou avec un module inexistant // Importe la page simple sans module ou avec un module inexistant
if ( if (
$this->getData(['page', $this->getUrl(0)]) !== null $this->getData(['page', $this->getUrl(0)]) !== null
@ -2974,53 +3014,53 @@ class core extends common
) )
and $access and $access
) { ) {
// Importe le CSS de la page principale
$this->addOutput([ $this->addOutput([
'title' => $title, 'title' => $title,
'content' => $this->getPage($this->getUrl(0), self::$i18nContent) . 'content' => $this->getPage($this->getUrl(0), self::$i18nContent),
// Concatène avec les paramètres avancés.
$this->getData(['page', $this->getUrl(0), 'css']) .
$this->getData(['page', $this->getUrl(0), 'js']),
'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']), 'metaDescription' => $this->getData(['page', $this->getUrl(0), 'metaDescription']),
'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']),
'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']),
'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']),
'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']),
'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) 'contentRight' => $contentRight,
? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) . 'contentLeft' => $contentLeft,
$this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'css']) . 'inlineStyle' => $inlineStyle,
$this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barRight']), 'js']) 'inlineScript' => $inlineScript,
: '',
'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft'])
? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent) .
$this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'css']) .
$this->getData(['page', $this->getData(['page', $this->getUrl(0), 'barLeft']), 'js'])
: ''
]); ]);
} }
// Importe le module // Importe le module
else { else {
// Id du module, et valeurs en sortie de la page si il s'agit d'un module de page // Id du module, et valeurs en sortie de la page s'il s'agit d'un module de page
if ($access and $this->getData(['page', $this->getUrl(0), 'moduleId'])) { if ($access and $this->getData(['page', $this->getUrl(0), 'moduleId'])) {
$moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']);
// Construit un meta absent
$metaDescription = $this->getData(['page', $this->getUrl(0), 'moduleId']) === 'blog' && !empty($this->getUrl(1)) && in_array($this->getUrl(1), $this->getData(['module']))
? strip_tags(substr($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'content']), 0, 159))
: $this->getData(['page', $this->getUrl(0), 'metaDescription']);
// Importe le CSS de la page principale
$pageContent = $this->getPage($this->getUrl(0), self::$i18nContent);
$this->addOutput([ $this->addOutput([
'title' => $title, 'title' => $title,
// Meta description = 160 premiers caractères de l'article // Meta description = 160 premiers caractères de l'article
'metaDescription' => $this->getData(['page', $this->getUrl(0), 'moduleId']) === 'blog' && !empty($this->getUrl(1)) && in_array($this->getUrl(1), $this->getData(['module'])) 'content' => $pageContent,
? strip_tags(substr($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'content']), 0, 159)) 'metaDescription' => $metaDescription,
: $this->getData(['page', $this->getUrl(0), 'metaDescription']),
'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']), 'metaTitle' => $this->getData(['page', $this->getUrl(0), 'metaTitle']),
'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']), 'typeMenu' => $this->getData(['page', $this->getUrl(0), 'typeMenu']),
'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']), 'iconUrl' => $this->getData(['page', $this->getUrl(0), 'iconUrl']),
'disable' => $this->getData(['page', $this->getUrl(0), 'disable']), 'disable' => $this->getData(['page', $this->getUrl(0), 'disable']),
'contentRight' => $this->getData(['page', $this->getUrl(0), 'barRight']) 'contentRight' => $contentRight,
? $this->getPage($this->getData(['page', $this->getUrl(0), 'barRight']), self::$i18nContent) 'contentLeft' => $contentLeft,
: '', 'inlineStyle' => $inlineStyle,
'contentLeft' => $this->getData(['page', $this->getUrl(0), 'barLeft']) 'inlineScript' => $inlineScript,
? $this->getPage($this->getData(['page', $this->getUrl(0), 'barLeft']), self::$i18nContent)
: ''
]); ]);
$pageContent = $this->getPage($this->getUrl(0), self::$i18nContent);
} else { } else {
$moduleId = $this->getUrl(0); $moduleId = $this->getUrl(0);
$pageContent = ''; $pageContent = '';
@ -3115,7 +3155,8 @@ class core extends common
} }
if ($output['style']) { if ($output['style']) {
$this->addOutput([ $this->addOutput([
'style' => $this->output['style'] . file_get_contents($output['style']) //'style' => $this->output['style'] . file_get_contents($output['style'])
'style' => file_get_contents($output['style'])
]); ]);
} }
@ -3187,7 +3228,6 @@ class core extends common
} }
} }
} }
// Erreurs // Erreurs
if ($access === 'login') { if ($access === 'login') {
http_response_code(302); http_response_code(302);
@ -3246,7 +3286,6 @@ class core extends common
'metaDescription' => $this->getData(['locale', 'metaDescription']) 'metaDescription' => $this->getData(['locale', 'metaDescription'])
]); ]);
} }
;
switch ($this->output['display']) { switch ($this->output['display']) {
// Layout brut // Layout brut
case self::DISPLAY_RAW: case self::DISPLAY_RAW:

View File

@ -11,6 +11,7 @@
<?php $this->showFavicon(); ?> <?php $this->showFavicon(); ?>
<?php $this->showVendor(); ?> <?php $this->showVendor(); ?>
<?php $this->showStyle(); ?> <?php $this->showStyle(); ?>
<?php $this->showFonts(); ?>
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/blank.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/blank.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>">

View File

@ -11,6 +11,7 @@
<?php $this->showFavicon(); ?> <?php $this->showFavicon(); ?>
<?php $this->showVendor(); ?> <?php $this->showVendor(); ?>
<?php $this->showStyle(); ?> <?php $this->showStyle(); ?>
<?php $this->showFonts(); ?>
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/light.css"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/light.css">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR.'theme.css'); ?>">

View File

@ -10,6 +10,7 @@
<?php $this->showMetaImage(); ?> <?php $this->showMetaImage(); ?>
<?php $this->showFavicon(); ?> <?php $this->showFavicon(); ?>
<?php $this->showVendor(); ?> <?php $this->showVendor(); ?>
<?php $this->showFonts(); ?>
<link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css?<?php echo md5_file('core/layout/common.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false); ?>core/layout/common.css?<?php echo md5_file('core/layout/common.css'); ?>">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR . 'theme.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>theme.css?<?php echo md5_file(self::DATA_DIR . 'theme.css'); ?>">
<link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>custom.css?<?php echo md5_file(self::DATA_DIR . 'custom.css'); ?>"> <link rel="stylesheet" href="<?php echo helper::baseUrl(false) . self::DATA_DIR; ?>custom.css?<?php echo md5_file(self::DATA_DIR . 'custom.css'); ?>">
@ -22,6 +23,7 @@
<link rel="alternate" type="application/rss+xml" href="'<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?>" title="fLUX rss"> <link rel="alternate" type="application/rss+xml" href="'<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?>" title="fLUX rss">
<?php endif; ?> <?php endif; ?>
<?php $this->showStyle(); ?> <?php $this->showStyle(); ?>
<?php $this->showInlineStyle(); ?>
<!-- Script perso dans le header --> <!-- Script perso dans le header -->
<?php if (file_exists(self::DATA_DIR . 'head.inc.html')) { <?php if (file_exists(self::DATA_DIR . 'head.inc.html')) {
include(self::DATA_DIR . 'head.inc.html'); include(self::DATA_DIR . 'head.inc.html');

View File

@ -492,8 +492,8 @@ class page extends common
'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN), 'hideMenuHead' => $this->getinput('pageEditHideMenuHead', helper::FILTER_BOOLEAN),
'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN), 'hideMenuChildren' => $this->getinput('pageEditHideMenuChildren', helper::FILTER_BOOLEAN),
'extraPosition' => $this->getinput('pageEditExtraPosition', helper::FILTER_BOOLEAN), 'extraPosition' => $this->getinput('pageEditExtraPosition', helper::FILTER_BOOLEAN),
'css' => $this->getData(['page', $this->getUrl(2), 'css']), 'css' => $this->getData(['page', $this->getUrl(2), 'css']) == null ? '' : $this->getData(['page', $this->getUrl(2), 'css']),
'js' => $this->getData(['page', $this->getUrl(2), 'js']), 'js' => $this->getData(['page', $this->getUrl(2), 'js']) == null ? '' : $this->getData(['page', $this->getUrl(2), 'js']),
] ]
]); ]);
@ -571,8 +571,7 @@ class page extends common
{ {
// Soumission du formulaire // Soumission du formulaire
if ($this->isPost()) { if ($this->isPost()) {
// Supprime les balises styles si elles ont été saisies $css = $this->getInput('pageCssEditorContent') === null ? '': $this->getInput('pageCssEditorContent');
$css = $this->getInput('pageCssEditorContent', null);
// Enregistre le CSS // Enregistre le CSS
$this->setData([ $this->setData([
'page', $this->getUrl(2), 'page', $this->getUrl(2),
@ -603,8 +602,7 @@ class page extends common
{ {
// Soumission du formulaire // Soumission du formulaire
if ($this->isPost()) { if ($this->isPost()) {
// Supprime les balises scripts si elles ont été saisies $js = $this->getInput('pageJsEditorContent') === null ? '' : $this->getInput('pageJsEditorContent');
$js = $this->getInput('pageJsEditorContent', null);
// Enregistre le JS // Enregistre le JS
$this->setData([ $this->setData([
'page', $this->getUrl(2), 'page', $this->getUrl(2),