forked from ZwiiCMS-Team/ZwiiCMS
News 3.1 dépublication
This commit is contained in:
parent
3908d75240
commit
364e6e4be5
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
class news extends common {
|
class news extends common {
|
||||||
|
|
||||||
const VERSION = '3.0';
|
const VERSION = '3.1';
|
||||||
const REALNAME = 'Actualités';
|
const REALNAME = 'Actualités';
|
||||||
const DELETE = true;
|
const DELETE = true;
|
||||||
const UPDATE = '0.0';
|
const UPDATE = '0.0';
|
||||||
@ -225,15 +225,28 @@ class news extends common {
|
|||||||
// News en fonction de la pagination
|
// News en fonction de la pagination
|
||||||
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
|
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
|
||||||
// Met en forme le tableau
|
// Met en forme le tableau
|
||||||
$date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true)
|
$dateOn = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true)
|
||||||
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))
|
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))
|
||||||
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])));
|
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])));
|
||||||
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true)
|
$dateOn .= ' à ';
|
||||||
|
$dateOn .= mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])), 'UTF-8', true)
|
||||||
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))
|
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn']))
|
||||||
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])));
|
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOn'])));
|
||||||
|
if ($this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])) {
|
||||||
|
$dateOff = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])), 'UTF-8', true)
|
||||||
|
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff']))
|
||||||
|
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])));
|
||||||
|
$dateOff .= ' à ';
|
||||||
|
$dateOff .= mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])), 'UTF-8', true)
|
||||||
|
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff']))
|
||||||
|
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'publishedOff'])));
|
||||||
|
} else {
|
||||||
|
$dateOff = 'Permanent';
|
||||||
|
}
|
||||||
self::$news[] = [
|
self::$news[] = [
|
||||||
$this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'title']),
|
$this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'title']),
|
||||||
$date .' à '. $heure,
|
$dateOn,
|
||||||
|
$dateOff,
|
||||||
self::$states[$this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'state'])],
|
self::$states[$this->getData(['module', $this->getUrl(0),'posts', $newsIds[$i], 'state'])],
|
||||||
template::button('newsConfigEdit' . $newsIds[$i], [
|
template::button('newsConfigEdit' . $newsIds[$i], [
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsIds[$i]. '/' . $_SESSION['csrf'],
|
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsIds[$i]. '/' . $_SESSION['csrf'],
|
||||||
@ -316,9 +329,12 @@ class news extends common {
|
|||||||
// Supprime l'ancien news
|
// Supprime l'ancien news
|
||||||
$this->deleteData(['module', $this->getUrl(0),'posts', $this->getUrl(2)]);
|
$this->deleteData(['module', $this->getUrl(0),'posts', $this->getUrl(2)]);
|
||||||
}
|
}
|
||||||
|
$publishedOn = $this->getInput('newsEditPublishedOn', helper::FILTER_DATETIME, true);
|
||||||
|
$publishedOff = $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),
|
'content' => $this->getInput('newsEditContent', null),
|
||||||
'publishedOn' => $this->getInput('newsEditPublishedOn', helper::FILTER_DATETIME, true),
|
'publishedOn' => $publishedOn,
|
||||||
|
'publishedOff' => $publishedOff < $publishedOn ? '' : $publishedOff,
|
||||||
'state' => $this->getInput('newsEditState', helper::FILTER_BOOLEAN),
|
'state' => $this->getInput('newsEditState', helper::FILTER_BOOLEAN),
|
||||||
'title' => $this->getInput('newsEditTitle', helper::FILTER_STRING_SHORT, true),
|
'title' => $this->getInput('newsEditTitle', helper::FILTER_STRING_SHORT, true),
|
||||||
'userId' => $this->getInput('newsEditUserId', helper::FILTER_ID, true)
|
'userId' => $this->getInput('newsEditUserId', helper::FILTER_ID, true)
|
||||||
@ -391,7 +407,14 @@ class news extends common {
|
|||||||
$newsIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC');
|
$newsIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'state', 'SORT_DESC');
|
||||||
$newsIds = [];
|
$newsIds = [];
|
||||||
foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) {
|
foreach($newsIdsPublishedOns as $newsId => $newsPublishedOn) {
|
||||||
if($newsPublishedOn <= time() AND $newsIdsStates[$newsId]) {
|
$newsIdsPublishedOff = $this->getData(['module', $this->getUrl(0), 'posts', $newsId, 'publishedOff']);
|
||||||
|
if( $newsPublishedOn <= time() AND
|
||||||
|
$newsIdsStates[$newsId] AND
|
||||||
|
// date de péremption tenant des champs non définis
|
||||||
|
(!is_integer($newsIdsPublishedOff) OR
|
||||||
|
$newsIdsPublishedOff > time()
|
||||||
|
)
|
||||||
|
) {
|
||||||
$newsIds[] = $newsId;
|
$newsIds[] = $newsId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php if($module::$news): ?>
|
<?php if($module::$news): ?>
|
||||||
<?php echo template::table([4, 4, 2, 1, 1], $module::$news, ['Titre', 'Date de publication', 'État', '', '']); ?>
|
<?php echo template::table([4, 2, 2, 2, 1, 1], $module::$news, ['Titre', 'Publication', 'Dépublication', 'État', '', '']); ?>
|
||||||
<?php echo $module::$pages; ?>
|
<?php echo $module::$pages; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php echo template::speech('Aucune news.'); ?>
|
<?php echo template::speech('Aucune news.'); ?>
|
||||||
|
@ -43,19 +43,26 @@
|
|||||||
<div class="block">
|
<div class="block">
|
||||||
<h4>Options de publication</h4>
|
<h4>Options de publication</h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col6">
|
<div class="col4">
|
||||||
<?php echo template::select('newsEditUserId', $module::$users, [
|
<?php echo template::select('newsEditUserId', $module::$users, [
|
||||||
'label' => 'Auteur',
|
'label' => 'Auteur',
|
||||||
'selected' => $this->getUser('id')
|
'selected' => $this->getUser('id')
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col6">
|
<div class="col4">
|
||||||
<?php echo template::date('newsEditPublishedOn', [
|
<?php echo template::date('newsEditPublishedOn', [
|
||||||
'help' => 'La news est consultable à partir du moment ou la date de publication est passée.',
|
'help' => 'La news est consultable à partir du moment ou la date de publication est passée.',
|
||||||
'label' => 'Date de publication',
|
'label' => 'Date de publication',
|
||||||
'value' => $this->getData(['module', $this->getUrl(0),'posts', $this->getUrl(2), 'publishedOn'])
|
'value' => $this->getData(['module', $this->getUrl(0),'posts', $this->getUrl(2), 'publishedOn'])
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col4">
|
||||||
|
<?php echo template::date('newsEditPublishedOff', [
|
||||||
|
'help' => 'La news est consultable Jusqu\'à cette date si elle est spécifiée.',
|
||||||
|
'label' => 'Date de dépublication',
|
||||||
|
'value' => $this->getData(['module', $this->getUrl(0),'posts', $this->getUrl(2), 'publishedOff'])
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
1
site/data/news/pages/telechargement/theme.css
Normal file
1
site/data/news/pages/telechargement/theme.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
.newsContent {height:auto;}.newsBlur {background: linear-gradient(rgba(255, 255, 255, 1) 100%,rgba(255,255,255,0) ); background-clip: text;-webkit-background-clip: text;-webkit-text-fill-color: transparent;}
|
Loading…
Reference in New Issue
Block a user