mirror of
https://grond.iut-fbleau.fr/stiti/SAE_2.02
synced 2024-11-09 21:11:40 +01:00
Correction de bugs
This commit is contained in:
parent
fb03d5b832
commit
82d46c251d
@ -57,6 +57,8 @@ $route['musiques'] = 'Musiques/index';
|
||||
$route['artiste/(:num)'] = 'artiste/index/$1';
|
||||
$route['search'] = 'search/index';
|
||||
$route['mentions-legals'] = 'MentionsLegales/index';
|
||||
$route['playlists/add_artist/(:num)'] = 'playlists/add_artist/$1';
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -77,7 +77,12 @@ class Playlists extends CI_Controller {
|
||||
'playlist_id' => $playlist_id,
|
||||
'song_id' => $this->input->post('song_id')
|
||||
);
|
||||
$this->Model_playlist->add_song_to_playlist($data);
|
||||
$result = $this->Model_playlist->add_song_to_playlist($data);
|
||||
if ($result) {
|
||||
$this->session->set_flashdata('success', 'La chanson a été ajoutée à la playlist.');
|
||||
} else {
|
||||
$this->session->set_flashdata('error', 'La chanson existe déjà dans la playlist.');
|
||||
}
|
||||
redirect('playlists/view/' . $playlist_id);
|
||||
} else {
|
||||
// Récupérer toutes les musiques disponibles
|
||||
@ -89,6 +94,7 @@ class Playlists extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function delete($playlist_id) {
|
||||
$this->Model_playlist->delete_playlist($playlist_id);
|
||||
redirect('playlists');
|
||||
@ -148,13 +154,14 @@ class Playlists extends CI_Controller {
|
||||
|
||||
public function add_album($playlist_id) {
|
||||
if ($this->input->post()) {
|
||||
// Récupérer l'ID de l'album à partir du formulaire
|
||||
$album_id = $this->input->post('album_id');
|
||||
|
||||
// Récupérer toutes les chansons de l'album
|
||||
// Vérifier si les chansons de l'album existent déjà dans la playlist
|
||||
if ($this->Model_playlist->album_songs_exist_in_playlist($playlist_id, $album_id)) {
|
||||
$this->session->set_flashdata('error', 'Certaines chansons de cet album existent déjà dans la playlist.');
|
||||
} else {
|
||||
$songs = $this->Model_music->get_songs_by_album($album_id);
|
||||
|
||||
// Ajouter chaque chanson à la playlist
|
||||
foreach ($songs as $song) {
|
||||
$data = array(
|
||||
'playlist_id' => $playlist_id,
|
||||
@ -163,9 +170,11 @@ class Playlists extends CI_Controller {
|
||||
$this->Model_playlist->add_song_to_playlist($data);
|
||||
}
|
||||
|
||||
$this->session->set_flashdata('success', 'Album ajouté avec succès à la playlist.');
|
||||
}
|
||||
|
||||
redirect('playlists/view/' . $playlist_id);
|
||||
} else {
|
||||
// Récupérer tous les albums disponibles
|
||||
$data['albums'] = $this->Model_music->get_all_albums();
|
||||
$data['playlist_id'] = $playlist_id;
|
||||
$this->load->view('layout/header_dark');
|
||||
@ -174,6 +183,7 @@ class Playlists extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function view($playlist_id) {
|
||||
// Charger les détails de la playlist spécifique en fonction de son ID
|
||||
$data['playlist'] = $this->Model_playlist->get_playlist_by_id($playlist_id);
|
||||
@ -187,6 +197,38 @@ class Playlists extends CI_Controller {
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
public function add_artist($playlist_id) {
|
||||
if ($this->input->post()) {
|
||||
// Récupérer l'ID de l'artiste à partir du formulaire
|
||||
$artist_id = $this->input->post('artist_id');
|
||||
|
||||
// Vérifier si les chansons de l'artiste existent déjà dans la playlist
|
||||
if ($this->Model_playlist->artist_songs_exist_in_playlist($playlist_id, $artist_id)) {
|
||||
$this->session->set_flashdata('error', 'Certaines chansons de cet artiste existent déjà dans la playlist.');
|
||||
} else {
|
||||
$songs = $this->Model_music->get_songs_by_artist($artist_id);
|
||||
|
||||
foreach ($songs as $song) {
|
||||
$data = array(
|
||||
'playlist_id' => $playlist_id,
|
||||
'song_id' => $song->id
|
||||
);
|
||||
$this->Model_playlist->add_song_to_playlist($data);
|
||||
}
|
||||
|
||||
$this->session->set_flashdata('success', 'Toutes les chansons de l\'artiste ont été ajoutées avec succès à la playlist.');
|
||||
}
|
||||
|
||||
redirect('playlists/view/' . $playlist_id);
|
||||
} else {
|
||||
// Récupérer tous les artistes disponibles
|
||||
$data['artists'] = $this->Model_music->get_all_artists();
|
||||
$data['playlist_id'] = $playlist_id;
|
||||
$this->load->view('layout/header_dark');
|
||||
$this->load->view('playlist_add_artist', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -87,10 +87,6 @@ class Utilisateur extends CI_Controller {
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function connexion(){
|
||||
// Définir les règles de validation
|
||||
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
|
||||
|
@ -136,6 +136,10 @@ class Model_music extends CI_Model {
|
||||
return $this->db->get('album')->result();
|
||||
}
|
||||
|
||||
public function get_all_artists() {
|
||||
return $this->db->get('artist')->result();
|
||||
}
|
||||
|
||||
public function get_songs_by_album($album_id) {
|
||||
$this->db->select('song.*');
|
||||
$this->db->from('track');
|
||||
@ -144,7 +148,6 @@ class Model_music extends CI_Model {
|
||||
return $this->db->get()->result();
|
||||
}
|
||||
|
||||
|
||||
public function get_random_songs($limit) {
|
||||
$this->db->order_by('RAND()');
|
||||
$this->db->limit($limit);
|
||||
@ -216,4 +219,14 @@ class Model_music extends CI_Model {
|
||||
return $query->row();
|
||||
}
|
||||
|
||||
public function get_songs_by_artist($artist_id) {
|
||||
$this->db->select('song.*');
|
||||
$this->db->from('track');
|
||||
$this->db->join('song', 'track.songid = song.id');
|
||||
$this->db->join('album', 'track.albumid = album.id');
|
||||
$this->db->where('album.artistid', $artist_id);
|
||||
return $this->db->get()->result();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -43,11 +43,48 @@ class Model_playlist extends CI_Model {
|
||||
return $this->db->delete('playlist');
|
||||
}
|
||||
|
||||
// Ajouter une chanson à une playlist
|
||||
public function add_song_to_playlist($data) {
|
||||
// Vérifier si la combinaison playlist_id et song_id existe déjà
|
||||
$this->db->where($data);
|
||||
$existing_entry = $this->db->get('playlist_song')->row();
|
||||
|
||||
// Si la combinaison existe déjà, retourner false
|
||||
if ($existing_entry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sinon, effectuer l'insertion
|
||||
return $this->db->insert('playlist_song', $data);
|
||||
}
|
||||
|
||||
public function song_exists_in_playlist($playlist_id, $song_id) {
|
||||
$this->db->where('playlist_id', $playlist_id);
|
||||
$this->db->where('song_id', $song_id);
|
||||
$query = $this->db->get('playlist_song');
|
||||
return $query->num_rows() > 0;
|
||||
}
|
||||
|
||||
public function artist_songs_exist_in_playlist($playlist_id, $artist_id) {
|
||||
// Récupérer les chansons de l'artiste spécifié
|
||||
$artist_songs = $this->Model_music->get_songs_by_artist($artist_id);
|
||||
|
||||
// Récupérer les chansons de la playlist
|
||||
$playlist_songs = $this->get_songs_by_playlist($playlist_id);
|
||||
|
||||
// Vérifier chaque chanson de l'artiste dans la playlist
|
||||
foreach ($artist_songs as $artist_song) {
|
||||
foreach ($playlist_songs as $playlist_song) {
|
||||
// Si la chanson de l'artiste est déjà dans la playlist, retourner true
|
||||
if ($artist_song->id == $playlist_song->id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Si aucune chanson de l'artiste n'est trouvée dans la playlist, retourner false
|
||||
return false;
|
||||
}
|
||||
|
||||
// Supprimer une chanson d'une playlist
|
||||
public function remove_song_from_playlist($playlist_id, $song_id) {
|
||||
$this->db->where('playlist_id', $playlist_id);
|
||||
|
@ -1,64 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #640875;
|
||||
}
|
||||
.container {
|
||||
width: 80%;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
color: #9f23b5;
|
||||
}
|
||||
|
||||
.hero {
|
||||
background-color: #2d1c30;
|
||||
color: #fff;
|
||||
padding: 50px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.contact-form {
|
||||
margin: 20px 0;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.contact-form h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.contact-form input, .contact-form textarea {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.contact-form button {
|
||||
padding: 10px 20px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/nous-contacter'); ?>">
|
||||
<title>Nous contacter - Onzeur</title>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ajouter un Album à la Playlist</title>
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/style.css'); ?>">
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/playlist_add_song'); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
24
CodeIgniter-3.1.13/application/views/playlist_add_artist.php
Normal file
24
CodeIgniter-3.1.13/application/views/playlist_add_artist.php
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ajouter les musiques d'un Artiste à la Playlist</title>
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/playlist_add_song'); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Ajouter les musiques d'un Artiste à la Playlist</h1>
|
||||
<?php echo form_open('playlists/add_artist/'.$playlist_id); ?>
|
||||
<div class="form-group">
|
||||
<label for="artist_id">Sélectionner un Artiste :</label>
|
||||
<select name="artist_id" class="form-control" required>
|
||||
<?php foreach ($artists as $artist): ?>
|
||||
<option value="<?php echo $artist->id; ?>"><?php echo $artist->name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Ajouter les musiques de l'artiste</button>
|
||||
<?php echo form_close(); ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -3,10 +3,23 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Détails de la Playlist</title>
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/playlist_view'); ?>">
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/playlist_view.css'); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!-- Messages Flash -->
|
||||
<?php if($this->session->flashdata('success')): ?>
|
||||
<div class="alert alert-success mt-3">
|
||||
<?php echo $this->session->flashdata('success'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($this->session->flashdata('error')): ?>
|
||||
<div class="alert alert-danger mt-3">
|
||||
<?php echo $this->session->flashdata('error'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h1><?php echo htmlspecialchars($playlist->name, ENT_QUOTES, 'UTF-8'); ?></h1>
|
||||
<form action="<?php echo site_url('playlists/update/' . $playlist->id); ?>" method="post">
|
||||
<div class="form-group">
|
||||
@ -48,6 +61,7 @@
|
||||
|
||||
<a href="<?php echo site_url('playlists/add_song/' . $playlist->id); ?>" class="btn btn-primary">Ajouter une musique</a>
|
||||
<a href="<?php echo site_url('playlists/add_album/' . $playlist->id); ?>" class="btn btn-primary">Ajouter un album</a>
|
||||
<a href="<?php echo site_url('playlists/add_artist/' . $playlist->id); ?>" class="btn btn-primary">Ajouter les musiques d'un artiste</a>
|
||||
<a href="<?php echo site_url('playlists'); ?>" class="btn btn-secondary">Retour</a>
|
||||
</div>
|
||||
</body>
|
||||
|
55
CodeIgniter-3.1.13/assets/css/nous-contacter.css
Normal file
55
CodeIgniter-3.1.13/assets/css/nous-contacter.css
Normal file
@ -0,0 +1,55 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #640875;
|
||||
}
|
||||
.container {
|
||||
width: 80%;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
h1, h2, h3 {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
color: #9f23b5;
|
||||
}
|
||||
|
||||
.hero {
|
||||
background-color: #2d1c30;
|
||||
color: #fff;
|
||||
padding: 50px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.contact-form {
|
||||
margin: 20px 0;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.contact-form h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.contact-form input, .contact-form textarea {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.contact-form button {
|
||||
padding: 10px 20px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
Loading…
Reference in New Issue
Block a user