85 lines
3.2 KiB
PHP
Raw Permalink Normal View History

2024-06-03 16:51:37 +02:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
2024-06-04 17:24:06 +02:00
class Artistes extends CI_Controller {
2024-06-16 17:39:26 +02:00
public function __construct() {
2024-06-04 21:08:14 +02:00
parent::__construct();
2024-06-19 14:08:59 +02:00
$this->load->model('Model_artist');
$this->load->model('Model_music');
$this->load->library('pagination');
2024-06-19 15:47:11 +02:00
$this->load->library('session');
2024-06-04 21:08:14 +02:00
}
2024-06-03 16:51:37 +02:00
2024-06-16 17:39:26 +02:00
public function index() {
2024-06-04 21:08:14 +02:00
$genre = $this->input->get('genre');
$order = $this->input->get('order');
2024-06-04 22:09:23 +02:00
$query = $this->input->get('query');
2024-06-19 14:08:59 +02:00
// 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
2024-06-19 15:47:11 +02:00
$config['page_query_string'] = TRUE;
2024-06-19 14:08:59 +02:00
$config['reuse_query_string'] = TRUE;
2024-06-19 15:47:11 +02:00
$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'] = '&laquo';
$config['prev_tag_open'] = '<li class="page-item">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '&raquo';
$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');
2024-06-19 14:08:59 +02:00
$this->pagination->initialize($config);
2024-06-19 15:47:11 +02:00
$page = $this->input->get('page');
$page = ($page) ? $page : 0;
2024-06-19 14:08:59 +02:00
2024-06-04 21:08:14 +02:00
$data = array(
2024-06-19 14:08:59 +02:00
'artists' => $this->Model_artist->getArtists($genre, $order, $query, $config['per_page'], $page),
'genres' => $this->Model_music->researchtype(),
2024-06-19 15:47:11 +02:00
'is_logged_in' => $this->session->userdata('logged_in'),
'pagination' => $this->pagination->create_links()
2024-06-04 21:08:14 +02:00
);
2024-06-19 14:08:59 +02:00
2024-06-04 21:08:14 +02:00
$this->load->view('layout/header', $data);
$this->load->view('layout/getter', $data);
2024-06-04 22:09:23 +02:00
$this->load->view('artists_list', $data);
2024-06-04 21:08:14 +02:00
$this->load->view('layout/footer');
}
2024-06-19 14:08:59 +02:00
2024-06-04 22:55:02 +02:00
public function view($artistId) {
2024-06-19 14:08:59 +02:00
$artistDetails = $this->Model_artist->getArtistDetails($artistId);
$albums = $this->Model_artist->getAlbumsByArtist($artistId);
if (!$artistDetails) {
show_404();
}
2024-06-16 17:39:26 +02:00
$data = array(
2024-06-19 14:08:59 +02:00
'artist' => $artistDetails,
2024-06-16 17:39:26 +02:00
'albums' => $albums,
2024-06-19 14:08:59 +02:00
'is_logged_in' => $this->session->userdata('logged_in')
2024-06-16 17:39:26 +02:00
);
2024-06-19 14:08:59 +02:00
2024-06-16 17:39:26 +02:00
$this->load->view('layout/header', $data);
$this->load->view('artist_details', $data);
$this->load->view('layout/footer');
}
}
2024-06-19 15:47:11 +02:00
?>