Vues affichages des listes par categorie/genre et fiche detaillee des jeux et creation de la page detail du jeu avec jointures gauches pour le developpeur et le poster
This commit is contained in:
@@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
| a PHP script and you can easily do that on your own.
|
||||
|
|
||||
*/
|
||||
$config['base_url'] = 'https://dwarves.iut-fbleau.fr/~doucoure/sae_r301_gr12/';
|
||||
$config['base_url'] = 'https://dwarves.iut-fbleau.fr/~doucoure/sae_r301_gr12/codeigniter-develop/';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -49,6 +49,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
| Examples: my-controller/index -> my_controller/index
|
||||
| my-controller/my-method -> my_controller/my_method
|
||||
*/
|
||||
$route['default_controller'] = 'welcome';
|
||||
$route['default_controller'] = 'home';
|
||||
$route['404_override'] = '';
|
||||
$route['translate_uri_dashes'] = FALSE;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Category extends CI_Controller {
|
||||
|
||||
public function view($id = NULL) {
|
||||
if ($id === NULL) {
|
||||
redirect('home');
|
||||
}
|
||||
|
||||
// 1. Charger les modèles nécessaires
|
||||
$this->load->model('Game_model');
|
||||
$this->load->model('Category_model');
|
||||
|
||||
// 2. Récupérer les infos de la catégorie pour afficher son nom
|
||||
$this->db->where('categoryId', $id);
|
||||
$data['category'] = $this->db->get('category')->row_array();
|
||||
|
||||
if (empty($data['category'])) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
// 3. Récupérer tous les jeux de cette catégorie
|
||||
$data['games'] = $this->Game_model->get_by_category($id);
|
||||
|
||||
// 4. Envoyer le tout à une nouvelle vue
|
||||
$this->load->view('games_list_view', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Game extends CI_Controller {
|
||||
|
||||
public function detail($id = NULL) {
|
||||
if ($id === NULL) {
|
||||
redirect('home');
|
||||
}
|
||||
|
||||
// 1. Charger le modèle des jeux
|
||||
$this->load->model('Game_model');
|
||||
|
||||
// 2. Récupérer les données du jeu cible
|
||||
$data['game'] = $this->Game_model->get_by_id($id);
|
||||
|
||||
if (empty($data['game'])) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
// 3. Charger la vue de détail en lui poussant les données
|
||||
$this->load->view('game_detail_view', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Genre extends CI_Controller {
|
||||
|
||||
public function view($id = NULL) {
|
||||
if ($id === NULL) {
|
||||
redirect('home');
|
||||
}
|
||||
|
||||
// 1. Charger les modèles nécessaires
|
||||
$this->load->model('Game_model');
|
||||
|
||||
// 2. Récupérer les informations du genre pour afficher son nom
|
||||
$this->db->where('genreId', $id);
|
||||
$data['genre'] = $this->db->get('genre')->row_array();
|
||||
|
||||
if (empty($data['genre'])) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
// 3. Récupérer tous les jeux liés à ce genre
|
||||
$data['games'] = $this->Game_model->get_by_genre($id);
|
||||
|
||||
// 4. Envoyer les données à la vue
|
||||
$this->load->view('genre_games_list_view', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Home extends CI_Controller {
|
||||
|
||||
public function index() {
|
||||
// 1. Charger les modèles
|
||||
$this->load->model('Category_model');
|
||||
$this->load->model('Genre_model');
|
||||
|
||||
// 2. Récupérer les données depuis les modèles
|
||||
$data['categories'] = $this->Category_model->get_all();
|
||||
$data['genres'] = $this->Genre_model->get_all();
|
||||
|
||||
// 3. Charger la vue en lui passant les données
|
||||
$this->load->view('home_view', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Category_model extends CI_Model {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère toutes les catégories de la base de données
|
||||
*/
|
||||
public function get_all() {
|
||||
$query = $this->db->get('category');
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Game_model extends CI_Model {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les jeux appartenant à une catégorie spécifique
|
||||
*/
|
||||
public function get_by_category($category_id) {
|
||||
$this->db->select('game.*');
|
||||
$this->db->from('game');
|
||||
|
||||
$this->db->join('game_category', 'game_category.gameId = game.gameId');
|
||||
|
||||
$this->db->where('game_category.categoryId', $category_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les jeux appartenant à un genre spécifique
|
||||
*/
|
||||
public function get_by_genre($genre_id) {
|
||||
$this->db->select('game.*');
|
||||
$this->db->from('game');
|
||||
|
||||
$this->db->join('game_genre', 'game_genre.gameId = game.gameId');
|
||||
|
||||
$this->db->where('game_genre.genreId', $genre_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les détails complets d'un jeu (avec développeur et poster)
|
||||
*/
|
||||
public function get_by_id($game_id) {
|
||||
|
||||
$this->db->select('game.*, developer.name as developer_name, poster.url as poster_url');
|
||||
$this->db->from('game');
|
||||
|
||||
$this->db->join('developer', 'developer.developerId = game.developerId', 'left');
|
||||
|
||||
$this->db->join('poster', 'poster.posterId = game.posterId', 'left');
|
||||
|
||||
$this->db->where('game.gameId', $game_id);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->row_array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Genre_model extends CI_Model {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère tous les genres de la base de données
|
||||
*/
|
||||
public function get_all() {
|
||||
$query = $this->db->get('genre');
|
||||
return $query->result_array();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><?php echo html_escape($game['title']); ?> - Détails</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p><a href="<?php echo site_url('home'); ?>">← Retour à l'accueil</a></p>
|
||||
|
||||
<main style="display: flex; gap: 40px; margin-top: 20px;">
|
||||
|
||||
<section style="max-width: 300px;">
|
||||
<?php if (!empty($game['poster_url'])): ?>
|
||||
<img src="<?php echo html_escape($game['poster_url']); ?>" alt="Jaquette de <?php echo html_escape($game['title']); ?>" style="width: 100%; height: auto; border-radius: 8px;">
|
||||
<?php else: ?>
|
||||
<div style="width: 200px; height: 300px; background: #ccc; display: flex; align-items: center; justify-content: center; text-align: center; border-radius: 8px;">
|
||||
<span>Aucune image<br>disponible</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h1><?php echo html_escape($game['title']); ?></h1>
|
||||
<ul>
|
||||
<li><strong>Année de sortie :</strong> <?php echo html_escape($game['year']); ?></li>
|
||||
<li><strong>Développeur :</strong>
|
||||
<?php echo !empty($game['developer_name']) ? html_escape($game['developer_name']) : 'Inconnu'; ?>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<hr>
|
||||
<p style="font-style: italic; color: #666;">Espace administration (Éditer / Supprimer)</p>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Jeux de la catégorie <?php echo html_escape($category['name']); ?></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p><a href="<?php echo site_url('home'); ?>">← Retour à l'accueil</a></p>
|
||||
|
||||
<h1>Jeux dans la catégorie : "<?php echo html_escape($category['name']); ?>"</h1>
|
||||
|
||||
<?php if (empty($games)): ?>
|
||||
<p>Aucun jeu trouvé dans cette catégorie pour le moment.</p>
|
||||
<?php else: ?>
|
||||
<ul>
|
||||
<?php foreach ($games as $game): ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('game/detail/' . $game['gameId']); ?>">
|
||||
<strong><?php echo html_escape($game['title']); ?></strong>
|
||||
</a>
|
||||
(<?php echo html_escape($game['year']); ?>)
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Jeux du genre <?php echo html_escape($genre['name']); ?></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p><a href="<?php echo site_url('home'); ?>">← Retour à l'accueil</a></p>
|
||||
|
||||
<h1>Jeux du genre : "<?php echo html_escape($genre['name']); ?>"</h1>
|
||||
|
||||
<?php if (empty($games)): ?>
|
||||
<p>Aucun jeu trouvé pour ce genre pour le moment.</p>
|
||||
<?php else: ?>
|
||||
<ul>
|
||||
<?php foreach ($games as $game): ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('game/detail/' . $game['gameId']); ?>">
|
||||
<strong><?php echo html_escape($game['title']); ?></strong>
|
||||
</a>
|
||||
(<?php echo html_escape($game['year']); ?>)
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Univers Jeux Vidéo - Accueil</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Bienvenue sur l'application Jeux Vidéo</h1>
|
||||
|
||||
<main style="display: flex; gap: 50px;">
|
||||
<section>
|
||||
<h2>Nos Catégories</h2>
|
||||
<ul>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('category/view/' . $category['id']); ?>">
|
||||
<?php echo html_escape($category['name']); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Nos Genres</h2>
|
||||
<ul>
|
||||
<?php foreach ($genres as $genre): ?>
|
||||
<li>
|
||||
<a href="<?php echo site_url('genre/view/' . $genre['id']); ?>">
|
||||
<?php echo html_escape($genre['name']); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user