diff --git a/CodeIgniter-3.1.13/application/config/routes.php b/CodeIgniter-3.1.13/application/config/routes.php index db535f9..7616e69 100644 --- a/CodeIgniter-3.1.13/application/config/routes.php +++ b/CodeIgniter-3.1.13/application/config/routes.php @@ -55,5 +55,8 @@ $route['translate_uri_dashes'] = FALSE; $route['albums'] = 'albums/index'; $route['musiques'] = 'Musiques/index'; $route['artiste/(:num)'] = 'artiste/index/$1'; +$route['search'] = 'search/index'; +$route['mentions-legals'] = 'MentionsLegales/index'; + diff --git a/CodeIgniter-3.1.13/application/controllers/MentionsLegales.php b/CodeIgniter-3.1.13/application/controllers/MentionsLegales.php new file mode 100644 index 0000000..2e84b0c --- /dev/null +++ b/CodeIgniter-3.1.13/application/controllers/MentionsLegales.php @@ -0,0 +1,17 @@ +load->helper('url'); + } + + public function index() + { + $this->load->view('layout/header_not_logged_dark'); + $this->load->view('mentions-legals'); + $this->load->view('layout/footer_dark'); + } +} diff --git a/CodeIgniter-3.1.13/application/controllers/Search.php b/CodeIgniter-3.1.13/application/controllers/Search.php new file mode 100644 index 0000000..122d87a --- /dev/null +++ b/CodeIgniter-3.1.13/application/controllers/Search.php @@ -0,0 +1,33 @@ +load->model('Search_model'); + $this->load->helper('url'); + } + + public function index(){ + // Récupérer la requête de recherche depuis la barre de recherche + $query = $this->input->get('query'); + + // Faire une recherche dans les musiques, les albums, les genres et les artistes + $musiques = $this->Search_model->searchMusiques($query); + $albums = $this->Search_model->searchAlbums($query); + $genres = $this->Search_model->searchGenres($query); + $artistes = $this->Search_model->searchArtistes($query); + + // Charger la vue avec les résultats de la recherche + $data['query'] = $query; + $data['musiques'] = $musiques; + $data['albums'] = $albums; + $data['genres'] = $genres; + $data['artistes'] = $artistes; + + $this->load->view('layout/header_not_logged_dark'); + $this->load->view('search_results', $data); + $this->load->view('layout/footer_dark'); + } +} \ No newline at end of file diff --git a/CodeIgniter-3.1.13/application/models/Search_model.php b/CodeIgniter-3.1.13/application/models/Search_model.php new file mode 100644 index 0000000..7e8fb61 --- /dev/null +++ b/CodeIgniter-3.1.13/application/models/Search_model.php @@ -0,0 +1,49 @@ +load->database(); + } + + public function searchMusiques($query){ + $sql = "SELECT song.id, song.name, artist.id as artist_id, artist.name as artistName, album.name as album_name, track.albumid as album_id, cover.jpeg as cover + FROM song + JOIN track ON song.id = track.songid + JOIN album ON track.albumid = album.id + JOIN artist ON album.artistid = artist.id + JOIN cover ON album.coverid = cover.id + WHERE song.name LIKE '%$query%' + ORDER BY song.name ASC"; + + $query = $this->db->query($sql); + return $query->result(); + } + + public function searchAlbums($query){ + $sql = "SELECT album.id, album.name, album.year, artist.name as artistName, genre.name as genreName, cover.jpeg + FROM album + JOIN artist ON album.artistid = artist.id + JOIN genre ON album.genreid = genre.id + JOIN cover ON album.coverid = cover.id + WHERE album.name LIKE '%$query%' + ORDER BY album.name ASC"; + + $query = $this->db->query($sql); + return $query->result(); + } + + public function searchGenres($query){ + $sql = "SELECT id, name FROM genre WHERE name LIKE '%$query%' ORDER BY name ASC"; + $query = $this->db->query($sql); + return $query->result(); + } + + public function searchArtistes($query){ + $sql = "SELECT id, name FROM artist WHERE name LIKE '%$query%' ORDER BY name ASC"; + $query = $this->db->query($sql); + return $query->result(); + } +} diff --git a/CodeIgniter-3.1.13/application/views/album_view.php b/CodeIgniter-3.1.13/application/views/album_view.php index 9098954..c955725 100644 --- a/CodeIgniter-3.1.13/application/views/album_view.php +++ b/CodeIgniter-3.1.13/application/views/album_view.php @@ -3,7 +3,7 @@
- +