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 @@

Bienvenue sur Onzeur !

Le service de streaming musical numéro 1 en France.

- +
diff --git a/CodeIgniter-3.1.13/application/views/album_musiques.php b/CodeIgniter-3.1.13/application/views/album_musiques.php new file mode 100644 index 0000000..0770d25 --- /dev/null +++ b/CodeIgniter-3.1.13/application/views/album_musiques.php @@ -0,0 +1,31 @@ + + + + + + + <?php echo $album->name; ?> - Musiques + + +
+

name; ?>

+

Artiste : artistName; ?>

+

Année : year; ?>

+

Genre : genreName; ?>

+ Image d'album + + tracks)): ?> +

Musiques

+ + +

Aucune musique n'est disponible dans cet album...

+ +
+ + diff --git a/CodeIgniter-3.1.13/application/views/musiques_list.php b/CodeIgniter-3.1.13/application/views/musiques_list.php new file mode 100644 index 0000000..ab3bd62 --- /dev/null +++ b/CodeIgniter-3.1.13/application/views/musiques_list.php @@ -0,0 +1,36 @@ + + + + + + + Liste des Musiques - Onzeur + + +

Liste des musiques

+ + + + + diff --git a/CodeIgniter-3.1.13/assets/css/musiques_list.css b/CodeIgniter-3.1.13/assets/css/musiques_list.css new file mode 100644 index 0000000..a76360d --- /dev/null +++ b/CodeIgniter-3.1.13/assets/css/musiques_list.css @@ -0,0 +1,61 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #f5f5f5; +} + +h1 { + color: #6a0dad; + text-align: center; + margin-top: 20px; +} + +ul { + list-style-type: none; + padding: 0; +} + +li { + background-color: #fff; + padding: 20px; + margin-bottom: 10px; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +strong { + color: #560d61; +} + +a { + color: #560d61; +} + +a:hover { + text-decoration: underline; +} +/* Styles pour les boutons de pagination */ +.pagination { + text-align: center; + margin-top: 20px; +} + +.pagination a { + display: inline-block; + padding: 8px 16px; + margin: 0 4px; + background-color: #6a0dad; + color: #fff; + border-radius: 4px; + text-decoration: none; + transition: background-color 0.3s ease; +} + +.pagination a:hover { + background-color: #4a0772; +} + +.pagination .active { + background-color: #29043e; +} \ No newline at end of file