Article okay
option select sizes
This commit is contained in:
Fred Tempez 2023-02-10 22:45:26 +01:00
parent ed46aeb65a
commit 862f8f3496
3 changed files with 107 additions and 85 deletions

View File

@ -208,7 +208,7 @@ class blog extends common
$newsArticle->addElementArray([
'title' => $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title']),
'link' => helper::baseUrl() . $this->getUrl(0) . '/' . $articleId,
'description' => '<img src="' . helper::baseUrl(false) . self::FILE_DIR .'thumb/' . $thumb
'description' => '<img src="' . helper::baseUrl(false) . self::FILE_DIR . 'thumb/' . $thumb
. '" alt="' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title'])
. '" title="' . $this->getData(['module', $this->getUrl(0), 'posts', $articleId, 'title'])
. '" />' .
@ -259,7 +259,8 @@ class blog extends common
'module',
$this->getUrl(0),
'posts',
$articleId, [
$articleId,
[
'content' => $this->getInput('blogAddContent', null),
'picture' => $this->getInput('blogAddPicture', helper::FILTER_STRING_SHORT),
'hidePicture' => $this->getInput('blogAddHidePicture', helper::FILTER_BOOLEAN),
@ -436,13 +437,18 @@ class blog extends common
// Inversion du statut
else {
$approved = !$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3), 'approval']);
$this->setData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3), [
$this->setData([
'module', $this->getUrl(0),
'posts', $this->getUrl(2),
'comment', $this->getUrl(3),
[
'author' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3), 'author']),
'content' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3), 'content']),
'createdOn' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3), 'createdOn']),
'userId' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment', $this->getUrl(3), 'userId']),
'approval' => $approved
]]);
]
]);
// Valeurs en sortie
$this->addOutput([
@ -539,7 +545,10 @@ class blog extends common
$this->update();
// Soumission du formulaire
if ($this->isPost()) {
$this->setData(['module', $this->getUrl(0), 'config', [
$this->setData([
'module', $this->getUrl(0),
'config',
[
'feeds' => $this->getInput('blogOptionShowFeeds', helper::FILTER_BOOLEAN),
'feedsLabel' => $this->getInput('blogOptionFeedslabel', helper::FILTER_STRING_SHORT),
'itemsperPage' => $this->getInput('blogOptionItemsperPage', helper::FILTER_INT, true),
@ -547,7 +556,8 @@ class blog extends common
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']),
'dateFormat' => $this->getInput('blogOptionDateFormat'),
'timeFormat' => $this->getInput('blogOptionTimeFormat'),
]]);
]
]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/option',
@ -634,7 +644,8 @@ class blog extends common
'module',
$this->getUrl(0),
'posts',
$articleId, [
$articleId,
[
'title' => $this->getInput('blogEditTitle', helper::FILTER_STRING_SHORT, true),
'comment' => $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(2), 'comment']),
'content' => $this->getInput('blogEditContent', null),
@ -723,13 +734,19 @@ class blog extends common
// Crée le commentaire
$commentId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment']));
$content = $this->getInput('blogArticleContent', false);
$this->setData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentId, [
$this->setData([
'module', $this->getUrl(0),
'posts', $this->getUrl(1),
'comment',
$commentId,
[
'author' => $this->getInput('blogArticleAuthor', helper::FILTER_STRING_SHORT, empty($this->getInput('blogArticleUserId')) ? TRUE : FALSE),
'content' => $content,
'createdOn' => time(),
'userId' => $this->getInput('blogArticleUserId'),
'approval' => !$this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'commentApproved']) // true commentaire publié false en attente de publication
]]);
]
]);
// Envoi d'une notification aux administrateurs
// Init tableau
$to = [];
@ -753,7 +770,8 @@ class blog extends common
'L\'article <a href="' . helper::baseUrl() . $this->getUrl(0) . '/ ' . $this->getUrl(1) . '">' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'title']) . '</a> a reçu un nouveau commentaire.<br><br>',
''
);
if ($sent === false) $error++;
if ($sent === false)
$error++;
}
// Valeurs en sortie
$this->addOutput([
@ -774,7 +792,8 @@ class blog extends common
$commentsApproved = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment']);
if ($commentsApproved) {
foreach ($commentsApproved as $key => $value) {
if ($value['approval'] === false) unset($commentsApproved[$key]);
if ($value['approval'] === false)
unset($commentsApproved[$key]);
}
// Ligne suivante si affichage du nombre total de commentaires approuvés sous l'article
self::$nbCommentsApproved = count($commentsApproved);
@ -804,6 +823,9 @@ class blog extends common
self::$comments[$commentIds[$i]] = $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'comment', $commentIds[$i]]);
}
}
// Format de temps
self::$dateFormat = $this->getData(['module', $this->getUrl(0), 'config', 'dateFormat']);
self::$timeFormat = $this->getData(['module', $this->getUrl(0), 'config', 'timeFormat']);
// Valeurs en sortie
$this->addOutput([
'showBarEditButton' => true,

View File

@ -15,7 +15,7 @@
<?php echo template::ico('user'); ?>
<?php echo $module::$articleSignature; ?>
<?php echo template::ico('calendar-empty'); ?>
<?php echo helper::dateUTF8('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])) . ' - ' . helper::dateUTF8('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])); ?>
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])) . ' - ' . helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn'])); ?>
<!-- Bloc edition -->
<?php if (
@ -147,7 +147,7 @@
<?php echo template::ico('user'); ?>
<?php echo $module::$commentsSignature[$commentId]; ?>
<?php echo template::ico('calendar-empty'); ?>
<?php echo helper::dateUTF8('%d %B %Y', $comment['createdOn']) . ' - ' . helper::dateUTF8('%H:%M', $comment['createdOn']); ?>
<?php echo helper::dateUTF8($module::$dateFormat, $comment['createdOn']) . ' - ' . helper::dateUTF8($module::$timeFormat, $comment['createdOn']); ?>
</h4>
<?php echo $comment['content']; ?>
</div>

View File

@ -16,13 +16,13 @@
<div class="block">
<h4><?php echo helper::translate('Paramètres');?></h4>
<div class="row">
<div class="col3">
<div class="col4">
<?php echo template::select('blogOptionArticlesLenght', $module::$articlesLenght, [
'label' => 'Disposition',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'articlesLenght'])
]); ?>
</div>
<div class="col3">
<div class="col2">
<?php echo template::select('blogOptionItemsperPage', $module::$ArticlesListed, [
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'itemsperPage'])