load->model('model_music'); $this->load->library('session'); } public function index(){ $genre = $this->model_music->getGenre(); $this->load->view('layout/header'); $this->load->view('GenreFilter',['genre'=>$genre]); $selectedGenre = '0'; $search = ''; if ($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST['Genre'])){ $selectedGenre = $_POST['Genre']; } } if ($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST['recherche'])){ $search = $_POST['recherche']; } } $mail = $this->session->userdata('mail'); $playlists = $this->model_music->getPlaylist($mail); $albums = $this->model_music->searchAlbums($search, $selectedGenre); $this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]); $this->load->view('layout/footer'); } public function view($album_id){ $songs = $this->model_music->getSongOfAlbum($album_id); if (empty($songs)) { $songs = []; } $mail = $this->session->userdata('mail'); $playlists = $this->model_music->getPlaylist($mail); $this->load->view('layout/header'); $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'); } } ?>