2024-05-20 21:59:37 +02:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Musiques 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-20 21:59:37 +02:00
|
|
|
$this->load->library('pagination');
|
|
|
|
$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-20 21:59:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index($page = 1){
|
2024-05-30 14:38:38 +02:00
|
|
|
$limit = 30;
|
2024-05-20 21:59:37 +02:00
|
|
|
$offset = ($page - 1) * $limit;
|
2024-05-22 22:05:48 +02:00
|
|
|
$sort = $this->input->get('sort');
|
2024-05-30 14:38:38 +02:00
|
|
|
$genre_id = $this->input->get('genre_id');
|
|
|
|
$artist_id = $this->input->get('artist_id');
|
2024-05-22 22:05:48 +02:00
|
|
|
|
2024-05-30 14:38:38 +02:00
|
|
|
$musiques = $this->Model_music->getMusiques($limit, $offset, $sort, 'ASC', $genre_id, $artist_id);
|
2024-06-07 13:41:17 +02:00
|
|
|
$total_musiques = $this->Model_music->get_total_musiques_filtered($genre_id, $artist_id); // Utiliser la nouvelle méthode ici
|
|
|
|
$total_pages = ceil($total_musiques / $limit);
|
|
|
|
|
2024-06-06 21:39:22 +02:00
|
|
|
// Vérifier si la page demandée est valide
|
|
|
|
if ($page < 1 || $page > $total_pages) {
|
|
|
|
redirect('errors/error_404');
|
|
|
|
return;
|
|
|
|
}
|
2024-06-07 13:41:17 +02:00
|
|
|
|
2024-05-22 22:05:48 +02:00
|
|
|
$current_page = $page;
|
2024-05-30 14:38:38 +02:00
|
|
|
$genres = $this->Model_music->getGenres();
|
|
|
|
$artists = $this->Model_music->getArtists();
|
2024-06-07 13:41:17 +02:00
|
|
|
|
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-06-07 13:41:17 +02:00
|
|
|
|
2024-05-20 21:59:37 +02:00
|
|
|
$data['musiques'] = $musiques;
|
2024-05-22 22:05:48 +02:00
|
|
|
$data['total_pages'] = $total_pages;
|
|
|
|
$data['current_page'] = $current_page;
|
2024-05-30 14:38:38 +02:00
|
|
|
$data['sort'] = $sort;
|
|
|
|
$data['genres'] = $genres;
|
|
|
|
$data['artists'] = $artists;
|
|
|
|
$data['genre_id'] = $genre_id;
|
|
|
|
$data['artist_id'] = $artist_id;
|
|
|
|
|
|
|
|
$data['title'] = "Musiques - Onzeur";
|
|
|
|
$data['css'] = "assets/css/musiques_list";
|
2024-05-20 22:42:38 +02:00
|
|
|
|
2024-05-30 13:49:35 +02:00
|
|
|
$this->load->view('layout/header_dark', $data);
|
2024-05-30 14:38:38 +02:00
|
|
|
$this->load->view('musiques_list', $data);
|
2024-05-25 01:13:18 +02:00
|
|
|
$this->load->view('layout/footer_dark');
|
2024-06-07 13:41:17 +02:00
|
|
|
}
|
2024-05-20 22:42:38 +02:00
|
|
|
|
2024-05-20 21:59:37 +02:00
|
|
|
}
|