load->model('model_music'); } public function index(){ $selectedGenre = '0'; // Valeur par défaut pour le genre si aucun n'est sélectionné if ($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST['Genre'])){ $selectedGenre = $_POST['Genre']; } } $albums = $this->model_music->getAlbums($selectedGenre); $playlists = $this->model_music->getPlaylist(); $this->load->view('layout/header'); $this->load->view('albums_list', ['albums' => $albums, 'playlists' => $playlists]); $this->load->view('layout/footer'); $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']; } } } public function view($album_id){ $songs = $this->model_music->getSongOfAlbum($album_id); if (empty($songs)) { $songs = []; } $playlists = $this->model_music->getPlaylist(); $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'); } } ?>