finition css

This commit is contained in:
2024-06-18 19:59:50 +02:00
parent 0b4dde90ac
commit 24fa946cf0
7 changed files with 133 additions and 112 deletions

View File

@@ -9,17 +9,18 @@ class Playlist extends CI_Controller {
$this->load->library('form_validation'); $this->load->library('form_validation');
} }
public function index(){ public function index(){
$user = $this->session->userdata('userId');
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){ if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
$playlists = $this->model_music->getPlaylist(); $playlists = $this->model_music->getPlaylist($user);
}else{ }else{
$recherche=filter_input(INPUT_GET,'recherche'); $recherche=filter_input(INPUT_GET,'recherche');
$playlists = $this->model_music->getSearchPlaylist($recherche); $playlists = $this->model_music->getSearchPlaylist($recherche,$user);
} }
$this->load->view('layout/header'); $this->load->view('layout/header');
if ($playlists == false){ if ($playlists == false){
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']); $page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
$this->load->view('error',['page'=>$page[count($page)-1]]); $this->load->view('error',['page'=>$page[count($page)-1]]);
$playlists = $this->model_music->getPlaylist(); $playlists = $this->model_music->getPlaylist($user);
} }
$this->load->view('playlist_list',['playlists'=>$playlists]); $this->load->view('playlist_list',['playlists'=>$playlists]);
$this->load->view('layout/footer'); $this->load->view('layout/footer');

View File

@@ -22,16 +22,27 @@ class User extends CI_Controller {
$this->load->view('create_user'); $this->load->view('create_user');
$this->load->view('layout/footer'); $this->load->view('layout/footer');
}else{ }else{
$user=array( $user=array(
"usernom" => $this->input->post("nom"), "usernom" => $this->input->post("nom"),
"userprenom" => $this->input->post("prenom"), "userprenom" => $this->input->post("prenom"),
"usermail" => $this->input->post("email"), "usermail" => $this->input->post("email"),
"userpassword" => password_hash(($this->input->post("password")), PASSWORD_DEFAULT), "userpassword" => password_hash(($this->input->post("password")), PASSWORD_DEFAULT),
); );
if($this->model_music->verifyMail($this->input->post("email")) == false){
$this->model_music->create_user($user); $this->model_music->create_user($user);
redirect("user/auth"); $dataUser=array(
"usernom" => $this->input->post("nom"),
"userprenom" => $this->input->post("prenom"),
"usermail" => $this->input->post("email"),
"userpassword" => password_hash(($this->input->post("password")), PASSWORD_DEFAULT),
"logged_in" => TRUE
);
$this->session->set_userdata($dataUser);
redirect("albums");
}else{
$this->session->set_flashdata('error', 'Cet email est déjà utilisé.');
redirect('user/create');
}
} }
} }
@@ -63,7 +74,7 @@ class User extends CI_Controller {
$this->session->set_userdata($dataUser); $this->session->set_userdata($dataUser);
redirect("albums"); redirect("albums");
}else{ }else{
redirect("user/create"); redirect("user/auth");
} }
} }

View File

