2016-03-10 16:33:27 +01:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
|
2016-03-11 11:35:34 +01:00
|
|
|
require '../lib/database.php';
|
|
|
|
require '../lib/project.php';
|
|
|
|
|
2016-03-10 16:33:27 +01:00
|
|
|
if(isset($_POST["disconect"])) {
|
|
|
|
$_SESSION = array();
|
|
|
|
session_destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_SESSION['user'], $_SESSION['password'])) {
|
|
|
|
|
|
|
|
$prout = $_SESSION['user'];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
header('Location: index.php');
|
|
|
|
}
|
|
|
|
|
2016-03-11 16:46:09 +01:00
|
|
|
if (isset($_POST['delete'])) {
|
|
|
|
$id = $_POST['delete'];
|
|
|
|
|
|
|
|
deleteProject($id);
|
|
|
|
}
|
2016-03-11 11:35:34 +01:00
|
|
|
|
|
|
|
if (isset($_POST['project-name'], $_POST['description-project'])) {
|
|
|
|
$projectName = trim($_POST['project-name']);
|
|
|
|
$projectDescription = trim($_POST['description-project']);
|
|
|
|
|
|
|
|
$valid = true;
|
|
|
|
|
|
|
|
foreach ([$projectName, $projectDescription] as $field) {
|
|
|
|
if (empty($field)) {
|
|
|
|
$valid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($valid) {
|
|
|
|
createProject($projectName, $projectDescription, new DateTime('now'));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2016-03-11 16:46:09 +01:00
|
|
|
|
|
|
|
$limit = 15;
|
|
|
|
|
|
|
|
$numberOfPages = getProjectNumberOfPages($limit);
|
|
|
|
|
|
|
|
if (isset($_GET['page'])) {
|
|
|
|
$page = (int) $_GET['page'];
|
|
|
|
} else {
|
|
|
|
$page = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($page > $numberOfPages) {
|
|
|
|
$page = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$projects = getProjects($page, $limit);
|
|
|
|
$pager = getProjectsPager($page, $numberOfPages);
|
|
|
|
|
|
|
|
$prev = $page - 1;
|
|
|
|
$next = $page + 1;
|
2016-03-10 16:33:27 +01:00
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
2016-03-11 16:46:09 +01:00
|
|
|
<link rel="stylesheet" href="../style.css" />
|
2016-03-10 16:33:27 +01:00
|
|
|
<title>
|
|
|
|
Mon super portfolio
|
|
|
|
</title>
|
|
|
|
</head>
|
|
|
|
<body style="font-family: Arial, sans-serif;">
|
|
|
|
<h1>Administration</h1>
|
|
|
|
<p>Bonjour <span style="font-weight: bold"><?php echo $prout ?></span></p>
|
|
|
|
|
|
|
|
<form action="" method="POST">
|
|
|
|
<input type="hidden" name="disconect" value="disconect"/>
|
|
|
|
<input type="submit" value="CIAO"/>
|
|
|
|
</form>
|
|
|
|
|
2016-03-11 11:35:34 +01:00
|
|
|
<h2>Gestion des projets</h2>
|
|
|
|
|
|
|
|
<p style="font-weight: bold;">Ajouter un projet sans mettre d'image parce que c'est trop long est chiant à faire</p>
|
|
|
|
|
|
|
|
<form action="" method="post">
|
|
|
|
<label for="project-name">Nom du projet</label>
|
|
|
|
<input style="display: block;" type="text" name="project-name" id="project-name"/>
|
|
|
|
<label for="description-project">Description du projet</label>
|
|
|
|
<textarea name="description-project" id="description-project" style="display: block;"></textarea>
|
|
|
|
|
|
|
|
<input type="submit" value="Ajouter"/>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<h3>Liste des projets</h3>
|
|
|
|
|
2016-03-11 16:46:09 +01:00
|
|
|
<section style="width: 640px;">
|
|
|
|
<?php foreach($projects as $project): ?>
|
|
|
|
<article>
|
|
|
|
<h2><?php echo $project['title'] ?></h2>
|
|
|
|
|
|
|
|
<figure>
|
|
|
|
<img src="../images/<?php echo $project['illustration'] ?>" alt="" width="130px" />
|
|
|
|
</figure>
|
|
|
|
|
|
|
|
<p class="description" style="text-overflow: ellipsis;white-space: nowrap;overflow: hidden;">
|
|
|
|
<?php echo $project['description'] ?>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<?php $date = new DateTime($project['date']); ?>
|
|
|
|
|
|
|
|
<form action="" method="post">
|
|
|
|
<input type="hidden" name="delete" value="<?php echo $project['id'] ?>"/>
|
|
|
|
<input type="submit" value="Supprimer"/>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<p class="date">
|
|
|
|
<time datetime="<?php echo $date->format(DateTime::W3C) ?>">
|
|
|
|
<?php echo $date->format('d/m/Y') ?>
|
|
|
|
</time>
|
|
|
|
</p>
|
|
|
|
</article>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<?php if (count($pager) > 1): ?>
|
|
|
|
<ul class="pager">
|
|
|
|
<?php foreach ($pager as $p): ?>
|
|
|
|
<li <?php if ($p['current'] === true): ?>class="active"<?php endif ?>>
|
|
|
|
<a href="?page=<?php echo $p['page'] ?>">
|
|
|
|
<?php echo $p['title'] ?>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</ul>
|
|
|
|
<?php endif ?>
|
|
|
|
|
2016-03-10 16:33:27 +01:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|