duplication playlist

This commit is contained in:
2024-06-16 19:05:37 +02:00
parent 9597b8492f
commit 4efd73e0bf
16 changed files with 428 additions and 152 deletions

View File

@@ -6,6 +6,7 @@ class Albums extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('model_music');
$this->load->library('form_validation');
}
public function index(){
$genre = $this->input->get('genre');
@@ -54,5 +55,21 @@ class Albums extends CI_Controller {
$this->load->view('layout/footer');
}
public function addAlbumtoPlaylist($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('addAlbumtoplaylist', ["playlists" => $playlists]);
$this->load->view('layout/footer');
}else{
$playlistId = $this->input->post('playlist_id');
$page = $this->input->get('page');
$this->model_music->AddAlbumtoPlaylist($playlistId,$id);
redirect($page);
}
}
}

View File

@@ -6,6 +6,7 @@ class Artistes extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('model_music');
$this->load->library('form_validation');
}
public function index(){
$genre = $this->input->get('genre');
@@ -35,5 +36,21 @@ class Artistes extends CI_Controller {
$this->load->view('layout/footer');
}
public function addArtistestoPlaylist($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('addArtistestoplaylist', ["playlists" => $playlists]);
$this->load->view('layout/footer');
}else{
$playlistId = $this->input->post('playlist_id');
$this->model_music->AddArtistestoPlaylist($playlistId,$id);
redirect('artistes');
}
}
}

View File

@@ -15,21 +15,20 @@ class Chansons extends CI_Controller {
$album = $this->input->get('albums');
$sort = $this->input->get('sort');
$order = $this->input->get('order');
$recherche = $this->input->get('recherche', true);
if (empty($recherche)) {
$data['chansons'] = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
} else {
$data['chansons'] = $this->model_music->getSearchChansons($recherche);
}
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
$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){
if ($data['chansons'] == false){
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
$this->load->view('error',['page'=>$page[count($page)-1]]);
$chansons = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
$data['chansons'] = $chansons;
$data['chansons'] = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
}
$data['genres'] = $this->model_music->get_all_genres_chansons();
$data['artists'] = $this->model_music->get_all_artists_chansons();

View File

@@ -48,4 +48,30 @@ class Playlist extends CI_Controller {
}
}
public function duplicatePlaylist($id){
$this->form_validation->set_rules('name', 'name', 'required');
if ($this->form_validation->run() == FALSE){
$this->load->view('layout/header');
$this->load->view('create_playlist');
$this->load->view('layout/footer');
}else{
$nom = $this->input->post('name');
$description = $this->input->post('Description');
$userId = $this->session->userdata('userId');
$playlist = array(
'name'=>$nom,
'description'=>$description,
'userId'=>$userId,
);
$this->model_music->addPlayliste($playlist);
$this->model_music->DuplicatePlaylist($id, $nom);
redirect('playlist');
}
}
public function deletePlaylist($id){
$this->model_music->DeletePlaylist($id);
redirect('playlist');
}
}