This commit is contained in:
Fred Tempez 2021-03-30 17:39:15 +02:00
parent 88b716a448
commit 08127b1fd5
4 changed files with 96 additions and 35 deletions

View File

@ -15,7 +15,7 @@
class news extends common {
const VERSION = '2.3';
const VERSION = '2.4';
const REALNAME = 'Actualités';
const DELETE = true;
const UPDATE = '0.0';
@ -42,7 +42,24 @@ class news extends common {
];
public static $users = [];
// Nombre d'objets par page
public static $ItemsList = [
4 => '4 articles',
8 => '8 articles',
12 => '12 articles',
16 => '16 articles',
22 => '22 articles'
];
// Nombre de colone par page
public static $ListeCol = [
12 => '1 Colonne',
6 => '2 Colonnes',
4 => '3 Colonnes',
2 => '4 Colonnes'
];
public static $nbrCol = 1;
/**
* Flux RSS
*/
@ -142,7 +159,9 @@ class news extends common {
if($this->isPost()) {
$this->setData(['module', $this->getUrl(0), 'config',[
'feeds' => $this->getInput('newsConfigShowFeeds',helper::FILTER_BOOLEAN),
'feedsLabel' => $this->getInput('newsConfigFeedslabel',helper::FILTER_STRING_SHORT)
'feedsLabel' => $this->getInput('newsConfigFeedslabel',helper::FILTER_STRING_SHORT),
'itemsperPage' => $this->getInput('newsConfigItemsperPage', helper::FILTER_INT,true),
'listeCol' => $this->getInput('newsConfigListeCol', helper::FILTER_INT,true)
]]);
// Valeurs en sortie
$this->addOutput([
@ -298,7 +317,10 @@ class news extends common {
}
}
// Pagination
$pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
//$pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
$pagination = helper::pagination($newsIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']));
// Nombre de colonnes
self::$nbrCol = $this->getData(['module', $this->getUrl(0),'config', 'listeCol']);
// Liste des pages
self::$pages = $pagination['pages'];
// News en fonction de la pagination

View File

@ -39,7 +39,27 @@
</div>
</div>
</div>
</div>
<!-- Block ajouté pour le sélecteur -->
<div class="block">
<h4>Nombre de news par page</h4>
<div class="row">
<div class="col4">
<?php echo template::select('newsConfigItemsperPage', $module::$ItemsList, [
'label' => 'News par page',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']),
'help' => 'Nombre de news par page'
]); ?>
</div>
<div class="col4">
<?php echo template::select('newsConfigListeCol', $module::$ListeCol, [
'label' => 'Nombre de colonne',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'listeCol']),
'help' => 'Nombre de colonnes par page'
]); ?>
</div>
</div>
</div>
<?php if($module::$news): ?>
<?php echo template::table([4, 4, 2, 1, 1], $module::$news, ['Titre', 'Date de publication', 'État', '', '']); ?>
<?php echo $module::$pages; ?>

View File

@ -12,7 +12,7 @@
* @link http://zwiicms.fr/
*/
/*
/*
* Module news
*/
@ -44,4 +44,25 @@
#rssFeed p {
display: inline;
vertical-align: top;
}
@media (min-width: 769px)
{
.col2 {width: 20%;}
.col3 {width: 24%;}
.col4 {width: 32%;}
.col6 {width: 49%;}
.col12 {width: 100%;}
}
@media (max-width: 768px)
{
.col2 {width: 49%;}
.col3 {width: 49%;}
.col4 {width: 49%;}
}
@media (max-width: 480px)
{
.col2 {width: 100%;}
.col3 {width: 100%;}
.col4 {width: 100%;}
}

View File

@ -2,36 +2,34 @@
<div class="row">
<div class="col12">
<?php foreach($module::$news as $newsId => $news): ?>
<div class="row ">
<div class="col12">
<h1 class="newsTitle" id="<?php echo $newsId;?>">
<?php echo $news['title']; ?>
</h1>
<div class="newsContent">
<?php echo $news['content']; ?>
</div>
<div class="newsSignature">
<i class="far fa-calendar-alt"></i>
<?php echo mb_detect_encoding(strftime('%d %B %Y', $news['publishedOn']), 'UTF-8', true)
? strftime('%d %B %Y', $news['publishedOn'])
: utf8_encode(strftime('%d %B %Y', $news['publishedOn'])); ?>
- <?php echo $news['userId']; ?>
<!-- Bloc edition -->
<?php if (
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
AND
( // Propriétaire
( $this->getUser('group') === self::GROUP_ADMIN )
)
): ?>
<a href ="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsId . '/' . $_SESSION['csrf'];?>">
<?php echo template::ico('pencil');?> Editer
</a>
<?php endif; ?>
</div>
<div class="col<?php echo $module::$nbrCol ;?>" >
<h1 class="newsTitle" id="<?php echo $newsId;?>">
<?php echo $news['title']; ?>
</h1>
<div class="newsContent">
<?php echo $news['content']; ?>
</div>
</div>
<div class="newsSignature">
<i class="far fa-calendar-alt"></i>
<?php echo mb_detect_encoding(strftime('%d %B %Y', $news['publishedOn']), 'UTF-8', true)
? strftime('%d %B %Y', $news['publishedOn'])
: utf8_encode(strftime('%d %B %Y', $news['publishedOn'])); ?>
- <?php echo $news['userId']; ?>
<!-- Bloc edition -->
<?php if (
$this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
AND
( // Propriétaire
( $this->getUser('group') === self::GROUP_ADMIN )
)
): ?>
<a href ="<?php echo helper::baseUrl() . $this->getUrl(0) . '/edit/' . $newsId . '/' . $_SESSION['csrf'];?>">
<?php echo template::ico('pencil');?> Editer
</a>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
@ -40,7 +38,7 @@
<div id="rssFeed">
<a type="application/rss+xml" href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/rss'; ?> ">
<img src='module/news/ressource/feed-icon-16.gif' />
<?php
<?php
echo '<p>' . $this->getData(['module',$this->getUrl(0), 'config', 'feedsLabel']) . '</p>' ;
?>
</a>