vraiment bon travail
This commit is contained in:
commit
1f04b03f30
codeigniter
application
config
controllers
models
views
assets
@ -51,8 +51,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*/
|
||||
$route['default_controller'] = 'albums';
|
||||
$route['connexion'] = 'ConnexionController/connexion';
|
||||
$route['inscription'] = 'InscriptionController/inscription';
|
||||
$route['traitement'] = 'InscriptionController/traitement';
|
||||
$route['traitement'] = 'ConnexionController/traitement';
|
||||
$route['authentifier'] = 'ConnexionController/authentifier';
|
||||
$route['deconnexion'] = 'ConnexionController/deconnexion';
|
||||
$route['404_override'] = '';
|
||||
|
@ -3,7 +3,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Albums extends CI_Controller {
|
||||
|
||||
private $filter = 'default';
|
||||
private $sort = 'Tri';
|
||||
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
@ -13,13 +14,37 @@ class Albums extends CI_Controller {
|
||||
$this->load->helper('form');
|
||||
}
|
||||
public function index(){
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$num_results = count($albums);
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list', ['albums' => $albums, 'sort' => $this->sort, 'num_results' => $num_results, 'is_search' => false]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function view($id){
|
||||
$tracks = $this->model_music->getTracksByAlbumId($id);
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('album_info', ['tracks' => $tracks]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list',['albums'=>$albums]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
public function tri(){
|
||||
$Ctri = $this->input->get('Ctri');
|
||||
$trie = $this->model_music->get_tri_Albums($Ctri);
|
||||
$num_results = count($trie);
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list', ['albums' => $trie, 'sort' => $this->sort, 'num_results' => $num_results, 'is_search' => false]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function search(){
|
||||
$query = $this->input->get('query');
|
||||
$albums = $this->model_music->searchAlbums($query);
|
||||
$num_results = count($albums);
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list', ['albums' => $albums, 'sort' => $this->sort, 'num_results' => $num_results, 'is_search' => true]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,39 @@ class ConnexionController extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function traitement() {
|
||||
if(isset($_POST['ok'])){
|
||||
$this->load->database();
|
||||
|
||||
|
||||
$prenom = ucfirst(strtolower($this->input->post('prenom')));
|
||||
$nom = strtoupper($this->input->post('nom'));
|
||||
$pseudo = $this->input->post('pseudo');
|
||||
$mdp = $this->input->post('pass');
|
||||
$email = $this->input->post('email');
|
||||
|
||||
$data = array(
|
||||
'pseudo' => $pseudo,
|
||||
'nom' => $nom,
|
||||
'prenom' => $prenom,
|
||||
'mdp' => $mdp,
|
||||
'email' => $email
|
||||
);
|
||||
|
||||
$this->db->insert('users', $data);
|
||||
|
||||
$this->session->set_userdata('pseudo', $pseudo);
|
||||
redirect('../index.php');
|
||||
|
||||
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('connexion', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
}
|
||||
|
||||
public function deconnexion() {
|
||||
$this->session->unset_userdata('pseudo');
|
||||
$this->session->sess_destroy();
|
||||
|
@ -10,7 +10,7 @@ class InscriptionController extends CI_Controller {
|
||||
|
||||
public function inscription() {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('inscription');
|
||||
$this->load->view('connexion');
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class InscriptionController extends CI_Controller {
|
||||
$data['confirmation_message'] = "Inscription réussie ! Vous êtes maintenant inscrit.";
|
||||
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('inscription', $data);
|
||||
$this->load->view('connexion', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ class Model_music extends CI_Model {
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public function getArtistes(){
|
||||
$query = $this->db->query(
|
||||
"SELECT artist.id AS artistId, artist.name AS artistName, album.name AS albumName, album.id AS albumId, album.year, cover.jpeg
|
||||
@ -70,8 +71,61 @@ class Model_music extends CI_Model {
|
||||
JOIN song ON track.songId = song.id
|
||||
WHERE album.id = ?
|
||||
ORDER BY track.diskNumber, track.number",
|
||||
=======
|
||||
public function getArtistes(){
|
||||
$query = $this->db->query(
|
||||
"SELECT artist.id AS artistId, artist.name AS artistName, album.name AS albumName, album.year, cover.jpeg
|
||||
FROM album
|
||||
INNER JOIN artist ON album.artistId = artist.id
|
||||
JOIN cover ON cover.id = album.coverId
|
||||
GROUP BY artist.name, album.year
|
||||
"
|
||||
);
|
||||
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function getTracksByAlbumId($albumId){
|
||||
$query = $this->db->query(
|
||||
"SELECT track.number, track.duration, song.name as songName
|
||||
FROM track
|
||||
JOIN album ON album.id = track.albumid
|
||||
JOIN artist ON artist.id = album.artistId
|
||||
JOIN song ON song.id = track.songId
|
||||
WHERE track.albumId = ?
|
||||
ORDER BY track.number",
|
||||
>>>>>>> 1bd8d93ce58f04d7fc10d62db226dd012b1f7560
|
||||
array($albumId)
|
||||
);
|
||||
return $query->result();
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
public function get_tri_Albums($Ctri){
|
||||
$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 album.name $Ctri
|
||||
"
|
||||
);
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function searchAlbums($query){
|
||||
$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');
|
||||
$this->db->like('album.name', $query);
|
||||
$this->db->or_like('artist.name', $query);
|
||||
$this->db->order_by('album.id', 'ASC');
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
>>>>>>> 1bd8d93ce58f04d7fc10d62db226dd012b1f7560
|
||||
}
|
||||
|
16
codeigniter/application/views/album_info.php
Normal file
16
codeigniter/application/views/album_info.php
Normal file
@ -0,0 +1,16 @@
|
||||
<h5>Détail de l'Album :</h5>
|
||||
<section class="track-list">
|
||||
<?php
|
||||
if(!empty($tracks)) {
|
||||
foreach($tracks as $track){
|
||||
echo "<div><article>";
|
||||
echo "<header class='track-id'>Id : {$track->number}</header>";
|
||||
echo "<div class='track-name'>Nom : {$track->songName}</div>";
|
||||
echo "<footer class='track_time'>Durée (en secondes) : {$track->duration}</footer>";
|
||||
echo "</article></div>";
|
||||
}
|
||||
} else {
|
||||
echo "<p>Aucune piste trouvée pour cet album.</p>";
|
||||
}
|
||||
?>
|
||||
</section>
|
@ -1,4 +1,27 @@
|
||||
<h5>Albums list</h5>
|
||||
<div class="sorting-search">
|
||||
<form action="<?= site_url('Albums/tri'); ?>" method="get" class="tri-form">
|
||||
<button type="submit" name="Ctri" value="ASC" class="tri-button">Tri A-Z</button>
|
||||
<button type="submit" name="Ctri" value="DESC" class="tri-button">Tri Z-A</button>
|
||||
</form>
|
||||
</ul>
|
||||
<form action="<?= site_url('Albums/search'); ?>" method="get" class="search-form">
|
||||
<input type="text" name="query" placeholder="Chercher des albums" class="search-input">
|
||||
<button type="submit" class="search-button">Rechercher</button>
|
||||
</form>
|
||||
|
||||
<?php if(isset($is_search) && $is_search): ?>
|
||||
<form action="<?= site_url('Albums'); ?>" method="get" class="back-form">
|
||||
<button type="submit" class="back-button">Retour à la liste complète</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if(isset($is_search) && $is_search): ?>
|
||||
<p>Nombre de résultats : <?php echo $num_results; ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="list">
|
||||
<?php
|
||||
foreach($albums as $album){
|
||||
|
@ -1,12 +1,53 @@
|
||||
<h1>Se connecter</h1>
|
||||
<form action="authentifier" method="POST">
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
<label for="password">Mot de passe:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
<button type="submit">Connexion</button>
|
||||
</form>
|
||||
|
||||
<?php if(isset($error_msg)): ?>
|
||||
<div class="error-message"><?= $error_msg ?></div>
|
||||
<?php endif; ?>
|
||||
<section class="connexion">
|
||||
|
||||
<div class="authentification">
|
||||
|
||||
<h3> Déjà abonné </h3>
|
||||
|
||||
<form action="authentifier" method="POST">
|
||||
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" id="email" name="email" placeholder="Entrez votre email" required>
|
||||
|
||||
<label for="password">Mot de passe:</label>
|
||||
<input type="password" id="password" name="password" placeholder="Entrez votre mot de passe" required>
|
||||
|
||||
<button type="submit">Connexion</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="new">
|
||||
|
||||
<h3> Création de compte </h3>
|
||||
|
||||
<form action="traitement" method="POST">
|
||||
<label for="nom">Votre nom*</label>
|
||||
<input type="text" id="nom" name="nom" placeholder="Entrez votre nom" required>
|
||||
|
||||
<label for="prenom">Votre prénom*</label>
|
||||
<input type="text" id="prenom" name="prenom" placeholder="Entrez votre prénom" required>
|
||||
|
||||
<label for="pseudo">Votre pseudo*</label>
|
||||
<input type="text" id="pseudo" name="pseudo" placeholder="Entrez votre pseudo" required>
|
||||
|
||||
<label for="email">Votre email*</label>
|
||||
<input type="email" id="email" name="email" placeholder="Entrez votre adresse email" required>
|
||||
|
||||
<label for="pass">Votre mot de passe*</label>
|
||||
<input type="password" id="pass" name="pass" placeholder="Entrez votre mdp" required>
|
||||
|
||||
<input type="submit" value="M'inscrire" name="ok">
|
||||
|
||||
</form>
|
||||
|
||||
<?php if(isset($confirmation_message)): ?>
|
||||
<div class="confirmation-message"><?= $confirmation_message ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
<h1>S'inscrire</h1>
|
||||
<form action="traitement" method="POST">
|
||||
<label for="nom">Votre nom*</label>
|
||||
<input type="text" id="nom" name="nom" placeholder="Entrez votre nom" required>
|
||||
|
||||
<label for="prenom">Votre prénom*</label>
|
||||
<input type="text" id="prenom" name="prenom" placeholder="Entrez votre prénom" required>
|
||||
|
||||
<label for="pseudo">Votre pseudo*</label>
|
||||
<input type="text" id="pseudo" name="pseudo" placeholder="Entrez votre pseudo" required>
|
||||
|
||||
<label for="email">Votre email*</label>
|
||||
<input type="email" id="email" name="email" placeholder="Entrez votre adresse email" required>
|
||||
|
||||
<label for="pass">Votre mot de passe*</label>
|
||||
<input type="password" id="pass" name="pass" placeholder="Entrez votre mdp" required>
|
||||
|
||||
<input type="submit" value="M'inscrire" name="ok">
|
||||
|
||||
</form>
|
||||
|
||||
<?php if(isset($confirmation_message)): ?>
|
||||
<div class="confirmation-message"><?= $confirmation_message ?></div>
|
||||
<?php endif; ?>
|
@ -17,17 +17,25 @@
|
||||
<ul>
|
||||
<li><strong>Music APP</strong></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?=anchor('albums','Albums');?></li>
|
||||
<li><?=anchor('artistes','Artistes');?></li>
|
||||
<?php if ($this->session->userdata('pseudo')) : // Vérifier si l'utilisateur est connecté ?>
|
||||
<li><?= $this->session->userdata('pseudo'); ?></li>
|
||||
<li><?= anchor('deconnexion', 'Se déconnecter'); ?></li>
|
||||
<?php else : ?>
|
||||
<li><?= anchor('connexion', 'Se connecter'); ?></li>
|
||||
<li><?= anchor('inscription', 'Inscription'); ?></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
<ul class="option">
|
||||
<li><?=anchor('albums','Albums');?></li>
|
||||
<li><?=anchor('artistes','Artistes');?></li>
|
||||
<li><?=anchor('playlist','Playlist');?></li>
|
||||
<?php if ($this->session->userdata('pseudo')) : /* Vérifier si l'utilisateur est connecté */ ?>
|
||||
|
||||
<li class="deroulant"><a><?= $this->session->userdata('pseudo'); ?></a>
|
||||
<ul class="sous">
|
||||
|
||||
<li><?= anchor('profil', 'Profil'); ?></li>
|
||||
<li><?=anchor('deconnexion', 'Se déconnecter'); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php else : ?>
|
||||
<li><?=anchor('connexion', 'Se connecter'); ?></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -25,7 +25,7 @@ section.list img {
|
||||
nav {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
|
||||
background-color: #283d5d;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
@ -34,15 +34,47 @@ main.container {
|
||||
margin-top: 60px;
|
||||
}
|
||||
|
||||
.container ul {
|
||||
left: 0;
|
||||
|
||||
.options {
|
||||
margin-right : 20px!important;
|
||||
|
||||
}
|
||||
|
||||
.container li {
|
||||
margin-right : 20px;
|
||||
.sous {
|
||||
display: none;
|
||||
border-radius: 5px;
|
||||
border: solid 1px black;
|
||||
background-color: #283d5d;
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
right: 12px;
|
||||
text-align: center
|
||||
}
|
||||
|
||||
.sous li {
|
||||
display: block!important;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
nav > ul li:hover .sous {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.deroulant a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.deroulant > a::after {
|
||||
content: " ▼ ";
|
||||
font-size: 17px;
|
||||
|
||||
}
|
||||
|
||||
.sous a:hover{
|
||||
color: #1399fc;
|
||||
}
|
||||
|
||||
section.connexion {
|
||||
display: flex;
|
||||
@ -56,3 +88,87 @@ div.authentification {
|
||||
div.new {
|
||||
width: 45%;
|
||||
}
|
||||
|
||||
/* Styles pour les détails des pistes */
|
||||
|
||||
.track-list {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.track-id {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.track-name {
|
||||
flex-grow: 1;
|
||||
overflow: visible;
|
||||
text-overflow: clip;
|
||||
}
|
||||
|
||||
.track-time {
|
||||
flex-shrink: 0;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
#tri {
|
||||
text-align: right;
|
||||
}
|
||||
/* mise en forme du tri */
|
||||
|
||||
|
||||
/*.sous_tri {
|
||||
display: none;
|
||||
position: absolute;
|
||||
text-align: right;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.tri {
|
||||
color: #a4acba;
|
||||
text-align: right;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.tri:hover sous_tri {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
.sous_tri a:hover{
|
||||
color: #1399fc;
|
||||
}*/
|
||||
|
||||
.sorting-search {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tri-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 200px;
|
||||
padding: 5px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.back-form {
|
||||
display: inline-block;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user