From 6fa5b603313f4789cd61a4ce7ec80cd457d8743f Mon Sep 17 00:00:00 2001 From: stiti Date: Wed, 22 May 2024 20:03:53 +0200 Subject: [PATCH] =?UTF-8?q?Commit=20de=20Louay=20(probl=C3=A8me=20de=20PC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/controllers/Albums.php | 2 +- .../application/controllers/Artiste.php | 12 ++- .../application/models/Model_artist.php | 4 + .../application/views/artists_list.php | 28 +++++++ .../views/layout/header_not_logged_dark.php | 2 +- CodeIgniter-3.1.13/assets/css/album_view.css | 64 ++++++++++----- .../assets/css/artists_list.css | 78 +++++++++++++++++++ 7 files changed, 164 insertions(+), 26 deletions(-) create mode 100644 CodeIgniter-3.1.13/application/views/artists_list.php create mode 100644 CodeIgniter-3.1.13/assets/css/artists_list.css diff --git a/CodeIgniter-3.1.13/application/controllers/Albums.php b/CodeIgniter-3.1.13/application/controllers/Albums.php index cf7d3b4..67abe11 100644 --- a/CodeIgniter-3.1.13/application/controllers/Albums.php +++ b/CodeIgniter-3.1.13/application/controllers/Albums.php @@ -10,7 +10,7 @@ class Albums extends CI_Controller { } public function index($page = 1){ - $limit = 21; + $limit = 21; // Nombre d'albums max par page $offset = ($page - 1) * $limit; $albums = $this->model_music->getAlbums($limit, $offset); diff --git a/CodeIgniter-3.1.13/application/controllers/Artiste.php b/CodeIgniter-3.1.13/application/controllers/Artiste.php index cc3d899..df2f05c 100644 --- a/CodeIgniter-3.1.13/application/controllers/Artiste.php +++ b/CodeIgniter-3.1.13/application/controllers/Artiste.php @@ -6,7 +6,7 @@ class Artiste extends CI_Controller { public function __construct(){ parent::__construct(); $this->load->model('Model_artist'); - $this->load->model('Model_music'); // Chargez également le modèle Model_music si vous en avez besoin + $this->load->model('Model_music'); $this->load->helper('url'); } @@ -16,7 +16,7 @@ class Artiste extends CI_Controller { if($artiste){ // Récupérer tous les albums de l'artiste - $albums = $this->Model_music->getAlbumsByArtiste($artiste_id); // Utilisez le modèle Model_music ici + $albums = $this->Model_music->getAlbumsByArtiste($artiste_id); // Charger la vue avec les détails de l'artiste et ses albums $data['artiste'] = $artiste; @@ -25,17 +25,21 @@ class Artiste extends CI_Controller { $this->load->view('artiste_details', $data); $this->load->view('layout/footer_dark'); } else { - // Gérer le cas où l'artiste n'est pas trouvé + // Gérer le cas où l'artiste n'est pas trouvé == afficher un error 404 show_404(); } } public function list_artists(){ + // Récupérer le paramètre de tri (croissant ou decroissant) + $order = $this->input->get('order') ? $this->input->get('order') : 'ASC'; + // Récupérer la liste des artistes - $artists = $this->Model_artist->getArtists(); + $artists = $this->Model_artist->getArtists($order); // Charger la vue avec la liste des artistes $data['artists'] = $artists; + $data['current_order'] = $order; $this->load->view('layout/header_not_logged_dark'); $this->load->view('artists_list', $data); $this->load->view('layout/footer_dark'); diff --git a/CodeIgniter-3.1.13/application/models/Model_artist.php b/CodeIgniter-3.1.13/application/models/Model_artist.php index 78d2887..46201c6 100644 --- a/CodeIgniter-3.1.13/application/models/Model_artist.php +++ b/CodeIgniter-3.1.13/application/models/Model_artist.php @@ -11,5 +11,9 @@ class Model_artist extends CI_Model { return $query->row(); } + public function getArtists($order = 'ASC'){ + $query = $this->db->query("SELECT * FROM artist ORDER BY name " . $order); + return $query->result(); + } } ?> diff --git a/CodeIgniter-3.1.13/application/views/artists_list.php b/CodeIgniter-3.1.13/application/views/artists_list.php new file mode 100644 index 0000000..6310747 --- /dev/null +++ b/CodeIgniter-3.1.13/application/views/artists_list.php @@ -0,0 +1,28 @@ + + + + + + + Liste des Artistes - Onzeur + + +
+

Liste des Artistes

+ + +
+ + diff --git a/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php b/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php index 5f8cf6d..ec7a154 100644 --- a/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php +++ b/CodeIgniter-3.1.13/application/views/layout/header_not_logged_dark.php @@ -17,7 +17,7 @@