forked from ZwiiCMS-Team/ZwiiCMS
Stat ok manque le total dans la liste et l'export
This commit is contained in:
parent
ed2130e8e1
commit
4ba7c59d32
@ -28,6 +28,7 @@ class download extends common {
|
|||||||
'delete' => self::GROUP_MODERATOR,
|
'delete' => self::GROUP_MODERATOR,
|
||||||
'edit' => self::GROUP_MODERATOR,
|
'edit' => self::GROUP_MODERATOR,
|
||||||
'stats' => self::GROUP_MODERATOR,
|
'stats' => self::GROUP_MODERATOR,
|
||||||
|
'statsDeleteAll' => self::GROUP_MODERATOR,
|
||||||
'index' => self::GROUP_VISITOR,
|
'index' => self::GROUP_VISITOR,
|
||||||
'rss' => self::GROUP_VISITOR,
|
'rss' => self::GROUP_VISITOR,
|
||||||
'downloadFile' => self::GROUP_VISITOR
|
'downloadFile' => self::GROUP_VISITOR
|
||||||
@ -795,7 +796,7 @@ class download extends common {
|
|||||||
$statId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats']));
|
$statId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats']));
|
||||||
$this->setData(['module',
|
$this->setData(['module',
|
||||||
$this->getUrl(0),
|
$this->getUrl(0),
|
||||||
'items',
|
'items',
|
||||||
$this->getUrl(2),
|
$this->getUrl(2),
|
||||||
'fileStats',
|
'fileStats',
|
||||||
$statId, [
|
$statId, [
|
||||||
@ -832,58 +833,60 @@ class download extends common {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public function stats() {
|
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
|
// 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']));
|
// Liste des pages
|
||||||
// Pagination
|
self::$pages = $pagination['pages'];
|
||||||
$pagination = helper::pagination($itemIds, $this->getUrl(),$this->getData(['config','itemsperPage']));
|
|
||||||
|
|
||||||
// Liste des pages
|
for($i = $pagination['first']; $i < $pagination['last']; $i++) {
|
||||||
self::$pages = $pagination['pages'];
|
|
||||||
|
|
||||||
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[] = [
|
||||||
echo $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'fileDate']);
|
$date,
|
||||||
|
$this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats', $itemIds[$i], 'ip'])
|
||||||
$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[] = [
|
$this->addOutput([
|
||||||
$date,
|
'title' => 'Statistiques de téléchargement',
|
||||||
$this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileStats', 'ip'])
|
'view' => 'stats'
|
||||||
];
|
]);
|
||||||
|
}
|
||||||
}
|
|
||||||
die();
|
public function statsDeleteAll() {
|
||||||
|
// Validité de la page demandée
|
||||||
|
if($this->getData(['module', $this->getUrl(0), 'items']) === null) {
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => 'Statistiques de téléchargement',
|
'access' => false
|
||||||
'view' => 'stats'
|
]);
|
||||||
|
}
|
||||||
|
// 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
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
22
module/download/view/stats/stats.js.php
Normal file
22
module/download/view/stats/stats.js.php
Normal 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"));
|
||||||
|
});
|
||||||
|
});
|
@ -3,21 +3,19 @@
|
|||||||
<div class="col2">
|
<div class="col2">
|
||||||
<?php echo template::button('statsConfigBack', [
|
<?php echo template::button('statsConfigBack', [
|
||||||
'class' => 'buttonGrey',
|
'class' => 'buttonGrey',
|
||||||
'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), 'items',
|
'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
|
||||||
'ico' => 'left',
|
'ico' => 'left',
|
||||||
'value' => 'Retour'
|
'value' => 'Retour'
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col2 offset6">
|
<div class="col2 offset8">
|
||||||
<?php echo template::button('statsConfigAdd', [
|
<?php echo template::button('statsConfigAdd', [
|
||||||
'href' => helper::baseUrl() . $this->getUrl(0) . '/add',
|
'class' => 'statsDeleteAll buttonRed',
|
||||||
'ico' => 'plus',
|
'href' => helper::baseUrl() . $this->getUrl(0) . '/statsDeleteAll' . '/' . $this->getUrl(2) . '/'. $_SESSION['csrf'] ,
|
||||||
'value' => 'Item'
|
'ico' => 'cancel',
|
||||||
|
'value' => 'Tout effacer'
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col2">
|
|
||||||
<?php echo template::submit('statsConfigSubmit'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<?php echo template::formClose(); ?>
|
<?php echo template::formClose(); ?>
|
||||||
<?php if($module::$items): ?>
|
<?php if($module::$items): ?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user