mirror of
https://grond.iut-fbleau.fr/stiti/SAE_2.02
synced 2024-12-27 01:12:18 +01:00
Commit de louay (problème de VM)
This commit is contained in:
parent
b099620b60
commit
b2b5e45015
@ -53,4 +53,6 @@ $route['default_controller'] = 'home/index';
|
||||
$route['404_override'] = '';
|
||||
$route['translate_uri_dashes'] = FALSE;
|
||||
$route['albums'] = 'albums/index';
|
||||
$route['musiques'] = 'Musiques/index';
|
||||
|
||||
|
||||
|
@ -32,5 +32,6 @@ class Albums extends CI_Controller {
|
||||
$this->load->view('album_view', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
32
CodeIgniter-3.1.13/application/controllers/Artiste.php
Normal file
32
CodeIgniter-3.1.13/application/controllers/Artiste.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Artiste extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('Model_music');
|
||||
$this->load->helper('url');
|
||||
}
|
||||
|
||||
public function index($artiste_id){
|
||||
// Récupérer les détails de l'artiste
|
||||
$artiste = $this->Model_music->getArtisteById($artiste_id);
|
||||
|
||||
if($artiste){
|
||||
// Récupérer tous les albums de l'artiste
|
||||
$albums = $this->Model_music->getAlbumsByArtiste($artiste_id);
|
||||
|
||||
// Charger la vue avec les détails de l'artiste et ses albums
|
||||
$data['artiste'] = $artiste;
|
||||
$data['albums'] = $albums;
|
||||
$this->load->view('layout/header_not_logged_dark');
|
||||
$this->load->view('artiste_details', $data); // Créez cette vue
|
||||
$this->load->view('layout/footer_dark');
|
||||
} else {
|
||||
// Gérer le cas où l'artiste n'est pas trouvé
|
||||
show_404(); // Affiche une page d'erreur 404
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
33
CodeIgniter-3.1.13/application/controllers/Musiques.php
Normal file
33
CodeIgniter-3.1.13/application/controllers/Musiques.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Musiques extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('Model_music');
|
||||
$this->load->library('pagination');
|
||||
$this->load->helper('url');
|
||||
}
|
||||
|
||||
public function index($page = 1){
|
||||
$limit = 100; // Nombre de musiques par page
|
||||
$offset = ($page - 1) * $limit;
|
||||
|
||||
$musiques = $this->Model_music->getMusiques($limit, $offset);
|
||||
|
||||
$total_musiques = $this->Model_music->get_total_musiques();
|
||||
$data['total_pages'] = ceil($total_musiques / $limit); // Calcul du nombre total de pages
|
||||
$data['current_page'] = $page; // Définition de la variable $current_page
|
||||
|
||||
// Données à passer à la vue
|
||||
$data['musiques'] = $musiques;
|
||||
|
||||
// Charger la vue
|
||||
$this->load->view('layout/header_not_logged_dark');
|
||||
$this->load->view('musiques_list', $data);
|
||||
$this->load->view('layout/footer_dark');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -50,5 +50,25 @@ class Model_music extends CI_Model {
|
||||
|
||||
return $album;
|
||||
}
|
||||
|
||||
public function getMusiques($limit, $offset) {
|
||||
$query = $this->db->query(
|
||||
"SELECT song.id, song.name, artist.name as artistName, album.name as album_name, track.albumid as album_id, cover.jpeg as cover
|
||||
FROM song
|
||||
JOIN track ON song.id = track.songid
|
||||
JOIN album ON track.albumid = album.id
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN cover ON album.coverid = cover.id
|
||||
LIMIT $limit OFFSET $offset"
|
||||
);
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function get_total_musiques(){
|
||||
$query = $this->db->query("SELECT COUNT(*) as total_musiques FROM song");
|
||||
$result = $query->row();
|
||||
return $result->total_musiques;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="hero">
|
||||
<h1>Bienvenue sur Onzeur !</h1>
|
||||
<p>Le service de streaming musical numéro 1 en France.</p>
|
||||
<a href="<?php echo site_url('albums'); ?>"><button type="button">Accéder à la musique</button></a>
|
||||
<a href="<?php echo site_url('musiques'); ?>"><button type="button">Accéder à la musique</button></a>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
31
CodeIgniter-3.1.13/application/views/album_musiques.php
Normal file
31
CodeIgniter-3.1.13/application/views/album_musiques.php
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/album_musiques'); ?>">
|
||||
<title><?php echo $album->name; ?> - Musiques</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="album-details">
|
||||
<h1><?php echo $album->name; ?></h1>
|
||||
<p><strong>Artiste :</strong> <?php echo $album->artistName; ?></p>
|
||||
<p><strong>Année :</strong> <?php echo $album->year; ?></p>
|
||||
<p><strong>Genre :</strong> <?php echo $album->genreName; ?></p>
|
||||
<img src="data:image/jpeg;base64,<?php echo base64_encode($album->jpeg); ?>" alt="Image d'album">
|
||||
|
||||
<?php if (!empty($album->tracks)): ?>
|
||||
<h2>Musiques</h2>
|
||||
<ul>
|
||||
<?php foreach ($album->tracks as $track): ?>
|
||||
<li>
|
||||
<strong><?php echo $track->diskNumber . '.' . $track->number; ?>:</strong> <?php echo $track->songName; ?> (<?php echo gmdate("i:s", $track->duration); ?>)
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<p>Aucune musique n'est disponible dans cet album...</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
36
CodeIgniter-3.1.13/application/views/musiques_list.php
Normal file
36
CodeIgniter-3.1.13/application/views/musiques_list.php
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="<?php echo base_url('assets/css/musiques_list'); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Liste des Musiques - Onzeur</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Liste des musiques</h1>
|
||||
<ul>
|
||||
<?php foreach($musiques as $musique): ?>
|
||||
<li>
|
||||
<strong>Titre:</strong> <?php echo $musique->name; ?> <br>
|
||||
<strong>Artiste:</strong> <?php echo $musique->artistName; ?> <br>
|
||||
<strong>Album:</strong> <a href="<?php echo base_url('index.php/albums/view/'.$musique->album_id); ?>"><?php echo $musique->album_name; ?></a> <br>
|
||||
<img src="data:image/jpeg;base64,<?php echo base64_encode($musique->cover); ?>" alt="Couverture d'album"> <br>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<div class="pagination">
|
||||
<?php if ($current_page > 1): ?>
|
||||
<a class="fleche" href="<?php echo base_url('index.php/musiques/index/'.($current_page-1)); ?>"><</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php for ($i = max(1, $current_page - 2); $i <= min($total_pages, $current_page + 2); $i++): ?>
|
||||
<a href="<?php echo base_url('index.php/musiques/index/'.$i); ?>" <?php echo ($i == $current_page) ? 'class="active"' : ''; ?>><?php echo $i; ?></a>
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php if ($current_page < $total_pages): ?>
|
||||
<a class="fleche" href="<?php echo base_url('index.php/musiques/index/'.($current_page+1)); ?>">></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
61
CodeIgniter-3.1.13/assets/css/musiques_list.css
Normal file
61
CodeIgniter-3.1.13/assets/css/musiques_list.css
Normal file
@ -0,0 +1,61 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #6a0dad;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
li {
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #560d61;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #560d61;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
/* Styles pour les boutons de pagination */
|
||||
.pagination {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.pagination a {
|
||||
display: inline-block;
|
||||
padding: 8px 16px;
|
||||
margin: 0 4px;
|
||||
background-color: #6a0dad;
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.pagination a:hover {
|
||||
background-color: #4a0772;
|
||||
}
|
||||
|
||||
.pagination .active {
|
||||
background-color: #29043e;
|
||||
}
|
Loading…
Reference in New Issue
Block a user