bug : corrections de messages d'erreurs dans les logs dû à des tests manquants

This commit is contained in:
Khaganat 2024-11-27 17:52:44 +01:00
parent 3d86c95a2d
commit 11c0d3d20e
2 changed files with 41 additions and 3 deletions

View file

@ -41,7 +41,13 @@ function template_main()
// Show the page index... "Pages: [1]". // Show the page index... "Pages: [1]".
// Exclude the "reply" button. // Exclude the "reply" button.
$buttons_normal = $context['normal_buttons']; $buttons_normal = $context['normal_buttons'];
unset($buttons_normal['reply']); //unset($buttons_normal['reply']);
// On reprends avec plus de verif :
if (isset($buttons_normal['reply'])) {
unset($buttons_normal['reply']);
} else {
error_log('Attention : La clé "reply" est absente de $buttons_normal.');
}
echo ' echo '
<div class="pagesection"> <div class="pagesection">
<div class="pagelinks"> <div class="pagelinks">
@ -267,7 +273,14 @@ function template_main()
// Show the page index... "Pages: [1]". But after all posts. // Show the page index... "Pages: [1]". But after all posts.
// Exclude the "reply" button. // Exclude the "reply" button.
$buttons_normal = $context['normal_buttons']; $buttons_normal = $context['normal_buttons'];
unset($buttons_normal['reply']); //unset($buttons_normal['reply']);
//unset($buttons_normal['reply']);
// On reprends avec plus de verif :
if (isset($buttons_normal['reply'])) {
unset($buttons_normal['reply']);
} else {
error_log('Attention : La clé "reply" est absente de $buttons_normal.');
}
echo ' echo '
<div class="pagesection khbottom"> <div class="pagesection khbottom">
<div class="pagelinks"> <div class="pagelinks">
@ -290,9 +303,21 @@ function template_main()
</div>'; </div>';
// Put the "reply" button in its own strip. // Put the "reply" button in its own strip.
$buttons_reply = [ /*$buttons_reply = [
'reply' => $context['normal_buttons']['reply'], 'reply' => $context['normal_buttons']['reply'],
]; ];
Toujours un reply foireux */
// Vérifie si la clé 'reply' existe dans $context['normal_buttons']
if (isset($context['normal_buttons']['reply'])) {
// Si la clé existe, ajoute le bouton à $buttons_reply
$buttons_reply = [
'reply' => $context['normal_buttons']['reply'],
];
} else {
// Sinon, initialise $buttons_reply sans le bouton 'reply'
$buttons_reply = [];
error_log('La clé "reply" est absente dans $context["normal_buttons"] lors de la création de $buttons_reply.');
}
echo ' echo '
<div class="pagesection khbottom"> <div class="pagesection khbottom">
<div style="margin-left: auto;"> <div style="margin-left: auto;">

View file

@ -676,9 +676,22 @@ function template_button_strip_single_button($key, $value, $buttons) {
if (!isset($value['id'])) if (!isset($value['id']))
$value['id'] = $key; $value['id'] = $key;
/* modif pour corriger une erreur de log
$button = ' $button = '
<a class="button button_strip_' . $key . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>'.(!empty($value['icon']) ? '<span class="main_icons '.$value['icon'].'"></span>' : '').'' . $txt[$value['text']] . '</a>'; <a class="button button_strip_' . $key . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>'.(!empty($value['icon']) ? '<span class="main_icons '.$value['icon'].'"></span>' : '').'' . $txt[$value['text']] . '</a>';
*/
// Construire le bouton de manière sécurisée
$class = isset($value['class']) ? ' ' . $value['class'] : '';
$url = !empty($value['url']) ? 'href="' . htmlspecialchars($value['url']) . '"' : ''; // Sécurise l'URL
$custom = isset($value['custom']) ? ' ' . $value['custom'] : '';
$icon = !empty($value['icon']) ? '<span class="main_icons ' . htmlspecialchars($value['icon']) . '"></span>' : '';
$text = isset($value['text']) && isset($txt[$value['text']]) ? $txt[$value['text']] : 'Texte manquant'; // Vérifie la validité de $value['text']
// Génère le bouton
$button = '
<a class="button button_strip_' . htmlspecialchars($key) . $class . '" ' . $url . $custom . '>' . $icon . $text . '</a>';
$buttons[] = $button; $buttons[] = $button;
} }