This commit is contained in:
Fred Tempez 2022-01-17 19:32:06 +01:00
parent 17f2e87cb8
commit 7d328124f4
5 changed files with 165 additions and 108 deletions

View File

@ -15,7 +15,7 @@
class blog extends common {
const VERSION = '5.1';
const VERSION = '6.0';
const REALNAME = 'Blog';
const DELETE = true;
const UPDATE = '0.0';
@ -32,6 +32,7 @@ class blog extends common {
'commentDelete' => self::GROUP_MODERATOR,
'commentDeleteAll' => self::GROUP_MODERATOR,
'config' => self::GROUP_MODERATOR,
'layout' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR,
@ -100,6 +101,9 @@ class blog extends common {
self::EDIT_OWNER => 'Propriétaire'
];
// Nombre d'articles dans la page de config:
public static $itemsperPage = 8;
public static $users = [];
@ -398,23 +402,7 @@ class blog extends common {
* Configuration
*/
public function config() {
// Mise à jour des données de module
$this->update();
// Soumission du formulaire
if($this->isPost()) {
$this->setData(['module', $this->getUrl(0), 'config',[
'feeds' => $this->getInput('blogConfigShowFeeds',helper::FILTER_BOOLEAN),
'feedsLabel' => $this->getInput('blogConfigFeedslabel',helper::FILTER_STRING_SHORT),
'itemsperPage' => $this->getInput('blogConfigItemsperPage', helper::FILTER_INT,true),
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Modifications enregistrées',
'state' => true
]);
} else {
// Ids des articles par ordre de publication
$articleIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'posts']), 'publishedOn', 'SORT_DESC'));
// Gestion des droits d'accès
@ -442,7 +430,7 @@ class blog extends common {
}
$articleIds = $filterData;
// Pagination
$pagination = helper::pagination($articleIds, $this->getUrl(),$this->getData(['module', $this->getUrl(0),'config', 'itemsperPage']));
$pagination = helper::pagination($articleIds, $this->getUrl(),self::$itemsperPage);
// Liste des pages
self::$pages = $pagination['pages'];
// Articles en fonction de la pagination
@ -493,7 +481,33 @@ class blog extends common {
'view' => 'config'
]);
}
public function layout() {
// Mise à jour des données de module
$this->update();
// Soumission du formulaire
if($this->isPost()) {
$this->setData(['module', $this->getUrl(0), 'config',[
'feeds' => $this->getInput('blogLayoutShowFeeds',helper::FILTER_BOOLEAN),
'feedsLabel' => $this->getInput('blogLayoutFeedslabel',helper::FILTER_STRING_SHORT),
'itemsperPage' => $this->getInput('blogLayoutItemsperPage', helper::FILTER_INT,true),
'versionData' => $this->getData(['module', $this->getUrl(0), 'config', 'versionData'])
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/layout',
'notification' => 'Modifications enregistrées',
'state' => true
]);
} else {
// Valeurs en sortie
$this->addOutput([
'title' => 'Mise en page',
'view' => 'layout'
]);
}
}
/**
* Suppression

2
module/blog/changes.md Normal file
View File

@ -0,0 +1,2 @@
# version 6
- mise à la norme avec le module news : le formulaire est sorti de l'écran principal

View File

@ -16,36 +16,12 @@
]); ?>
</div>
<div class="col2">
<?php echo template::submit('blogConfigSubmit'); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Paramètres du module</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('blogConfigShowFeeds', true, 'Lien du flux RSS', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']),
<?php echo template::button('blogConfigLayout', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/layout',
'ico' => 'brush',
'value' => 'Mise en page'
]); ?>
</div>
<div class="col6">
<?php echo template::text('blogConfigFeedslabel', [
'label' => 'Texte de l\'étiquette',
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6 offset6">
<?php echo template::select('blogConfigItemsperPage', $module::$ItemsList, [
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>
<?php if($module::$articles): ?>

View File

@ -0,0 +1,18 @@
/**
* 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-2022, Frédéric Tempez
* @license GNU General Public License, version 3
* @link http://zwiicms.fr/
*/
/** NE PAS EFFACER
* admin.css
*/

View File

@ -0,0 +1,47 @@
<?php echo template::formOpen('blogLayout'); ?>
<div class="row">
<div class="col2">
<?php echo template::button('blogLayoutBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
'ico' => 'left',
'value' => 'Retour'
]); ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('blogLayoutSubmit'); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Paramètres du module</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('blogLayoutShowFeeds', true, 'Lien du flux RSS', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']),
]); ?>
</div>
<div class="col6">
<?php echo template::text('blogLayoutFeedslabel', [
'label' => 'Texte de l\'étiquette',
'value' => $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6 offset6">
<?php echo template::select('blogLayoutItemsperPage', $module::$ItemsList, [
'label' => 'Articles par page',
'selected' => $this->getData(['module', $this->getUrl(0),'config', 'itemsperPage'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<?php echo $module::VERSION; ?>
</div>