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

View File

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

View File

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

View File

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