From 00f085a28e5ee30e784a8c6cfaffe5a8edc93c7c Mon Sep 17 00:00:00 2001
From: vbochet <vbochet@gmail.com>
Date: Thu, 31 Mar 2016 20:32:46 +0200
Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20de=20fichiers=20et=20r=C3=A9per?=
 =?UTF-8?q?toires=20pour=20la=20page=20d'affichage=20de=20jeux=20(page=20d?=
 =?UTF-8?q?'exemple=20MVC)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/controller/JeuController.php | 10 ++++++++++
 app/model/Jeu.php                | 27 +++++++++++++++++++++++++++
 app/view/jeu/display.html        | 20 ++++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 app/controller/JeuController.php
 create mode 100644 app/model/Jeu.php
 create mode 100644 app/view/jeu/display.html

diff --git a/app/controller/JeuController.php b/app/controller/JeuController.php
new file mode 100644
index 0000000..e6d070a
--- /dev/null
+++ b/app/controller/JeuController.php
@@ -0,0 +1,10 @@
+<?php
+
+class JeuController extends Controller {
+   public function display() {
+      $slug = $this->route["params"]["slug"];
+      $this->view->jeu = Jeu::getFromSlug($slug);
+      $this->view->display();
+   }
+
+}
diff --git a/app/model/Jeu.php b/app/model/Jeu.php
new file mode 100644
index 0000000..df1905a
--- /dev/null
+++ b/app/model/Jeu.php
@@ -0,0 +1,27 @@
+<?php
+
+class Jeu extends Model {
+   public $id, $nom, $description, $slug;
+
+   public static function getFromSlug($slug) {
+      $db = Database::getInstance();
+      $sql = "SELECT * FROM jeux WHERE slug = :slug";
+      $stmt = $db->prepare($sql);
+      $stmt->setFetchMode(PDO::FETCH_CLASS, "Jeu");
+      $stmt->execute(array(":slug" => $slug));
+      return $stmt->fetch();
+   }
+
+   public static function getList() {
+      $db = Database::getInstance();
+      $sql = "SELECT * FROM jeux";
+      $stmt = $db->query($sql);
+      $stmt->setFetchMode(PDO::FETCH_CLASS, "Jeu");
+      return $stmt->fetchAll();
+
+   }
+
+}
+
+
+
diff --git a/app/view/jeu/display.html b/app/view/jeu/display.html
new file mode 100644
index 0000000..f3d467e
--- /dev/null
+++ b/app/view/jeu/display.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+   <meta charset="utf-8"/>
+   <title>Affichage d'un jeu</title>
+   <base href="http://localhost/projet-web-2016/www/"/>
+</head>
+<body>
+   <header>
+      <h1>Exemple d'affichage d'un jeu</h1>
+   </header>
+   <h2><?php echo $this->jeu->nom; ?></h2>
+   <h3><?php echo $this->jeu->description; ?></h3>
+   <footer>
+      <p>Pied de page...</p>
+   </footer>
+</body>
+
+
+</html>
-- 
GitLab