mirror of
https://grond.iut-fbleau.fr/stiti/SAE_2.02
synced 2024-12-27 17:22:17 +01:00
Commit de Louay : Correction de bug
This commit is contained in:
parent
b2b5e45015
commit
4e02203e84
@ -54,5 +54,6 @@ $route['404_override'] = '';
|
||||
$route['translate_uri_dashes'] = FALSE;
|
||||
$route['albums'] = 'albums/index';
|
||||
$route['musiques'] = 'Musiques/index';
|
||||
$route['artiste/(:num)'] = 'artiste/index/$1';
|
||||
|
||||
|
||||
|
@ -5,28 +5,40 @@ class Artiste extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('Model_music');
|
||||
$this->load->model('Model_artist');
|
||||
$this->load->model('Model_music'); // Chargez également le modèle Model_music si vous en avez besoin
|
||||
$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);
|
||||
$artiste = $this->Model_artist->getArtisteById($artiste_id);
|
||||
|
||||
if($artiste){
|
||||
// Récupérer tous les albums de l'artiste
|
||||
$albums = $this->Model_music->getAlbumsByArtiste($artiste_id);
|
||||
$albums = $this->Model_music->getAlbumsByArtiste($artiste_id); // Utilisez le modèle Model_music ici
|
||||
|
||||
// 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('artiste_details', $data);
|
||||
$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
|
||||
show_404();
|
||||
}
|
||||
}
|
||||
|
||||
public function list_artists(){
|
||||
// Récupérer la liste des artistes
|
||||
$artists = $this->Model_artist->getArtists();
|
||||
|
||||
// Charger la vue avec la liste des artistes
|
||||
$data['artists'] = $artists;
|
||||
$this->load->view('layout/header_not_logged_dark');
|
||||
$this->load->view('artists_list', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -11,7 +11,7 @@ class Musiques extends CI_Controller {
|
||||
}
|
||||
|
||||
public function index($page = 1){
|
||||
$limit = 100; // Nombre de musiques par page
|
||||
$limit = 30; // Nombre de musiques par page
|
||||
$offset = ($page - 1) * $limit;
|
||||
|
||||
$musiques = $this->Model_music->getMusiques($limit, $offset);
|
||||
@ -29,5 +29,6 @@ class Musiques extends CI_Controller {
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
15
CodeIgniter-3.1.13/application/models/Model_artist.php
Normal file
15
CodeIgniter-3.1.13/application/models/Model_artist.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Model_artist extends CI_Model {
|
||||
public function __construct(){
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function getArtisteById($artiste_id){
|
||||
$query = $this->db->query("SELECT * FROM artist WHERE id = ?", array($artiste_id));
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -53,7 +53,7 @@ class Model_music extends CI_Model {
|
||||
|
||||
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
|
||||
"SELECT song.id, song.name, artist.id as artist_id, 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
|
||||
@ -64,11 +64,26 @@ class Model_music extends CI_Model {
|
||||
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;
|
||||
}
|
||||
|
||||
public function getAlbumsByArtiste($artiste_id){
|
||||
$query = $this->db->query("
|
||||
SELECT album.id, album.name, album.year, artist.name as artistName, genre.name as genreName, cover.jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON album.genreid = genre.id
|
||||
JOIN cover ON album.coverid = cover.id
|
||||
WHERE artist.id = ?
|
||||
", array($artiste_id));
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -10,6 +10,7 @@
|
||||
<body>
|
||||
<div class="album-details">
|
||||
<h1><?php echo $album->name; ?></h1>
|
||||
|
||||
<p><strong>Artiste :</strong> <?php echo $album->artistName; ?></p>
|
||||
<p><strong>Année :</strong> <?php echo $album->year; ?></p>
|
||||
<p><strong>Genre :</strong> <?php echo $album->genreName; ?></p>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/style.css'); ?>">
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/style'); ?>">
|
||||
<link rel="icon" type="image/x-icon" href="<?php echo base_url('assets/img/Logo_ONZEUR.png'); ?>">
|
||||
<title>Albums - Onzeur</title>
|
||||
</head>
|
||||
|
32
CodeIgniter-3.1.13/application/views/artiste_details.php
Normal file
32
CodeIgniter-3.1.13/application/views/artiste_details.php
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/artiste_details'); ?>">
|
||||
<title>Détails de l'artiste <?php echo $artiste->name; ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="artist-details">
|
||||
<h1>Détails de l'artiste <?php echo $artiste->name; ?></h1>
|
||||
|
||||
<h2>Albums de <?php echo $artiste->name; ?></h2>
|
||||
<ul class="albums-list">
|
||||
<?php foreach($albums as $album): ?>
|
||||
<li>
|
||||
<div class="album-details">
|
||||
<h3><?php echo $album->name; ?></h3>
|
||||
<p><strong>Année :</strong> <?php echo $album->year; ?></p>
|
||||
<p><strong>Genre :</strong> <?php echo $album->genreName; ?></p>
|
||||
<?php if (!empty($album->jpeg)): ?>
|
||||
<img src="data:image/jpeg;base64,<?php echo base64_encode($album->jpeg); ?>" alt="Couverture de l'album">
|
||||
<?php else: ?>
|
||||
<span class="no-cover">Aucune couverture disponible</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -17,7 +17,7 @@
|
||||
<nav class="nav">
|
||||
<div class="nav-buttons">
|
||||
<a href="<?php echo site_url('albums'); ?>" class="btn-albums">Albums</a>
|
||||
<a href="<?php echo site_url('artistes'); ?>" class="btn-artistes">Artistes</a>
|
||||
<a href="<?php echo site_url('artiste'); ?>" class="btn-artistes">Artistes</a>
|
||||
<a href="<?php echo site_url('musiques'); ?>" class="btn-musiques">Musiques</a>
|
||||
<a href="#CONNEXIONBIENTOT" class="btn-connexion">Connexion</a>
|
||||
<a href="#INSCRIPTIONBIENTOT" class="btn-inscription">Inscription</a>
|
||||
|
@ -12,7 +12,7 @@
|
||||
<?php foreach($musiques as $musique): ?>
|
||||
<li>
|
||||
<strong>Titre:</strong> <?php echo $musique->name; ?> <br>
|
||||
<strong>Artiste:</strong> <?php echo $musique->artistName; ?> <br>
|
||||
<strong>Artiste :</strong> <a href="<?php echo site_url('artiste/'.$musique->artist_id); ?>"><?php echo $musique->artistName; ?></a> <br>
|
||||
<strong>Album:</strong> <a href="<?php echo base_url('index.php/albums/view/'.$musique->album_id); ?>"><?php echo $musique->album_name; ?></a> <br>
|
||||
<img src="data:image/jpeg;base64,<?php echo base64_encode($musique->cover); ?>" alt="Couverture d'album"> <br>
|
||||
</li>
|
||||
|
47
CodeIgniter-3.1.13/assets/css/artiste_details.css
Normal file
47
CodeIgniter-3.1.13/assets/css/artiste_details.css
Normal file
@ -0,0 +1,47 @@
|
||||
/* Styles pour la mise en page générale */
|
||||
.artist-details {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* Styles pour le titre principal */
|
||||
.artist-details h1 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Styles pour la liste des albums */
|
||||
.albums-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.albums-list li {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.album-details {
|
||||
border: 1px solid #ccc;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.album-details h3 {
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.album-details p {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.album-details img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.album-details .no-cover {
|
||||
font-style: italic;
|
||||
color: #888;
|
||||
}
|
Loading…
Reference in New Issue
Block a user