diff --git a/CodeIgniter-3.1.13/application/controllers/Artistes.php b/CodeIgniter-3.1.13/application/controllers/Artistes.php index 03e7d68..d71eafb 100644 --- a/CodeIgniter-3.1.13/application/controllers/Artistes.php +++ b/CodeIgniter-3.1.13/application/controllers/Artistes.php @@ -8,19 +8,30 @@ class Artistes extends CI_Controller { $this->load->model('model_music'); } public function index(){ + $genre = $this->input->get('genre'); + $sort = $this->input->get('sort'); + $order = $this->input->get('order'); + if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){ $artistes = $this->model_music->getArtistes(); + $artistes = $this->model_music->get_filtered_artistes($genre, $sort, $order); + $data['artistes'] = $artistes; }else{ $recherche=filter_input(INPUT_GET,'recherche'); $artistes = $this->model_music->getSearchArtistes($recherche); + $data['artistes'] = $artistes; } $this->load->view('layout/header'); if ($artistes == false){ $page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']); $this->load->view('error',['page'=>$page[count($page)-1]]); $artistes = $this->model_music->getArtistes(); + $artistes = $this->model_music->get_filtered_artistes($genre, $sort, $order); + $data['artistes'] = $artistes; } - $this->load->view('artistes_list',['artistes'=>$artistes]); + $data['genres'] = $this->model_music->get_all_genres_artistes(); + + $this->load->view('artistes_list',$data); $this->load->view('layout/footer'); } diff --git a/CodeIgniter-3.1.13/application/models/Model_music.php b/CodeIgniter-3.1.13/application/models/Model_music.php index a8fbb1a..435893d 100644 --- a/CodeIgniter-3.1.13/application/models/Model_music.php +++ b/CodeIgniter-3.1.13/application/models/Model_music.php @@ -63,6 +63,33 @@ class Model_music extends CI_Model { return $query->result(); } + public function get_filtered_artistes($genre = [], $sort = null, $order = null) { + $this->db->distinct(); + $this->db->select('artist.Id,artist.name, genre.name as genreName'); + $this->db->from('artist'); + $this->db->join('album', 'album.artistId = artist.Id'); + $this->db->join('genre', 'album.genreId = genre.Id'); + + if (!empty($genre)) { + $this->db->where_in('genre.name', $genre); + } + if ($sort && in_array($sort, ['name'])) { + $this->db->order_by($sort, $order); + } + $query = $this->db->get(); + return $query->result(); + } + + public function get_all_genres_artistes() { + $this->db->distinct(); + $this->db->select('genreId,genre.name as genreName'); + $this->db->from('artist'); + $this->db->join('album', 'album.artistId = artist.Id'); + $this->db->join('genre', 'album.genreId = genre.Id'); + $query = $this->db->get(); + return $query->result(); + } + public function get_filtered_chansons($genre = [], $artist = [], $year = [], $album = [], $sort = null, $order = null) { $this->db->select('track.id as trackId, song.name,song.id,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName'); $this->db->from('song'); diff --git a/CodeIgniter-3.1.13/application/views/albums_list.php b/CodeIgniter-3.1.13/application/views/albums_list.php index 69bb1e3..92ad99d 100644 --- a/CodeIgniter-3.1.13/application/views/albums_list.php +++ b/CodeIgniter-3.1.13/application/views/albums_list.php @@ -72,7 +72,8 @@ window.location.href = url; } - +
Filter Albums
@@ -127,7 +128,7 @@ - +
Albums list
diff --git a/CodeIgniter-3.1.13/application/views/artistes_list.php b/CodeIgniter-3.1.13/application/views/artistes_list.php index a065e22..32781e6 100644 --- a/CodeIgniter-3.1.13/application/views/artistes_list.php +++ b/CodeIgniter-3.1.13/application/views/artistes_list.php @@ -1,10 +1,114 @@ + + + +
Filter Artiste
+ + +
+
+
+ +
+ + + + +
+
+ +
Sort Artiste
+ +
+ + +
+
Artiste list
"; echo "
"; - echo anchor("albums/viewAlbum/{$artistes->id}","{$artistes->name}"); + echo anchor("albums/viewAlbum/{$artistes->Id}","{$artistes->name}"); echo "
"; echo "
"; } diff --git a/CodeIgniter-3.1.13/application/views/chansons_list.php b/CodeIgniter-3.1.13/application/views/chansons_list.php index 9ac745c..f51be70 100644 --- a/CodeIgniter-3.1.13/application/views/chansons_list.php +++ b/CodeIgniter-3.1.13/application/views/chansons_list.php @@ -147,8 +147,10 @@ foreach($chansons as $chanson){ echo "
"; echo "
"; echo anchor("chansons/view/{$chanson->id}","{$chanson->name}"); - echo anchor("chansons/addSongtoPlaylist/{$chanson->trackId}",""); - echo "
"; + if($this->session->userdata('logged_in')){ + echo anchor("chansons/addSongtoPlaylist/{$chanson->trackId}",""); + } + echo ""; echo ""; echo ""; echo "