vaujdui
This commit is contained in:
		@@ -5,27 +5,56 @@ class Albums extends CI_Controller {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function __construct(){
 | 
					    public function __construct(){
 | 
				
			||||||
        parent::__construct();
 | 
					        parent::__construct();
 | 
				
			||||||
        $this->load->model('model_music');
 | 
					        $this->load->model('Model_album');
 | 
				
			||||||
 | 
					        $this->load->library('pagination');
 | 
				
			||||||
        $this->load->library('session');
 | 
					        $this->load->library('session');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function index(){
 | 
					    public function index() {
 | 
				
			||||||
        $order = $this->input->get('order');
 | 
					 | 
				
			||||||
        $genre = $this->input->get('genre');
 | 
					        $genre = $this->input->get('genre');
 | 
				
			||||||
 | 
					        $order = $this->input->get('order');
 | 
				
			||||||
        $artist = $this->input->get('artist');
 | 
					        $artist = $this->input->get('artist');
 | 
				
			||||||
        $query = $this->input->get('query');
 | 
					        $query = $this->input->get('query');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $albums = $this->model_music->getAlbums($genre, $order, $artist, $query);
 | 
					        // Configuration de la pagination
 | 
				
			||||||
 | 
					        $config = array();
 | 
				
			||||||
 | 
					        $config['base_url'] = site_url('albums/index');
 | 
				
			||||||
 | 
					        $config['total_rows'] = $this->Model_album->countAllAlbums($genre, $artist, $query);
 | 
				
			||||||
 | 
					        $config['per_page'] = 16;
 | 
				
			||||||
 | 
					        $config['page_query_string'] = TRUE;
 | 
				
			||||||
 | 
					        $config['reuse_query_string'] = TRUE;
 | 
				
			||||||
 | 
					        $config['query_string_segment'] = 'page';
 | 
				
			||||||
 | 
					        $config['full_tag_open'] = '<nav aria-label="Page navigation"><ul class="pagination">';
 | 
				
			||||||
 | 
					        $config['full_tag_close'] = '</ul></nav>';
 | 
				
			||||||
 | 
					        $config['first_link'] = 'First';
 | 
				
			||||||
 | 
					        $config['last_link'] = 'Last';
 | 
				
			||||||
 | 
					        $config['first_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['first_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['prev_link'] = '«';
 | 
				
			||||||
 | 
					        $config['prev_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['prev_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['next_link'] = '»';
 | 
				
			||||||
 | 
					        $config['next_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['next_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['last_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['last_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['cur_tag_open'] = '<li class="page-item active"><a href="#" class="page-link">';
 | 
				
			||||||
 | 
					        $config['cur_tag_close'] = '</a></li>';
 | 
				
			||||||
 | 
					        $config['num_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['num_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['attributes'] = array('class' => 'page-link');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $genres = $this->model_music->researchtype();
 | 
					        $this->pagination->initialize($config);
 | 
				
			||||||
        $artists = $this->model_music->nameArtist();
 | 
					
 | 
				
			||||||
 | 
					        $page = $this->input->get('page');
 | 
				
			||||||
 | 
					        $page = ($page) ? $page : 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					 | 
				
			||||||
        $data = array(
 | 
					        $data = array(
 | 
				
			||||||
            'albums' => $albums,
 | 
					            'albums' => $this->Model_album->getAlbums($genre, $order, $artist, $query, $config['per_page'], $page),
 | 
				
			||||||
            'is_logged_in' => $is_logged_in,
 | 
					            'genres' => $this->Model_album->getGenres(),
 | 
				
			||||||
            'genres' => $genres,
 | 
					            'artists' => $this->Model_album->getArtists(),
 | 
				
			||||||
            'artistes' => $artists
 | 
					            'is_logged_in' => $this->session->userdata('logged_in'),
 | 
				
			||||||
 | 
					            'pagination' => $this->pagination->create_links()
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
@@ -35,17 +64,21 @@ class Albums extends CI_Controller {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function view($albumId) {
 | 
					    public function view($albumId) {
 | 
				
			||||||
        $albumData = $this->model_music->getAlbumDetails($albumId);
 | 
					        $albumDetails = $this->Model_album->getAlbumDetails($albumId);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!$albumDetails) {
 | 
				
			||||||
 | 
					            show_404();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					 | 
				
			||||||
        $data = array(
 | 
					        $data = array(
 | 
				
			||||||
            'album' => $albumData['album'],
 | 
					            'album' => $albumDetails['album'],
 | 
				
			||||||
            'songs' => $albumData['songs'],
 | 
					            'songs' => $albumDetails['songs'],
 | 
				
			||||||
            'is_logged_in' => $is_logged_in
 | 
					            'is_logged_in' => $this->session->userdata('logged_in')
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
        $this->load->view('album_details', $data);
 | 
					        $this->load->view('album_details', $data);
 | 
				
			||||||
        $this->load->view('layout/footer');
 | 
					        $this->load->view('layout/footer');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,11 +2,11 @@
 | 
				
			|||||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
					defined('BASEPATH') OR exit('No direct script access allowed');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Artistes extends CI_Controller {
 | 
					class Artistes extends CI_Controller {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function __construct() {
 | 
					    public function __construct() {
 | 
				
			||||||
        parent::__construct();
 | 
					        parent::__construct();
 | 
				
			||||||
        $this->load->model('model_music');
 | 
					        $this->load->model('Model_artist');
 | 
				
			||||||
        $this->load->library('session');
 | 
					        $this->load->model('Model_music');
 | 
				
			||||||
 | 
					        $this->load->library('pagination');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function index() {
 | 
					    public function index() {
 | 
				
			||||||
@@ -14,14 +14,29 @@ class Artistes extends CI_Controller {
 | 
				
			|||||||
        $order = $this->input->get('order');
 | 
					        $order = $this->input->get('order');
 | 
				
			||||||
        $query = $this->input->get('query');
 | 
					        $query = $this->input->get('query');
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        $artists = $this->model_music->getArtists($genre, $order, $query);
 | 
					        // Configuration de la pagination
 | 
				
			||||||
        $genres = $this->model_music->researchtype();
 | 
					        $config = array();
 | 
				
			||||||
 | 
					        $config['base_url'] = site_url('artistes');
 | 
				
			||||||
 | 
					        $config['total_rows'] = $this->Model_artist->get_total_artists($genre, $query);
 | 
				
			||||||
 | 
					        $config['per_page'] = 16; // Nombre d'artistes par page
 | 
				
			||||||
 | 
					        $config['uri_segment'] = 2; // Segment de l'URI contenant le numéro de la page
 | 
				
			||||||
 | 
					        $config['reuse_query_string'] = TRUE;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        $this->pagination->initialize($config);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        $page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        // Correction pour éviter l'erreur str_replace()
 | 
				
			||||||
 | 
					        $pagination_links = $this->pagination->create_links();
 | 
				
			||||||
 | 
					        if ($pagination_links === null) {
 | 
				
			||||||
 | 
					            $pagination_links = '';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					 | 
				
			||||||
        $data = array(
 | 
					        $data = array(
 | 
				
			||||||
            'artists' => $artists,
 | 
					            'artists' => $this->Model_artist->getArtists($genre, $order, $query, $config['per_page'], $page),
 | 
				
			||||||
            'genres' => $genres,
 | 
					            'genres' => $this->Model_music->researchtype(),
 | 
				
			||||||
            'is_logged_in' => $is_logged_in
 | 
					            'pagination' => $pagination_links,
 | 
				
			||||||
 | 
					            'is_logged_in' => $this->session->userdata('logged_in')
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
@@ -30,20 +45,26 @@ class Artistes extends CI_Controller {
 | 
				
			|||||||
        $this->load->view('layout/footer');
 | 
					        $this->load->view('layout/footer');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public function view($artistId) {
 | 
					 | 
				
			||||||
        $artist = $this->model_music->getArtistDetails($artistId);
 | 
					 | 
				
			||||||
        $albums = $this->model_music->getAlbumsByArtist($artistId);
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function view($artistId) {
 | 
				
			||||||
 | 
					        $artistDetails = $this->Model_artist->getArtistDetails($artistId);
 | 
				
			||||||
 | 
					        $albums = $this->Model_artist->getAlbumsByArtist($artistId);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if (!$artistDetails) {
 | 
				
			||||||
 | 
					            show_404();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
        $data = array(
 | 
					        $data = array(
 | 
				
			||||||
            'artist' => $artist,
 | 
					            'artist' => $artistDetails,
 | 
				
			||||||
            'albums' => $albums,
 | 
					            'albums' => $albums,
 | 
				
			||||||
            'is_logged_in' => $is_logged_in
 | 
					            'is_logged_in' => $this->session->userdata('logged_in')
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
        $this->load->view('artist_details', $data);
 | 
					        $this->load->view('artist_details', $data);
 | 
				
			||||||
        $this->load->view('layout/footer');
 | 
					        $this->load->view('layout/footer');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
?>
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,26 +5,56 @@ class Music extends CI_Controller {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function __construct(){
 | 
					    public function __construct(){
 | 
				
			||||||
        parent::__construct();
 | 
					        parent::__construct();
 | 
				
			||||||
        $this->load->model('model_music');
 | 
					        $this->load->model('Model_music');
 | 
				
			||||||
 | 
					        $this->load->library('pagination');
 | 
				
			||||||
        $this->load->library('session');
 | 
					        $this->load->library('session');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function index(){
 | 
					    public function index() {
 | 
				
			||||||
        $genre = $this->input->get('genre');
 | 
					        $genre = $this->input->get('genre');
 | 
				
			||||||
        $order = $this->input->get('order');
 | 
					        $order = $this->input->get('order');
 | 
				
			||||||
        $artist = $this->input->get('artist');
 | 
					        $artist = $this->input->get('artist');
 | 
				
			||||||
        $query = $this->input->get('query');
 | 
					        $query = $this->input->get('query');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $musics = $this->model_music->getMusics($genre, $order, $artist, $query);
 | 
					        // Configuration de la pagination
 | 
				
			||||||
        $genres = $this->model_music->researchtype();
 | 
					        $config = array();
 | 
				
			||||||
        $artists = $this->model_music->nameArtist(); // S'assurer que cette méthode récupère bien les artistes
 | 
					        $config['base_url'] = site_url('music/index');
 | 
				
			||||||
 | 
					        $config['total_rows'] = $this->Model_music->countAllMusics($genre, $artist, $query);
 | 
				
			||||||
 | 
					        $config['per_page'] = 16;
 | 
				
			||||||
 | 
					        $config['page_query_string'] = TRUE;
 | 
				
			||||||
 | 
					        $config['reuse_query_string'] = TRUE;
 | 
				
			||||||
 | 
					        $config['query_string_segment'] = 'page';
 | 
				
			||||||
 | 
					        $config['full_tag_open'] = '<nav aria-label="Page navigation"><ul class="pagination">';
 | 
				
			||||||
 | 
					        $config['full_tag_close'] = '</ul></nav>';
 | 
				
			||||||
 | 
					        $config['first_link'] = 'First';
 | 
				
			||||||
 | 
					        $config['last_link'] = 'Last';
 | 
				
			||||||
 | 
					        $config['first_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['first_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['prev_link'] = '«';
 | 
				
			||||||
 | 
					        $config['prev_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['prev_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['next_link'] = '»';
 | 
				
			||||||
 | 
					        $config['next_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['next_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['last_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['last_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['cur_tag_open'] = '<li class="page-item active"><a href="#" class="page-link">';
 | 
				
			||||||
 | 
					        $config['cur_tag_close'] = '</a></li>';
 | 
				
			||||||
 | 
					        $config['num_tag_open'] = '<li class="page-item">';
 | 
				
			||||||
 | 
					        $config['num_tag_close'] = '</li>';
 | 
				
			||||||
 | 
					        $config['attributes'] = array('class' => 'page-link');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->pagination->initialize($config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $page = $this->input->get('page');
 | 
				
			||||||
 | 
					        $page = ($page) ? $page : 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					 | 
				
			||||||
        $data = array(
 | 
					        $data = array(
 | 
				
			||||||
            'musics' => $musics,
 | 
					            'musics' => $this->Model_music->getMusics($genre, $order, $artist, $query, $config['per_page'], $page),
 | 
				
			||||||
            'genres' => $genres,
 | 
					            'genres' => $this->Model_music->researchtype(),
 | 
				
			||||||
            'artistes' => $artists, // Passer les artistes à la vue
 | 
					            'artists' => $this->Model_music->nameArtist(),
 | 
				
			||||||
            'is_logged_in' => $is_logged_in
 | 
					            'is_logged_in' => $this->session->userdata('logged_in'),
 | 
				
			||||||
 | 
					            'pagination' => $this->pagination->create_links()
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
@@ -34,7 +64,7 @@ class Music extends CI_Controller {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function view($songId) {
 | 
					    public function view($songId) {
 | 
				
			||||||
        $songData = $this->model_music->getSongDetails($songId);
 | 
					        $songData = $this->Model_music->getSongDetails($songId);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        if (!$songData) {
 | 
					        if (!$songData) {
 | 
				
			||||||
            show_404();
 | 
					            show_404();
 | 
				
			||||||
@@ -50,6 +80,6 @@ class Music extends CI_Controller {
 | 
				
			|||||||
        $this->load->view('song_details', $data);
 | 
					        $this->load->view('song_details', $data);
 | 
				
			||||||
        $this->load->view('layout/footer');
 | 
					        $this->load->view('layout/footer');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,22 +5,20 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
    public function __construct() {
 | 
					    public function __construct() {
 | 
				
			||||||
        parent::__construct();
 | 
					        parent::__construct();
 | 
				
			||||||
        $this->load->model('Model_playlist');
 | 
					        $this->load->model('Model_playlist');
 | 
				
			||||||
        $this->load->model('Model_music'); // Ajouté pour accéder aux musiques
 | 
					        $this->load->model('Model_music');
 | 
				
			||||||
        $this->load->library('session');
 | 
					        $this->load->library('session');
 | 
				
			||||||
 | 
					        if (!$this->session->userdata('logged_in')) {
 | 
				
			||||||
 | 
					            redirect('connect/login');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function index() {
 | 
					    public function index($data = []) {
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
        $user_email = $this->session->userdata('email');
 | 
					        $user_email = $this->session->userdata('email');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$is_logged_in) {
 | 
					        $data['is_logged_in'] = $is_logged_in;
 | 
				
			||||||
            redirect('connect/login');
 | 
					        $data['playlists'] = $this->Model_playlist->getPlaylistsByUser($user_email);
 | 
				
			||||||
        }
 | 
					        $data['genres'] = $this->Model_playlist->getGenres();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $data = array(
 | 
					 | 
				
			||||||
            'is_logged_in' => $is_logged_in,
 | 
					 | 
				
			||||||
            'playlists' => $this->Model_playlist->getPlaylistsByUser($user_email)
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
        $this->load->view('playlists_list', $data);
 | 
					        $this->load->view('playlists_list', $data);
 | 
				
			||||||
@@ -31,18 +29,24 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
        $user_email = $this->session->userdata('email');
 | 
					        $user_email = $this->session->userdata('email');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$is_logged_in) {
 | 
					 | 
				
			||||||
            redirect('connect/login');
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $name = $this->input->post('name');
 | 
					        $name = $this->input->post('name');
 | 
				
			||||||
        $type = $this->input->post('type');
 | 
					        $type = $this->input->post('type');
 | 
				
			||||||
 | 
					        $numSongs = $this->input->post('numSongs');
 | 
				
			||||||
 | 
					        $genre = $this->input->post('genre');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($type == 'random') {
 | 
					        if ($type == 'random') {
 | 
				
			||||||
            $numSongs = $this->input->post('numSongs');
 | 
					            if ($numSongs <= 0) {
 | 
				
			||||||
            $artist = $this->input->post('artist');
 | 
					                $data['error'] = 'Le nombre de chansons doit être supérieur à 0';
 | 
				
			||||||
            $genre = $this->input->post('genre');
 | 
					                $this->index($data);
 | 
				
			||||||
            $this->Model_playlist->createRandomPlaylist($user_email, $name, $numSongs, $artist, $genre);
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $result = $this->Model_playlist->createRandomPlaylist($user_email, $name, $numSongs, $genre);
 | 
				
			||||||
 | 
					            if (!$result) {
 | 
				
			||||||
 | 
					                $data['error'] = 'Erreur lors de la création de la playlist aléatoire';
 | 
				
			||||||
 | 
					                $this->index($data);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $this->Model_playlist->addPlaylist($user_email, $name);
 | 
					            $this->Model_playlist->addPlaylist($user_email, $name);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -51,11 +55,13 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function selectPlaylist() {
 | 
					    public function selectPlaylist() {
 | 
				
			||||||
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
        $itemId = $this->input->post('itemId');
 | 
					        $itemId = $this->input->post('itemId');
 | 
				
			||||||
        $itemType = $this->input->post('itemType');
 | 
					        $itemType = $this->input->post('itemType');
 | 
				
			||||||
        $playlists = $this->Model_playlist->getPlaylistsByUser($this->session->userdata('email'));
 | 
					        $playlists = $this->Model_playlist->getPlaylistsByUser($this->session->userdata('email'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $data = array(
 | 
					        $data = array(
 | 
				
			||||||
 | 
					            'is_logged_in' => $is_logged_in,
 | 
				
			||||||
            'itemId' => $itemId,
 | 
					            'itemId' => $itemId,
 | 
				
			||||||
            'itemType' => $itemType,
 | 
					            'itemType' => $itemType,
 | 
				
			||||||
            'playlists' => $playlists
 | 
					            'playlists' => $playlists
 | 
				
			||||||
@@ -74,14 +80,14 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
        if ($itemType == 'album') {
 | 
					        if ($itemType == 'album') {
 | 
				
			||||||
            $songs = $this->Model_music->getSongsByAlbum($itemId);
 | 
					            $songs = $this->Model_music->getSongsByAlbum($itemId);
 | 
				
			||||||
            foreach ($songs as $song) {
 | 
					            foreach ($songs as $song) {
 | 
				
			||||||
                $this->Model_playlist->addItem($playlistId, $song->id, 'song');
 | 
					                $this->Model_playlist->addItem($playlistId, $song->trackId, 'song');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if ($itemType == 'artist') {
 | 
					        } else if ($itemType == 'artist') {
 | 
				
			||||||
            $albums = $this->Model_music->getAlbumsByArtist($itemId);
 | 
					            $albums = $this->Model_music->getAlbumsByArtist($itemId);
 | 
				
			||||||
            foreach ($albums as $album) {
 | 
					            foreach ($albums as $album) {
 | 
				
			||||||
                $songs = $this->Model_music->getSongsByAlbum($album->albumId);
 | 
					                $songs = $this->Model_music->getSongsByAlbum($album->albumId);
 | 
				
			||||||
                foreach ($songs as $song) {
 | 
					                foreach ($songs as $song) {
 | 
				
			||||||
                    $this->Model_playlist->addItem($playlistId, $song->id, 'song');
 | 
					                    $this->Model_playlist->addItem($playlistId, $song->trackId, 'song');
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
@@ -94,9 +100,12 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
    public function view($playlistId) {
 | 
					    public function view($playlistId) {
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
        $items = $this->Model_playlist->getPlaylistItems($playlistId);
 | 
					        $items = $this->Model_playlist->getPlaylistItems($playlistId);
 | 
				
			||||||
 | 
					        $itemCount = $this->Model_playlist->getPlaylistItemCount($playlistId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $data = array(
 | 
					        $data = array(
 | 
				
			||||||
            'is_logged_in' => $is_logged_in,
 | 
					            'is_logged_in' => $is_logged_in,
 | 
				
			||||||
            'items' => $items
 | 
					            'items' => $items,
 | 
				
			||||||
 | 
					            'itemCount' => $itemCount
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
@@ -113,10 +122,6 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
        $user_email = $this->session->userdata('email');
 | 
					        $user_email = $this->session->userdata('email');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$is_logged_in) {
 | 
					 | 
				
			||||||
            redirect('connect/login');
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->Model_playlist->deletePlaylist($playlist_id);
 | 
					        $this->Model_playlist->deletePlaylist($playlist_id);
 | 
				
			||||||
        redirect('playlist');
 | 
					        redirect('playlist');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -125,10 +130,6 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
        $user_email = $this->session->userdata('email');
 | 
					        $user_email = $this->session->userdata('email');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$is_logged_in) {
 | 
					 | 
				
			||||||
            redirect('connect/login');
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->Model_playlist->duplicatePlaylist($playlist_id, $user_email);
 | 
					        $this->Model_playlist->duplicatePlaylist($playlist_id, $user_email);
 | 
				
			||||||
        redirect('playlist');
 | 
					        redirect('playlist');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -137,10 +138,6 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
        $user_email = $this->session->userdata('email');
 | 
					        $user_email = $this->session->userdata('email');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$is_logged_in) {
 | 
					 | 
				
			||||||
            redirect('connect/login');
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $playlistId = $this->input->post('playlistId');
 | 
					        $playlistId = $this->input->post('playlistId');
 | 
				
			||||||
        $newName = $this->input->post('newName');
 | 
					        $newName = $this->input->post('newName');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -148,4 +145,3 @@ class Playlist extends CI_Controller {
 | 
				
			|||||||
        redirect('playlist');
 | 
					        redirect('playlist');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										96
									
								
								application/models/Model_album.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								application/models/Model_album.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,96 @@
 | 
				
			|||||||
 | 
					<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Model_album extends CI_Model {
 | 
				
			||||||
 | 
					    public function __construct(){
 | 
				
			||||||
 | 
					        parent::__construct();
 | 
				
			||||||
 | 
					        $this->load->database();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Méthode pour obtenir les albums avec pagination et filtres
 | 
				
			||||||
 | 
					    public function getAlbums($genre = '', $order = 'asc', $artist = '', $query = '', $limit = 10, $offset = 0) {
 | 
				
			||||||
 | 
					        $this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
 | 
				
			||||||
 | 
					        $this->db->from('album');
 | 
				
			||||||
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!empty($genre)){
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!empty($artist)){
 | 
				
			||||||
 | 
					            $this->db->where('artist.name', $artist);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if($order == 'asc' || $order == 'desc'){
 | 
				
			||||||
 | 
					            $this->db->order_by('album.name', $order);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!empty($query)){
 | 
				
			||||||
 | 
					            $this->db->like('album.name', $query);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->db->limit($limit, $offset);
 | 
				
			||||||
 | 
					        $query = $this->db->get();
 | 
				
			||||||
 | 
					        return $query->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Méthode pour obtenir le nombre total d'albums avec les filtres
 | 
				
			||||||
 | 
					    public function countAllAlbums($genre = '', $artist = '', $query = '') {
 | 
				
			||||||
 | 
					        $this->db->from('album');
 | 
				
			||||||
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!empty($genre)){
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!empty($artist)){
 | 
				
			||||||
 | 
					            $this->db->where('artist.name', $artist);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!empty($query)){
 | 
				
			||||||
 | 
					            $this->db->like('album.name', $query);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->db->count_all_results();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Méthode pour obtenir tous les genres
 | 
				
			||||||
 | 
					    public function getGenres() {
 | 
				
			||||||
 | 
					        $this->db->select('name');
 | 
				
			||||||
 | 
					        $this->db->from('genre');
 | 
				
			||||||
 | 
					        $query = $this->db->get();
 | 
				
			||||||
 | 
					        return $query->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Méthode pour obtenir tous les artistes
 | 
				
			||||||
 | 
					    public function getArtists() {
 | 
				
			||||||
 | 
					        $this->db->select('name');
 | 
				
			||||||
 | 
					        $this->db->from('artist');
 | 
				
			||||||
 | 
					        $query = $this->db->get();
 | 
				
			||||||
 | 
					        return $query->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getAlbumDetails($albumId) {
 | 
				
			||||||
 | 
					        $this->db->select('album.name as albumName, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
 | 
				
			||||||
 | 
					        $this->db->from('album');
 | 
				
			||||||
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					        $this->db->where('album.id', $albumId);
 | 
				
			||||||
 | 
					        $albumQuery = $this->db->get();
 | 
				
			||||||
 | 
					        $albumDetails = $albumQuery->row();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        $this->db->select('song.name as trackName, track.id as trackId');
 | 
				
			||||||
 | 
					        $this->db->from('track');
 | 
				
			||||||
 | 
					        $this->db->join('song', 'track.songId = song.id');
 | 
				
			||||||
 | 
					        $this->db->where('track.albumId', $albumId);
 | 
				
			||||||
 | 
					        $songsQuery = $this->db->get();
 | 
				
			||||||
 | 
					        $songs = $songsQuery->result();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        return array('album' => $albumDetails, 'songs' => $songs);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										81
									
								
								application/models/Model_artist.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								application/models/Model_artist.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
				
			|||||||
 | 
					<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Model_artist extends CI_Model {
 | 
				
			||||||
 | 
					    public function __construct(){
 | 
				
			||||||
 | 
					        $this->load->database();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getArtists($genre = '', $order = 'asc', $query = '', $limit = 10, $start = 0) {
 | 
				
			||||||
 | 
					        $this->db->select('artist.name as artistName, artist.id as artistId');
 | 
				
			||||||
 | 
					        $this->db->from('artist');
 | 
				
			||||||
 | 
					        $this->db->join('album', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->distinct();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if ($order == 'asc' || $order == 'desc') {
 | 
				
			||||||
 | 
					            $this->db->order_by('artist.name', $order);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if (!empty($query)) {
 | 
				
			||||||
 | 
					            $this->db->like('artist.name', $query);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        $this->db->limit($limit, $start);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        $result = $this->db->get();
 | 
				
			||||||
 | 
					        return $result->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getArtistDetails($artistId) {
 | 
				
			||||||
 | 
					        $this->db->select('artist.name as artistName, artist.id');
 | 
				
			||||||
 | 
					        $this->db->from('artist');
 | 
				
			||||||
 | 
					        $this->db->where('artist.id', $artistId);
 | 
				
			||||||
 | 
					        $artistQuery = $this->db->get();
 | 
				
			||||||
 | 
					        return $artistQuery->row();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getAlbumsByArtist($artistId) {
 | 
				
			||||||
 | 
					        $this->db->select('album.id as albumId, album.name as albumName, album.year, cover.jpeg, genre.name as genreName');
 | 
				
			||||||
 | 
					        $this->db->from('album');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'album.genreid = genre.id');
 | 
				
			||||||
 | 
					        $this->db->join('cover', 'album.coverid = cover.id');
 | 
				
			||||||
 | 
					        $this->db->where('album.artistid', $artistId);
 | 
				
			||||||
 | 
					        $albumsQuery = $this->db->get();
 | 
				
			||||||
 | 
					        $albums = $albumsQuery->result();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        foreach ($albums as $album) {
 | 
				
			||||||
 | 
					            $this->db->select('track.id as trackId, song.name as songName');
 | 
				
			||||||
 | 
					            $this->db->from('track');
 | 
				
			||||||
 | 
					            $this->db->join('song', 'track.songid = song.id');
 | 
				
			||||||
 | 
					            $this->db->where('track.albumid', $album->albumId);
 | 
				
			||||||
 | 
					            $album->songs = $this->db->get()->result();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        return $albums;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function get_total_artists($genre = '', $query = '') {
 | 
				
			||||||
 | 
					        $this->db->select('artist.id'); // Sélectionnez uniquement l'ID de l'artiste
 | 
				
			||||||
 | 
					        $this->db->from('artist');
 | 
				
			||||||
 | 
					        $this->db->join('album', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if (!empty($query)) {
 | 
				
			||||||
 | 
					            $this->db->like('artist.name', $query);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        $this->db->distinct(); // Assurez-vous que seules les lignes distinctes sont comptées
 | 
				
			||||||
 | 
					        return $this->db->count_all_results();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -5,33 +5,56 @@ class Model_music extends CI_Model {
 | 
				
			|||||||
        $this->load->database();
 | 
					        $this->load->database();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getAlbums($genre = '', $order = 'asc', $artist = '', $query = '') {
 | 
					    public function getAlbums($genre = '', $order = '', $artist = '', $query = '', $limit = 10, $offset = 0) {
 | 
				
			||||||
        $this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
 | 
					        $this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
 | 
				
			||||||
        $this->db->from('album');
 | 
					        $this->db->from('album');
 | 
				
			||||||
        $this->db->join('artist', 'album.artistid = artist.id');
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
        $this->db->join('genre', 'genre.id = album.genreid');
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
        $this->db->join('cover', 'cover.id = album.coverid');
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!empty($genre)){
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
            $this->db->where('genre.name', $genre);
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(!empty($artist)){
 | 
					        if (!empty($artist)) {
 | 
				
			||||||
            $this->db->where('artist.name', $artist);
 | 
					            $this->db->where('artist.name', $artist);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($order == 'asc' || $order == 'desc'){
 | 
					        if (!empty($query)) {
 | 
				
			||||||
            $this->db->order_by('album.name', $order);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(!empty($query)){
 | 
					 | 
				
			||||||
            $this->db->like('album.name', $query);
 | 
					            $this->db->like('album.name', $query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($order == 'asc' || $order == 'desc') {
 | 
				
			||||||
 | 
					            $this->db->order_by('album.name', $order);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->db->limit($limit, $offset);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        $query = $this->db->get();
 | 
					        $query = $this->db->get();
 | 
				
			||||||
        return $query->result();
 | 
					        return $query->result();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function countAllAlbums($genre = '', $artist = '', $query = '') {
 | 
				
			||||||
 | 
					        $this->db->from('album');
 | 
				
			||||||
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!empty($artist)) {
 | 
				
			||||||
 | 
					            $this->db->where('artist.name', $artist);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!empty($query)) {
 | 
				
			||||||
 | 
					            $this->db->like('album.name', $query);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->db->count_all_results();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function researchtype(){
 | 
					    public function researchtype(){
 | 
				
			||||||
        $this->db->select('name');
 | 
					        $this->db->select('name');
 | 
				
			||||||
        $this->db->from('genre');
 | 
					        $this->db->from('genre');
 | 
				
			||||||
@@ -46,40 +69,21 @@ class Model_music extends CI_Model {
 | 
				
			|||||||
        return $query->result();
 | 
					        return $query->result();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getArtists($genre = '', $order = 'asc', $query = '') {
 | 
					    public function getArtists() {
 | 
				
			||||||
        $this->db->select('artist.name as artistName, artist.id as artistId');
 | 
					        $this->db->select('id, name');
 | 
				
			||||||
        $this->db->from('artist');
 | 
					        $this->db->from('artist');
 | 
				
			||||||
        $this->db->join('album', 'album.artistid = artist.id');
 | 
					        $query = $this->db->get();
 | 
				
			||||||
        $this->db->join('genre', 'genre.id = album.genreid');
 | 
					        return $query->result();
 | 
				
			||||||
        $this->db->join('cover', 'cover.id = album.coverid');
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        $this->db->distinct("artist.name");
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        if (!empty($genre)) {
 | 
					 | 
				
			||||||
            $this->db->where('genre.name', $genre);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        if ($order == 'asc' || $order == 'desc') {
 | 
					 | 
				
			||||||
            $this->db->order_by('artist.name', $order);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        if (!empty($query)) {
 | 
					 | 
				
			||||||
            $this->db->like('artist.name', $query);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        $result = $this->db->get();
 | 
					 | 
				
			||||||
        return $result->result();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getMusics($genre = '', $order = '', $artist = '', $query = '') {
 | 
					    public function getMusics($genre = '', $order = '', $artist = '', $query = '', $limit = 10, $offset = 0) {
 | 
				
			||||||
        $this->db->select('album.name as albumName, album.id as albumId, year, artist.name as artistName, genre.name as genreName, jpeg, song.name as trackName, track.id as trackId');
 | 
					        $this->db->select('album.name as albumName, album.id as albumId, year, artist.name as artistName, genre.name as genreName, jpeg, song.name as trackName, track.id as trackId');
 | 
				
			||||||
        $this->db->from('track');
 | 
					        $this->db->from('track');
 | 
				
			||||||
        $this->db->join('album', 'track.albumId = album.id');
 | 
					        $this->db->join('album', 'track.albumid = album.id');
 | 
				
			||||||
        $this->db->join('song', 'song.id = track.songId');
 | 
					        $this->db->join('song', 'song.id = track.songid');
 | 
				
			||||||
        $this->db->join('artist', 'album.artistid = artist.id');
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
        $this->db->join('genre', 'genre.id = album.genreid');
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
        $this->db->join('cover', 'cover.id = album.coverid');
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
        $this->db->limit(100);
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        if (!empty($genre)) {
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
            $this->db->where('genre.name', $genre);
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
@@ -89,18 +93,68 @@ class Model_music extends CI_Model {
 | 
				
			|||||||
            $this->db->where('artist.name', $artist);
 | 
					            $this->db->where('artist.name', $artist);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					        if (!empty($query)) {
 | 
				
			||||||
 | 
					            $this->db->like('song.name', $query);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
        if ($order == 'asc' || $order == 'desc') {
 | 
					        if ($order == 'asc' || $order == 'desc') {
 | 
				
			||||||
            $this->db->order_by('song.name', $order);
 | 
					            $this->db->order_by('song.name', $order);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->db->limit($limit, $offset);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        $result = $this->db->get();
 | 
				
			||||||
 | 
					        return $result->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getTotalMusics($genre = '', $artist = '', $query = '') {
 | 
				
			||||||
 | 
					        $this->db->from('track');
 | 
				
			||||||
 | 
					        $this->db->join('album', 'track.albumid = album.id');
 | 
				
			||||||
 | 
					        $this->db->join('song', 'song.id = track.songid');
 | 
				
			||||||
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!empty($artist)) {
 | 
				
			||||||
 | 
					            $this->db->where('artist.name', $artist);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        if (!empty($query)) {
 | 
					        if (!empty($query)) {
 | 
				
			||||||
            $this->db->like('song.name', $query);
 | 
					            $this->db->like('song.name', $query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        $result = $this->db->get();
 | 
					        return $this->db->count_all_results();
 | 
				
			||||||
        return $result->result();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    public function countAllMusics($genre = '', $artist = '', $query = '') {
 | 
				
			||||||
 | 
					        $this->db->from('track');
 | 
				
			||||||
 | 
					        $this->db->join('album', 'track.albumid = album.id');
 | 
				
			||||||
 | 
					        $this->db->join('song', 'song.id = track.songid');
 | 
				
			||||||
 | 
					        $this->db->join('artist', 'album.artistid = artist.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!empty($artist)) {
 | 
				
			||||||
 | 
					            $this->db->where('artist.name', $artist);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!empty($query)) {
 | 
				
			||||||
 | 
					            $this->db->like('song.name', $query);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return $this->db->count_all_results();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getAlbumDetails($albumId) {
 | 
					    public function getAlbumDetails($albumId) {
 | 
				
			||||||
        $this->db->select('album.name as albumName, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
 | 
					        $this->db->select('album.name as albumName, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
 | 
				
			||||||
        $this->db->from('album');
 | 
					        $this->db->from('album');
 | 
				
			||||||
@@ -122,25 +176,14 @@ class Model_music extends CI_Model {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getAlbumsByArtist($artistId) {
 | 
					    public function getAlbumsByArtist($artistId) {
 | 
				
			||||||
        $this->db->select('album.id as albumId, album.name as albumName, album.year, cover.jpeg, genre.name as genreName');
 | 
					        $this->db->select('album.id as albumId');
 | 
				
			||||||
        $this->db->from('album');
 | 
					        $this->db->from('album');
 | 
				
			||||||
        $this->db->join('genre', 'album.genreid = genre.id');
 | 
					 | 
				
			||||||
        $this->db->join('cover', 'album.coverid = cover.id');
 | 
					 | 
				
			||||||
        $this->db->where('album.artistid', $artistId);
 | 
					        $this->db->where('album.artistid', $artistId);
 | 
				
			||||||
        $albumsQuery = $this->db->get();
 | 
					        $query = $this->db->get();
 | 
				
			||||||
        $albums = $albumsQuery->result();
 | 
					        return $query->result();
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        foreach ($albums as $album) {
 | 
					 | 
				
			||||||
            $this->db->select('track.id as trackId, song.name as songName');
 | 
					 | 
				
			||||||
            $this->db->from('track');
 | 
					 | 
				
			||||||
            $this->db->join('song', 'track.songid = song.id');
 | 
					 | 
				
			||||||
            $this->db->where('track.albumid', $album->albumId);
 | 
					 | 
				
			||||||
            $album->songs = $this->db->get()->result();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        return $albums;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getArtistDetails($artistId) {
 | 
					    public function getArtistDetails($artistId) {
 | 
				
			||||||
        $this->db->select('artist.name as artistName, artist.id');
 | 
					        $this->db->select('artist.name as artistName, artist.id');
 | 
				
			||||||
        $this->db->from('artist');
 | 
					        $this->db->from('artist');
 | 
				
			||||||
@@ -175,22 +218,35 @@ class Model_music extends CI_Model {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getSongsByAlbum($albumId) {
 | 
					    public function getSongsByAlbum($albumId) {
 | 
				
			||||||
        $this->db->select('track.id');
 | 
					        $this->db->select('track.id as trackId');
 | 
				
			||||||
        $this->db->from('track');
 | 
					        $this->db->from('track');
 | 
				
			||||||
        $this->db->where('track.albumid', $albumId);
 | 
					        $this->db->where('track.albumid', $albumId);
 | 
				
			||||||
        $query = $this->db->get();
 | 
					        $query = $this->db->get();
 | 
				
			||||||
        return $query->result();
 | 
					        return $query->result();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public function getSongsByArtist($artistId) {
 | 
					
 | 
				
			||||||
        $this->db->select('track.id');
 | 
					    public function getSongsByArtist($artistName) {
 | 
				
			||||||
 | 
					        $this->db->select('track.id as trackId, song.name as trackName');
 | 
				
			||||||
        $this->db->from('track');
 | 
					        $this->db->from('track');
 | 
				
			||||||
        $this->db->join('album', 'track.albumid = album.id');
 | 
					        $this->db->join('song', 'song.id = track.songid');
 | 
				
			||||||
        $this->db->where('album.artistid', $artistId);
 | 
					        $this->db->join('album', 'album.id = track.albumid');
 | 
				
			||||||
 | 
					        $this->db->join('artist', 'artist.id = album.artistid');
 | 
				
			||||||
 | 
					        $this->db->where('artist.name', $artistName);
 | 
				
			||||||
        $query = $this->db->get();
 | 
					        $query = $this->db->get();
 | 
				
			||||||
        return $query->result();
 | 
					        return $query->result();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    public function getSongsByGenre($genreName) {
 | 
				
			||||||
 | 
					        $this->db->select('track.id as trackId, song.name as trackName');
 | 
				
			||||||
 | 
					        $this->db->from('track');
 | 
				
			||||||
 | 
					        $this->db->join('song', 'song.id = track.songid');
 | 
				
			||||||
 | 
					        $this->db->join('album', 'album.id = track.albumid');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
 | 
					        $this->db->where('genre.name', $genreName);
 | 
				
			||||||
 | 
					        $query = $this->db->get();
 | 
				
			||||||
 | 
					        return $query->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getRandomSongs($numSongs, $artist = '', $genre = '') {
 | 
					    public function getRandomSongs($numSongs, $artist = '', $genre = '') {
 | 
				
			||||||
        $this->db->select('track.id as trackId');
 | 
					        $this->db->select('track.id as trackId');
 | 
				
			||||||
@@ -222,4 +278,13 @@ class Model_music extends CI_Model {
 | 
				
			|||||||
        $query = $this->db->get();
 | 
					        $query = $this->db->get();
 | 
				
			||||||
        return $query->result();
 | 
					        return $query->result();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getAllSongs() {
 | 
				
			||||||
 | 
					        $this->db->select('track.id as trackId, song.name as trackName');
 | 
				
			||||||
 | 
					        $this->db->from('track');
 | 
				
			||||||
 | 
					        $this->db->join('song', 'song.id = track.songid');
 | 
				
			||||||
 | 
					        $query = $this->db->get();
 | 
				
			||||||
 | 
					        return $query->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -95,4 +95,58 @@ class Model_playlist extends CI_Model {
 | 
				
			|||||||
        $this->db->where('id', $playlistId);
 | 
					        $this->db->where('id', $playlistId);
 | 
				
			||||||
        return $this->db->update('playlists', $data);
 | 
					        return $this->db->update('playlists', $data);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function createRandomPlaylist($userEmail, $name, $numSongs, $genre) {
 | 
				
			||||||
 | 
					        if ($numSongs <= 0) {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Création de la nouvelle playlist
 | 
				
			||||||
 | 
					        $data = array(
 | 
				
			||||||
 | 
					            'user_email' => $userEmail,
 | 
				
			||||||
 | 
					            'name' => $name
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        $this->db->insert('playlists', $data);
 | 
				
			||||||
 | 
					        $playlistId = $this->db->insert_id();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Filtrage des chansons par genre
 | 
				
			||||||
 | 
					        $this->db->select('track.id');
 | 
				
			||||||
 | 
					        $this->db->from('track');
 | 
				
			||||||
 | 
					        $this->db->join('song', 'track.songid = song.id');
 | 
				
			||||||
 | 
					        $this->db->join('album', 'track.albumid = album.id');
 | 
				
			||||||
 | 
					        $this->db->join('genre', 'album.genreid = genre.id');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($genre) {
 | 
				
			||||||
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $query = $this->db->get();
 | 
				
			||||||
 | 
					        $songs = $query->result();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($numSongs > count($songs)) {
 | 
				
			||||||
 | 
					            $numSongs = count($songs);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Sélection aléatoire de chansons
 | 
				
			||||||
 | 
					        $randomKeys = array_rand($songs, $numSongs);
 | 
				
			||||||
 | 
					        foreach ($randomKeys as $key) {
 | 
				
			||||||
 | 
					            $song = $songs[$key];
 | 
				
			||||||
 | 
					            $this->addItem($playlistId, $song->id, 'song');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getGenres() {
 | 
				
			||||||
 | 
					        $this->db->select('name');
 | 
				
			||||||
 | 
					        $this->db->from('genre');
 | 
				
			||||||
 | 
					        $query = $this->db->get();
 | 
				
			||||||
 | 
					        return $query->result();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function getPlaylistItemCount($playlistId) {
 | 
				
			||||||
 | 
					        $this->db->where('playlist_id', $playlistId);
 | 
				
			||||||
 | 
					        $this->db->from('playlist_items');
 | 
				
			||||||
 | 
					        return $this->db->count_all_results();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,12 +22,20 @@
 | 
				
			|||||||
                    <thead>
 | 
					                    <thead>
 | 
				
			||||||
                        <tr>
 | 
					                        <tr>
 | 
				
			||||||
                            <th>Titre</th>
 | 
					                            <th>Titre</th>
 | 
				
			||||||
 | 
					                            <th>Action</th>
 | 
				
			||||||
                        </tr>
 | 
					                        </tr>
 | 
				
			||||||
                    </thead>
 | 
					                    </thead>
 | 
				
			||||||
                    <tbody>
 | 
					                    <tbody>
 | 
				
			||||||
                        <?php foreach ($songs as $song): ?>
 | 
					                        <?php foreach ($songs as $song): ?>
 | 
				
			||||||
                            <tr>
 | 
					                            <tr>
 | 
				
			||||||
                                <td><?= anchor("music/view/{$song->trackId}", $song->trackName) ?></td>
 | 
					                                <td><?= anchor("music/view/{$song->trackId}", $song->trackName) ?></td>
 | 
				
			||||||
 | 
					                                <td>
 | 
				
			||||||
 | 
					                                    <form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
 | 
				
			||||||
 | 
					                                        <input type="hidden" name="itemId" value="<?= $song->trackId ?>">
 | 
				
			||||||
 | 
					                                        <input type="hidden" name="itemType" value="song">
 | 
				
			||||||
 | 
					                                        <button type="submit" class="button is-link">Ajouter à la playlist</button>
 | 
				
			||||||
 | 
					                                    </form>
 | 
				
			||||||
 | 
					                                </td>
 | 
				
			||||||
                            </tr>
 | 
					                            </tr>
 | 
				
			||||||
                        <?php endforeach; ?>
 | 
					                        <?php endforeach; ?>
 | 
				
			||||||
                    </tbody>
 | 
					                    </tbody>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,14 +5,17 @@
 | 
				
			|||||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
					    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
				
			||||||
    <title>Liste des Albums - Dix heures</title>
 | 
					    <title>Liste des Albums - Dix heures</title>
 | 
				
			||||||
    <link rel="stylesheet" href="<?= base_url('assets/style.css') ?>">
 | 
					    <link rel="stylesheet" href="<?= base_url('assets/style.css') ?>">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
    <section class="section">
 | 
					    <section class="section">
 | 
				
			||||||
        <div class="container">
 | 
					        <div class="container">
 | 
				
			||||||
            <h1 class="title is-4 has-text-dark">Liste des Albums</h1>
 | 
					            <h1 class="title">Liste des Albums</h1>
 | 
				
			||||||
            <div class="columns is-multiline is-centered">
 | 
					            
 | 
				
			||||||
 | 
					            <!-- Liste des albums -->
 | 
				
			||||||
 | 
					            <div class="columns is-multiline">
 | 
				
			||||||
                <?php foreach ($albums as $album): ?>
 | 
					                <?php foreach ($albums as $album): ?>
 | 
				
			||||||
                    <div class="column is-one-quarter-desktop is-half-tablet is-full-mobile">
 | 
					                    <div class="column is-one-quarter">
 | 
				
			||||||
                        <div class="card">
 | 
					                        <div class="card">
 | 
				
			||||||
                            <div class="card-image">
 | 
					                            <div class="card-image">
 | 
				
			||||||
                                <figure class="image is-4by3">
 | 
					                                <figure class="image is-4by3">
 | 
				
			||||||
@@ -22,13 +25,13 @@
 | 
				
			|||||||
                            <div class="card-content">
 | 
					                            <div class="card-content">
 | 
				
			||||||
                                <div class="media">
 | 
					                                <div class="media">
 | 
				
			||||||
                                    <div class="media-content">
 | 
					                                    <div class="media-content">
 | 
				
			||||||
                                        <p class="title is-4 album-title"><?= anchor("albums/view/{$album->id}", $album->name) ?></p>
 | 
					                                        <p class="title is-4"><?= anchor("albums/view/{$album->id}", $album->name) ?></p>
 | 
				
			||||||
                                        <p class="subtitle is-6"><?= "{$album->year} - {$album->artistName}" ?></p>
 | 
					                                        <p class="subtitle is-6"><?= $album->artistName ?> - <?= $album->year ?></p>
 | 
				
			||||||
                                        <?php if (isset($is_logged_in) && $is_logged_in): ?>
 | 
					                                        <?php if ($is_logged_in): ?>
 | 
				
			||||||
                                            <form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
 | 
					                                            <form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
 | 
				
			||||||
                                                <input type="hidden" name="itemId" value="<?= $album->id ?>">
 | 
					                                                <input type="hidden" name="itemId" value="<?= $album->id ?>">
 | 
				
			||||||
                                                <input type="hidden" name="itemType" value="album">
 | 
					                                                <input type="hidden" name="itemType" value="album">
 | 
				
			||||||
                                                <button type="submit" class="button is-link is-fullwidth">Ajouter à la playlist</button>
 | 
					                                                <button type="submit" class="button is-link">Ajouter à la playlist</button>
 | 
				
			||||||
                                            </form>
 | 
					                                            </form>
 | 
				
			||||||
                                        <?php endif; ?>
 | 
					                                        <?php endif; ?>
 | 
				
			||||||
                                    </div>
 | 
					                                    </div>
 | 
				
			||||||
@@ -38,7 +41,64 @@
 | 
				
			|||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                <?php endforeach; ?>
 | 
					                <?php endforeach; ?>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <!-- Pagination -->
 | 
				
			||||||
 | 
					            <nav class="pagination" role="navigation" aria-label="pagination">
 | 
				
			||||||
 | 
					                <?= $pagination ?>
 | 
				
			||||||
 | 
					            </nav>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </section>
 | 
					    </section>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					        .card {
 | 
				
			||||||
 | 
					            display: flex;
 | 
				
			||||||
 | 
					            flex-direction: column;
 | 
				
			||||||
 | 
					            height: 100%;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .card-image {
 | 
				
			||||||
 | 
					            flex-shrink: 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .card-content {
 | 
				
			||||||
 | 
					            flex-grow: 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .card-footer {
 | 
				
			||||||
 | 
					            flex-shrink: 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .album-title, .artist-title, .music-title {
 | 
				
			||||||
 | 
					            display: -webkit-box;
 | 
				
			||||||
 | 
					            -webkit-box-orient: vertical;
 | 
				
			||||||
 | 
					            -webkit-line-clamp: 2; /* Limite à 2 lignes */
 | 
				
			||||||
 | 
					            overflow: hidden;
 | 
				
			||||||
 | 
					            text-overflow: ellipsis;
 | 
				
			||||||
 | 
					            height: 3em; /* Ajuste en fonction de la taille de la police */
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .pagination a, .pagination span {
 | 
				
			||||||
 | 
					            padding: 8px 12px;
 | 
				
			||||||
 | 
					            margin: 0 2px;
 | 
				
			||||||
 | 
					            border-radius: 4px;
 | 
				
			||||||
 | 
					            border: 1px solid #ddd;
 | 
				
			||||||
 | 
					            color: #333;
 | 
				
			||||||
 | 
					            text-decoration: none;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .pagination a:hover {
 | 
				
			||||||
 | 
					            background-color: #f0f0f0;
 | 
				
			||||||
 | 
					            border-color: #bbb;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        .pagination .is-current {
 | 
				
			||||||
 | 
					            background-color: #3273dc;
 | 
				
			||||||
 | 
					            border-color: #3273dc;
 | 
				
			||||||
 | 
					            color: #fff;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    </style>
 | 
				
			||||||
@@ -19,11 +19,30 @@
 | 
				
			|||||||
                                <p><strong>Genre:</strong> <?= $album->genreName ?></p>
 | 
					                                <p><strong>Genre:</strong> <?= $album->genreName ?></p>
 | 
				
			||||||
                                <p><strong>Year:</strong> <?= $album->year ?></p>
 | 
					                                <p><strong>Year:</strong> <?= $album->year ?></p>
 | 
				
			||||||
                                <h4 class="title is-6">Songs</h4>
 | 
					                                <h4 class="title is-6">Songs</h4>
 | 
				
			||||||
                                <ul>
 | 
					                                <div class="table-container">
 | 
				
			||||||
                                    <?php foreach ($album->songs as $song): ?>
 | 
					                                    <table class="table is-striped is-fullwidth">
 | 
				
			||||||
                                        <li><?= anchor("music/view/{$song->trackId}", $song->songName) ?></li>
 | 
					                                        <thead>
 | 
				
			||||||
                                    <?php endforeach; ?>
 | 
					                                            <tr>
 | 
				
			||||||
                                </ul>
 | 
					                                                <th>Titre</th>
 | 
				
			||||||
 | 
					                                                <th>Action</th>
 | 
				
			||||||
 | 
					                                            </tr>
 | 
				
			||||||
 | 
					                                        </thead>
 | 
				
			||||||
 | 
					                                        <tbody>
 | 
				
			||||||
 | 
					                                            <?php foreach ($album->songs as $song): ?>
 | 
				
			||||||
 | 
					                                                <tr>
 | 
				
			||||||
 | 
					                                                    <td><?= anchor("music/view/{$song->trackId}", $song->songName) ?></td>
 | 
				
			||||||
 | 
					                                                    <td>
 | 
				
			||||||
 | 
					                                                        <form method="post" action="<?= site_url('playlist/selectPlaylist') ?>" style="display:inline;">
 | 
				
			||||||
 | 
					                                                            <input type="hidden" name="itemId" value="<?= $song->trackId ?>">
 | 
				
			||||||
 | 
					                                                            <input type="hidden" name="itemType" value="song">
 | 
				
			||||||
 | 
					                                                            <button type="submit" class="button is-link is-small">Ajouter à la playlist</button>
 | 
				
			||||||
 | 
					                                                        </form>
 | 
				
			||||||
 | 
					                                                    </td>
 | 
				
			||||||
 | 
					                                                </tr>
 | 
				
			||||||
 | 
					                                            <?php endforeach; ?>
 | 
				
			||||||
 | 
					                                        </tbody>
 | 
				
			||||||
 | 
					                                    </table>
 | 
				
			||||||
 | 
					                                </div>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,27 +1,51 @@
 | 
				
			|||||||
<section class="section">
 | 
					<section class="section">
 | 
				
			||||||
    <div class="container">
 | 
					    <div class="container">
 | 
				
			||||||
        <h1 class="title is-4">Liste des Artistes</h1>
 | 
					        <h1 class="title">Artistes</h1>
 | 
				
			||||||
        <div class="columns is-multiline">
 | 
					        <div class="columns is-multiline">
 | 
				
			||||||
            <?php foreach ($artists as $artist): ?>
 | 
					            <?php foreach ($artists as $artist): ?>
 | 
				
			||||||
                <div class="column is-one-quarter-desktop is-half-tablet is-full-mobile">
 | 
					                <div class="column is-one-quarter">
 | 
				
			||||||
                    <div class="card artist-card">
 | 
					                    <div class="card">
 | 
				
			||||||
                        <div class="card-content">
 | 
					                        <div class="card-content">
 | 
				
			||||||
                            <div class="media">
 | 
					                            <div class="content">
 | 
				
			||||||
                                <div class="media-content">
 | 
					                                <a href="<?= site_url('artistes/view/'.$artist->artistId) ?>"><?= $artist->artistName ?></a>
 | 
				
			||||||
                                    <p class="title is-4 artist-title"><?= anchor("artistes/view/{$artist->artistId}", $artist->artistName) ?></p>
 | 
					                                <?php if ($is_logged_in): ?>
 | 
				
			||||||
                                    <?php if (isset($is_logged_in) && $is_logged_in): ?>
 | 
					                                    <form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
 | 
				
			||||||
                                        <form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
 | 
					                                        <input type="hidden" name="itemId" value="<?= $artist->artistId ?>">
 | 
				
			||||||
                                            <input type="hidden" name="itemId" value="<?= $artist->artistId ?>">
 | 
					                                        <input type="hidden" name="itemType" value="artist">
 | 
				
			||||||
                                            <input type="hidden" name="itemType" value="artist">
 | 
					                                        <button type="submit" class="button is-link">Ajouter à la playlist</button>
 | 
				
			||||||
                                            <button type="submit" class="button is-link">Ajouter à la playlist</button>
 | 
					                                    </form>
 | 
				
			||||||
                                        </form>
 | 
					                                <?php endif; ?>
 | 
				
			||||||
                                    <?php endif; ?>
 | 
					 | 
				
			||||||
                                </div>
 | 
					 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            <?php endforeach; ?>
 | 
					            <?php endforeach; ?>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					        <!-- Pagination -->
 | 
				
			||||||
 | 
					        <nav class="pagination" role="navigation" aria-label="pagination">
 | 
				
			||||||
 | 
					            <?= $pagination ?>
 | 
				
			||||||
 | 
					        </nav>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</section>
 | 
					</section>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					    .pagination a, .pagination span {
 | 
				
			||||||
 | 
					        padding: 8px 12px;
 | 
				
			||||||
 | 
					        margin: 0 2px;
 | 
				
			||||||
 | 
					        border-radius: 4px;
 | 
				
			||||||
 | 
					        border: 1px solid #ddd;
 | 
				
			||||||
 | 
					        color: #333;
 | 
				
			||||||
 | 
					        text-decoration: none;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    .pagination a:hover {
 | 
				
			||||||
 | 
					        background-color: #f0f0f0;
 | 
				
			||||||
 | 
					        border-color: #bbb;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    .pagination .is-current {
 | 
				
			||||||
 | 
					        background-color: #3273dc;
 | 
				
			||||||
 | 
					        border-color: #3273dc;
 | 
				
			||||||
 | 
					        color: #fff;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
<div class="box">
 | 
					<div class="box">
 | 
				
			||||||
    <div class="field">
 | 
					    <div class="field">
 | 
				
			||||||
        <!-- Champ de recherche -->
 | 
					        <form method="GET" action="<?= site_url($this->uri->segment(1) . '/index') ?>">
 | 
				
			||||||
        <form method="GET" action="">
 | 
					 | 
				
			||||||
            <div class="control has-icons-left">
 | 
					            <div class="control has-icons-left">
 | 
				
			||||||
                <input class="input is-dark" type="text" name="query" placeholder="Rechercher..." value="<?= isset($_GET['query']) ? $_GET['query'] : '' ?>">
 | 
					                <input class="input is-dark" type="text" name="query" placeholder="Rechercher..." value="<?= isset($_GET['query']) ? $_GET['query'] : '' ?>">
 | 
				
			||||||
                <span class="icon is-left">
 | 
					                <span class="icon is-left">
 | 
				
			||||||
@@ -9,24 +8,21 @@
 | 
				
			|||||||
                </span>
 | 
					                </span>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
        </form>
 | 
					        </form>
 | 
				
			||||||
 | 
					 | 
				
			||||||
        <!-- Bouton pour afficher/masquer les filtres -->
 | 
					 | 
				
			||||||
        <button class="button is-dark" type="button" onclick="toggleFilters()">Filtrer</button>
 | 
					        <button class="button is-dark" type="button" onclick="toggleFilters()">Filtrer</button>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <!-- Div contenant les filtres, cachée par défaut -->
 | 
					 | 
				
			||||||
    <div id="filters" style="display: none;">
 | 
					    <div id="filters" style="display: none;">
 | 
				
			||||||
        <form method="GET" action="">
 | 
					        <form method="GET" action="<?= site_url($this->uri->segment(1) . '/index') ?>">
 | 
				
			||||||
 | 
					            <input type="hidden" name="query" value="<?= isset($_GET['query']) ? $_GET['query'] : '' ?>">
 | 
				
			||||||
            <?php if ($this->uri->segment(1) != 'artistes'): ?>
 | 
					            <?php if ($this->uri->segment(1) != 'artistes'): ?>
 | 
				
			||||||
            <!-- Filtre par artiste -->
 | 
					 | 
				
			||||||
            <div class="field">
 | 
					            <div class="field">
 | 
				
			||||||
                <label class="label" for="artist">Artiste</label>
 | 
					                <label class="label" for="artist">Artiste</label>
 | 
				
			||||||
                <div class="control">
 | 
					                <div class="control">
 | 
				
			||||||
                    <div class="select is-dark">
 | 
					                    <div class="select is-dark">
 | 
				
			||||||
                        <select name="artist" id="artist" onchange="this.form.submit()">
 | 
					                        <select name="artist" id="artist" onchange="this.form.submit()">
 | 
				
			||||||
                            <option value=''>Tous</option>
 | 
					                            <option value=''>Tous</option>
 | 
				
			||||||
                            <?php foreach($artistes as $artiste): ?>
 | 
					                            <?php foreach($artists as $artist): ?>
 | 
				
			||||||
                                <option value="<?= $artiste->name ?>" <?= isset($_GET['artist']) && $_GET['artist'] == $artiste->name ? 'selected' : '' ?>><?= $artiste->name ?></option>
 | 
					                                <option value="<?= $artist->name ?>" <?= isset($_GET['artist']) && $_GET['artist'] == $artist->name ? 'selected' : '' ?>><?= $artist->name ?></option>
 | 
				
			||||||
                            <?php endforeach; ?>
 | 
					                            <?php endforeach; ?>
 | 
				
			||||||
                        </select>
 | 
					                        </select>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
@@ -34,7 +30,6 @@
 | 
				
			|||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <?php endif; ?>
 | 
					            <?php endif; ?>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <!-- Filtre par genre -->
 | 
					 | 
				
			||||||
            <div class="field">
 | 
					            <div class="field">
 | 
				
			||||||
                <label class="label" for="genre">Genre</label>
 | 
					                <label class="label" for="genre">Genre</label>
 | 
				
			||||||
                <div class="control">
 | 
					                <div class="control">
 | 
				
			||||||
@@ -49,7 +44,6 @@
 | 
				
			|||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <!-- Filtre par ordre -->
 | 
					 | 
				
			||||||
            <div class="field">
 | 
					            <div class="field">
 | 
				
			||||||
                <label class="label" for="order">Ordre</label>
 | 
					                <label class="label" for="order">Ordre</label>
 | 
				
			||||||
                <div class="control">
 | 
					                <div class="control">
 | 
				
			||||||
@@ -67,7 +61,6 @@
 | 
				
			|||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
    // Fonction pour afficher/masquer les filtres
 | 
					 | 
				
			||||||
    function toggleFilters() {
 | 
					    function toggleFilters() {
 | 
				
			||||||
        var filters = document.getElementById('filters');
 | 
					        var filters = document.getElementById('filters');
 | 
				
			||||||
        if (filters.style.display === 'none') {
 | 
					        if (filters.style.display === 'none') {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@
 | 
				
			|||||||
    <link rel="stylesheet" href="<?= base_url('assets/style.css') ?>">
 | 
					    <link rel="stylesheet" href="<?= base_url('assets/style.css') ?>">
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
    <nav class="navbar">
 | 
					    <nav class="navbar is-fixed-top">
 | 
				
			||||||
        <div class="container">
 | 
					        <div class="container">
 | 
				
			||||||
            <div class="navbar-brand">
 | 
					            <div class="navbar-brand">
 | 
				
			||||||
                <a class="navbar-item" href="#">
 | 
					                <a class="navbar-item" href="#">
 | 
				
			||||||
@@ -45,4 +45,24 @@
 | 
				
			|||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
    </nav>
 | 
					    </nav>
 | 
				
			||||||
    <main class="container" style="padding-top: 90px;"> <!-- Ajout de padding-top pour éviter que la navbar ne masque le contenu -->
 | 
					    <main class="container" style="padding-top: 90px;">
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <script>
 | 
				
			||||||
 | 
					        document.addEventListener('DOMContentLoaded', () => {
 | 
				
			||||||
 | 
					            const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($navbarBurgers.length > 0) {
 | 
				
			||||||
 | 
					                $navbarBurgers.forEach(el => {
 | 
				
			||||||
 | 
					                    el.addEventListener('click', () => {
 | 
				
			||||||
 | 
					                        const target = el.dataset.target;
 | 
				
			||||||
 | 
					                        const $target = document.getElementById(target);
 | 
				
			||||||
 | 
					                        el.classList.toggle('is-active');
 | 
				
			||||||
 | 
					                        $target.classList.toggle('is-active');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    </script>
 | 
				
			||||||
 | 
					</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,5 +29,36 @@
 | 
				
			|||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            <?php endforeach; ?>
 | 
					            <?php endforeach; ?>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					        <!-- Pagination -->
 | 
				
			||||||
 | 
					        <nav class="pagination" role="navigation" aria-label="pagination">
 | 
				
			||||||
 | 
					                <?= $pagination ?>
 | 
				
			||||||
 | 
					            </nav>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</section>
 | 
					</section>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.pagination a, .pagination span {
 | 
				
			||||||
 | 
					    padding: 8px 12px;
 | 
				
			||||||
 | 
					    margin: 0 2px;
 | 
				
			||||||
 | 
					    border-radius: 4px;
 | 
				
			||||||
 | 
					    border: 1px solid #ddd;
 | 
				
			||||||
 | 
					    color: #333;
 | 
				
			||||||
 | 
					    text-decoration: none;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.pagination a:hover {
 | 
				
			||||||
 | 
					    background-color: #f0f0f0;
 | 
				
			||||||
 | 
					    border-color: #bbb;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.pagination .is-current {
 | 
				
			||||||
 | 
					    background-color: #3273dc;
 | 
				
			||||||
 | 
					    border-color: #3273dc;
 | 
				
			||||||
 | 
					    color: #fff;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@
 | 
				
			|||||||
        <h1 class="title">Détails de la Playlist</h1>
 | 
					        <h1 class="title">Détails de la Playlist</h1>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <?php if ($items): ?>
 | 
					        <?php if ($items): ?>
 | 
				
			||||||
 | 
					            <p><strong>Nombre de chansons:</strong> <?= $itemCount ?></p>
 | 
				
			||||||
            <div class="table-container" style="max-height: 400px; overflow-y: auto;">
 | 
					            <div class="table-container" style="max-height: 400px; overflow-y: auto;">
 | 
				
			||||||
                <table class="table is-fullwidth is-striped">
 | 
					                <table class="table is-fullwidth is-striped">
 | 
				
			||||||
                    <thead>
 | 
					                    <thead>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,18 +17,18 @@
 | 
				
			|||||||
                                <div class="media">
 | 
					                                <div class="media">
 | 
				
			||||||
                                    <div class="media-content">
 | 
					                                    <div class="media-content">
 | 
				
			||||||
                                        <p class="title is-4"><?= anchor("playlist/view/{$playlist->id}", $playlist->name) ?></p>
 | 
					                                        <p class="title is-4"><?= anchor("playlist/view/{$playlist->id}", $playlist->name) ?></p>
 | 
				
			||||||
                                    </div>
 | 
					                                        <div class="buttons">
 | 
				
			||||||
                                    <div class="media-right buttons-right">
 | 
					                                            <?= form_open('playlist/duplicate/'.$playlist->id, ['style' => 'display:inline;']) ?>
 | 
				
			||||||
                                        <?= form_open('playlist/duplicate/'.$playlist->id, ['style' => 'display:inline;']) ?>
 | 
					                                                <button type="submit" class="button button-duplicate is-small">Dupliquer</button>
 | 
				
			||||||
                                            <button type="submit" class="button is-info is-small">Dupliquer</button>
 | 
					                                            <?= form_close() ?>
 | 
				
			||||||
                                        <?= form_close() ?>
 | 
					                                            <button class="button button-rename is-small" onclick="showRenameModal('<?= $playlist->id ?>', '<?= $playlist->name ?>')">Renommer</button>
 | 
				
			||||||
                                        <button class="button is-warning is-small" onclick="showRenameModal('<?= $playlist->id ?>', '<?= $playlist->name ?>')">Renommer</button>
 | 
					                                        </div>
 | 
				
			||||||
                                    </div>
 | 
					                                    </div>
 | 
				
			||||||
                                </div>
 | 
					                                </div>
 | 
				
			||||||
                            </div>
 | 
					                            </div>
 | 
				
			||||||
                            <footer class="card-footer">
 | 
					                            <footer class="card-footer">
 | 
				
			||||||
                                <?= form_open('playlist/delete/'.$playlist->id, ['class' => 'card-footer-item']) ?>
 | 
					                                <?= form_open('playlist/delete/'.$playlist->id, ['class' => 'card-footer-item']) ?>
 | 
				
			||||||
                                    <button type="submit" class="button is-danger is-small">Supprimer</button>
 | 
					                                    <button type="submit" class="button button-delete is-small">Supprimer</button>
 | 
				
			||||||
                                <?= form_close() ?>
 | 
					                                <?= form_close() ?>
 | 
				
			||||||
                            </footer>
 | 
					                            </footer>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
@@ -52,7 +52,7 @@
 | 
				
			|||||||
                    <div class="control">
 | 
					                    <div class="control">
 | 
				
			||||||
                        <div class="select">
 | 
					                        <div class="select">
 | 
				
			||||||
                            <select name="type" id="playlistType" onchange="toggleRandomOptions()">
 | 
					                            <select name="type" id="playlistType" onchange="toggleRandomOptions()">
 | 
				
			||||||
                                <option value="empty">Vide</option>
 | 
					                                <option value="empty" selected>Vide</option>
 | 
				
			||||||
                                <option value="random">Aléatoire</option>
 | 
					                                <option value="random">Aléatoire</option>
 | 
				
			||||||
                            </select>
 | 
					                            </select>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
@@ -63,20 +63,7 @@
 | 
				
			|||||||
                    <div class="field">
 | 
					                    <div class="field">
 | 
				
			||||||
                        <label class="label">Nombre de chansons</label>
 | 
					                        <label class="label">Nombre de chansons</label>
 | 
				
			||||||
                        <div class="control">
 | 
					                        <div class="control">
 | 
				
			||||||
                            <input type="number" name="numSongs" class="input" placeholder="Nombre de chansons">
 | 
					                            <input type="number" name="numSongs" class="input" placeholder="Nombre de chansons" min="1">
 | 
				
			||||||
                        </div>
 | 
					 | 
				
			||||||
                    </div>
 | 
					 | 
				
			||||||
                    <div class="field">
 | 
					 | 
				
			||||||
                        <label class="label">Artiste</label>
 | 
					 | 
				
			||||||
                        <div class="control">
 | 
					 | 
				
			||||||
                            <div class="select">
 | 
					 | 
				
			||||||
                                <select name="artist">
 | 
					 | 
				
			||||||
                                    <option value="">Tous</option>
 | 
					 | 
				
			||||||
                                    <?php foreach($artists as $artist): ?>
 | 
					 | 
				
			||||||
                                        <option value="<?= $artist->name ?>"><?= $artist->name ?></option>
 | 
					 | 
				
			||||||
                                    <?php endforeach; ?>
 | 
					 | 
				
			||||||
                                </select>
 | 
					 | 
				
			||||||
                            </div>
 | 
					 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    <div class="field">
 | 
					                    <div class="field">
 | 
				
			||||||
@@ -132,6 +119,10 @@
 | 
				
			|||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
 | 
					    document.addEventListener('DOMContentLoaded', function () {
 | 
				
			||||||
 | 
					        toggleRandomOptions();
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function toggleRandomOptions() {
 | 
					    function toggleRandomOptions() {
 | 
				
			||||||
        var playlistType = document.getElementById('playlistType').value;
 | 
					        var playlistType = document.getElementById('playlistType').value;
 | 
				
			||||||
        var randomOptions = document.getElementById('randomOptions');
 | 
					        var randomOptions = document.getElementById('randomOptions');
 | 
				
			||||||
@@ -152,3 +143,38 @@
 | 
				
			|||||||
        document.getElementById('renameModal').classList.remove('is-active');
 | 
					        document.getElementById('renameModal').classList.remove('is-active');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					.button-rename {
 | 
				
			||||||
 | 
					    background-color: #D17B8F; /* Rose */
 | 
				
			||||||
 | 
					    border-color: #D17B8F;
 | 
				
			||||||
 | 
					    color: #FFF;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button-rename:hover {
 | 
				
			||||||
 | 
					    background-color: #B5697D; /* Rose plus foncé */
 | 
				
			||||||
 | 
					    border-color: #B5697D;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button-duplicate {
 | 
				
			||||||
 | 
					    background-color: #A569BD; /* Violet */
 | 
				
			||||||
 | 
					    border-color: #A569BD;
 | 
				
			||||||
 | 
					    color: #FFF;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button-duplicate:hover {
 | 
				
			||||||
 | 
					    background-color: #8E57A8; /* Violet plus foncé */
 | 
				
			||||||
 | 
					    border-color: #8E57A8;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button-delete {
 | 
				
			||||||
 | 
					    background-color: #C3423F; /* Rougeâtre */
 | 
				
			||||||
 | 
					    border-color: #C3423F;
 | 
				
			||||||
 | 
					    color: #FFF;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.button-delete:hover {
 | 
				
			||||||
 | 
					    background-color: #A83835; /* Rougeâtre plus foncé */
 | 
				
			||||||
 | 
					    border-color: #A83835;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,31 +1,37 @@
 | 
				
			|||||||
<section class="section">
 | 
					<section class="section">
 | 
				
			||||||
    <div class="container">
 | 
					    <div class="container">
 | 
				
			||||||
        <h1 class="title is-4">Sélectionner une playlist</h1>
 | 
					        <h1 class="title">Sélectionnez une Playlist</h1>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <?php if ($playlists): ?>
 | 
					        <?php if ($is_logged_in): ?>
 | 
				
			||||||
            <form method="post" action="<?= site_url('playlist/addItems') ?>">
 | 
					            <?php if ($playlists): ?>
 | 
				
			||||||
                <input type="hidden" name="itemId" value="<?= $itemId ?>">
 | 
					                <div class="columns is-multiline">
 | 
				
			||||||
                <input type="hidden" name="itemType" value="<?= $itemType ?>">
 | 
					                    <?php foreach ($playlists as $playlist): ?>
 | 
				
			||||||
                <div class="field">
 | 
					                        <div class="column is-one-third">
 | 
				
			||||||
                    <label class="label">Choisir une playlist</label>
 | 
					                            <div class="card">
 | 
				
			||||||
                    <div class="control">
 | 
					                                <div class="card-content">
 | 
				
			||||||
                        <div class="select is-dark">
 | 
					                                    <div class="media">
 | 
				
			||||||
                            <select name="playlistId">
 | 
					                                        <div class="media-content">
 | 
				
			||||||
                                <?php foreach ($playlists as $playlist): ?>
 | 
					                                            <p class="title is-4"><?= $playlist->name ?></p>
 | 
				
			||||||
                                    <option value="<?= $playlist->id ?>"><?= $playlist->name ?></option>
 | 
					                                        </div>
 | 
				
			||||||
                                <?php endforeach; ?>
 | 
					                                    </div>
 | 
				
			||||||
                            </select>
 | 
					                                </div>
 | 
				
			||||||
 | 
					                                <footer class="card-footer">
 | 
				
			||||||
 | 
					                                    <?= form_open('playlist/addItems') ?>
 | 
				
			||||||
 | 
					                                        <input type="hidden" name="playlistId" value="<?= $playlist->id ?>">
 | 
				
			||||||
 | 
					                                        <input type="hidden" name="itemId" value="<?= $itemId ?>">
 | 
				
			||||||
 | 
					                                        <input type="hidden" name="itemType" value="<?= $itemType ?>">
 | 
				
			||||||
 | 
					                                        <button type="submit" class="button is-link card-footer-item">Ajouter</button>
 | 
				
			||||||
 | 
					                                    <?= form_close() ?>
 | 
				
			||||||
 | 
					                                </footer>
 | 
				
			||||||
 | 
					                            </div>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </div>
 | 
					                    <?php endforeach; ?>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div class="field">
 | 
					            <?php else: ?>
 | 
				
			||||||
                    <div class="control">
 | 
					                <p>Vous n'avez pas encore de playlists.</p>
 | 
				
			||||||
                        <button type="submit" class="button is-link">Ajouter</button>
 | 
					            <?php endif; ?>
 | 
				
			||||||
                    </div>
 | 
					 | 
				
			||||||
                </div>
 | 
					 | 
				
			||||||
            </form>
 | 
					 | 
				
			||||||
        <?php else: ?>
 | 
					        <?php else: ?>
 | 
				
			||||||
            <p>Vous n'avez pas encore de playlists. Veuillez en créer une.</p>
 | 
					            <p>Vous devez être connecté pour ajouter des éléments à une playlist.</p>
 | 
				
			||||||
        <?php endif; ?>
 | 
					        <?php endif; ?>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</section>
 | 
					</section>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,11 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					function format_duration($seconds) {
 | 
				
			||||||
 | 
					    $minutes = floor($seconds / 60);
 | 
				
			||||||
 | 
					    $seconds = $seconds % 60;
 | 
				
			||||||
 | 
					    return sprintf("%02d:%02d", $minutes, $seconds);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					?>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!DOCTYPE html>
 | 
					<!DOCTYPE html>
 | 
				
			||||||
<html>
 | 
					<html>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
@@ -15,11 +23,37 @@
 | 
				
			|||||||
                    </figure>
 | 
					                    </figure>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <div class="column">
 | 
					                <div class="column">
 | 
				
			||||||
                    <p><strong>Album:</strong> <?= anchor("albums/view/{$song['albumId']}", $song['albumName']) ?> (<?= $song['year'] ?>)</p>
 | 
					                    <div class="table-container">
 | 
				
			||||||
                    <p><strong>Artist:</strong> <?= $song['artistName'] ?></p>
 | 
					                        <table class="table is-striped is-fullwidth">
 | 
				
			||||||
                    <p><strong>Disk Number:</strong> <?= $song['diskNumber'] ?></p>
 | 
					                            <tbody>
 | 
				
			||||||
                    <p><strong>Track Number:</strong> <?= $song['number'] ?></p>
 | 
					                                <tr>
 | 
				
			||||||
                    <p><strong>Duration:</strong> <?= $song['duration'] ?> seconds</p>
 | 
					                                    <th>Album</th>
 | 
				
			||||||
 | 
					                                    <td><?= anchor("albums/view/{$song['albumId']}", $song['albumName']) ?> (<?= $song['year'] ?>)</td>
 | 
				
			||||||
 | 
					                                </tr>
 | 
				
			||||||
 | 
					                                <tr>
 | 
				
			||||||
 | 
					                                    <th>Artist</th>
 | 
				
			||||||
 | 
					                                    <td><?= $song['artistName'] ?></td>
 | 
				
			||||||
 | 
					                                </tr>
 | 
				
			||||||
 | 
					                                <tr>
 | 
				
			||||||
 | 
					                                    <th>Disk Number</th>
 | 
				
			||||||
 | 
					                                    <td><?= $song['diskNumber'] ?></td>
 | 
				
			||||||
 | 
					                                </tr>
 | 
				
			||||||
 | 
					                                <tr>
 | 
				
			||||||
 | 
					                                    <th>Track Number</th>
 | 
				
			||||||
 | 
					                                    <td><?= $song['number'] ?></td>
 | 
				
			||||||
 | 
					                                </tr>
 | 
				
			||||||
 | 
					                                <tr>
 | 
				
			||||||
 | 
					                                    <th>Duration</th>
 | 
				
			||||||
 | 
					                                    <td><?= format_duration($song['duration']) ?></td>
 | 
				
			||||||
 | 
					                                </tr>
 | 
				
			||||||
 | 
					                            </tbody>
 | 
				
			||||||
 | 
					                        </table>
 | 
				
			||||||
 | 
					                    </div>
 | 
				
			||||||
 | 
					                    <form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
 | 
				
			||||||
 | 
					                        <input type="hidden" name="itemId" value="<?= $song['songId'] ?>">
 | 
				
			||||||
 | 
					                        <input type="hidden" name="itemType" value="song">
 | 
				
			||||||
 | 
					                        <button type="submit" class="button is-link">Ajouter à la playlist</button>
 | 
				
			||||||
 | 
					                    </form>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,3 +36,23 @@
 | 
				
			|||||||
    width: 100%;
 | 
					    width: 100%;
 | 
				
			||||||
    height: auto;
 | 
					    height: auto;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.pagination a, .pagination span {
 | 
				
			||||||
 | 
					    padding: 8px 12px;
 | 
				
			||||||
 | 
					    margin: 0 2px;
 | 
				
			||||||
 | 
					    border-radius: 4px;
 | 
				
			||||||
 | 
					    border: 1px solid #ddd;
 | 
				
			||||||
 | 
					    color: #333;
 | 
				
			||||||
 | 
					    text-decoration: none;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.pagination a:hover {
 | 
				
			||||||
 | 
					    background-color: #f0f0f0;
 | 
				
			||||||
 | 
					    border-color: #bbb;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.pagination .is-current {
 | 
				
			||||||
 | 
					    background-color: #3273dc;
 | 
				
			||||||
 | 
					    border-color: #3273dc;
 | 
				
			||||||
 | 
					    color: #fff;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -297,7 +297,7 @@ class CI_Pagination {
 | 
				
			|||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * @var	bool
 | 
						 * @var	bool
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	protected $reuse_query_string = FALSE;
 | 
						protected $reuse_query_string = TRUE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Use global URL suffix flag
 | 
						 * Use global URL suffix flag
 | 
				
			||||||
@@ -523,7 +523,7 @@ class CI_Pagination {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// If something isn't quite right, back to the default base page.
 | 
							// If something isn't quite right, back to the default base page.
 | 
				
			||||||
		if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
 | 
							if ( ! ctype_digit((string) $this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			$this->cur_page = $base_page;
 | 
								$this->cur_page = $base_page;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user