This commit is contained in:
stiti 2024-06-06 12:07:45 +02:00
parent fc16b575ed
commit 9693d4be20
4 changed files with 50 additions and 27 deletions

View File

@ -48,16 +48,19 @@ class Albums extends CI_Controller {
}
public function view($id){
$album = $this->model_music->get_album_by_id($id);
[$album,$tracks] = $this->model_music->get_album_by_id($id);
$data['album'] = $album;
$data['title'] = $album->name." - Details";
$data['css']='assets/css/album_view';
$data['tracks'] = $tracks;
if ($this->session->userdata('user_id')) {
$user_id = $this->session->userdata('user_id');
$data['user_playlists'] = $this->Model_playlist->get_user_playlists($user_id);
}
$this->load->view('layout/header_dark', $data);
$this->load->view('album_view');
$this->load->view('layout/footer_dark');
}
}
?>

View File

@ -95,10 +95,10 @@ class Model_music extends CI_Model {
WHERE track.albumid = ?
ORDER BY track.diskNumber, track.number", array($id)
);
$album->tracks = $query->result();
$tracks = $query->result();
}
return $album;
return [$album,$tracks];
}
public function getMusiques($limit, $offset, $order_by = 'name', $order_direction = 'ASC', $genre_id = null, $artist_id = null) {

View File

@ -1,22 +1,44 @@
<div class="album-details">
<div class="album-details">
<h1><?php echo $album->name; ?></h1>
<p><strong>Artiste :</strong> <a href="<?php echo site_url('artiste/index/' . $album->artistId); ?>"><?php echo $album->artistName; ?></a></p>
<p><strong>Année :</strong> <?php echo $album->year; ?></p>
<p><strong>Genre :</strong> <a href="<?php echo base_url('index.php/musiques/index?genre_id='.$album->genreId); ?>"><?php echo $album->genreName; ?></a></p>
<img src="data:image/jpeg;base64,<?php echo base64_encode($album->jpeg); ?>" alt="Image d'album">
<?php if (!empty($album->tracks)): ?>
<?php if ($this->session->userdata('user_id')): ?>
<!-- Si l'utilisateur est connecté -->
<?php if (!empty($user_playlists)): ?>
<h2>Ajouter à la playlist :</h2>
<select id="playlist_<?php echo $album->id; ?>" class="select-playlist">
<?php foreach ($user_playlists as $playlist) : ?>
<option value="<?php echo $playlist->id; ?>"><?php echo $playlist->name; ?></option>
<?php endforeach; ?>
</select>
<button onclick="addToPlaylist(<?php echo $album->id; ?>)" class="btn-add-to-playlist">Ajouter à la playlist</button>
<?php else: ?>
<p>Vous n'avez pas encore de playlist. Créez-en une pour ajouter cet album !</p>
<?php endif; ?>
<?php endif; ?>
<?php if (!empty($tracks)): ?>
<h2>Musiques</h2>
<ul>
<?php foreach ($album->tracks as $track): ?>
<?php foreach ($tracks as $track): ?>
<li>
<strong><?php echo $track->diskNumber . '.' . $track->number; ?>:</strong> <?php echo $track->songName; ?> (<?php echo gmdate("i:s", $track->duration); ?>)
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>Aucune musique n'est disponible dans cette album...</p>
<p>Aucune musique n'est disponible dans cet album...</p>
<?php endif; ?>
</div>
</body>
</div>
<script>
function addToPlaylist(albumId) {
// Récupérer l'ID de la playlist sélectionnée
var playlistId = document.getElementById('playlist_' + albumId).value;
// Redirection vers la méthode du contrôleur Playlists pour ajouter la chanson à la playlist spécifiée
window.location.href = "<?php echo base_url('index.php/playlists/add_album_to_playlist/'); ?>" + albumId + "/" + playlistId;
}
</script>

View File

@ -1,13 +1,13 @@
<div class="artist-details">
<h1>Détails de l'artiste <?php echo $artiste->name; ?></h1>
<p><strong>Genre le plus utilisé :</strong> <?php echo $mostUsedGenre->genreName; ?></p>
<p><strong>Genre le plus utilisé par l'artiste :</strong> <?php echo $mostUsedGenre->genreName; ?></p>
<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>
<h2><a href="<?php echo site_url('albums/view/' . $album->id); ?>"><?php echo $album->name; ?></a></h2>
<p><strong>Année :</strong> <?php echo $album->year; ?></p>
<p><strong>Genre :</strong> <?php echo $album->genreName; ?></p>
<?php if (!empty($album->jpeg)): ?>
@ -15,7 +15,6 @@
<?php else: ?>
<span class="no-cover">Aucune couverture disponible</span>
<?php endif; ?>
<!-- Liste des musiques de l'album -->
<ul class="songs-list">
<?php foreach($album->tracks as $track): ?>
<li>
@ -24,7 +23,6 @@
<span><strong><?php echo gmdate("i:s", $track->duration); ?></strong></span>
</li>
<?php endforeach; ?>
</ul>
</div>
</li>