ajout song d un album a une playlist + correction bug supprimer song playlist
This commit is contained in:
parent
ba57a3adc3
commit
831f05ca6b
@ -10,8 +10,9 @@ class Albums extends CI_Controller {
|
||||
|
||||
public function index(){
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list', ['albums' => $albums]);
|
||||
$this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
@ -25,5 +26,15 @@ class Albums extends CI_Controller {
|
||||
$this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addAllSongsToPlaylist(){
|
||||
$album_id = $this->input->post('album_id');
|
||||
$playlistId = $this->input->post('playlist');
|
||||
$songs = $this->model_music->getSongOfAlbum($album_id);
|
||||
foreach ($songs as $song) {
|
||||
$this->model_music->addSongToPlaylist($song->name, $playlistId);
|
||||
}
|
||||
redirect('playlist');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -16,9 +16,20 @@ class artistes extends CI_Controller {
|
||||
|
||||
public function view($AlbumsOfArtistId){
|
||||
$AlbumsOfArtists = $this->model_music->getAlbumsOfArtist($AlbumsOfArtistId);
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_artist_list',['AlbumsOfArtists'=>$AlbumsOfArtists]);
|
||||
$this->load->view('albums_artist_list', ['AlbumsOfArtists' => $AlbumsOfArtists, 'playlists' => $playlists, 'artist_id' => $AlbumsOfArtistId]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addAllSongsToPlaylist(){
|
||||
$album_id = $this->input->post('album_id');
|
||||
$playlistId = $this->input->post('playlist');
|
||||
$songs = $this->model_music->getSongOfAlbum($album_id);
|
||||
foreach ($songs as $song) {
|
||||
$this->model_music->addSongToPlaylist($song->name, $playlistId);
|
||||
}
|
||||
redirect('playlist');
|
||||
}
|
||||
|
||||
}
|
@ -50,8 +50,9 @@ class Model_music extends CI_Model {
|
||||
}
|
||||
|
||||
public function delete_Song($playlist_id,$Song_name){
|
||||
$Song_name = urldecode($Song_name);
|
||||
$this->db->query(
|
||||
"DELETE FROM SongPlaylist Where id = ? AND name LIKE ?",
|
||||
"DELETE FROM SongPlaylist Where id = ? AND name=?",
|
||||
array($playlist_id, $Song_name)
|
||||
);
|
||||
}
|
||||
|
@ -1,16 +1,27 @@
|
||||
<section class="container">
|
||||
<?php
|
||||
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>";
|
||||
|
||||
<section class="container">
|
||||
<?php
|
||||
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>";
|
||||
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($AlbumsOfArtist->jpeg) . '" alt="' . $AlbumsOfArtist->name . '" />';
|
||||
echo "<footer class='short-text'>$AlbumsOfArtist->year</footer>";
|
||||
echo "</article></div>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
// 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>";
|
||||
|
||||
echo "</article></div>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
|
@ -4,11 +4,21 @@
|
||||
foreach($albums as $album){
|
||||
echo "<div class='album'><article>";
|
||||
echo "<header class='album-title'>";
|
||||
echo anchor("Song/view/{$album->id}", "{$album->name}");
|
||||
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>";
|
||||
echo "</article></div>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user