From eef73dd92b12eddc702490e00a1b1bc44314eb85 Mon Sep 17 00:00:00 2001 From: Vincent <xefal77@gmail.com> Date: Tue, 4 Jun 2024 21:08:14 +0200 Subject: [PATCH] Fix Erreur getter --- application/controllers/Albums.php | 1 + application/controllers/Artistes.php | 40 +++++++++++++++----------- application/controllers/Music.php | 42 +++++++++++++++++----------- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/application/controllers/Albums.php b/application/controllers/Albums.php index e0c0af3..7360c40 100644 --- a/application/controllers/Albums.php +++ b/application/controllers/Albums.php @@ -6,6 +6,7 @@ class Albums extends CI_Controller { public function __construct(){ parent::__construct(); $this->load->model('model_music'); + $this->load->library('session'); } public function index(){ diff --git a/application/controllers/Artistes.php b/application/controllers/Artistes.php index 86ccf4d..559ad0f 100644 --- a/application/controllers/Artistes.php +++ b/application/controllers/Artistes.php @@ -3,20 +3,28 @@ 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'); - } - public function index(){ - $genre = $this->input->get('genre'); - $order = $this->input->get('order'); - $artists = $this->model_music->getArtists($genre, $order); - $genres = $this->model_music->researchtype(); - $this->load->view('layout/header',['genres'=>$genres]); - $this->load->view('layout/getter', $this->session->userdata('logged_in')); - $this->load->view('artists_name',['artists'=>$artists]); - $this->load->view('layout/footer'); - } + public function __construct(){ + parent::__construct(); + $this->load->model('model_music'); + $this->load->library('session'); // La session est déjà chargée via autoload.php, mais par précaution. + } -} \ No newline at end of file + public function index(){ + $genre = $this->input->get('genre'); + $order = $this->input->get('order'); + $artists = $this->model_music->getArtists($genre, $order); + $genres = $this->model_music->researchtype(); + + $is_logged_in = $this->session->userdata('logged_in'); + $data = array( + 'artists' => $artists, + 'genres' => $genres, + 'is_logged_in' => $is_logged_in + ); + + $this->load->view('layout/header', $data); + $this->load->view('layout/getter', $data); + $this->load->view('artists_name', $data); + $this->load->view('layout/footer'); + } +} diff --git a/application/controllers/Music.php b/application/controllers/Music.php index 018087d..a5b9d22 100644 --- a/application/controllers/Music.php +++ b/application/controllers/Music.php @@ -3,23 +3,31 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class Music extends CI_Controller { - public function __construct(){ - parent::__construct(); - $this->load->model('model_music'); - $this->load->library('session'); - } + public function __construct(){ + parent::__construct(); + $this->load->model('model_music'); + $this->load->library('session'); // La session est déjà chargée via autoload.php, mais par précaution. + } - - public function index(){ - $genre = $this->input->get('genre'); - $order = $this->input->get('order'); - $musics = $this->model_music->getMusics($genre, $order); - $genres = $this->model_music->researchtype(); - $this->load->view('layout/header',['genres'=>$genres]); - $this->load->view('layout/getter', $this->session->userdata('logged_in')); - $this->load->view('musiques_name',['musics'=>$musics]); - $this->load->view('layout/footer'); - } + public function index(){ + $genre = $this->input->get('genre'); + $order = $this->input->get('order'); + $artist = $this->input->get('artist'); + $musics = $this->model_music->getMusics($genre, $order, $artist); + $genres = $this->model_music->researchtype(); + $artists = $this->model_music->nameArtist(); + $is_logged_in = $this->session->userdata('logged_in'); + $data = array( + 'musics' => $musics, + 'genres' => $genres, + 'artists' => $artists, + 'is_logged_in' => $is_logged_in + ); + + $this->load->view('layout/header', $data); + $this->load->view('layout/getter', $data); + $this->load->view('musiques_name', $data); + $this->load->view('layout/footer'); + } } -