mirror of
https://grond.iut-fbleau.fr/stiti/SAE_2.02
synced 2024-12-26 17:02:18 +01:00
Ajouts
This commit is contained in:
parent
5c3141dd01
commit
06a5d409ff
@ -21,6 +21,11 @@ class Artiste extends CI_Controller {
|
||||
if($artiste){
|
||||
// Récupérer tous les albums de l'artiste
|
||||
$albums = $this->Model_music->getAlbumsByArtiste($artiste_id);
|
||||
|
||||
if ($this->session->userdata('user_id')) {
|
||||
$user_id = $this->session->userdata('user_id');
|
||||
$data['user_playlists'] = $this->Model_playlist->get_user_playlists($user_id);
|
||||
}
|
||||
|
||||
// Charger la vue avec les détails de l'artiste et ses albums
|
||||
$data['artiste'] = $artiste;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
<div class="artist-details">
|
||||
<h1>Détails de l'artiste <?php echo $artiste->name; ?></h1>
|
||||
<p><strong>Genre le plus utilisé par l'artiste :</strong> <?php echo $mostUsedGenre->genreName; ?></p>
|
||||
@ -7,6 +6,7 @@
|
||||
<?php foreach($albums as $album): ?>
|
||||
<li>
|
||||
<div class="album-details">
|
||||
|
||||
<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>
|
||||
@ -24,9 +24,34 @@
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php if ($this->session->userdata('user_id')): ?>
|
||||
<!-- Si l'utilisateur est connecté -->
|
||||
<?php if (!empty($user_playlists)): ?>
|
||||
<h3>Ajouter l'album à la playlist :</h3>
|
||||
<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 class="no-playlist">Vous n'avez pas encore de playlist. Créez-en une pour ajouter cet album !</p>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
<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>
|
@ -45,3 +45,32 @@
|
||||
font-style: italic;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.select-playlist {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
font-size: 16px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.btn-add-to-playlist {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 10px 20px;
|
||||
background-color: #6814c7;
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.btn-add-to-playlist:hover {
|
||||
background-color: #45087a;
|
||||
}
|
||||
|
||||
.no-playlist {
|
||||
color: red;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user