2024-05-30 16:14:38 +02:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Playlist extends CI_Controller {
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->model('model_music');
|
2024-06-12 18:17:31 +02:00
|
|
|
$this->load->library('session');
|
2024-05-30 16:14:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index(){
|
2024-06-12 18:17:31 +02:00
|
|
|
$mail = $this->session->userdata('mail');
|
|
|
|
$playlists = $this->model_music->getPlaylist($mail);
|
2024-06-05 14:57:43 +02:00
|
|
|
$this->load->view('layout/header');
|
2024-05-30 16:14:38 +02:00
|
|
|
$this->load->view('playlist_list', ['playlists' => $playlists]);
|
2024-06-05 13:51:23 +02:00
|
|
|
$this->load->view('layout/footer');
|
2024-05-30 16:14:38 +02:00
|
|
|
}
|
2024-06-03 15:02:52 +02:00
|
|
|
|
|
|
|
public function view(){
|
|
|
|
$playlists = $this->model_music->deletePlaylist();
|
2024-06-05 14:57:43 +02:00
|
|
|
$this->load->view('layout/header');
|
2024-06-03 15:02:52 +02:00
|
|
|
$this->load->view('playlist_list', ['playlists' => $playlists]);
|
2024-06-05 13:51:23 +02:00
|
|
|
$this->load->view('layout/footer');
|
2024-06-03 15:02:52 +02:00
|
|
|
}
|
|
|
|
|
2024-06-03 17:52:42 +02:00
|
|
|
public function SongPlaylist($playlist_id){
|
2024-06-03 15:02:52 +02:00
|
|
|
$songPlaylists = $this->model_music->getSongOfPlaylist($playlist_id);
|
2024-06-11 16:12:33 +02:00
|
|
|
$songs = $this->model_music->getSongOfAlbum($playlist_id);
|
2024-06-12 18:17:31 +02:00
|
|
|
$mail = $this->session->userdata('mail');
|
|
|
|
$playlists = $this->model_music->getPlaylist($mail); // Récupère toutes les playlists
|
2024-06-05 17:38:12 +02:00
|
|
|
$id_playlist = null; // Initialise $id_playlist à null
|
|
|
|
foreach ($playlists as $playlist_item) {
|
|
|
|
if ($playlist_item->id == $playlist_id) {
|
|
|
|
$id_playlist = $playlist_item;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2024-06-11 16:12:33 +02:00
|
|
|
$this->load->view('song_playlist', ['songPlaylists' => $songPlaylists, 'id_playlist' => $id_playlist, 'songs'=>$songs]);
|
2024-06-03 15:02:52 +02:00
|
|
|
}
|
2024-06-03 16:10:43 +02:00
|
|
|
|
2024-06-03 17:52:42 +02:00
|
|
|
public function delete($playlist_id) {
|
2024-06-12 18:17:31 +02:00
|
|
|
$mail = $this->session->userdata('mail');
|
|
|
|
$delete = $this->model_music->deletePlaylist($playlist_id, $mail);
|
2024-06-03 17:52:42 +02:00
|
|
|
redirect('playlist');
|
2024-06-03 16:10:43 +02:00
|
|
|
}
|
2024-06-03 18:44:18 +02:00
|
|
|
|
2024-06-05 17:38:12 +02:00
|
|
|
public function deleteSong($id_playlist, $Song_name){
|
|
|
|
$deleteSong = $this->model_music->delete_Song($id_playlist, $Song_name);
|
|
|
|
redirect("playlist/SongPlaylist/$id_playlist");
|
|
|
|
}
|
|
|
|
|
2024-06-03 18:44:18 +02:00
|
|
|
public function MenuCreate() {
|
2024-06-05 14:57:43 +02:00
|
|
|
$this->load->view('layout/header');
|
2024-06-03 18:44:18 +02:00
|
|
|
$this->load->view('create_playlist');
|
2024-06-05 13:51:23 +02:00
|
|
|
$this->load->view('layout/footer');
|
|
|
|
|
2024-06-03 18:44:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function createPlaylistController() {
|
2024-06-12 18:17:31 +02:00
|
|
|
$mail = $this->session->userdata('mail');
|
2024-06-03 18:44:18 +02:00
|
|
|
$name_playlist = $this->input->post('name_playlist');
|
2024-06-12 18:17:31 +02:00
|
|
|
$create = $this->model_music->createPlaylist($name_playlist, $mail);
|
2024-06-03 18:44:18 +02:00
|
|
|
redirect('playlist');
|
|
|
|
}
|
2024-06-05 19:36:03 +02:00
|
|
|
|
|
|
|
public function addSongToPlaylist(){
|
|
|
|
$songName = $this->input->post('song');
|
|
|
|
$playlistId = $this->input->post('playlist');
|
|
|
|
$this->model_music->addSongToPlaylist($songName, $playlistId);
|
|
|
|
redirect('playlist');
|
|
|
|
}
|
2024-06-06 10:59:12 +02:00
|
|
|
|
|
|
|
public function duplicate($playlist_id){
|
2024-06-12 18:17:31 +02:00
|
|
|
$mail = $this->session->userdata('mail');
|
2024-06-06 10:59:12 +02:00
|
|
|
// Charger le modèle si ce n'est pas déjà fait
|
|
|
|
$this->load->model('model_music');
|
|
|
|
|
|
|
|
// Dupliquer la playlist avec l'ID spécifié
|
2024-06-12 18:17:31 +02:00
|
|
|
$this->model_music->duplicatePlaylist($playlist_id, $mail);
|
2024-06-06 10:59:12 +02:00
|
|
|
|
|
|
|
// Rediriger l'utilisateur vers la page des playlists
|
|
|
|
redirect('playlist');
|
|
|
|
}
|
2024-06-03 18:44:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|