vaujdui
This commit is contained in:
parent
9436fd05cc
commit
6bfbf46dcc
application
controllers
models
views
assets
system/libraries
@ -5,27 +5,56 @@ class Albums extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->model('Model_album');
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('session');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$order = $this->input->get('order');
|
||||
$genre = $this->input->get('genre');
|
||||
$order = $this->input->get('order');
|
||||
$artist = $this->input->get('artist');
|
||||
$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();
|
||||
$artists = $this->model_music->nameArtist();
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
$page = $this->input->get('page');
|
||||
$page = ($page) ? $page : 0;
|
||||
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$data = array(
|
||||
'albums' => $albums,
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'genres' => $genres,
|
||||
'artistes' => $artists
|
||||
'albums' => $this->Model_album->getAlbums($genre, $order, $artist, $query, $config['per_page'], $page),
|
||||
'genres' => $this->Model_album->getGenres(),
|
||||
'artists' => $this->Model_album->getArtists(),
|
||||
'is_logged_in' => $this->session->userdata('logged_in'),
|
||||
'pagination' => $this->pagination->create_links()
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
@ -35,17 +64,21 @@ class Albums extends CI_Controller {
|
||||
}
|
||||
|
||||
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(
|
||||
'album' => $albumData['album'],
|
||||
'songs' => $albumData['songs'],
|
||||
'is_logged_in' => $is_logged_in
|
||||
'album' => $albumDetails['album'],
|
||||
'songs' => $albumDetails['songs'],
|
||||
'is_logged_in' => $this->session->userdata('logged_in')
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('album_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Artistes extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->library('session');
|
||||
$this->load->model('Model_artist');
|
||||
$this->load->model('Model_music');
|
||||
$this->load->library('pagination');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
@ -14,14 +14,29 @@ class Artistes extends CI_Controller {
|
||||
$order = $this->input->get('order');
|
||||
$query = $this->input->get('query');
|
||||
|
||||
$artists = $this->model_music->getArtists($genre, $order, $query);
|
||||
$genres = $this->model_music->researchtype();
|
||||
// Configuration de la pagination
|
||||
$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(
|
||||
'artists' => $artists,
|
||||
'genres' => $genres,
|
||||
'is_logged_in' => $is_logged_in
|
||||
'artists' => $this->Model_artist->getArtists($genre, $order, $query, $config['per_page'], $page),
|
||||
'genres' => $this->Model_music->researchtype(),
|
||||
'pagination' => $pagination_links,
|
||||
'is_logged_in' => $this->session->userdata('logged_in')
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
@ -30,20 +45,26 @@ class Artistes extends CI_Controller {
|
||||
$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(
|
||||
'artist' => $artist,
|
||||
'artist' => $artistDetails,
|
||||
'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('artist_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -5,7 +5,8 @@ class Music extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->model('Model_music');
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('session');
|
||||
}
|
||||
|
||||
@ -15,16 +16,45 @@ class Music extends CI_Controller {
|
||||
$artist = $this->input->get('artist');
|
||||
$query = $this->input->get('query');
|
||||
|
||||
$musics = $this->model_music->getMusics($genre, $order, $artist, $query);
|
||||
$genres = $this->model_music->researchtype();
|
||||
$artists = $this->model_music->nameArtist(); // S'assurer que cette méthode récupère bien les artistes
|
||||
// Configuration de la pagination
|
||||
$config = array();
|
||||
$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(
|
||||
'musics' => $musics,
|
||||
'genres' => $genres,
|
||||
'artistes' => $artists, // Passer les artistes à la vue
|
||||
'is_logged_in' => $is_logged_in
|
||||
'musics' => $this->Model_music->getMusics($genre, $order, $artist, $query, $config['per_page'], $page),
|
||||
'genres' => $this->Model_music->researchtype(),
|
||||
'artists' => $this->Model_music->nameArtist(),
|
||||
'is_logged_in' => $this->session->userdata('logged_in'),
|
||||
'pagination' => $this->pagination->create_links()
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
@ -34,7 +64,7 @@ class Music extends CI_Controller {
|
||||
}
|
||||
|
||||
public function view($songId) {
|
||||
$songData = $this->model_music->getSongDetails($songId);
|
||||
$songData = $this->Model_music->getSongDetails($songId);
|
||||
|
||||
if (!$songData) {
|
||||
show_404();
|
||||
@ -50,6 +80,6 @@ class Music extends CI_Controller {
|
||||
$this->load->view('song_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,22 +5,20 @@ class Playlist extends CI_Controller {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('Model_playlist');
|
||||
$this->load->model('Model_music'); // Ajouté pour accéder aux musiques
|
||||
$this->load->model('Model_music');
|
||||
$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');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'playlists' => $this->Model_playlist->getPlaylistsByUser($user_email)
|
||||
);
|
||||
$data['is_logged_in'] = $is_logged_in;
|
||||
$data['playlists'] = $this->Model_playlist->getPlaylistsByUser($user_email);
|
||||
$data['genres'] = $this->Model_playlist->getGenres();
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
$this->load->view('playlists_list', $data);
|
||||
@ -31,18 +29,24 @@ class Playlist extends CI_Controller {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$name = $this->input->post('name');
|
||||
$type = $this->input->post('type');
|
||||
$numSongs = $this->input->post('numSongs');
|
||||
$genre = $this->input->post('genre');
|
||||
|
||||
if ($type == 'random') {
|
||||
$numSongs = $this->input->post('numSongs');
|
||||
$artist = $this->input->post('artist');
|
||||
$genre = $this->input->post('genre');
|
||||
$this->Model_playlist->createRandomPlaylist($user_email, $name, $numSongs, $artist, $genre);
|
||||
if ($numSongs <= 0) {
|
||||
$data['error'] = 'Le nombre de chansons doit être supérieur à 0';
|
||||
$this->index($data);
|
||||
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 {
|
||||
$this->Model_playlist->addPlaylist($user_email, $name);
|
||||
}
|
||||
@ -51,11 +55,13 @@ class Playlist extends CI_Controller {
|
||||
}
|
||||
|
||||
public function selectPlaylist() {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$itemId = $this->input->post('itemId');
|
||||
$itemType = $this->input->post('itemType');
|
||||
$playlists = $this->Model_playlist->getPlaylistsByUser($this->session->userdata('email'));
|
||||
|
||||
$data = array(
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'itemId' => $itemId,
|
||||
'itemType' => $itemType,
|
||||
'playlists' => $playlists
|
||||
@ -74,14 +80,14 @@ class Playlist extends CI_Controller {
|
||||
if ($itemType == 'album') {
|
||||
$songs = $this->Model_music->getSongsByAlbum($itemId);
|
||||
foreach ($songs as $song) {
|
||||
$this->Model_playlist->addItem($playlistId, $song->id, 'song');
|
||||
$this->Model_playlist->addItem($playlistId, $song->trackId, 'song');
|
||||
}
|
||||
} else if ($itemType == 'artist') {
|
||||
$albums = $this->Model_music->getAlbumsByArtist($itemId);
|
||||
foreach ($albums as $album) {
|
||||
$songs = $this->Model_music->getSongsByAlbum($album->albumId);
|
||||
foreach ($songs as $song) {
|
||||
$this->Model_playlist->addItem($playlistId, $song->id, 'song');
|
||||
$this->Model_playlist->addItem($playlistId, $song->trackId, 'song');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -94,9 +100,12 @@ class Playlist extends CI_Controller {
|
||||
public function view($playlistId) {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$items = $this->Model_playlist->getPlaylistItems($playlistId);
|
||||
$itemCount = $this->Model_playlist->getPlaylistItemCount($playlistId);
|
||||
|
||||
$data = array(
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'items' => $items
|
||||
'items' => $items,
|
||||
'itemCount' => $itemCount
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
@ -113,10 +122,6 @@ class Playlist extends CI_Controller {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$this->Model_playlist->deletePlaylist($playlist_id);
|
||||
redirect('playlist');
|
||||
}
|
||||
@ -125,10 +130,6 @@ class Playlist extends CI_Controller {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$this->Model_playlist->duplicatePlaylist($playlist_id, $user_email);
|
||||
redirect('playlist');
|
||||
}
|
||||
@ -137,10 +138,6 @@ class Playlist extends CI_Controller {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
|
||||
if (!$is_logged_in) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$playlistId = $this->input->post('playlistId');
|
||||
$newName = $this->input->post('newName');
|
||||
|
||||
@ -148,4 +145,3 @@ class Playlist extends CI_Controller {
|
||||
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,7 +5,7 @@ class Model_music extends CI_Model {
|
||||
$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->from('album');
|
||||
$this->db->join('artist', 'album.artistid = artist.id');
|
||||
@ -20,16 +20,39 @@ class Model_music extends CI_Model {
|
||||
$this->db->where('artist.name', $artist);
|
||||
}
|
||||
|
||||
if (!empty($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();
|
||||
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);
|
||||
}
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function researchtype(){
|
||||
@ -46,40 +69,21 @@ class Model_music extends CI_Model {
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function getArtists($genre = '', $order = 'asc', $query = '') {
|
||||
$this->db->select('artist.name as artistName, artist.id as artistId');
|
||||
public function getArtists() {
|
||||
$this->db->select('id, name');
|
||||
$this->db->from('artist');
|
||||
$this->db->join('album', 'album.artistid = artist.id');
|
||||
$this->db->join('genre', 'genre.id = album.genreid');
|
||||
$this->db->join('cover', 'cover.id = album.coverid');
|
||||
|
||||
$this->db->distinct("artist.name");
|
||||
|
||||
if (!empty($genre)) {
|
||||
$this->db->where('genre.name', $genre);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
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->from('track');
|
||||
$this->db->join('album', 'track.albumId = album.id');
|
||||
$this->db->join('song', 'song.id = track.songId');
|
||||
$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');
|
||||
$this->db->limit(100);
|
||||
|
||||
if (!empty($genre)) {
|
||||
$this->db->where('genre.name', $genre);
|
||||
@ -89,18 +93,68 @@ class Model_music extends CI_Model {
|
||||
$this->db->where('artist.name', $artist);
|
||||
}
|
||||
|
||||
if (!empty($query)) {
|
||||
$this->db->like('song.name', $query);
|
||||
}
|
||||
|
||||
if ($order == 'asc' || $order == 'desc') {
|
||||
$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)) {
|
||||
$this->db->like('song.name', $query);
|
||||
}
|
||||
|
||||
$result = $this->db->get();
|
||||
return $result->result();
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
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) {
|
||||
$this->db->select('album.name as albumName, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
|
||||
$this->db->from('album');
|
||||
@ -122,24 +176,13 @@ class Model_music extends CI_Model {
|
||||
}
|
||||
|
||||
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->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();
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
return $albums;
|
||||
}
|
||||
|
||||
public function getArtistDetails($artistId) {
|
||||
$this->db->select('artist.name as artistName, artist.id');
|
||||
@ -175,22 +218,35 @@ class Model_music extends CI_Model {
|
||||
}
|
||||
|
||||
public function getSongsByAlbum($albumId) {
|
||||
$this->db->select('track.id');
|
||||
$this->db->select('track.id as trackId');
|
||||
$this->db->from('track');
|
||||
$this->db->where('track.albumid', $albumId);
|
||||
$query = $this->db->get();
|
||||
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->join('album', 'track.albumid = album.id');
|
||||
$this->db->where('album.artistid', $artistId);
|
||||
$this->db->join('song', 'song.id = track.songid');
|
||||
$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();
|
||||
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 = '') {
|
||||
$this->db->select('track.id as trackId');
|
||||
@ -222,4 +278,13 @@ class Model_music extends CI_Model {
|
||||
$query = $this->db->get();
|
||||
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);
|
||||
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>
|
||||
<tr>
|
||||
<th>Titre</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($songs as $song): ?>
|
||||
<tr>
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
@ -5,14 +5,17 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Liste des Albums - Dix heures</title>
|
||||
<link rel="stylesheet" href="<?= base_url('assets/style.css') ?>">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title is-4 has-text-dark">Liste des Albums</h1>
|
||||
<div class="columns is-multiline is-centered">
|
||||
<h1 class="title">Liste des Albums</h1>
|
||||
|
||||
<!-- Liste des albums -->
|
||||
<div class="columns is-multiline">
|
||||
<?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-image">
|
||||
<figure class="image is-4by3">
|
||||
@ -22,13 +25,13 @@
|
||||
<div class="card-content">
|
||||
<div class="media">
|
||||
<div class="media-content">
|
||||
<p class="title is-4 album-title"><?= anchor("albums/view/{$album->id}", $album->name) ?></p>
|
||||
<p class="subtitle is-6"><?= "{$album->year} - {$album->artistName}" ?></p>
|
||||
<?php if (isset($is_logged_in) && $is_logged_in): ?>
|
||||
<p class="title is-4"><?= anchor("albums/view/{$album->id}", $album->name) ?></p>
|
||||
<p class="subtitle is-6"><?= $album->artistName ?> - <?= $album->year ?></p>
|
||||
<?php if ($is_logged_in): ?>
|
||||
<form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
|
||||
<input type="hidden" name="itemId" value="<?= $album->id ?>">
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -38,7 +41,64 @@
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<nav class="pagination" role="navigation" aria-label="pagination">
|
||||
<?= $pagination ?>
|
||||
</nav>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</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>Year:</strong> <?= $album->year ?></p>
|
||||
<h4 class="title is-6">Songs</h4>
|
||||
<ul>
|
||||
<div class="table-container">
|
||||
<table class="table is-striped is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Titre</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($album->songs as $song): ?>
|
||||
<li><?= anchor("music/view/{$song->trackId}", $song->songName) ?></li>
|
||||
<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; ?>
|
||||
</ul>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,15 +1,14 @@
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title is-4">Liste des Artistes</h1>
|
||||
<h1 class="title">Artistes</h1>
|
||||
<div class="columns is-multiline">
|
||||
<?php foreach ($artists as $artist): ?>
|
||||
<div class="column is-one-quarter-desktop is-half-tablet is-full-mobile">
|
||||
<div class="card artist-card">
|
||||
<div class="column is-one-quarter">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="media">
|
||||
<div class="media-content">
|
||||
<p class="title is-4 artist-title"><?= anchor("artistes/view/{$artist->artistId}", $artist->artistName) ?></p>
|
||||
<?php if (isset($is_logged_in) && $is_logged_in): ?>
|
||||
<div class="content">
|
||||
<a href="<?= site_url('artistes/view/'.$artist->artistId) ?>"><?= $artist->artistName ?></a>
|
||||
<?php if ($is_logged_in): ?>
|
||||
<form method="post" action="<?= site_url('playlist/selectPlaylist') ?>">
|
||||
<input type="hidden" name="itemId" value="<?= $artist->artistId ?>">
|
||||
<input type="hidden" name="itemType" value="artist">
|
||||
@ -20,8 +19,33 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<!-- Pagination -->
|
||||
<nav class="pagination" role="navigation" aria-label="pagination">
|
||||
<?= $pagination ?>
|
||||
</nav>
|
||||
</div>
|
||||
</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="field">
|
||||
<!-- Champ de recherche -->
|
||||
<form method="GET" action="">
|
||||
<form method="GET" action="<?= site_url($this->uri->segment(1) . '/index') ?>">
|
||||
<div class="control has-icons-left">
|
||||
<input class="input is-dark" type="text" name="query" placeholder="Rechercher..." value="<?= isset($_GET['query']) ? $_GET['query'] : '' ?>">
|
||||
<span class="icon is-left">
|
||||
@ -9,24 +8,21 @@
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Bouton pour afficher/masquer les filtres -->
|
||||
<button class="button is-dark" type="button" onclick="toggleFilters()">Filtrer</button>
|
||||
</div>
|
||||
|
||||
<!-- Div contenant les filtres, cachée par défaut -->
|
||||
<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'): ?>
|
||||
<!-- Filtre par artiste -->
|
||||
<div class="field">
|
||||
<label class="label" for="artist">Artiste</label>
|
||||
<div class="control">
|
||||
<div class="select is-dark">
|
||||
<select name="artist" id="artist" onchange="this.form.submit()">
|
||||
<option value=''>Tous</option>
|
||||
<?php foreach($artistes as $artiste): ?>
|
||||
<option value="<?= $artiste->name ?>" <?= isset($_GET['artist']) && $_GET['artist'] == $artiste->name ? 'selected' : '' ?>><?= $artiste->name ?></option>
|
||||
<?php foreach($artists as $artist): ?>
|
||||
<option value="<?= $artist->name ?>" <?= isset($_GET['artist']) && $_GET['artist'] == $artist->name ? 'selected' : '' ?>><?= $artist->name ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
@ -34,7 +30,6 @@
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Filtre par genre -->
|
||||
<div class="field">
|
||||
<label class="label" for="genre">Genre</label>
|
||||
<div class="control">
|
||||
@ -49,7 +44,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filtre par ordre -->
|
||||
<div class="field">
|
||||
<label class="label" for="order">Ordre</label>
|
||||
<div class="control">
|
||||
@ -67,7 +61,6 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Fonction pour afficher/masquer les filtres
|
||||
function toggleFilters() {
|
||||
var filters = document.getElementById('filters');
|
||||
if (filters.style.display === 'none') {
|
||||
|
@ -9,7 +9,7 @@
|
||||
<link rel="stylesheet" href="<?= base_url('assets/style.css') ?>">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar">
|
||||
<nav class="navbar is-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="#">
|
||||
@ -45,4 +45,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<!-- Pagination -->
|
||||
<nav class="pagination" role="navigation" aria-label="pagination">
|
||||
<?= $pagination ?>
|
||||
</nav>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
<?php if ($items): ?>
|
||||
<p><strong>Nombre de chansons:</strong> <?= $itemCount ?></p>
|
||||
<div class="table-container" style="max-height: 400px; overflow-y: auto;">
|
||||
<table class="table is-fullwidth is-striped">
|
||||
<thead>
|
||||
|
@ -17,18 +17,18 @@
|
||||
<div class="media">
|
||||
<div class="media-content">
|
||||
<p class="title is-4"><?= anchor("playlist/view/{$playlist->id}", $playlist->name) ?></p>
|
||||
</div>
|
||||
<div class="media-right buttons-right">
|
||||
<div class="buttons">
|
||||
<?= form_open('playlist/duplicate/'.$playlist->id, ['style' => 'display:inline;']) ?>
|
||||
<button type="submit" class="button is-info is-small">Dupliquer</button>
|
||||
<button type="submit" class="button button-duplicate is-small">Dupliquer</button>
|
||||
<?= form_close() ?>
|
||||
<button class="button is-warning is-small" onclick="showRenameModal('<?= $playlist->id ?>', '<?= $playlist->name ?>')">Renommer</button>
|
||||
<button class="button button-rename is-small" onclick="showRenameModal('<?= $playlist->id ?>', '<?= $playlist->name ?>')">Renommer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="card-footer">
|
||||
<?= 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() ?>
|
||||
</footer>
|
||||
</div>
|
||||
@ -52,7 +52,7 @@
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select name="type" id="playlistType" onchange="toggleRandomOptions()">
|
||||
<option value="empty">Vide</option>
|
||||
<option value="empty" selected>Vide</option>
|
||||
<option value="random">Aléatoire</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -63,20 +63,7 @@
|
||||
<div class="field">
|
||||
<label class="label">Nombre de chansons</label>
|
||||
<div class="control">
|
||||
<input type="number" name="numSongs" class="input" placeholder="Nombre de chansons">
|
||||
</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>
|
||||
<input type="number" name="numSongs" class="input" placeholder="Nombre de chansons" min="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
@ -132,6 +119,10 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
toggleRandomOptions();
|
||||
});
|
||||
|
||||
function toggleRandomOptions() {
|
||||
var playlistType = document.getElementById('playlistType').value;
|
||||
var randomOptions = document.getElementById('randomOptions');
|
||||
@ -152,3 +143,38 @@
|
||||
document.getElementById('renameModal').classList.remove('is-active');
|
||||
}
|
||||
</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">
|
||||
<div class="container">
|
||||
<h1 class="title is-4">Sélectionner une playlist</h1>
|
||||
<h1 class="title">Sélectionnez une Playlist</h1>
|
||||
|
||||
<?php if ($is_logged_in): ?>
|
||||
<?php if ($playlists): ?>
|
||||
<form method="post" action="<?= site_url('playlist/addItems') ?>">
|
||||
<div class="columns is-multiline">
|
||||
<?php foreach ($playlists as $playlist): ?>
|
||||
<div class="column is-one-third">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="media">
|
||||
<div class="media-content">
|
||||
<p class="title is-4"><?= $playlist->name ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</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 ?>">
|
||||
<div class="field">
|
||||
<label class="label">Choisir une playlist</label>
|
||||
<div class="control">
|
||||
<div class="select is-dark">
|
||||
<select name="playlistId">
|
||||
<?php foreach ($playlists as $playlist): ?>
|
||||
<option value="<?= $playlist->id ?>"><?= $playlist->name ?></option>
|
||||
<button type="submit" class="button is-link card-footer-item">Ajouter</button>
|
||||
<?= form_close() ?>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<button type="submit" class="button is-link">Ajouter</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<p>Vous n'avez pas encore de playlists. Veuillez en créer une.</p>
|
||||
<p>Vous n'avez pas encore de playlists.</p>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<p>Vous devez être connecté pour ajouter des éléments à une playlist.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</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>
|
||||
<html>
|
||||
<body>
|
||||
@ -15,11 +23,37 @@
|
||||
</figure>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p><strong>Album:</strong> <?= anchor("albums/view/{$song['albumId']}", $song['albumName']) ?> (<?= $song['year'] ?>)</p>
|
||||
<p><strong>Artist:</strong> <?= $song['artistName'] ?></p>
|
||||
<p><strong>Disk Number:</strong> <?= $song['diskNumber'] ?></p>
|
||||
<p><strong>Track Number:</strong> <?= $song['number'] ?></p>
|
||||
<p><strong>Duration:</strong> <?= $song['duration'] ?> seconds</p>
|
||||
<div class="table-container">
|
||||
<table class="table is-striped is-fullwidth">
|
||||
<tbody>
|
||||
<tr>
|
||||
<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>
|
||||
|
@ -36,3 +36,23 @@
|
||||
width: 100%;
|
||||
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
|
||||
*/
|
||||
protected $reuse_query_string = FALSE;
|
||||
protected $reuse_query_string = TRUE;
|
||||
|
||||
/**
|
||||
* 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 ( ! 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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user