News 6.0 ajout des options date et heure

This commit is contained in:
Fred Tempez 2024-10-12 08:46:05 +02:00
parent 1a6fadf976
commit 483ebd64fe
6 changed files with 222 additions and 118 deletions

View File

@ -1,3 +1,6 @@
# Versions 6.0
- Ajoute deux nouvelles options pour afficher ou masquer la date et l'heure de l'article.
- Corrige un mauvais format de la propriété buttonBack non stockée au type booléen.
# Versions 5.9 # Versions 5.9
- Largeur d'un bouton de retour. - Largeur d'un bouton de retour.
# Versions 5.7 - 5.8 # Versions 5.7 - 5.8

View File

@ -16,7 +16,7 @@
class news extends common class news extends common
{ {
const VERSION = '5.9'; const VERSION = '6.0';
const REALNAME = 'News'; const REALNAME = 'News';
const DATADIRECTORY = self::DATA_DIR . 'news/'; const DATADIRECTORY = self::DATA_DIR . 'news/';
@ -124,11 +124,12 @@ class news extends common
$feeds = new \FeedWriter\RSS2(); $feeds = new \FeedWriter\RSS2();
// En-tête // En-tête
$feeds->setTitle($this->getData(['page', $this->getUrl(0), 'title']) ? $this->getData(['page', $this->getUrl(0), 'title']): ''); $feeds->setTitle($this->getData(['page', $this->getUrl(0), 'title']) ? $this->getData(['page', $this->getUrl(0), 'title']) : '');
$feeds->setLink(helper::baseUrl() . $this->getUrl(0)); $feeds->setLink(helper::baseUrl() . $this->getUrl(0));
if ($this->getData(['page', $this->getUrl(0), 'metaDescription'])) { if ($this->getData(['page', $this->getUrl(0), 'metaDescription'])) {
$feeds->setDescription($this->getData(['page', $this->getUrl(0), 'metaDescription'])); $feeds->setDescription($this->getData(['page', $this->getUrl(0), 'metaDescription']));
}; }
;
$feeds->setChannelElement('language', 'fr-FR'); $feeds->setChannelElement('language', 'fr-FR');
$feeds->setDate(date('r', time())); $feeds->setDate(date('r', time()));
$feeds->addGenerator(); $feeds->addGenerator();
@ -174,7 +175,8 @@ class news extends common
$publishedOn = $this->getInput('newsAddPublishedOn', helper::FILTER_DATETIME, true); $publishedOn = $this->getInput('newsAddPublishedOn', helper::FILTER_DATETIME, true);
$publishedOff = $this->getInput('newsAddPublishedOff') ? $this->getInput('newsAddPublishedOff', helper::FILTER_DATETIME) : ''; $publishedOff = $this->getInput('newsAddPublishedOff') ? $this->getInput('newsAddPublishedOff', helper::FILTER_DATETIME) : '';
$this->setData([ $this->setData([
'module', $this->getUrl(0), 'module',
$this->getUrl(0),
'posts', 'posts',
$newsId, $newsId,
[ [
@ -288,7 +290,8 @@ class news extends common
// Fin feuille de style // Fin feuille de style
$this->setData([ $this->setData([
'module', $this->getUrl(0), 'module',
$this->getUrl(0),
'theme', 'theme',
[ [
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '', 'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '',
@ -300,7 +303,8 @@ class news extends common
]); ]);
$this->setData([ $this->setData([
'module', $this->getUrl(0), 'module',
$this->getUrl(0),
'config', 'config',
[ [
'feeds' => $this->getInput('newsOptionShowFeeds', helper::FILTER_BOOLEAN), 'feeds' => $this->getInput('newsOptionShowFeeds', helper::FILTER_BOOLEAN),
@ -310,7 +314,9 @@ class news extends common
'height' => $this->getInput('newsOptionHeight', helper::FILTER_INT, true), 'height' => $this->getInput('newsOptionHeight', helper::FILTER_INT, true),
'dateFormat' => $this->getInput('newsOptionDateFormat'), 'dateFormat' => $this->getInput('newsOptionDateFormat'),
'timeFormat' => $this->getInput('newsOptionTimeFormat'), 'timeFormat' => $this->getInput('newsOptionTimeFormat'),
'buttonBack' => $this->getInput('newsOptionButtonBack'), 'buttonBack' => $this->getInput('newsOptionButtonBack', helper::FILTER_BOOLEAN),
'showDate' => $this->getInput('newsOptionShowDate', helper::FILTER_BOOLEAN),
'showTime' => $this->getInput('newsOptionShowTime', helper::FILTER_BOOLEAN),
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']), 'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData']),
] ]
]); ]);
@ -318,7 +324,7 @@ class news extends common
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/option', 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => helper::translate('Modifications enregistrées'), 'notification' => helper::translate('Modifications enregistrées'),
'state' => true 'state' => true
]); ]);
@ -428,7 +434,8 @@ class news extends common
$publishedOn = $this->getInput('newsEditPublishedOn', helper::FILTER_DATETIME, true); $publishedOn = $this->getInput('newsEditPublishedOn', helper::FILTER_DATETIME, true);
$publishedOff = $this->getInput('newsEditPublishedOff') ? $this->getInput('newsEditPublishedOff', helper::FILTER_DATETIME) : ''; $publishedOff = $this->getInput('newsEditPublishedOff') ? $this->getInput('newsEditPublishedOff', helper::FILTER_DATETIME) : '';
$this->setData([ $this->setData([
'module', $this->getUrl(0), 'module',
$this->getUrl(0),
'posts', 'posts',
$newsId, $newsId,
[ [
@ -490,6 +497,8 @@ class news extends common
} }
// L'article existe // L'article existe
else { else {
self::$dateFormat = $this->getData(['module', $this->getUrl(0), 'config', 'dateFormat']);
self::$timeFormat = $this->getData(['module', $this->getUrl(0), 'config', 'timeFormat']);
self::$articleSignature = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'userId'])); self::$articleSignature = $this->signature($this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'userId']));
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -609,6 +618,14 @@ class news extends common
// Mettre à jour la version // Mettre à jour la version
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '5.3']); $this->setData(['module', $this->getUrl(0), 'config', 'versionData', '5.3']);
} }
// Mise à jour 6.0
if (version_compare($versionData, '6.0', '<')) {
$this->setData(['module', $this->getUrl(0), 'config', 'buttonBack', true]);
$this->setData(['module', $this->getUrl(0), 'config', 'showTime', true]);
$this->setData(['module', $this->getUrl(0), 'config', 'showDate', true]);
// Mettre à jour la version
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '6.0']);
}
} }

