Protection des données de config

This commit is contained in:
Fred Tempez 2020-11-16 18:39:32 +01:00
parent 9158a48d39
commit 21580cf4fa
2 changed files with 107 additions and 64 deletions

View File

@ -230,8 +230,25 @@ class blog extends common {
* Configuration
*/
public function config() {
// 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)
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Modifications enregistrées',
'state' => true
]);
} else {
// Extraire la clé config mot clé réservé
$articles = $this->getData(['module', $this->getUrl(0)]);
unset($articles['config']);
// Ids des articles par ordre de publication
$articleIds = array_keys(helper::arrayCollumn($this->getData(['module', $this->getUrl(0)]), 'publishedOn', 'SORT_DESC'));
$articleIds = array_keys(helper::arrayCollumn($articles, 'publishedOn', 'SORT_DESC'));
// Supprimer le bloc config
// Pagination
$pagination = helper::pagination($articleIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
// Liste des pages
@ -266,6 +283,7 @@ class blog extends common {
'view' => 'config'
]);
}
}
/**
* Suppression

View File

@ -1,4 +1,5 @@
<div class="row">
<?php echo template::formOpen('blogConfig'); ?>
<div class="row">
<div class="col2">
<?php echo template::button('blogConfigBack', [
'class' => 'buttonGrey',
@ -7,7 +8,7 @@
'value' => 'Retour'
]); ?>
</div>
<div class="col3 offset5">
<div class="col3 offset3">
<?php echo template::button('blogConfigComment', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/comment',
'value' => 'Gérer les commentaires'
@ -20,13 +21,37 @@
'value' => 'Article'
]); ?>
</div>
</div>
<?php if($module::$articles): ?>
<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, 'Afficher les flux RSS', [
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'feeds']),
]); ?>
</div>
<div class="col6">
<?php echo template::text('blogConfigFeedslabel', [
'label' => 'Etiquette',
'value' => empty($this->getData(['module', $this->getUrl(0), 'config','feedsLabel'])) ? 'Syndication RSS' : $this->getData(['module', $this->getUrl(0), 'config', 'feedsLabel'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php if($module::$articles): ?>
<?php echo template::table([4, 4, 2, 1, 1], $module::$articles, ['Titre', 'Date de publication', 'État', '', '']); ?>
<?php echo $module::$pages; ?>
<?php else: ?>
<?php else: ?>
<?php echo template::speech('Aucun article.'); ?>
<?php endif; ?>
<div class="moduleVersion">Version
<?php endif; ?>
<?php echo template::formClose(); ?>
<div class="moduleVersion">Version
<?php echo $module::BLOG_VERSION; ?>
</div>
</div>