Revert "Formatage du message d'erreur d'erreur de démarrage"

This reverts commit 688e10e35617d728dcd2d4bafda187e8286b1011.
This commit is contained in:
Fred Tempez 2025-01-27 18:44:04 +01:00
parent 688e10e356
commit 3c180b04f9
13 changed files with 52 additions and 251 deletions

View File

@ -1,89 +0,0 @@
<?php
/**
* This file is part of Zwii.
*
* For full copyright and license information, please see the LICENSE
* file that was distributed with this source code.
*
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2025, Frédéric Tempez
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
* @link http://zwiicms.fr/
*/
class chat extends common
{
const VERSION = '0.1';
const REALNAME = 'Chat';
const DELETE = true;
const UPDATE = '0.0';
const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json)
public static $actions = [
//'add' => self::GROUP_MODERATOR,
//'config' => self::GROUP_MODERATOR,
//'edit' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR,
'getFormattedMessages' => self::GROUP_VISITOR,
];
public static $messages = [];
public function index(): void
{
if ($this->isPost()) {
$message = filter_input(INPUT_POST, 'message');
if ($message) {
$timestamp = time();
$userId = $this->getUser('id');
$chatData = $this->getData(['module', $this->getUrl(2), 'chat']) ?? [];
$chatData[$timestamp] = [
'user_id' => $userId,
'message' => $message
];
$this->setData(['module', $this->getUrl(2), 'chat'], $chatData);
if (
isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'
) {
echo json_encode(['success' => true]);
exit;
}
}
}
self::$messages = $this->getFormattedMessages();
// Valeurs en sortie
$this->addOutput([
'title' => 'ChatRoom',
'view' => 'index'
]);
}
private function getFormattedMessages()
{
$chatData = $this->getData(['module', $this->getUrl(2), 'chat']) ?? [];
$messages = [];
krsort($chatData);
foreach ($chatData as $timestamp => $data) {
$messages[] = [
'timestamp' => $timestamp,
'user_id' => $data['user_id'],
'username' => $this->getUser('id'),
'message' => $data['message']
];
}
return $messages;
}
}

View File

@ -1,55 +0,0 @@
.chat-container {
max-width: 800px;
margin: 0 auto;
}
.chat-messages {
height: 400px;
overflow-y: auto;
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 10px;
}
.message {
margin-bottom: 10px;
padding: 5px;
background: #f5f5f5;
border-radius: 4px;
}
.username {
font-weight: bold;
margin-right: 10px;
color: #2c5282;
}
.timestamp {
color: #666;
font-size: 0.8em;
}
.chat-form {
display: flex;
gap: 10px;
}
#messageInput {
flex: 1;
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 8px 16px;
background: #4299e1;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background: #2b6cb0;
}

View File

@ -1,37 +0,0 @@
document.getElementById('chatForm').addEventListener('submit', function (e) {
e.preventDefault();
const messageInput = document.getElementById('messageInput');
const message = messageInput.value;
fetch(window.location.href, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
},
body: 'message=' + encodeURIComponent(message)
})
.then(response => response.json())
.then(data => {
if (data.success) {
messageInput.value = '';
location.reload(); // Option simple - vous pourriez préférer une mise à jour AJAX plus sophistiquée
}
});
});
// Fonction optionnelle pour actualiser automatiquement le chat
function refreshChat() {
fetch(window.location.href)
.then(response => response.text())
.then(html => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const newMessages = doc.querySelector('#chatMessages').innerHTML;
document.getElementById('chatMessages').innerHTML = newMessages;
});
}
// Décommentez pour activer l'actualisation automatique
// setInterval(refreshChat, 10000); // Actualise toutes les 10 secondes

View File

@ -1,18 +0,0 @@
<div class="chat-container">
<div class="chat-messages" id="chatMessages">
<?php
foreach (chat::$messages as $message):
?>
<div class="message">
<span class="username"><?= htmlspecialchars($message['username']) ?></span>
<span class="timestamp"><?= date('H:i', $message['timestamp']) ?></span>
<p class="content"><?= htmlspecialchars($message['message']) ?></p>
</div>
<?php endforeach; ?>
</div>
<form id="chatForm" class="chat-form" method="post">
<input type="text" name="message" id="messageInput" placeholder="Votre message..." required>
<button type="submit">Envoyer</button>
</form>
</div>

View File

