2024-05-19 15:27:13 +02:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Albums extends CI_Controller {
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->model('model_music');
|
2024-05-31 11:35:07 +02:00
|
|
|
$this->load->model('Model_playlist');
|
2024-05-19 15:27:13 +02:00
|
|
|
$this->load->helper('url');
|
2024-05-23 11:52:41 +02:00
|
|
|
$this->load->helper('html');
|
2024-05-31 11:35:07 +02:00
|
|
|
$this->load->library('session');
|
2024-05-19 15:27:13 +02:00
|
|
|
}
|
2024-05-20 18:18:00 +02:00
|
|
|
|
2024-05-20 16:31:29 +02:00
|
|
|
public function index($page = 1){
|
2024-05-22 20:03:53 +02:00
|
|
|
$limit = 21; // Nombre d'albums max par page
|
2024-05-19 15:27:13 +02:00
|
|
|
$offset = ($page - 1) * $limit;
|
2024-05-20 18:18:00 +02:00
|
|
|
|
2024-05-22 20:59:59 +02:00
|
|
|
// Récupérer les paramètres de tri et de filtre
|
|
|
|
$order_by = $this->input->get('order_by') ? $this->input->get('order_by') : 'year';
|
|
|
|
$genre_id = $this->input->get('genre_id');
|
|
|
|
$artist_id = $this->input->get('artist_id');
|
|
|
|
|
|
|
|
$albums = $this->model_music->getAlbums($limit, $offset, $order_by, $genre_id, $artist_id);
|
|
|
|
$total_albums = $this->model_music->get_total_albums($genre_id, $artist_id);
|
|
|
|
|
2024-05-31 11:35:07 +02:00
|
|
|
if ($this->session->userdata('user_id')) {
|
|
|
|
$user_id = $this->session->userdata('user_id');
|
|
|
|
$data['user_playlists'] = $this->Model_playlist->get_user_playlists($user_id);
|
|
|
|
}
|
|
|
|
|
2024-05-19 15:27:13 +02:00
|
|
|
$data['total_pages'] = ceil($total_albums / $limit);
|
|
|
|
$data['current_page'] = $page;
|
2024-05-19 15:57:25 +02:00
|
|
|
$data['albums'] = $albums;
|
2024-05-22 20:59:59 +02:00
|
|
|
$data['order_by'] = $order_by;
|
|
|
|
$data['genre_id'] = $genre_id;
|
|
|
|
$data['artist_id'] = $artist_id;
|
2024-05-30 13:49:35 +02:00
|
|
|
$data['title']= 'Albums - Onzeur';
|
|
|
|
$data['css']='assets/css/style';
|
2024-05-22 20:59:59 +02:00
|
|
|
|
|
|
|
// Récupérer les genres et les artistes pour les filtres
|
|
|
|
$data['genres'] = $this->model_music->getGenres();
|
|
|
|
$data['artists'] = $this->model_music->getArtists();
|
2024-05-23 14:33:23 +02:00
|
|
|
|
2024-05-30 13:49:35 +02:00
|
|
|
$this->load->view('layout/header_dark', $data);
|
|
|
|
$this->load->view('albums_list',$data);
|
2024-05-25 01:13:18 +02:00
|
|
|
$this->load->view('layout/footer_dark');
|
2024-05-19 15:27:13 +02:00
|
|
|
}
|
2024-05-20 18:18:00 +02:00
|
|
|
|
|
|
|
public function view($id){
|
2024-06-06 12:07:45 +02:00
|
|
|
[$album,$tracks] = $this->model_music->get_album_by_id($id);
|
2024-05-20 18:18:00 +02:00
|
|
|
$data['album'] = $album;
|
2024-05-30 16:13:46 +02:00
|
|
|
$data['title'] = $album->name." - Details";
|
|
|
|
$data['css']='assets/css/album_view';
|
2024-06-06 12:07:45 +02:00
|
|
|
$data['tracks'] = $tracks;
|
|
|
|
if ($this->session->userdata('user_id')) {
|
|
|
|
$user_id = $this->session->userdata('user_id');
|
|
|
|
$data['user_playlists'] = $this->Model_playlist->get_user_playlists($user_id);
|
|
|
|
}
|
2024-05-30 16:13:46 +02:00
|
|
|
|
2024-05-30 13:49:35 +02:00
|
|
|
$this->load->view('layout/header_dark', $data);
|
2024-05-30 16:13:46 +02:00
|
|
|
$this->load->view('album_view');
|
2024-05-25 01:13:18 +02:00
|
|
|
$this->load->view('layout/footer_dark');
|
2024-05-20 18:18:00 +02:00
|
|
|
}
|
2024-05-19 15:27:13 +02:00
|
|
|
}
|
2024-05-20 18:18:00 +02:00
|
|
|
?>
|