Stat ok manque le total dans la liste et l'export

This commit is contained in:
fredtempez 2021-02-12 18:37:31 +01:00
parent ed2130e8e1
commit 4ba7c59d32
3 changed files with 75 additions and 52 deletions

View File

@ -28,6 +28,7 @@ class download extends common {
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
'stats' => self::GROUP_MODERATOR,
'statsDeleteAll' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR,
'rss' => self::GROUP_VISITOR,
'downloadFile' => self::GROUP_VISITOR
@ -832,58 +833,60 @@ class download extends common {
*/
public function stats() {
// Soumission du formulaire
if($this->isPost()) {
// Jeton incorrect
if ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/config',
'notification' => 'Action non autorisée'
]);
}
// L'item n'existe pas
if($this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2)]) === null) {
// Valeurs en sortie
$this->addOutput([
'access' => false
]);
}
} else {
// Construction de la page des statistiques
// Ids des items par ordre de publication
$itemIds = array_keys($this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats']));
// Pagination
$pagination = helper::pagination($itemIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
$itemIds = array_keys($this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats']));
// Pagination
$pagination = helper::pagination($itemIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
// Liste des pages
self::$pages = $pagination['pages'];
// Liste des pages
self::$pages = $pagination['pages'];
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
// Format des variables
$date = mb_detect_encoding(strftime('%d %B %Y - %H:%M', $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'time'])), 'UTF-8', true)
? strftime('%d %B %Y - %H:%M',$this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'time']))
: utf8_encode(strftime('%d %B %Y - %H:%M', $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'time'])));
// Format des variables
// Met en forme le tableau
self::$items[] = [
$date,
$this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'ip'])
];
echo $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'fileDate']);
}
$this->addOutput([
'title' => 'Statistiques de téléchargement',
'view' => 'stats'
]);
}
$date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'fileDate'])), 'UTF-8', true)
? strftime('%d %B %Y',$this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'fileDate']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'fileDate'])));
// Met en forme le tableau
self::$items[] = [
$date,
$this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileStats', 'ip'])
];
}
die();
public function statsDeleteAll() {
// Validité de la page demandée
if($this->getData(['module', $this->getUrl(0), 'items']) === null) {
// Valeurs en sortie
$this->addOutput([
'title' => 'Statistiques de téléchargement',
'view' => 'stats'
'access' => false
]);
}
// Jeton incorrect
elseif ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0),
'notification' => 'Action non autorisée'
]);
}
// Téléchargement
else {
$this->setData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', [] ]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/stats/' . $this->getUrl(2),
'notification' => 'Purge des statistiques',
'state' => true
]);
}
}
}

View File

@ -0,0 +1,22 @@
/**
* 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
* @license GNU General Public License, version 3
* @link http://zwiicms.fr/
*/
/**
* Confirmation de suppression
*/
$(".statsDeleteAll").on("click", function() {
var _this = $(this);
return core.confirm("Êtes-vous sûr de vouloir purger les statistiques ?", function() {
$(location).attr("href", _this.attr("href"));
});
});

View File

@ -3,21 +3,19 @@
<div class="col2">
<?php echo template::button('statsConfigBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), 'items',
'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
'ico' => 'left',
'value' => 'Retour'
]); ?>
</div>
<div class="col2 offset6">
<div class="col2 offset8">
<?php echo template::button('statsConfigAdd', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/add',
'ico' => 'plus',
'value' => 'Item'
'class' => 'statsDeleteAll buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/statsDeleteAll' . '/' . $this->getUrl(2) . '/'. $_SESSION['csrf'] ,
'ico' => 'cancel',
'value' => 'Tout effacer'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('statsConfigSubmit'); ?>
</div>
</div>
<?php echo template::formClose(); ?>
<?php if($module::$items): ?>