View File

@ -12,12 +12,28 @@
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="col6 newsDate textAlignRight"> <div class="col6 newsDate textAlignRight">
<!-- bloc signature et date --> <!-- bloc signature -->
<?php echo template::ico('user'); ?> <?php echo template::ico('user'); ?>
<?php echo $module::$articleSignature . ' - '; ?> <?php echo $module::$articleSignature . ' - '; ?>
<?php echo template::ico('calendar-empty'); ?> <!-- bloc date -->
<?php echo helper::dateUTF8('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']), self::$i18nUI) . '&nbsp' . helper::dateUTF8('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']), self::$i18nUI); ?> <?php if (
<!-- Bloc edition --> $this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
|| $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo template::ico('calendar-empty', ['margin' => 'left']); ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true): ?>
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']), self::$i18nUI); ?>
<?php endif; ?>
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
&& $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo '&nbsp;-&nbsp;'; ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true): ?>
<?php echo helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']), self::$i18nUI); ?>
<?php endif; ?> <!-- Bloc edition -->
<?php if ( <?php if (
$this->isConnected() === true $this->isConnected() === true
and and

View File

@ -1,5 +1,6 @@
<?php if ($module::$news): ?> <?php if ($module::$news): ?>
<link rel="stylesheet" type="text/css" href="<?php echo helper::baseUrl(false) . $this->getData(['module', $this->getUrl(0), 'theme', 'style']);?> "/> <link rel="stylesheet" type="text/css"
href="<?php echo helper::baseUrl(false) . $this->getData(['module', $this->getUrl(0), 'theme', 'style']); ?> " />
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'feeds'])): ?> <?php if ($this->getData(['module', $this->getUrl(0), 'config', 'feeds'])): ?>
<div id="rssFeed"> <div id="rssFeed">
<a type="application/rss+xml" href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?>" target="_blank"> <a type="application/rss+xml" href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?>" target="_blank">
@ -20,10 +21,28 @@
<?php echo '<a href="' . helper::baseUrl(true) . $this->getUrl(0) . '/' . $newsId . '">' . $news['title'] . '</a>'; ?> <?php echo '<a href="' . helper::baseUrl(true) . $this->getUrl(0) . '/' . $newsId . '">' . $news['title'] . '</a>'; ?>
</h2> </h2>
<div class="newsSignature"> <div class="newsSignature">
<!-- bloc signature -->
<?php echo template::ico('user'); ?> <?php echo template::ico('user'); ?>
<?php echo $news['userId'] . ' - '; ?> <?php echo $news['userId']; ?>
<?php echo template::ico('calendar-empty'); ?> <!-- bloc Date -->
<?php echo helper::dateUTF8($module::$dateFormat, $news['publishedOn'], self::$i18nUI) . '&nbsp;' . helper::dateUTF8($module::$timeFormat, $news['publishedOn'], self::$i18nUI); ?> <?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
|| $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo template::ico('calendar-empty', ['margin' => 'left']); ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true): ?>
<?php echo helper::dateUTF8($module::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']), self::$i18nUI); ?>
<?php endif; ?>
<?php if (
$this->getData(['module', $this->getUrl(0), 'config', 'showDate']) === true
&& $this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true
): ?>
<?php echo '&nbsp;-&nbsp;'; ?>
<?php endif; ?>
<?php if ($this->getData(['module', $this->getUrl(0), 'config', 'showTime']) === true): ?>
<?php echo helper::dateUTF8($module::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'publishedOn']), self::$i18nUI); ?>
<?php endif; ?>
<!-- Bloc edition --> <!-- Bloc edition -->
<?php if ( <?php if (
$this->isConnected() === true $this->isConnected() === true
@ -32,10 +51,8 @@
($this->getUser('group') === self::GROUP_ADMIN) ($this->getUser('group') === self::GROUP_ADMIN)
) )
): ?> ): ?>
&nbsp;-&nbsp; <a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsId; ?>">
<a <?php echo template::ico('pencil', ['margin' => 'left']); ?> Éditer
href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsId; ?>">
<?php echo template::ico('pencil'); ?> Éditer
</a> </a>
<?php endif; ?> <?php endif; ?>
</div> </div>
@ -51,7 +68,6 @@
</div> </div>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</article> </article>
<?php echo $module::$pages; ?> <?php echo $module::$pages; ?>

