Test pages * 1/?

This commit is contained in:
Vincent 2024-06-04 23:26:09 +02:00
parent a59966d698
commit f0260ba791
6 changed files with 54 additions and 9 deletions

@ -6,7 +6,7 @@ class Artistes extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('model_music');
$this->load->library('session'); // La session est déjà chargée via autoload.php, mais par précaution.
$this->load->library('session');
}
public function index(){
@ -14,7 +14,7 @@ class Artistes extends CI_Controller {
$order = $this->input->get('order');
$query = $this->input->get('query');
$artists = $this->model_music->getArtists($genre, $order, $query); // Pass $query
$artists = $this->model_music->getArtists($genre, $order, $query);
$genres = $this->model_music->researchtype();
$is_logged_in = $this->session->userdata('logged_in');

@ -13,8 +13,7 @@ class Music extends CI_Controller {
$genre = $this->input->get('genre');
$order = $this->input->get('order');
$artist = $this->input->get('artist');
$query = $this->input->get('query');
$query = $this->input->get('query');
$musics = $this->model_music->getMusics($genre, $order, $artist, $query);
$genres = $this->model_music->researchtype();
@ -33,4 +32,19 @@ class Music extends CI_Controller {
$this->load->view('musiques_list', $data);
$this->load->view('layout/footer');
}
public function song($songId) {
$songData = $this->model_music->getSongDetails($songId);
$is_logged_in = $this->session->userdata('logged_in');
$data = array(
'song' => $songData,
'is_logged_in' => $is_logged_in
);
$this->load->view('layout/header', $data);
$this->load->view('song_details', $data);
$this->load->view('layout/footer');
}
}

@ -128,13 +128,13 @@ class Model_music extends CI_Model {
$this->db->select('artist.name as artistName, artist.id, genre.name as genreName, artist.jpeg');
$this->db->from('artist');
$this->db->join('album', 'album.artistid = artist.id');
$this->db->join('genre', 'genre.id = album.genreid');
$this->db->join('genre', 'genre.id = album.genreid', 'left');
$this->db->where('artist.id', $artistId);
$artistQuery = $this->db->get();
$artistDetails = $artistQuery->row();
// Get artist's albums
$this->db->select('album.name as albumName, album.id as albumId, album.year');
$this->db->select('album.id as albumId, album.name as albumName, album.year');
$this->db->from('album');
$this->db->where('album.artistid', $artistId);
$albumsQuery = $this->db->get();
@ -143,6 +143,20 @@ class Model_music extends CI_Model {
return array('artist' => $artistDetails, 'albums' => $albums);
}
public function getSongDetails($songId) {
// Get song details
$this->db->select('song.name as songName, track.id as trackId, album.name as albumName, album.year, artist.name as artistName, genre.name as genreName, cover.jpeg');
$this->db->from('track');
$this->db->join('song', 'track.songId = song.id');
$this->db->join('album', 'track.albumId = album.id');
$this->db->join('artist', 'album.artistid = artist.id');
$this->db->join('genre', 'album.genreid = genre.id');
$this->db->join('cover', 'album.coverid = cover.id');
$this->db->where('track.id', $songId);
$songQuery = $this->db->get();
return $songQuery->row();
}

@ -13,7 +13,7 @@
<h2>Songs</h2>
<ul>
<?php foreach ($songs as $song): ?>
<li><?= $song->trackName ?></li>
<li><?= anchor("music/song/{$song->trackId}", $song->trackName) ?></li>
<?php endforeach; ?>
</ul>
</body>

@ -5,8 +5,12 @@
</head>
<body>
<h1><?= $artist->artistName ?></h1>
<p><strong>Genre:</strong> <?= $artist->genreName ?></p>
<img src="data:image/jpeg;base64,<?= base64_encode($artist->jpeg) ?>" alt="<?= $artist->artistName ?> Photo">
<?php if (!empty($artist->genreName)): ?>
<p><strong>Genre:</strong> <?= $artist->genreName ?></p>
<?php endif; ?>
<?php if (!empty($artist->jpeg)): ?>
<img src="data:image/jpeg;base64,<?= base64_encode($artist->jpeg) ?>" alt="<?= $artist->artistName ?> Photo">
<?php endif; ?>
<h2>Albums</h2>
<ul>

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title><?= $song->songName ?> - Details</title>
</head>
<body>
<h1><?= $song->songName ?></h1>
<p><strong>Album:</strong> <?= anchor("albums/view/{$song->trackId}", $song->albumName) ?> (<?= $song->year ?>)</p>
<p><strong>Artist:</strong> <?= $song->artistName ?></p>
<p><strong>Genre:</strong> <?= $song->genreName ?></p>
<img src="data:image/jpeg;base64,<?= base64_encode($song->jpeg) ?>" alt="<?= $song->albumName ?> Cover">
</body>
</html>