diff --git a/ci/application/config/config.php b/ci/application/config/config.php index bfc3804..3efe38d 100644 --- a/ci/application/config/config.php +++ b/ci/application/config/config.php @@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = '/~boutaric/SAEWEB2.2/ci/'; +$config['base_url'] = '/~brigitte/SAEWEB2.2/ci/'; /* |-------------------------------------------------------------------------- diff --git a/ci/application/controllers/Albums.php b/ci/application/controllers/Albums.php index e33d9c4..9cc72c4 100644 --- a/ci/application/controllers/Albums.php +++ b/ci/application/controllers/Albums.php @@ -20,8 +20,9 @@ class Albums extends CI_Controller { if (empty($songs)) { $songs = []; } + $playlists = $this->model_music->getPlaylist(); $this->load->view('layout/header'); - $this->load->view('song_album_list', ['songs' => $songs]); + $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]); $this->load->view('layout/footer'); } } diff --git a/ci/application/controllers/Playlist.php b/ci/application/controllers/Playlist.php index 967266c..113845f 100644 --- a/ci/application/controllers/Playlist.php +++ b/ci/application/controllers/Playlist.php @@ -57,6 +57,13 @@ class Playlist extends CI_Controller { $create = $this->model_music->createPlaylist($name_playlist); redirect('playlist'); } + + public function addSongToPlaylist(){ + $songName = $this->input->post('song'); + $playlistId = $this->input->post('playlist'); + $this->model_music->addSongToPlaylist($songName, $playlistId); + redirect('playlist'); + } } diff --git a/ci/application/controllers/Song.php b/ci/application/controllers/Song.php index 82d44d3..4056ef7 100644 --- a/ci/application/controllers/Song.php +++ b/ci/application/controllers/Song.php @@ -10,8 +10,9 @@ class Song extends CI_Controller { public function view($album_id){ $songs = $this->model_music->getSongOfAlbum($album_id); + $playlists = $this->model_music->getPlaylist(); $this->load->view('layout/header'); - $this->load->view('song_album_list',['songs'=>$songs]); + $this->load->view('song_album_list', ['songs' => $songs, 'playlists' => $playlists]); $this->load->view('layout/footer'); } } diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index 0ab9208..aa3904b 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -99,4 +99,11 @@ class Model_music extends CI_Model { return $query->result(); } + public function addSongToPlaylist($songName, $playlistId){ + $query = $this->db->query( + "INSERT INTO SongPlaylist (id, name) VALUES (?, ?)", + array($playlistId, $songName) + ); + } + } diff --git a/ci/application/views/Welcome.php b/ci/application/views/Welcome.php index c6ad400..a6903e0 100644 --- a/ci/application/views/Welcome.php +++ b/ci/application/views/Welcome.php @@ -14,21 +14,21 @@