71 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
						|
 | 
						|
class Artistes extends CI_Controller {
 | 
						|
    public function __construct() {
 | 
						|
        parent::__construct();
 | 
						|
        $this->load->model('Model_artist');
 | 
						|
        $this->load->model('Model_music');
 | 
						|
        $this->load->library('pagination');
 | 
						|
    }
 | 
						|
 | 
						|
    public function index() {
 | 
						|
        $genre = $this->input->get('genre');
 | 
						|
        $order = $this->input->get('order');
 | 
						|
        $query = $this->input->get('query');
 | 
						|
    
 | 
						|
        // 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 = '';
 | 
						|
        }
 | 
						|
    
 | 
						|
        $data = array(
 | 
						|
            '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);
 | 
						|
        $this->load->view('layout/getter', $data);
 | 
						|
        $this->load->view('artists_list', $data);
 | 
						|
        $this->load->view('layout/footer');
 | 
						|
    }
 | 
						|
    
 | 
						|
    
 | 
						|
    
 | 
						|
 | 
						|
    public function view($artistId) {
 | 
						|
        $artistDetails = $this->Model_artist->getArtistDetails($artistId);
 | 
						|
        $albums = $this->Model_artist->getAlbumsByArtist($artistId);
 | 
						|
    
 | 
						|
        if (!$artistDetails) {
 | 
						|
            show_404();
 | 
						|
        }
 | 
						|
    
 | 
						|
        $data = array(
 | 
						|
            'artist' => $artistDetails,
 | 
						|
            'albums' => $albums,
 | 
						|
            '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');
 | 
						|
    }
 | 
						|
    
 | 
						|
}
 |