Ajout search bar , genre...
This commit is contained in:
parent
affc3760d3
commit
edadb309a8
application
controllers
models
views
@ -9,11 +9,21 @@ class Albums extends CI_Controller {
|
||||
$this->load->library('session');
|
||||
}
|
||||
public function index(){
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$genre = $this->input->get('genre');
|
||||
$order = $this->input->get('order');
|
||||
$artist = $this->input->get('artist');
|
||||
|
||||
$albums = $this->model_music->getAlbums($genre, $order, $artist);
|
||||
$genres = $this->model_music->researchtype();
|
||||
$artists = $this->model_music->nameArtist();
|
||||
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$data = array(
|
||||
'albums' => $albums,
|
||||
'is_logged_in' => $is_logged_in
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'genres' => $genre,
|
||||
'artistes' => $artist
|
||||
|
||||
);
|
||||
$this->load->view('layout/header',$data);
|
||||
$this->load->view('albums_list', $data);
|
||||
|
21
application/controllers/Artist.php
Normal file
21
application/controllers/Artist.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Artist extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
}
|
||||
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('artists_name',['artists'=>$artists]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
}
|
||||
|
23
application/controllers/Music.php
Normal file
23
application/controllers/Music.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Music extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
}
|
||||
|
||||
|
||||
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('musiques_name',['musics'=>$musics]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,16 +5,118 @@ class Model_music extends CI_Model {
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function getAlbums(){
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
ORDER BY year
|
||||
"
|
||||
);
|
||||
return $query->result();
|
||||
public function getAlbums($genre = '', $order = '', $artist = '') {
|
||||
$this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
|
||||
$this->db->from('album');
|
||||
$this->db->join('artist', 'album.artistid = artist.id');
|
||||
$this->db->join('genre', 'genre.id = album.genreid');
|
||||
$this->db->join('cover', 'cover.id = album.coverid');
|
||||
|
||||
|
||||
if(!empty($genre)){
|
||||
$this->db->where('genre.name', $genre);
|
||||
}
|
||||
|
||||
if(!empty($artist)){
|
||||
$this->db->where('artist.name', $artist);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($order == 'asc' || $order == 'desc'){
|
||||
$this->db->order_by('album.name',$order );
|
||||
}
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
public function getArtists($genre = '', $order = '') {
|
||||
$this->db->select('artist.name as artistName, artist.id as artistId');
|
||||
$this->db->from('artist');
|
||||
$this->db->join('album', 'album.artistid = artist.id');
|
||||
$this->db->join('genre', 'genre.id = album.genreid');
|
||||
$this->db->join('cover', 'cover.id = album.coverid');
|
||||
|
||||
$this->db->distinct("artist.name");
|
||||
|
||||
if(!empty($genre)){
|
||||
$this->db->where('genre.name', $genre);
|
||||
}
|
||||
|
||||
|
||||
if($order == 'asc' || $order == 'desc'){
|
||||
$this->db->order_by('artist.name',$order );
|
||||
}
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
public function getMusics($genre = '', $order = '', $artist = '') {
|
||||
|
||||
$this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg, song.name as trackName, track.id as trackId');
|
||||
$this->db->from('track');
|
||||
$this->db->join('album', 'track.albumId = album.id');
|
||||
$this->db->join('song', 'song.id = track.songId');
|
||||
$this->db->join('artist', 'album.artistid = artist.id');
|
||||
$this->db->join('genre', 'genre.id = album.genreid');
|
||||
$this->db->join('cover', 'cover.id = album.coverid');
|
||||
$this->db->limit(100);
|
||||
|
||||
|
||||
|
||||
if(!empty($genre)){
|
||||
$this->db->where('genre.name', $genre);
|
||||
}
|
||||
|
||||
if(!empty($artist)){
|
||||
$this->db->where('artist.name', $artist);
|
||||
}
|
||||
|
||||
|
||||
if($order == 'asc' || $order == 'desc'){
|
||||
$this->db->order_by('song.name',$order );
|
||||
}
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function research(){
|
||||
$query = $this->db->query(
|
||||
|
||||
);}
|
||||
|
||||
public function researchtype(){
|
||||
|
||||
$this->db->select('name');
|
||||
$this->db->from('genre');
|
||||
/*
|
||||
if(!empty($playlist_id)){
|
||||
$this->db->where('playlists.playlist_id', $playlist_id);
|
||||
}*/
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
public function nameArtist(){
|
||||
|
||||
$this->db->select('name');
|
||||
$this->db->from('artist');
|
||||
|
||||
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
12
application/views/artists_name.php
Normal file
12
application/views/artists_name.php
Normal file
@ -0,0 +1,12 @@
|
||||
<h5>Artists list</h5>
|
||||
<section class="list">
|
||||
<?php
|
||||
foreach($artists as $artist){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("artist/view/{$artist->artistId}","{$artist->artistName}");
|
||||
echo "</header></article></div>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
|
@ -27,6 +27,31 @@
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<form methode="GET">
|
||||
<select name="artist" id="artist">
|
||||
<option value=''>Tous</option>
|
||||
<?php foreach($artistes as $artiste){
|
||||
echo "<option value='{$artiste->name}'>{$artiste->name}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<select name="genre" id="genre">
|
||||
<option value=''>Tous</option>
|
||||
<?php foreach($genres as $genre){
|
||||
echo "<option value='{$genre->name}'>{$genre->name}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<select name="order" id="order">
|
||||
<option value="">Ordre :</option>
|
||||
<option value="asc">Croissant</option>
|
||||
<option value="desc">Decroissant</option>
|
||||
</select>
|
||||
<button type="submit">Envoyer</button>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
16
application/views/musiques_name.php
Normal file
16
application/views/musiques_name.php
Normal file
@ -0,0 +1,16 @@
|
||||
<h5>Musiques List</h5>
|
||||
<section class="list">
|
||||
<?php
|
||||
foreach($musics as $music){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("albums/view/{$music->trackId}","{$music->trackName}");
|
||||
echo "</header>";
|
||||
echo '<img src="data:image/jpeg;base64,'.base64_encode($music->jpeg).'" />';
|
||||
|
||||
echo "<footer class='short-text'>{$music->year} - {$music->artistName}</footer>
|
||||
</article></div>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
|
Loading…
x
Reference in New Issue
Block a user