@ -56,13 +56,13 @@
]); ?>
</div>
<div class="col3">
<?php echo template::select('downloadAddLicense', download::$licenses, [
<?php echo template::select('downloadAddLicense', $module::$licenses, [
'label' => 'Licence'
]); ?>
</div>
<div class="col3">
<?php if (download::$categories) {
echo template::select('downloadAddCategorie', download::$categories, [
<?php if ($module::$categories) {
echo template::select('downloadAddCategorie', $module::$categories, [
'label' => 'Catégorie'
]);
} else {
@ -83,7 +83,7 @@
</div>
<div class="row">
<div class="col3">
<?php echo template::select('downloadAddRessourceType', download::$ressourceType, [
<?php echo template::select('downloadAddRessourceType', $module::$ressourceType, [
'label' => 'Type de ressource',
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'ressourceType'])
]); ?>
@ -123,7 +123,7 @@
<h4>Options de publication</h4>
<div class="row">
<div class="col4">
<?php echo template::select('downloadAddUserId', download::$users, [
<?php echo template::select('downloadAddUserId', $module::$users, [
'label' => 'Auteur',
'selected' => $this->getUser('id'),
'disabled' => $this->getUser('group') !== self::GROUP_ADMIN ? true : false
@ -138,9 +138,9 @@
]); ?>
</div>
<div class="col4">
<?php echo template::select('downloadAddConsent', download::$itemConsent, [
<?php echo template::select('downloadAddConsent', $module::$itemConsent, [
'label' => 'Edition - Suppression',
'selected' => is_numeric($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent'])) ? download::EDIT_GROUP : $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent']),
'selected' => is_numeric($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent'])) ? $module::EDIT_GROUP : $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent']),
'help' => 'Les utilisateurs des groupes supérieurs accèdent à l\'item sans restriction'
]); ?>
</div>
@ -165,7 +165,7 @@
]); ?>
</div>
<div class="col4 commentOptionsWrapper">
<?php echo template::select('downloadAddCommentMaxlength', download::$commentLength, [
<?php echo template::select('downloadAddCommentMaxlength', $module::$commentLength, [
'help' => 'Choix du nombre maximum de caractères pour chaque commentaire de l\'item, mise en forme html comprise.',
'label' => 'Caractères par commentaire',
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentMaxlength'])
@ -180,7 +180,7 @@
]); ?>
</div>
<div class="col4 commentOptionsWrapper">
<?php echo template::select('downloadAddCommentGroupNotification', download::$groupNews, [
<?php echo template::select('downloadAddCommentGroupNotification', $module::$groupNews, [
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentGroupNotification']),
'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs'
]); ?>

View File

@ -29,12 +29,12 @@
</div>
</div>
<?php echo template::formClose(); ?>
<?php if (download::$categories): ?>
<?php echo template::table([2, 6, 1, 1], download::$categories, ['Nom', 'URL', '', '']); ?>
<?php echo download::$pages; ?>
<?php if ($module::$categories): ?>
<?php echo template::table([2, 6, 1, 1], $module::$categories, ['Nom', 'URL', '', '']); ?>
<?php echo $module::$pages; ?>
<?php else: ?>
<?php echo template::speech('Aucune catégorie'); ?>
<?php endif; ?>
<div class=" moduleVersion">Version
<?php echo download::VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

View File

@ -7,14 +7,14 @@
]); ?>
</div>
<?php if(download::$comments): ?>
<?php if($module::$comments): ?>
<div class="col2 offset9">
<?php echo download::$commentsDelete; ?>
<?php echo $module::$commentsDelete; ?>
</div>
</div>
<?php echo template::table([3, 5, 2, 1, 1], download::$comments, ['Date', 'Contenu', 'Auteur', '', '']); ?>
<?php echo download::$pages.'<br/>'; ?>
<?php echo template::table([3, 5, 2, 1, 1], $module::$comments, ['Date', 'Contenu', 'Auteur', '', '']); ?>
<?php echo $module::$pages.'<br/>'; ?>
<?php else: ?>
</div>
<?php echo template::speech('Aucun commentaire.'); ?>

View File

@ -29,12 +29,12 @@
]); ?>
</div>
</div>
<?php if (download::$items): ?>
<?php echo template::table([2, 2, 1, 2, 1, 1, 1, 1, 1], download::$items, ['Titre', 'Catégorie ' . download::$allCategories, 'Version', 'Du', 'Stats', 'État', 'Comm', '', '']); ?>
<?php echo download::$pages; ?>
<?php if ($module::$items): ?>
<?php echo template::table([2, 2, 1, 2, 1, 1, 1, 1, 1], $module::$items, ['Titre', 'Catégorie ' . $module::$allCategories, 'Version', 'Du', 'Stats', 'État', 'Comm', '', '']); ?>
<?php echo $module::$pages; ?>
<?php else: ?>
<?php echo template::speech('Aucune ressource'); ?>
<?php endif; ?>
<div class="moduleVersion">Version
<?php echo download::VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

View File

@ -68,14 +68,14 @@
]); ?>
</div>
<div class="col3">
<?php echo template::select('downloadEditLicense', download::$licenses, [
<?php echo template::select('downloadEditLicense', $module::$licenses, [
'label' => 'Licence',
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'license'])
]); ?>
</div>
<div class="col3">
<?php if (download::$categories) {
echo template::select('downloadEditCategorie', download::$categories, [
<?php if ($module::$categories) {
echo template::select('downloadEditCategorie', $module::$categories, [
'label' => 'Catégorie',
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'category'])
]);
@ -99,7 +99,7 @@
</div>
<div class="row">
<div class="col3">
<?php echo template::select('downloadEditRessourceType', download::$ressourceType, [
<?php echo template::select('downloadEditRessourceType', $module::$ressourceType, [
'label' => 'Type de ressource',
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'ressourceType'])
]); ?>
@ -141,7 +141,7 @@
<h4>Options de publication</h4>
<div class="row">
<div class="col4">
<?php echo template::select('downloadEditUserId', download::$users, [
<?php echo template::select('downloadEditUserId', $module::$users, [
'label' => 'Auteur',
'selected' => $this->getUser('id'),
'disabled' => $this->getUser('group') !== self::GROUP_ADMIN ? true : false
@ -156,9 +156,9 @@
]); ?>
</div>
<div class="col4">
<?php echo template::select('downloadEditConsent', download::$itemConsent, [
<?php echo template::select('downloadEditConsent', $module::$itemConsent, [
'label' => 'Edition - Suppression',
'selected' => is_numeric($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent'])) ? download::EDIT_GROUP : $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent']),
'selected' => is_numeric($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent'])) ? $module::EDIT_GROUP : $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'editConsent']),
'help' => 'Les utilisateurs des groupes supérieurs accèdent à l\'item sans restriction'
]); ?>
</div>
@ -183,7 +183,7 @@
]); ?>
</div>
<div class="col4 commentOptionsWrapper">
<?php echo template::select('downloadEditCommentMaxlength', download::$commentLength, [
<?php echo template::select('downloadEditCommentMaxlength', $module::$commentLength, [
'help' => 'Choix du nombre maximum de caractères pour chaque commentaire de l\'item, mise en forme html comprise.',
'label' => 'Caractères par commentaire',
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentMaxlength'])
@ -198,7 +198,7 @@
]); ?>
</div>
<div class="col4 commentOptionsWrapper">
<?php echo template::select('downloadEditCommentGroupNotification', download::$groupNews, [
<?php echo template::select('downloadEditCommentGroupNotification', $module::$groupNews, [
'selected' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'commentGroupNotification']),
'help' => 'Editeurs = éditeurs + administrateurs<br/> Membres = membres + éditeurs + administrateurs'
]); ?>

View File

@ -1,7 +1,7 @@
<?php if(download::$items): ?>
<?php if($module::$items): ?>
<div class="row">
<div class="col12">
<?php foreach(download::$items as $itemId => $item): ?>
<?php foreach($module::$items as $itemId => $item): ?>
<div class="row rowitem">
<div class="col3 downloadLeft">
<?php
@ -51,7 +51,7 @@
<?php endforeach; ?>
</div>
</div>
<?php echo download::$pages; ?>
<?php echo $module::$pages; ?>
<?php if ($this->getData(['module',$this->getUrl(0), 'config', 'feeds'])): ?>
<div id="rssFeed">
<a type="application/rss+xml" href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?> ">

View File

@ -65,14 +65,14 @@
<div class="row">
<div class="col12 textAlignCenter">
<span>Licence :
<?php echo download::$licenses[$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'license'])]; ?>
<?php echo $module::$licenses[$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'license'])]; ?>
</span>
</div>
</div>
<?php if ($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'file'])): ?>
<div class="row">
<div class="col12 textAlignCenter">
<span>Téléchargements : <span id="downloadStats"><?php echo download::$statSum;'<span>'?></span>
<span>Téléchargements : <span id="downloadStats"><?php echo $module::$statSum;'<span>'?></span>
</div>
</div>
<?php endif; ?>
@ -85,7 +85,7 @@
</div>
<div class="row verticalAlignMiddle">
<div class="col12 downloadDate">
<?php echo download::$itemSignature . ' - ';?>
<?php echo $module::$itemSignature . ' - ';?>
<i class="far fa-calendar-alt"></i>
<?php $date = mb_detect_encoding(\PHP81_BC\strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])), 'UTF-8', true)
? \PHP81_BC\strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']))
@ -102,7 +102,7 @@
AND
( // Propriétaire
(
$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === download::EDIT_OWNER
$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === $module::EDIT_OWNER
AND ( $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'userId']) === $this->getUser('id')
OR $this->getUser('group') === self::GROUP_ADMIN )
)
@ -114,8 +114,8 @@
)
OR (
// Tout le monde
$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === download::EDIT_ALL
AND $this->getUser('group') >= download::$actions['config']
$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1),'editConsent']) === $module::EDIT_ALL
AND $this->getUser('group') >= $module::$actions['config']
)
)
): ?>
@ -145,8 +145,8 @@
<p>Cet item ne reçoit pas de commentaire.</p>
<?php else: ?>
<h3 id="comment">
<?php //$commentsNb = count(download::$comments); ?>
<?php $commentsNb = download::$nbCommentsApproved; ?>
<?php //$commentsNb = count($module::$comments); ?>
<?php $commentsNb = $module::$nbCommentsApproved; ?>
<?php $s = $commentsNb === 1 ? '': 's' ?>
<?php echo $commentsNb > 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?>
</h3>
@ -160,7 +160,7 @@
<?php echo template::text('downloadItemUserName', [
'label' => 'Nom',
'readonly' => true,
'value' => download::$editCommentSignature
'value' => $module::$editCommentSignature
]); ?>
<?php echo template::hidden('downloadItemUserId', [
'value' => $this->getUser('id')
@ -218,9 +218,9 @@
<?php endif;?>
<div class="row">
<div class="col12">
<?php foreach(download::$comments as $commentId => $comment): ?>
<?php foreach($module::$comments as $commentId => $comment): ?>
<div class="block">
<h4><?php echo download::$commentsSignature[$commentId]; ?>
<h4><?php echo $module::$commentsSignature[$commentId]; ?>
le <?php echo mb_detect_encoding(\PHP81_BC\strftime('%d %B %Y - %H:%M', $comment['createdOn']), 'UTF-8', true)
? \PHP81_BC\strftime('%d %B %Y - %H:%M', $comment['createdOn'])
: utf8_encode(\PHP81_BC\strftime('%d %B %Y - %H:%M', $comment['createdOn']));
@ -232,4 +232,4 @@
</div>
</div>
</div>
<?php echo download::$pages; ?>
<?php echo $module::$pages; ?>

View File

@ -30,7 +30,7 @@
]); ?>
</div>
<div class="col4">
<?php echo template::select('blogConfigItemsperPage', download::$ItemsList, [
<?php echo template::select('blogConfigItemsperPage', $module::$ItemsList, [
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])
]); ?>
@ -42,6 +42,6 @@
</div>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<?php echo download::VERSION; ?>
<?php echo $module::VERSION; ?>
</div>

View File

@ -21,16 +21,16 @@
<div class="row">
<div class="col12">
<h3> Nombre de téléchargements :
<?php echo download::$statSum; ?>
<?php echo $module::$statSum; ?>
</h3>
</div>
</div>
<?php if(download::$items): ?>
<?php echo template::table([6, 6], download::$items, ['Date', 'Adresse IP']); ?>
<?php echo download::$pages; ?>
<?php if($module::$items): ?>
<?php echo template::table([6, 6], $module::$items, ['Date', 'Adresse IP']); ?>
<?php echo $module::$pages; ?>
<?php else: ?>
<?php echo template::speech('Aucun item.'); ?>
<?php endif; ?>
<div class="moduleVersion">Version
<?php echo download::VERSION; ?>
<?php echo $module::VERSION; ?>
</div>