ajout connexion,ajout playlist, ajout chanson dans playlist, ajout filtre et tri pour chanson et album
This commit is contained in:
@@ -6,25 +6,53 @@ class Chansons extends CI_Controller {
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->helper('html');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
}
|
||||
public function index(){
|
||||
$genre = $this->input->get('genre');
|
||||
$artist = $this->input->get('artist');
|
||||
$year = $this->input->get('year');
|
||||
$album = $this->input->get('albums');
|
||||
$sort = $this->input->get('sort');
|
||||
$order = $this->input->get('order');
|
||||
|
||||
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
|
||||
$chansons = $this->model_music->getChansons();
|
||||
$chansons = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
|
||||
$data['chansons'] = $chansons;
|
||||
}else{
|
||||
$recherche=filter_input(INPUT_GET,'recherche');
|
||||
$chansons = $this->model_music->getSearchChansons($recherche);
|
||||
$data['chansons'] = $chansons;
|
||||
}
|
||||
$this->load->view('layout/header');
|
||||
if ($chansons == false){
|
||||
$page = preg_split('/[\/]/',$_SERVER['HTTP_REFERER']);
|
||||
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
$this->load->view('error',['page'=>$page[count($page)-1]]);
|
||||
$chansons = $this->model_music->getChansons();
|
||||
$chansons = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
|
||||
$data['chansons'] = $chansons;
|
||||
}
|
||||
$this->load->view('chansons_list',['chansons'=>$chansons]);
|
||||
$data['genres'] = $this->model_music->get_all_genres_chansons();
|
||||
$data['artists'] = $this->model_music->get_all_artists_chansons();
|
||||
$data['years'] = $this->model_music->get_all_years_chansons();
|
||||
$data['albums'] = $this->model_music->get_all_albums_chansons();
|
||||
|
||||
$this->load->view('chansons_list',$data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addSongtoPlaylist($id){
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
|
||||
$this->form_validation->set_rules('playlist_id', 'playlist_id', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('addSongtoplaylist', ["playlists" => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$playlistId = $this->input->post('playlist_id');
|
||||
$this->model_music->AddSongtoPlaylist($playlistId,$id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user