<!DOCTYPE html>
<!-- Page: admin wiki files -->
<html lang="fr">

	<?php include('blocks/d.head.html'); ?>

	<body>

		<?php include('blocks/d.nav.html'); ?>

		<!-- Files table -->
		<section id="wiki_files">
			<h1><?=$head['title']?></h1>

			<!-- Pagination summary -->
			<p class="subtitle">Fichiers attachés <?=$first?> à <?=$last?> sur les <?=$filenb?> présents</p>

			<br>
			<br>

			<!-- Upload form -->
			<form action="<?=$config['rel_root_folder']?>admin/wiki-files/upload/" method="post" enctype="multipart/form-data" id="send_file">
				<div>
					<label for="file">Envoyer un fichier :</label>
					<input type="file" id="file" name="file">
				</div>
				<input type="submit" value="Envoyer">
			</form>

			<!-- File list -->
			<table>
				<tr class="first">
					<th>
						<a href="<?=$config['rel_root_folder']?>admin/wiki-files/<?=$page+1?>?orderby=name&amp;order=<?=$order=='ASC'?'DESC':'ASC'?>">Nom</a>
						<?=$orderby=='name'?$order=='ASC'?'<i class="fas fa-caret-down" aria-hidden="true"></i>':'<i class="fas fa-caret-up" aria-hidden="true"></i>':''?>
					</th>
					<th>
						<a href="<?=$config['rel_root_folder']?>admin/wiki-files/<?=$page+1?>?orderby=type&amp;order=<?=$order=='ASC'?'DESC':'ASC'?>">Type</a>
						<?=$orderby=='type'?$order=='ASC'?'<i class="fas fa-caret-down" aria-hidden="true"></i>':'<i class="fas fa-caret-up" aria-hidden="true"></i>':''?>
					</th>
					<th>
						<a href="<?=$config['rel_root_folder']?>admin/wiki-files/<?=$page+1?>?orderby=size&amp;order=<?=$order=='ASC'?'DESC':'ASC'?>">Taille</a>
						<?=$orderby=='size'?$order=='ASC'?'<i class="fas fa-caret-down" aria-hidden="true"></i>':'<i class="fas fa-caret-up" aria-hidden="true"></i>':''?>
					</th>
					<th>
						<a href="<?=$config['rel_root_folder']?>admin/wiki-files/<?=$page+1?>?orderby=creation_date&amp;order=<?=$order=='ASC'?'DESC':'ASC'?>">Date de création</a>
						<?=$orderby=='creation_date'?$order=='ASC'?'<i class="fas fa-caret-down" aria-hidden="true"></i>':'<i class="fas fa-caret-up" aria-hidden="true"></i>':''?>
					</th>
					<?php if ($user->rankIsHigher("administrator")) { ?>
						<th>Suppression</th>
					<?php } ?>
				</tr>
			<?php foreach (array_slice($files, $first-1, $rows_per_pages, true) as $file) { ?>
				<tr>
					<td>
						<a href="<?=$config['rel_root_folder']?>medias/wiki/<?=$file['name']?>"><?=$file['name']?></a>
					</td>
					<td><i class='fas <?=getFontAwesomeIcon($file['type'])?>'></i> <?=$file['type']?></td>
					<td><?=formatBytes($file['size'], $user->locale)?></td>
					<td><?php echo datefmt_format($user->date_format,date_create($file['creation_date'], new DateTimeZone("UTC"))) ?></td>
					<?php if ($user->rankIsHigher("administrator")) { ?>
						<td class="center">
							<a href="<?=$config['rel_root_folder']?>admin/wiki-files/delete/<?=$file['name']?>?orderby=<?=$orderby?>&amp;order=<?=$order?>" onclick="return confirm('Es-tu sûr de vouloir supprimer ?');"><span class="external-link"><i class="fas fa-trash"></i></span></a>
						</td>
					<?php } ?>
				</tr>
			<?php } ?>
			</table> 
			<!-- Pagination controls -->
			<div class="pagebuttons">
				<?php if ($page != 0) { ?><a class="previous" href="<?=$config['rel_root_folder']?>admin/wiki-files/<?=$page?>?orderby=<?=$orderby?>&amp;order=<?=$order?>"><i class="fas fa-chevron-left fa-fw"></i></a><?php }
				if (($page+1)*$rows_per_pages < $filenb) { ?><a class="next" href="<?=$config['rel_root_folder']?>admin/wiki-files/<?=$page+2?>?orderby=<?=$orderby?>&amp;order=<?=$order?>"><i class="fas fa-chevron-right fa-fw"></i></a><?php } ?>
			</div>

		</section>

		<?php include('blocks/d.footer.html'); ?>

	</body>
</html>