View File

@ -0,0 +1,40 @@
/**
* 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 Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2024, Frédéric Tempez
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
* @link http://zwiicms.fr/
*/
$(document).ready(function() {
// Gestion du changement de la case "Afficher la date"
$('#newsOptionShowDate').change(function() {
var showDateChecked = $(this).is(':checked');
// Afficher ou masquer le wrapper de l'heure selon l'état de la date
if (showDateChecked) {
$('.timeWrapper').show();
} else {
$('.timeWrapper').hide();
// Désactiver l'option "Afficher l'heure" lorsque la date est désactivée
$('#newsOptionShowTime').prop('checked', false).trigger('change');
}
// Afficher ou masquer le format de la date
$('#newsOptionDateFormatWrapper').toggle(showDateChecked);
}).trigger('change'); // Déclenchement au chargement de la page
// Gestion du changement de la case "Afficher l'heure"
$('#newsOptionShowTime').change(function() {
var showTimeChecked = $(this).is(':checked');
// Afficher ou masquer le format de l'heure
$('#newsOptionTimeFormatWrapper').toggle(showTimeChecked);
}).trigger('change'); // Déclenchement au chargement de la page
});

View File

@ -1,111 +1,123 @@
<?php echo template::formOpen('newsOption'); ?> <?php echo template::formOpen('newsOption'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('newsOptionBack', [ <?php echo template::button('newsOptionBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . $this->getUrl(0) . '/config', 'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('newsOptionSubmit'); ?>
</div>
</div> </div>
<div class="row"> <div class="col2 offset9">
<div class="col12"> <?php echo template::submit('newsOptionSubmit'); ?>
<div class="block"> </div>
<h4><?php echo helper::translate('Paramètres'); ?></h4> </div>
<div class="row"> <div class="row">
<div class="col2"> <div class="col12">
<?php echo template::select('newsOptionItemsperCol', $module::$columns, [ <div class="block">
'label' => 'Nombre de colonnes', <h4><?php echo helper::translate('Paramètres'); ?></h4>
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol']) <div class="row">
]); ?> <div class="col3">
</div> <?php echo template::checkbox('newsOptionShowDate', true, 'Afficher la date', [
<div class="col2"> 'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'showDate']),
<?php echo template::select('newsOptionItemsperPage', $module::$itemsList, [ ]); ?>
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])
]); ?>
</div>
<div class="col2">
<?php echo template::select('newsOptionHeight', $module::$height, [
'label' => 'Abrégé de l\'article',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'height'])
]); ?>
</div>
<div class="col3">
<?php echo template::select('newsOptionDateFormat', $module::$dateFormats, [
'label' => 'Format des dates',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'dateFormat'])
]); ?>
</div>
<div class="col3">
<?php echo template::select('newsOptionTimeFormat', $module::$timeFormats, [
'label' => 'Format des heures',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'timeFormat'])
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col3">
<div class="col3"> <?php echo template::select('newsOptionDateFormat', $module::$dateFormats, [
<?php echo template::checkbox('newsOptionShowFeeds', true, 'Lien du flux RSS', [ 'label' => 'Format des dates',
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']), 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'dateFormat'])
'help' => 'Flux limité aux articles de la première page.' ]); ?>
]); ?> </div>
</div> <div class="col3 timeWrapper">
<div class="col3"> <?php echo template::checkbox('newsOptionShowTime', true, 'Afficher l\'heure', [
<?php echo template::checkbox('newsOptionButtonBack', true, 'Bouton de retour', [ 'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'showTime']),
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'buttonBack']) ]); ?>
]); ?> </div>
</div> <div class="col3 timeWrapper">
<div class="col6"> <?php echo template::select('newsOptionTimeFormat', $module::$timeFormats, [
<?php echo template::text('newsOptionFeedslabel', [ 'label' => 'Format des heures',
'label' => 'Étiquette RSS', 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'timeFormat'])
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel']) ]); ?>
]); ?> </div>
</div> </div>
<div class="row">
<div class="col4">
<?php echo template::select('newsOptionItemsperCol', $module::$columns, [
'label' => 'Nombre de colonnes',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'itemsperCol'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('newsOptionItemsperPage', $module::$itemsList, [
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'itemsperPage'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('newsOptionHeight', $module::$height, [
'label' => 'Abrégé de l\'article',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'height'])
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('newsOptionButtonBack', true, 'Bouton de retour', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'buttonBack'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('newsOptionShowFeeds', true, 'Lien du flux RSS', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']),
'help' => 'Flux limité aux articles de la première page.'
]); ?>
</div>
<div class="col6">
<?php echo template::text('newsOptionFeedslabel', [
'label' => 'Texte de l\'étiquette RSS',
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel'])
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<div class="block"> <div class="col12">
<h4><?php echo helper::translate('Thème');?></h4> <div class="block">
<div class="row"> <h4><?php echo helper::translate('Thème'); ?></h4>
<div class="col3"> <div class="row">
<?php echo template::select('newsThemeBorderStyle', $module::$borderStyle, [ <div class="col3">
'label' => 'Bordure', <?php echo template::select('newsThemeBorderStyle', $module::$borderStyle, [
'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'borderStyle']) 'label' => 'Bordure',
]); ?> 'selected' => $this->getData(['module', $this->getUrl(0), 'theme', 'borderStyle'])
</div> ]); ?>
<div class="col3"> </div>
<?php echo template::select('newsThemeBorderWidth', $module::$borderWidth, [ <div class="col3">
'label' => 'Épaisseur', <?php echo template::select('newsThemeBorderWidth', $module::$borderWidth, [
'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'borderWidth']) 'label' => 'Épaisseur',
]); ?> 'selected' => $this->getData(['module', $this->getUrl(0), 'theme', 'borderWidth'])
</div> ]); ?>
<div class="col3"> </div>
<?php echo template::text('newsThemeBorderColor', [ <div class="col3">
'class' => 'colorPicker', <?php echo template::text('newsThemeBorderColor', [
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', 'class' => 'colorPicker',
'label' => 'Couleur de la bordure', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'borderColor']) 'label' => 'Couleur de la bordure',
]); ?> 'value' => $this->getData(['module', $this->getUrl(0), 'theme', 'borderColor'])
</div> ]); ?>
<div class="col3"> </div>
<?php echo template::text('newsThemeBackgroundColor', [ <div class="col3">
'class' => 'colorPicker', <?php echo template::text('newsThemeBackgroundColor', [
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', 'class' => 'colorPicker',
'label' => 'Couleur du fond', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'backgroundColor']) 'label' => 'Couleur du fond',
]); ?> 'value' => $this->getData(['module', $this->getUrl(0), 'theme', 'backgroundColor'])
</div> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>
<div class="moduleVersion">Version <div class="moduleVersion">Version
<?php echo $module::VERSION; ?> <?php echo $module::VERSION; ?>