diff --git a/CodeIgniter-3.1.13/application/config/routes.php b/CodeIgniter-3.1.13/application/config/routes.php index befec1a..2f107b9 100644 --- a/CodeIgniter-3.1.13/application/config/routes.php +++ b/CodeIgniter-3.1.13/application/config/routes.php @@ -53,4 +53,6 @@ $route['default_controller'] = 'home/index'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; $route['albums'] = 'albums/index'; +$route['musiques'] = 'Musiques/index'; + diff --git a/CodeIgniter-3.1.13/application/controllers/Albums.php b/CodeIgniter-3.1.13/application/controllers/Albums.php index 010d835..cf7d3b4 100644 --- a/CodeIgniter-3.1.13/application/controllers/Albums.php +++ b/CodeIgniter-3.1.13/application/controllers/Albums.php @@ -32,5 +32,6 @@ class Albums extends CI_Controller { $this->load->view('album_view', $data); $this->load->view('layout/footer_dark'); } + } ?> diff --git a/CodeIgniter-3.1.13/application/controllers/Artiste.php b/CodeIgniter-3.1.13/application/controllers/Artiste.php new file mode 100644 index 0000000..cf6af3c --- /dev/null +++ b/CodeIgniter-3.1.13/application/controllers/Artiste.php @@ -0,0 +1,32 @@ +load->model('Model_music'); + $this->load->helper('url'); + } + + public function index($artiste_id){ + // Récupérer les détails de l'artiste + $artiste = $this->Model_music->getArtisteById($artiste_id); + + if($artiste){ + // Récupérer tous les albums de l'artiste + $albums = $this->Model_music->getAlbumsByArtiste($artiste_id); + + // Charger la vue avec les détails de l'artiste et ses albums + $data['artiste'] = $artiste; + $data['albums'] = $albums; + $this->load->view('layout/header_not_logged_dark'); + $this->load->view('artiste_details', $data); // Créez cette vue + $this->load->view('layout/footer_dark'); + } else { + // Gérer le cas où l'artiste n'est pas trouvé + show_404(); // Affiche une page d'erreur 404 + } + } +} +?> diff --git a/CodeIgniter-3.1.13/application/controllers/Musiques.php b/CodeIgniter-3.1.13/application/controllers/Musiques.php new file mode 100644 index 0000000..1074d0e --- /dev/null +++ b/CodeIgniter-3.1.13/application/controllers/Musiques.php @@ -0,0 +1,33 @@ +load->model('Model_music'); + $this->load->library('pagination'); + $this->load->helper('url'); + } + + public function index($page = 1){ + $limit = 100; // Nombre de musiques par page + $offset = ($page - 1) * $limit; + + $musiques = $this->Model_music->getMusiques($limit, $offset); + + $total_musiques = $this->Model_music->get_total_musiques(); + $data['total_pages'] = ceil($total_musiques / $limit); // Calcul du nombre total de pages + $data['current_page'] = $page; // Définition de la variable $current_page + + // Données à passer à la vue + $data['musiques'] = $musiques; + + // Charger la vue + $this->load->view('layout/header_not_logged_dark'); + $this->load->view('musiques_list', $data); + $this->load->view('layout/footer_dark'); + } + +} +?> diff --git a/CodeIgniter-3.1.13/application/models/Model_music.php b/CodeIgniter-3.1.13/application/models/Model_music.php index 461b4b2..b3b690d 100644 --- a/CodeIgniter-3.1.13/application/models/Model_music.php +++ b/CodeIgniter-3.1.13/application/models/Model_music.php @@ -50,5 +50,25 @@ class Model_music extends CI_Model { return $album; } + + public function getMusiques($limit, $offset) { + $query = $this->db->query( + "SELECT song.id, song.name, artist.name as artistName, album.name as album_name, track.albumid as album_id, cover.jpeg as cover + FROM song + JOIN track ON song.id = track.songid + JOIN album ON track.albumid = album.id + JOIN artist ON album.artistid = artist.id + JOIN cover ON album.coverid = cover.id + LIMIT $limit OFFSET $offset" + ); + return $query->result(); + } + + public function get_total_musiques(){ + $query = $this->db->query("SELECT COUNT(*) as total_musiques FROM song"); + $result = $query->row(); + return $result->total_musiques; + } + } ?> diff --git a/CodeIgniter-3.1.13/application/views/accueil.php b/CodeIgniter-3.1.13/application/views/accueil.php index b75c0eb..9e12f84 100644 --- a/CodeIgniter-3.1.13/application/views/accueil.php +++ b/CodeIgniter-3.1.13/application/views/accueil.php @@ -8,7 +8,7 @@
Artiste : artistName; ?>
+Année : year; ?>
+Genre : genreName; ?>
+ + + tracks)): ?> +Aucune musique n'est disponible dans cet album...
+ +