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) { 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
echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>"; if ($this->session->userdata('logged')):
echo "<input type='hidden' name='album_id' value='{$AlbumsOfArtist->id}'>"; echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>";
echo "<select name='playlist'>"; echo "<input type='hidden' name='album_id' value='{$AlbumsOfArtist->id}'>";
foreach($playlists as $playlist){ echo "<select name='playlist'>";
echo "<option value='{$playlist->id}'>{$playlist->name}</option>"; foreach($playlists as $playlist){
} echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
echo "</select>"; }
echo "<button type='submit'>Ajouter toutes les chansons</button>"; echo "</select>";
echo "</form>"; echo "<button type='submit'>Ajouter toutes les chansons</button>";
echo "</form>";
endif;
echo "</article></div>"; echo "</article></div>";
} }

View File

@ -4,18 +4,22 @@
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>";
echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>";
echo "<input type='hidden' name='album_id' value='{$album->id}'>"; if ($this->session->userdata('logged')):
echo "<select name='playlist'>"; echo "<form action='" . base_url('index.php/albums/addAllSongsToPlaylist') . "' method='post'>";
foreach($playlists as $playlist){ echo "<input type='hidden' name='album_id' value='{$album->id}'>";
echo "<option value='{$playlist->id}'>{$playlist->name}</option>"; echo "<select name='playlist'>";
} foreach($playlists as $playlist){
echo "</select>"; echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
echo "<button type='submit'>Ajouter toutes les chansons</button>"; }
echo "</form>"; echo "</select>";
echo "<button type='submit'>Ajouter toutes les chansons</button>";
echo "</form>";
endif;
echo "</article></div>"; echo "</article></div>";
} }
?> ?>

View File

@ -3,14 +3,17 @@
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}");
echo "<select name='playlist'>";
foreach ($playlists as $playlist) { if ($this->session->userdata('logged')):
echo "<option value='{$playlist->id}'>{$playlist->name}</option>"; echo "<select name='playlist'>";
} foreach ($playlists as $playlist) {
echo "</select>"; echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
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 "</select>";
echo "</form>"; 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>"; echo "<br>";
} }
?> ?>

View File

@ -3,16 +3,19 @@
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} ";
echo "<select name='playlist'>";
foreach ($playlists as $playlist) { if ($this->session->userdata('logged')):
echo "<option value='{$playlist->id}'>{$playlist->name}</option>"; echo "<form action='" . base_url("index.php/playlist/addSongToPlaylist") . "' method='post'>";
} echo "<select name='playlist'>";
echo "</select>"; foreach ($playlists as $playlist) {
echo "<input type='hidden' name='song' value='{$song->name}' />"; echo "<option value='{$playlist->id}'>{$playlist->name}</option>";
echo "<button type='submit' class='add-to-playlist'>+</button>"; }
echo "</form>"; 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 "<br>";
echo "</header>"; echo "</header>";
echo "</article></div>"; echo "</article></div>";