2024-05-22 23:26:06 +02:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Search extends CI_Controller {
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
parent::__construct();
|
2024-05-30 14:11:04 +02:00
|
|
|
$this->load->model('Search_model');
|
2024-06-01 17:49:36 +02:00
|
|
|
$this->load->model('Model_playlist');
|
2024-05-30 14:11:04 +02:00
|
|
|
$this->load->helper(['url', 'html']);
|
2024-06-01 17:49:36 +02:00
|
|
|
$this->load->library('session');
|
2024-05-22 23:26:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function index(){
|
|
|
|
$query = $this->input->get('query');
|
|
|
|
|
2024-05-23 09:59:04 +02:00
|
|
|
if (empty($query)) {
|
|
|
|
$data['query'] = $query;
|
|
|
|
$data['musiques'] = [];
|
|
|
|
$data['albums'] = [];
|
|
|
|
$data['genres'] = [];
|
|
|
|
$data['artistes'] = [];
|
|
|
|
$data['error'] = "La requête de recherche ne peut pas être vide.";
|
|
|
|
|
2024-05-30 14:11:04 +02:00
|
|
|
$data['title'] = "Résultats de la recherche";
|
|
|
|
$data['css'] = "assets/css/search_results";
|
2024-05-30 13:49:35 +02:00
|
|
|
|
|
|
|
$this->load->view('layout/header_dark', $data);
|
2024-05-30 14:11:04 +02:00
|
|
|
$this->load->view('search_results', $data);
|
2024-05-25 01:13:18 +02:00
|
|
|
$this->load->view('layout/footer_dark');
|
2024-05-27 13:39:48 +02:00
|
|
|
return;
|
2024-05-23 09:59:04 +02:00
|
|
|
}
|
|
|
|
|
2024-05-22 23:26:06 +02:00
|
|
|
$musiques = $this->Search_model->searchMusiques($query);
|
|
|
|
$albums = $this->Search_model->searchAlbums($query);
|
|
|
|
$genres = $this->Search_model->searchGenres($query);
|
|
|
|
$artistes = $this->Search_model->searchArtistes($query);
|
|
|
|
|
|
|
|
$data['query'] = $query;
|
|
|
|
$data['musiques'] = $musiques;
|
|
|
|
$data['albums'] = $albums;
|
|
|
|
$data['genres'] = $genres;
|
|
|
|
$data['artistes'] = $artistes;
|
2024-06-01 17:49:36 +02:00
|
|
|
|
|
|
|
if ($this->session->userdata('user_id')) {
|
|
|
|
$user_id = $this->session->userdata('user_id');
|
|
|
|
$data['user_playlists'] = $this->Model_playlist->get_user_playlists($user_id);
|
|
|
|
}
|
2024-05-30 13:49:35 +02:00
|
|
|
|
2024-05-30 14:11:04 +02:00
|
|
|
$data['title'] = "Résultats de la recherche";
|
|
|
|
$data['css'] = "assets/css/search_results";
|
2024-05-23 14:33:23 +02:00
|
|
|
|
2024-05-30 13:49:35 +02:00
|
|
|
$this->load->view('layout/header_dark', $data);
|
2024-05-30 14:11:04 +02:00
|
|
|
$this->load->view('search_results', $data);
|
2024-05-25 01:13:18 +02:00
|
|
|
$this->load->view('layout/footer_dark');
|
2024-05-22 23:26:06 +02:00
|
|
|
}
|
2024-05-23 09:59:04 +02:00
|
|
|
}
|
2024-05-30 14:11:04 +02:00
|
|
|
?>
|