vaujdui
This commit is contained in:
		@@ -2,48 +2,69 @@
 | 
			
		||||
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() {
 | 
			
		||||
        $genre = $this->input->get('genre');
 | 
			
		||||
        $order = $this->input->get('order');
 | 
			
		||||
        $query = $this->input->get('query');
 | 
			
		||||
 | 
			
		||||
        $artists = $this->model_music->getArtists($genre, $order, $query);
 | 
			
		||||
        $genres = $this->model_music->researchtype();
 | 
			
		||||
 | 
			
		||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
			
		||||
    
 | 
			
		||||
        // 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' => $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);
 | 
			
		||||
        $this->load->view('layout/getter', $data);
 | 
			
		||||
        $this->load->view('artists_list', $data);
 | 
			
		||||
        $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');
 | 
			
		||||
        $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');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user