push
This commit is contained in:
@@ -3,13 +3,13 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Artistes extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->library('session');
|
||||
}
|
||||
|
||||
public function index(){
|
||||
public function index() {
|
||||
$genre = $this->input->get('genre');
|
||||
$order = $this->input->get('order');
|
||||
$query = $this->input->get('query');
|
||||
@@ -31,20 +31,19 @@ class Artistes extends CI_Controller {
|
||||
}
|
||||
|
||||
public function view($artistId) {
|
||||
$artistData = $this->model_music->getArtistDetails($artistId);
|
||||
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$data = array(
|
||||
'artist' => $artistData['artist'],
|
||||
'albums' => $artistData['albums'],
|
||||
'is_logged_in' => $is_logged_in
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('artist_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
$artist = $this->model_music->getArtistDetails($artistId);
|
||||
$albums = $this->model_music->getAlbumsByArtist($artistId);
|
||||
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$data = array(
|
||||
'artist' => $artist,
|
||||
'albums' => $albums,
|
||||
'is_logged_in' => $is_logged_in
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('artist_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -17,13 +17,13 @@ class Music extends CI_Controller {
|
||||
|
||||
$musics = $this->model_music->getMusics($genre, $order, $artist, $query);
|
||||
$genres = $this->model_music->researchtype();
|
||||
$artists = $this->model_music->nameArtist();
|
||||
$artists = $this->model_music->nameArtist(); // S'assurer que cette méthode récupère bien les artistes
|
||||
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$data = array(
|
||||
'musics' => $musics,
|
||||
'genres' => $genres,
|
||||
'artists' => $artists,
|
||||
'artistes' => $artists, // Passer les artistes à la vue
|
||||
'is_logged_in' => $is_logged_in
|
||||
);
|
||||
|
||||
@@ -33,17 +33,23 @@ class Music extends CI_Controller {
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function view($trackId) {
|
||||
$songData = $this->model_music->getSongDetails($trackId);
|
||||
|
||||
public function view($songId) {
|
||||
$songData = $this->model_music->getSongDetails($songId);
|
||||
|
||||
if (!$songData) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$data = array(
|
||||
'song' => $songData,
|
||||
'is_logged_in' => $is_logged_in
|
||||
);
|
||||
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('song_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
151
application/controllers/Playlist.php
Normal file
151
application/controllers/Playlist.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Playlist extends CI_Controller {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('Model_playlist');
|
||||
$this->load->model('Model_music'); // Ajouté pour accéder aux musiques
|
||||
$this->load->library('session');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'playlists' => $this->Model_playlist->getPlaylistsByUser($user_email)
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('playlists_list', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function add() {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$name = $this->input->post('name');
|
||||
$type = $this->input->post('type');
|
||||
|
||||
if ($type == 'random') {
|
||||
$numSongs = $this->input->post('numSongs');
|
||||
$artist = $this->input->post('artist');
|
||||
$genre = $this->input->post('genre');
|
||||
$this->Model_playlist->createRandomPlaylist($user_email, $name, $numSongs, $artist, $genre);
|
||||
} else {
|
||||
$this->Model_playlist->addPlaylist($user_email, $name);
|
||||
}
|
||||
|
||||
redirect('playlist');
|
||||
}
|
||||
|
||||
public function selectPlaylist() {
|
||||
$itemId = $this->input->post('itemId');
|
||||
$itemType = $this->input->post('itemType');
|
||||
$playlists = $this->Model_playlist->getPlaylistsByUser($this->session->userdata('email'));
|
||||
|
||||
$data = array(
|
||||
'itemId' => $itemId,
|
||||
'itemType' => $itemType,
|
||||
'playlists' => $playlists
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('select_playlist', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addItems() {
|
||||
$playlistId = $this->input->post('playlistId');
|
||||
$itemId = $this->input->post('itemId');
|
||||
$itemType = $this->input->post('itemType');
|
||||
|
||||
if ($itemType == 'album') {
|
||||
$songs = $this->Model_music->getSongsByAlbum($itemId);
|
||||
foreach ($songs as $song) {
|
||||
$this->Model_playlist->addItem($playlistId, $song->id, 'song');
|
||||
}
|
||||
} else if ($itemType == 'artist') {
|
||||
$albums = $this->Model_music->getAlbumsByArtist($itemId);
|
||||
foreach ($albums as $album) {
|
||||
$songs = $this->Model_music->getSongsByAlbum($album->albumId);
|
||||
foreach ($songs as $song) {
|
||||
$this->Model_playlist->addItem($playlistId, $song->id, 'song');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->Model_playlist->addItem($playlistId, $itemId, 'song');
|
||||
}
|
||||
|
||||
redirect('playlist/view/' . $playlistId);
|
||||
}
|
||||
|
||||
public function view($playlistId) {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$items = $this->Model_playlist->getPlaylistItems($playlistId);
|
||||
$data = array(
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'items' => $items
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('playlist_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function deleteItem($playlistId, $itemId) {
|
||||
$this->Model_playlist->deleteItem($playlistId, $itemId);
|
||||
redirect('playlist/view/' . $playlistId);
|
||||
}
|
||||
|
||||
public function delete($playlist_id) {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$this->Model_playlist->deletePlaylist($playlist_id);
|
||||
redirect('playlist');
|
||||
}
|
||||
|
||||
public function duplicate($playlist_id) {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$this->Model_playlist->duplicatePlaylist($playlist_id, $user_email);
|
||||
redirect('playlist');
|
||||
}
|
||||
|
||||
public function rename() {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$playlistId = $this->input->post('playlistId');
|
||||
$newName = $this->input->post('newName');
|
||||
|
||||
$this->Model_playlist->renamePlaylist($playlistId, $newName);
|
||||
redirect('playlist');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user