@@ -176,16 +176,14 @@ class Model_music extends CI_Model {
} }
public function getSearchAlbums($nom){ public function getSearchAlbums($nom){
$query = $this->db->query( $this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg ');
"SELECT album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg $this->db->from('album');
FROM album $this->db->join('artist','album.artistid = artist.id');
JOIN artist ON album.artistid = artist.id $this->db->join('genre','genre.id = album.genreid');
JOIN genre ON genre.id = album.genreid $this->db->join('cover','cover.id = album.coverid');
JOIN cover ON cover.id = album.coverid $this->db->where('album.name', $nom);
WHERE album.name LIKE '$nom' $this->db->order_by('year','ASC');
" $query = $this->db->get();
);
//$query->result();
if ($query->num_rows() > 0){ if ($query->num_rows() > 0){
return $query->result(); return $query->result();
} }
@@ -193,13 +191,10 @@ class Model_music extends CI_Model {
} }
public function getSearchArtistes($nom){ public function getSearchArtistes($nom){
$query = $this->db->query( $this->db->select('artist.name, artist.id');
"SELECT artist.name, artist.id $this->db->from('artist');
FROM artist $this->db->like('artist.name',$nom);
WHERE artist.name LIKE '$nom' $query = $this->db->get();
"
);
$query->result();
if ($query->num_rows() > 0){ if ($query->num_rows() > 0){
return $query->result(); return $query->result();
} }
@@ -207,18 +202,15 @@ class Model_music extends CI_Model {
} }
public function getSearchChansons($nom){ public function getSearchChansons($nom){
$query = $this->db->query( $this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg ');
"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');
FROM song $this->db->join('track','track.songId = song.id');
JOIN track ON track.songId = song.id $this->db->join('album','track.artistid = album.id');
JOIN album ON album.id = track.albumId $this->db->join('artist','album.artistid = artist.id');
JOIN artist ON album.artistid = artist.id $this->db->join('genre','genre.id = album.genreid');
JOIN genre ON genre.id = album.genreid $this->db->where('song.name', $nom);
WHERE song.name LIKE '$nom' $this->db->order_by('year','ASC');
$query = $this->db->get();
"
);
$query->result();
if ($query->num_rows() > 0){ if ($query->num_rows() > 0){
return $query->result(); return $query->result();
} }
@@ -230,18 +222,16 @@ class Model_music extends CI_Model {
$query = $this->db->get('album'); $query = $this->db->get('album');
$album = $query->row(); $album = $query->row();
// Recupere la couverture
$this->db->where('id', $album->coverId); $this->db->where('id', $album->coverId);
$coverQuery = $this->db->get('cover'); $coverQuery = $this->db->get('cover');
$cover = $coverQuery->row(); $cover = $coverQuery->row();
$album->coverImage = $cover->jpeg; $album->coverImage = $cover->jpeg;
// Recupere le l'id de la musique a partie de l'album
$this->db->select('songId'); $this->db->select('songId');
$this->db->where('albumId', $id); $this->db->where('albumId', $id);
$songsQuery = $this->db->get('track'); $songsQuery = $this->db->get('track');
$songIds = $songsQuery->result(); $songIds = $songsQuery->result();
// Récupérer les noms des chansons à partir des songIds
$album->songs = []; $album->songs = [];
foreach ($songIds as $song) { foreach ($songIds as $song) {
$this->db->select('name'); $this->db->select('name');
@@ -272,22 +262,18 @@ class Model_music extends CI_Model {
$artist = $artistQuery->row(); $artist = $artistQuery->row();
$album->artist = $artist; $album->artist = $artist;
return $album; return $album;
} }
public function getAlbumsByArtistId($artistId) { public function getAlbumsByArtistId($artistId) {
$query = $this->db->query( $this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg');
"SELECT album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg $this->db->from('album');
FROM album $this->db->join('artist','album.artistid = artist.id');
JOIN artist ON album.artistid = artist.id $this->db->join('genre','genre.id = album.genreid');
JOIN genre ON genre.id = album.genreid $this->db->join('cover','cover.id = album.coverid');
JOIN cover ON cover.id = album.coverid $this->db->where('album.artistid', $artistId);
WHERE album.artistid=$artistId $this->db->order_by('year','ASC');
ORDER BY year $query = $this->db->get();
"
);
return $query->result(); return $query->result();
} }
@@ -305,23 +291,20 @@ class Model_music extends CI_Model {
return $query->row(); return $query->row();
} }
public function getPlaylist(){ public function getPlaylist($iduser){
$query = $this->db->query( $this->db->select("Playlist.name, Playlist.playlistId");
"SELECT Playlist.name, Playlist.playlistId $this->db->from('Playlist');
FROM Playlist $this->db->where('Playlist.userId',$iduser);
ORDER BY Playlist.name $query = $this->db->get();
"
);
return $query->result(); return $query->result();
} }
public function getSearchPlaylist($nom){ public function getSearchPlaylist($nom,$iduser){
$query = $this->db->query( $this->db->select("Playlist.name, Playlist.playlistId");
"SELECT Playlist.name, Playlist.playlistId $this->db->from('Playlist');
FROM Playlist $this->db->where('Playlist.name',$nom);
WHERE Playlist.name LIKE '$nom' $this->db->where('Playlist.userId',$iduser);
" $query = $this->db->get();
);
$query->result(); $query->result();
if ($query->num_rows() > 0){ if ($query->num_rows() > 0){
return $query->result(); return $query->result();
@@ -335,14 +318,12 @@ class Model_music extends CI_Model {
$track = $result->row(); $track = $result->row();
$trackId = $track->trackId; $trackId = $track->trackId;
$query = $this->db->query( $this->db->select('Playlist.name, Playlist.playlistId');
"SELECT Playlist.name, Playlist.playlistId $this->db->from('Playlist');
FROM Playlist $this->db->join('PlaylistSong','Playlist.playlistId = PlaylistSong.playlistId');
JOIN PlaylistSong ON Playlist.playlistId = PlaylistSong.playlistId $this->db->where('PlaylistSong.trackId',$trackId);
WHERE PlaylistSong.trackId = $trackId $this->db->order_by('Playlist.name','ASC');
ORDER BY Playlist.name $query = $this->db->get();
"
);
return $query->result(); return $query->result();
} }
@@ -387,7 +368,6 @@ class Model_music extends CI_Model {
public function SongInPlaylist($id){ public function SongInPlaylist($id){
$result = $this->model_music->TrackidSonginPlaylist($id); $result = $this->model_music->TrackidSonginPlaylist($id);
// Si on trouve au moins une piste de cette chanson dans la playlist, retourner true
if ($result->num_rows() > 0) { if ($result->num_rows() > 0) {
return true; return true;
} }
@@ -399,23 +379,19 @@ class Model_music extends CI_Model {
$idtrack = array($idtrack); $idtrack = array($idtrack);
} }
// Étape 1: Récupérer l'ID de la chanson à partir de l'un des IDs de piste fournis
$this->db->select('song.id as songId'); $this->db->select('song.id as songId');
$this->db->from('track'); $this->db->from('track');
$this->db->join('song', 'song.id = track.songId'); $this->db->join('song', 'song.id = track.songId');
$this->db->where_in('track.id', $idtrack); $this->db->where_in('track.id', $idtrack);
$query = $this->db->get(); $query = $this->db->get();
// Vérifier si des résultats ont été trouvés
if ($query->num_rows() == 0) { if ($query->num_rows() == 0) {
return false; // Si aucun résultat trouvé, retourner false return false;
} }
// Récupérer le premier songId correspondant
$result = $query->row(); $result = $query->row();
$songId = $result->songId; $songId = $result->songId;
// Étape 2: Récupérer tous les IDs de pistes associés à cette chanson
$this->db->select('track.id as trackId'); $this->db->select('track.id as trackId');
$this->db->from('track'); $this->db->from('track');
$this->db->where('track.songId', $songId); $this->db->where('track.songId', $songId);
@@ -425,14 +401,12 @@ class Model_music extends CI_Model {
$trackIds[] = $track->trackId; $trackIds[] = $track->trackId;
} }
// Étape 3: Vérifier si l'une des pistes de cette chanson est dans la playlist
$this->db->select('PlaylistSong.trackid as trackId'); $this->db->select('PlaylistSong.trackid as trackId');
$this->db->from('PlaylistSong'); $this->db->from('PlaylistSong');
$this->db->where_in('PlaylistSong.trackId', $trackIds); $this->db->where_in('PlaylistSong.trackId', $trackIds);
$this->db->where('PlaylistSong.playlistId',$idplaylist); $this->db->where('PlaylistSong.playlistId',$idplaylist);
$query = $this->db->get(); $query = $this->db->get();
// Si on trouve au moins une piste de cette chanson dans la playlist, retourner true
if ($query->num_rows() > 0) { if ($query->num_rows() > 0) {
return true; return true;
} }
@@ -444,23 +418,19 @@ class Model_music extends CI_Model {
$id = array($id); $id = array($id);
} }
// Étape 1: Récupérer l'ID de la chanson à partir de l'un des IDs de piste fournis
$this->db->select('song.id as songId'); $this->db->select('song.id as songId');
$this->db->from('track'); $this->db->from('track');
$this->db->join('song', 'song.id = track.songId'); $this->db->join('song', 'song.id = track.songId');
$this->db->where_in('track.id', $id); $this->db->where_in('track.id', $id);
$query = $this->db->get(); $query = $this->db->get();
// Vérifier si des résultats ont été trouvés
if ($query->num_rows() == 0) { if ($query->num_rows() == 0) {
return false; // Si aucun résultat trouvé, retourner false return false;
} }
// Récupérer le premier songId correspondant
$result = $query->row(); $result = $query->row();
$songId = $result->songId; $songId = $result->songId;
// Étape 2: Récupérer tous les IDs de pistes associés à cette chanson
$this->db->select('track.id as trackId'); $this->db->select('track.id as trackId');
$this->db->from('track'); $this->db->from('track');
$this->db->where('track.songId', $songId); $this->db->where('track.songId', $songId);
@@ -470,7 +440,6 @@ class Model_music extends CI_Model {
$trackIds[] = $track->trackId; $trackIds[] = $track->trackId;
} }
// Étape 3: Vérifier si l'une des pistes de cette chanson est dans la playlist
$this->db->select('PlaylistSong.trackId as trackId'); $this->db->select('PlaylistSong.trackId as trackId');
$this->db->from('PlaylistSong'); $this->db->from('PlaylistSong');
$this->db->where_in('PlaylistSong.trackId', $trackIds); $this->db->where_in('PlaylistSong.trackId', $trackIds);
@@ -554,9 +523,23 @@ class Model_music extends CI_Model {
$this->db->where_in('year', $years); $this->db->where_in('year', $years);
} }
$this->db->order_by('RAND()'); $this->db->order_by('trackId','RANDOM');
$this->db->limit($num_tracks); $this->db->limit($num_tracks);
$query = $this->db->get(); $query = $this->db->get();
return $query->result(); return $query->result();
} }
public function verifyMail($email){
$this->db->select('usermail');
$this->db->from('User');
$this->db->where('usermail', $email);
$query = $this->db->get();
if($query->num_rows() > 0){
return true;
}
return false;
}
} }

View File

@@ -1,7 +1,6 @@
<form method="post"> <form method="post">
<!-- Markup example 2: input is after label -->
<label for="email">Adresse mail</label> <label for="email">Adresse mail</label>
<input type="email" id="email" name="email" placeholder="Email" value="<?=set_value('email')?>" required> <input type="email" id="email" name="email" placeholder="Email" value="<?=set_value('email')?>" required>
<div class="grid"> <div class="grid">
@@ -9,7 +8,6 @@
<input type="password" id="password" name="password" placeholder="Password" value="<?=set_value('password')?>" required> <input type="password" id="password" name="password" placeholder="Password" value="<?=set_value('password')?>" required>
</label> </label>
</div> </div>
<!-- Button -->
<button type="submit">Submit</button> <button type="submit">Submit</button>
<?=anchor('user/create','Création de Compte');?> <?=anchor('user/create','Création de Compte');?>
</form> </form>

View File

@@ -1,9 +1,6 @@
<form method="post"> <form method="post">
<!-- Grid -->
<div class="grid"> <div class="grid">
<!-- Markup example 1: input is inside label -->
<label for="prenom"> <label for="prenom">
Prénom Prénom
<input type="text" id="prenom" name="prenom" placeholder="Prénom" required> <input type="text" id="prenom" name="prenom" placeholder="Prénom" required>
@@ -14,7 +11,6 @@
<input type="text" id="nom" name="nom" placeholder="nom" required> <input type="text" id="nom" name="nom" placeholder="nom" required>
</label> </label>
</div> </div>
<!-- Markup example 2: input is after label -->
<label for="email">Adresse mail</label> <label for="email">Adresse mail</label>
<input type="email" id="email" name="email" placeholder="Email" required> <input type="email" id="email" name="email" placeholder="Email" required>
<div class="grid"> <div class="grid">
@@ -24,9 +20,13 @@
<label for="cpassword">Confirmation password <label for="cpassword">Confirmation password
<input type="password" id="cpassword" name="cpassword" placeholder="Password" required> <input type="password" id="cpassword" name="cpassword" placeholder="Password" required>
</label> </label>
</div> </div>
<!-- Button --> <?php if ($this->session->flashdata('error')): ?>
<div class="alert-danger">
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php endif; ?>
<br>
<br>
<button type="submit">Submit</button> <button type="submit">Submit</button>
</form> </form>

View File

@@ -17,11 +17,17 @@
<?php <?php
$page = preg_split('/[\/]/', $_SERVER['REQUEST_URI']); $page = preg_split('/[\/]/', $_SERVER['REQUEST_URI']);
if ($page[count($page) - 1] != 'auth' && $page[count($page) - 1] != 'create') { ?> if ($page[count($page) - 1] != 'auth' && $page[count($page) - 1] != 'create') { ?>
<?php if($this->session->userdata('logged_in')){ ?>
<form method="GET"> <form method="GET">
<input type="text" name="recherche" placeholder="Recherche... "> <input type="text" class="recherchelog" name="recherche" placeholder="Recherche... ">
</form>
<?php }else{ ?>
<form method="GET">
<input type="text" class="recherche" name="recherche" placeholder="Recherche... ">
</form> </form>
<?php } ?> <?php } ?>
<ul> <?php } ?>
<ul class="onglet">
<li><?= anchor('albums', 'Albums'); ?></li> <li><?= anchor('albums', 'Albums'); ?></li>
<li><?= anchor('artistes', 'Artistes'); ?></li> <li><?= anchor('artistes', 'Artistes'); ?></li>
<li><?= anchor('chansons', 'Chansons'); ?></li> <li><?= anchor('chansons', 'Chansons'); ?></li>

View File

@@ -12,16 +12,28 @@ section.list img {
display:inline-block; display:inline-block;
} }
.short-text { .short-text, h6{
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
color: #2a2a2a; color: #d8d3d3;
}
h5,h3{
font-size: 25px;
color: #5106dd;
} }
.recherche { .recherche {
width : 75px; width : 150px;
height : 24px; height : 24px;
margin-left: -200px;
margin-right: 150px;
}
.recherchelog{
margin-left: -150px;
margin-right: 50px;
} }
.short-text{ .short-text{
@@ -30,10 +42,15 @@ section.list img {
align-items: center; align-items: center;
} }
.appli{ li .appli{
width : 100px; position: relative;
height : 75px; bottom: 15px;
color: #444; font-size: 30px;
color: #ad1010;
}
.onglet{
font-size: 20px;
} }
.apliiiiiii{ .apliiiiiii{
@@ -95,6 +112,7 @@ html {
background-color: #13171f; background-color: #13171f;
color: #ffffff; color: #ffffff;
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
padding: 10px;
} }
.album-details { .album-details {
@@ -177,3 +195,7 @@ i {
font-size: 14px; font-size: 14px;
border-radius: 4px; border-radius: 4px;
} }
article, article header, article footer{
background-color: #444;
}