ajout dans les playlist seulement si connecté

This commit is contained in:
Wilfried BRIGITTE 2024-06-10 18:14:32 +02:00
parent 04968758d1
commit a1b797a1c5
4 changed files with 49 additions and 36 deletions

View File

@ -4,21 +4,24 @@
foreach ($AlbumsOfArtists as $AlbumsOfArtist) {
echo "<div class='album'><article>";
echo "<header class='album-title'>";
echo anchor("albums/view/{$AlbumsOfArtist->id}", "{$AlbumsOfArtist->name}");
echo "<br>";
echo "</header>";
echo '<img src="data:image/jpeg;base64,' . base64_encode($AlbumsOfArtist->jpeg) . '" alt="' . $AlbumsOfArtist->name . '" />';
echo "<footer class='short-text'>$AlbumsOfArtist->year</footer>";
// Ajout du formulaire pour ajouter toutes les chansons de l'album à une playlist
echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>";
echo "<input type='hidden' name='album_id' value='{$AlbumsOfArtist->id}'>";
echo "<select name='playlist'>";
foreach($playlists as $playlist){
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<button type='submit'>Ajouter toutes les chansons</button>";
echo "</form>";
if ($this->session->userdata('logged')):
echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>";
echo "<input type='hidden' name='album_id' value='{$AlbumsOfArtist->id}'>";
echo "<select name='playlist'>";
foreach($playlists as $playlist){
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<button type='submit'>Ajouter toutes les chansons</button>";
echo "</form>";
endif;
echo "</article></div>";
}

View File

@ -4,18 +4,22 @@
foreach($albums as $album){
echo "<div class='album'><article>";
echo "<header class='album-title'>";
echo anchor("albums/view/{$album->id}", "{$album->name}");
echo "</header>";
echo '<img src="data:image/jpeg;base64,' . base64_encode($album->jpeg) . '" alt="' . $album->name . '" />';
echo "<footer class='short-text'>{$album->year} - {$album->artistName}</footer>";
echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>";
echo "<input type='hidden' name='album_id' value='{$album->id}'>";
echo "<select name='playlist'>";
foreach($playlists as $playlist){
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<button type='submit'>Ajouter toutes les chansons</button>";
echo "</form>";
if ($this->session->userdata('logged')):
echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>";
echo "<input type='hidden' name='album_id' value='{$album->id}'>";
echo "<select name='playlist'>";
foreach($playlists as $playlist){
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<button type='submit'>Ajouter toutes les chansons</button>";
echo "</form>";
endif;
echo "</article></div>";
}
?>

View File

@ -3,14 +3,17 @@
foreach($artistes as $artiste){
echo "<form action='" . base_url("index.php/artistes/addSongOfArtistToPlaylist") . "' method='post'>";
echo anchor("artistes/view/{$artiste->id}", "{$artiste->name}");
echo "<select name='playlist'>";
foreach ($playlists as $playlist) {
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<input type='hidden' name='artistId' value='{$artiste->id}' />"; // Utilisez l'identifiant de l'artiste ici
echo "<button type='submit' class='add-to-playlist'>+</button>";
echo "</form>";
if ($this->session->userdata('logged')):
echo "<select name='playlist'>";
foreach ($playlists as $playlist) {
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<input type='hidden' name='artistId' value='{$artiste->id}' />"; // Utilisez l'identifiant de l'artiste ici
echo "<button type='submit' class='add-to-playlist'>+</button>";
echo "</form>";
endif;
echo "<br>";
}
?>

View File

@ -2,17 +2,20 @@
<?php
foreach($songs as $song){
echo "<div><article>";
echo "<header class='short-text'>";
echo "<form action='" . base_url("index.php/playlist/addSongToPlaylist") . "' method='post'>";
echo "<header class='short-text'>";
echo "{$song->name} ";
echo "<select name='playlist'>";
foreach ($playlists as $playlist) {
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<input type='hidden' name='song' value='{$song->name}' />";
echo "<button type='submit' class='add-to-playlist'>+</button>";
echo "</form>";
if ($this->session->userdata('logged')):
echo "<form action='" . base_url("index.php/playlist/addSongToPlaylist") . "' method='post'>";
echo "<select name='playlist'>";
foreach ($playlists as $playlist) {
echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
}
echo "</select>";
echo "<input type='hidden' name='song' value='{$song->name}' />";
echo "<button type='submit' class='add-to-playlist'>+</button>";
echo "</form>";
endif;
echo "<br>";
echo "</header>";
echo "</article></div>";