Module téléchargement

This commit is contained in:
fredtempez 2021-02-14 14:21:58 +01:00
parent 4ba7c59d32
commit 6a7642e5a0
6 changed files with 43 additions and 16 deletions

View File

@ -53,6 +53,9 @@ class download extends common {
public static $pages;
// Nombre de téléchargements
public static $statSum = 0;
public static $states = [
false => 'Brouillon',
true => 'Publié'
@ -90,7 +93,7 @@ class download extends common {
public static $users = [];
const VERSION = '4.2';
const VERSION = '1.0';
const REALNAME = 'Téléchargement';
/**
@ -426,22 +429,25 @@ class download extends common {
$toApprove = 0;
$approved = count($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'comment']));
}
// Nombre de téléchargements
$stats = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'fileStats']), 'time');
// Met en forme le tableau
$date = mb_detect_encoding(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate'])), 'UTF-8', true)
? strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate']))
: utf8_encode(strftime('%d %B %Y', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate'])));
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate'])));
$heure = mb_detect_encoding(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate'])), 'UTF-8', true)
? strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate']))
: utf8_encode(strftime('%H:%M', $this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileDate'])));
$stat = count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'fileStats']), 'time') ) === 0
? '0'
: '<a href="' . helper::baseurl() . $this->getUrl(0) . '/stats/' . $itemIds[$i] . '" >' .
count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i],'fileStats']), 'time') ) .
'</a>';
self::$items[] = [
'<a href="' . helper::baseurl() . $this->getUrl(0) . '/' . $itemIds[$i] . '" target="_blank" >' .
$this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'title']) .
'</a>',
$this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'fileVersion']),
$date .' à '. $heure,
'<a href="' . helper::baseurl() . $this->getUrl(0) . '/stats/' . $itemIds[$i] . '" >' . count($stats) . '</a>',
$stat,
self::$states[$this->getData(['module', $this->getUrl(0), 'items', $itemIds[$i], 'state'])],
// Bouton pour afficher les commentaires de l'item
template::button('downloadConfigComment' . $itemIds[$i], [
@ -684,6 +690,10 @@ class download extends common {
$commentIds = array_keys(helper::arrayCollumn($commentsApproved, 'createdOn', 'SORT_DESC'));
// Pagination
$pagination = helper::pagination($commentIds, $this->getUrl(),$this->getData(['config','itemsperPage']),'#comment');
// Nombre de téléchargements
self::$statSum = count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items',$this->getUrl(1),'fileStats']), 'time') ) === 0
? '0'
: count(helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(1),'fileStats']), 'time') ) ;
// Liste des pages
self::$pages = $pagination['pages'];
// Signature de l'item
@ -836,6 +846,8 @@ class download extends common {
// Construction de la page des statistiques
$itemIds = array_keys($this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'fileStats']));
// Total des téléchargements
self::$statSum = count ($itemIds);
// Pagination
$pagination = helper::pagination($itemIds, $this->getUrl(),$this->getData(['config','itemsperPage']));

View File

@ -12,7 +12,7 @@
<?php echo template::button('downloadConfigAdd', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/add',
'ico' => 'plus',
'value' => 'Item'
'value' => 'Fichier'
]); ?>
</div>
<div class="col2">

View File

@ -26,10 +26,11 @@
padding-right: 10px;
float: right;
}
.downloadTitle {
/*background-color: #ECEFF1;*/
padding: 0px;
h2{
margin-bottom: 5px;
margin-top: 0px;
padding: 0px;
}
.downloadContent {
float: left;

View File

@ -3,7 +3,7 @@
<div class="col12">
<?php foreach($module::$items as $itemId => $item): ?>
<div class="row rowitem">
<div class="col3">
<div class="col3 downloadLeft">
<?php
// Déterminer le nom de la miniature
$parts = explode('/',$item['picture']);
@ -20,13 +20,13 @@
<img src="<?php echo helper::baseUrl(false) . self::FILE_DIR . 'thumb/' . $thumb; ?>" alt="<?php echo $item['picture']; ?>">
</a>
</div>
<div class="col9">
<div class="col9 downloadRight">
<article>
<h1 class="downloadTitle">
<h2 class="downloadTitle">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $itemId; ?>">
<?php echo $item['title']; ?>
</a>
</h1>
</h2>
<div class="downloadComment">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0) . '/' . $itemId; ?>#comment">
<?php if ($item['comment']): ?>

View File

@ -77,6 +77,13 @@
<?php echo ' du ' . $date; ?>
</div>
</div>
<div class="row">
<div class="col12 textAlignCenter">
<span>Téléchargements :
<?php echo $module::$statSum; ?>
</span>
</div>
</div>
</div>
<div class="col9">
<?php echo $this->getData(['module', $this->getUrl(0),'items', $this->getUrl(1), 'content']); ?>

View File

@ -13,11 +13,18 @@
'class' => 'statsDeleteAll buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/statsDeleteAll' . '/' . $this->getUrl(2) . '/'. $_SESSION['csrf'] ,
'ico' => 'cancel',
'value' => 'Tout effacer'
'value' => 'Purger'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?>
<div class="row">
<div class="col12">
<h3> Nombre de téléchargements :
<?php echo $module::$statSum; ?>
</h3>
</div>
</div>
<?php if($module::$items): ?>
<?php echo template::table([6, 6], $module::$items, ['Date', 'Adresse IP']); ?>
<?php echo $module::$pages; ?>