diff --git a/ci/application/controllers/Albums.php b/ci/application/controllers/Albums.php index 9cc72c4..ca5e760 100644 --- a/ci/application/controllers/Albums.php +++ b/ci/application/controllers/Albums.php @@ -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'); + } } ?> diff --git a/ci/application/controllers/Artistes.php b/ci/application/controllers/Artistes.php index 207e2be..50e7a22 100644 --- a/ci/application/controllers/Artistes.php +++ b/ci/application/controllers/Artistes.php @@ -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'); + } + } \ No newline at end of file diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index aa3904b..a40d57d 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -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) ); } diff --git a/ci/application/views/albums_artist_list.php b/ci/application/views/albums_artist_list.php index b2868f9..e22408b 100644 --- a/ci/application/views/albums_artist_list.php +++ b/ci/application/views/albums_artist_list.php @@ -1,16 +1,27 @@ +
+
"; + echo "
"; + echo anchor("albums/view/{$AlbumsOfArtist->id}", "{$AlbumsOfArtist->name}"); + echo "
"; + echo "
"; -
-
"; - echo "
"; - echo anchor("albums/view/{$AlbumsOfArtist->id}", "{$AlbumsOfArtist->name}"); - echo "
"; - echo "
"; + echo '' . $AlbumsOfArtist->name . ''; + echo "
$AlbumsOfArtist->year
"; - echo '' . $AlbumsOfArtist->name . ''; - echo "
$AlbumsOfArtist->year
"; - echo "
"; - } - ?> -
\ No newline at end of file + // Ajout du formulaire pour ajouter toutes les chansons de l'album à une playlist + echo "
"; + echo ""; + echo ""; + echo ""; + echo "
"; + + echo "
"; +} +?> +
diff --git a/ci/application/views/albums_list.php b/ci/application/views/albums_list.php index 20cac90..6dabe59 100644 --- a/ci/application/views/albums_list.php +++ b/ci/application/views/albums_list.php @@ -4,11 +4,21 @@ foreach($albums as $album){ echo "
"; echo "
"; - echo anchor("Song/view/{$album->id}", "{$album->name}"); + echo anchor("albums/view/{$album->id}", "{$album->name}"); echo "
"; echo '' . $album->name . ''; echo "
{$album->year} - {$album->artistName}
"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo "
"; echo "
"; } ?> +