This commit is contained in:
Fred Tempez 2023-02-12 11:14:07 +01:00
parent c3d95644f0
commit f159f0b304
4 changed files with 161 additions and 93 deletions

View File

@ -1,3 +1,5 @@
# Version 4.4
- Intl date Formats
# Version 4.3
- Multilinguisme
# Version 4.23

View File

@ -22,8 +22,10 @@ class news extends common
public static $actions = [
'add' => self::GROUP_MODERATOR,
'config' => self::GROUP_MODERATOR, // Edition des news
'option' => self::GROUP_MODERATOR, // paramétrage des news
'config' => self::GROUP_MODERATOR,
// Edition des news
'option' => self::GROUP_MODERATOR,
// paramétrage des news
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR,
@ -87,6 +89,25 @@ class news extends common
// Nombre d'articles dans la page de config:
public static $itemsperPage = 8;
public static $dateFormats = [
'%d %B %Y' => 'DD MMMM YYYY',
'%d/%m/%Y' => 'DD/MM/YYYY',
'%m/%d/%Y' => 'MM/DD/YYYY',
'%d/%m/%y' => 'DD/MM/YY',
'%m/%d/%y' => 'MM/DD/YY',
'%d-%m-%Y' => 'DD-MM-YYYY',
'%m-%d-%Y' => 'MM-DD-YYYY',
'%d-%m-%y' => 'DD-MM-YY',
'%m-%d-%y' => 'MM-DD-YY',
];
public static $timeFormats = [
'%H:%M' => 'HH:MM',
'%I:%M %p' => "HH:MM tt",
];
public static $timeFormat = '';
public static $dateFormat = '';
/**
* Flux RSS
*/
@ -147,14 +168,19 @@ class news extends common
$newsId = helper::increment($this->getInput('newsAddTitle', helper::FILTER_ID), (array) $this->getData(['module', $this->getUrl(0), 'posts']));
$publishedOn = $this->getInput('newsAddPublishedOn', helper::FILTER_DATETIME, true);
$publishedOff = $this->getInput('newsAddPublishedOff') ? $this->getInput('newsAddPublishedOff', helper::FILTER_DATETIME) : '';
$this->setData(['module', $this->getUrl(0), 'posts', $newsId, [
$this->setData([
'module', $this->getUrl(0),
'posts',
$newsId,
[
'content' => $this->getInput('newsAddContent', null),
'publishedOn' => $publishedOn,
'publishedOff' => $publishedOff,
'state' => $this->getInput('newsAddState', helper::FILTER_BOOLEAN),
'title' => $this->getInput('newsAddTitle', helper::FILTER_STRING_SHORT, true),
'userId' => $this->getInput('newsAddUserId', helper::FILTER_ID, true)
]]);
]
]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
@ -195,12 +221,15 @@ class news extends common
$pagination = helper::pagination($newsIds, $this->getUrl(), self::$itemsperPage);
// Liste des pages
self::$pages = $pagination['pages'];
// Format de temps
self::$dateFormat = $this->getData(['module', $this->getUrl(0), 'config', 'dateFormat']);
self::$timeFormat = $this->getData(['module', $this->getUrl(0), 'config', 'timeFormat']);
// News en fonction de la pagination
for ($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Met en forme le tableau
$dateOn = helper::dateUTF8('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOn'])) . ' - ' . helper::dateUTF8('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOn']));
$dateOn = helper::dateUTF8(self::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOn'])) . ' - ' . helper::dateUTF8(self::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOn']));
if ($this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOff'])) {
$dateOff = helper::dateUTF8('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOff'])) . ' - ' . helper::dateUTF8('%H:%M', $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOff']));
$dateOff = helper::dateUTF8(self::$dateFormat, $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOff'])) . ' - ' . helper::dateUTF8(self::$timeFormat, $this->getData(['module', $this->getUrl(0), 'posts', $newsIds[$i], 'publishedOff']));
} else {
$dateOff = 'Permanent';
}
@ -251,22 +280,32 @@ class news extends common
// Fin feuille de style
$this->setData(['module', $this->getUrl(0), 'theme', [
$this->setData([
'module', $this->getUrl(0),
'theme',
[
'style' => $success ? self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' : '',
'borderStyle' => $this->getInput('newsThemeBorderStyle', helper::FILTER_STRING_SHORT),
'borderColor' => $this->getInput('newsThemeBorderColor'),
'borderWidth' => $this->getInput('newsThemeBorderWidth', helper::FILTER_STRING_SHORT),
'backgroundColor' => $this->getInput('newsThemeBackgroundColor')
]]);
]
]);
$this->setData(['module', $this->getUrl(0), 'config', [
$this->setData([
'module', $this->getUrl(0),
'config',
[
'feeds' => $this->getInput('newsOptionShowFeeds', helper::FILTER_BOOLEAN),
'feedsLabel' => $this->getInput('newsOptionFeedslabel', helper::FILTER_STRING_SHORT),
'itemsperPage' => $this->getInput('newsOptionItemsperPage', helper::FILTER_INT, true),
'itemsperCol' => $this->getInput('newsOptionItemsperCol', helper::FILTER_INT, true),
'height' => $this->getInput('newsOptionHeight', helper::FILTER_INT, true),
'dateFormat' => $this->getInput('newsOptionDateFormat'),
'timeFormat' => $this->getInput('newsOptionTimeFormat'),
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
]]);
]
]);
// Valeurs en sortie
@ -384,14 +423,19 @@ class news extends common
}
$publishedOn = $this->getInput('newsEditPublishedOn', helper::FILTER_DATETIME, true);
$publishedOff = $this->getInput('newsEditPublishedOff') ? $this->getInput('newsEditPublishedOff', helper::FILTER_DATETIME) : '';
$this->setData(['module', $this->getUrl(0), 'posts', $newsId, [
$this->setData([
'module', $this->getUrl(0),
'posts',
$newsId,
[
'content' => $this->getInput('newsEditContent', null),
'publishedOn' => $publishedOn,
'publishedOff' => $publishedOff < $publishedOn ? '' : $publishedOff,
'state' => $this->getInput('newsEditState', helper::FILTER_BOOLEAN),
'title' => $this->getInput('newsEditTitle', helper::FILTER_STRING_SHORT, true),
'userId' => $this->getInput('newsEditUserId', helper::FILTER_ID, true)
]]);
]
]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
@ -562,7 +606,7 @@ class news extends common
// Mettre à jour la version
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '3.3']);
}
// Mise à jour 3.4
// Mise à jour 4.4
if (version_compare($versionData, '3.4', '<')) {
// Effacer le style précédent
unlink(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css');
@ -572,6 +616,14 @@ class news extends common
// Mettre à jour la version
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '3.4']);
}
// Mise à jour 3.4
if (version_compare($versionData, '4.4', '<')) {
$this->setData(['module', $this->getUrl(0), 'config', 'dateFormat', '%d %B %Y']);
$this->setData(['module', $this->getUrl(0), 'config', 'timeFormat', '%H:%M']);
// Mettre à jour la version
$this->setData(['module', $this->getUrl(0), 'config', 'versionData', '3.4']);
}
}
/**

View File

@ -6,7 +6,9 @@ class init extends news {
'itemsperPage' => 8,
'itemsperCol' => 12,
'height' => -1,
'versionData' => '3.4'
'versionData' => '3.5',
'dateFormat' => '%d %B %Y',
'timeFormat' =>'%H:%M',
];
public static $defaultTheme = [

View File

@ -14,7 +14,39 @@
<div class="row">
<div class="col12">
<div class="block">
<h4>Paramètres du module</h4>
<h4><?php echo helper::translate('Paramètres'); ?></h4>
<div class="row">
<div class="col2">
<?php echo template::select('newsOptionItemsperCol', $module::$columns, [
'label' => 'Nombre de colonnes',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperCol'])
]); ?>
</div>
<div class="col2">
<?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 class="row">
<div class="col6">
<?php echo template::checkbox('newsOptionShowFeeds', true, 'Lien du flux RSS', [
@ -29,33 +61,13 @@
]); ?>
</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>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Thème du module</h4>
<h4><?php echo helper::translate('Thème');?></h4>
<div class="row">
<div class="col3">
<?php echo template::select('newsThemeBorderStyle', $module::$borderStyle, [