adding views songs
This commit is contained in:
		@@ -33,18 +33,19 @@ class Music extends CI_Controller {
 | 
			
		||||
        $this->load->view('layout/footer');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function song($songId) {
 | 
			
		||||
        $songData = $this->model_music->getSongDetails($songId);
 | 
			
		||||
    public function view($songId) {
 | 
			
		||||
		$songData = $this->model_music->getArtistDetails($songId);
 | 
			
		||||
	
 | 
			
		||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
			
		||||
        $data = array(
 | 
			
		||||
            'song' => $songData,
 | 
			
		||||
            'is_logged_in' => $is_logged_in
 | 
			
		||||
        );
 | 
			
		||||
		$is_logged_in = $this->session->userdata('logged_in');
 | 
			
		||||
		$data = array(
 | 
			
		||||
			'artist' => $songData['artist'],
 | 
			
		||||
			'albums' => $songData['albums'],
 | 
			
		||||
			'is_logged_in' => $is_logged_in
 | 
			
		||||
		);
 | 
			
		||||
	
 | 
			
		||||
        $this->load->view('layout/header', $data);
 | 
			
		||||
        $this->load->view('song_details', $data);
 | 
			
		||||
        $this->load->view('layout/footer');
 | 
			
		||||
    }
 | 
			
		||||
		$this->load->view('layout/header', $data);
 | 
			
		||||
		$this->load->view('song_details', $data);
 | 
			
		||||
		$this->load->view('layout/footer');
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -152,25 +152,37 @@ class Model_music extends CI_Model {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    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);
 | 
			
		||||
        $this->db->select('song.name as songName, song.id');
 | 
			
		||||
        $this->db->from('song');
 | 
			
		||||
        $this->db->where('song.id', $songId);
 | 
			
		||||
        $songQuery = $this->db->get();
 | 
			
		||||
        return $songQuery->row();
 | 
			
		||||
        $songDetails = $songQuery->row();
 | 
			
		||||
    
 | 
			
		||||
        // Get album details for the song
 | 
			
		||||
        $this->db->select('album.id as albumId, album.name as albumName, album.year');
 | 
			
		||||
        $this->db->from('album');
 | 
			
		||||
        $this->db->join('track', 'track.albumid = album.id');
 | 
			
		||||
        $this->db->where('track.songid', $songId);
 | 
			
		||||
        $albumQuery = $this->db->get();
 | 
			
		||||
        $albumDetails = $albumQuery->row();
 | 
			
		||||
    
 | 
			
		||||
        // Get artist details for the album
 | 
			
		||||
        $this->db->select('artist.id as artistId, artist.name as artistName');
 | 
			
		||||
        $this->db->from('artist');
 | 
			
		||||
        $this->db->join('album', 'album.artistid = artist.id');
 | 
			
		||||
        $this->db->where('album.id', $albumDetails->albumId);
 | 
			
		||||
        $artistQuery = $this->db->get();
 | 
			
		||||
        $artistDetails = $artistQuery->row();
 | 
			
		||||
    
 | 
			
		||||
        return array('song' => $songDetails, 'album' => $albumDetails, 'artist' => $artistDetails);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    // Suppression de la deuxième méthode researchtype
 | 
			
		||||
 | 
			
		||||
    public function research(){
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,15 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
    <title><?= $song->songName ?> - Details</title>
 | 
			
		||||
    <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">
 | 
			
		||||
    <h1><?= $song['songName'] ?></h1>
 | 
			
		||||
    <p><strong>Album:</strong> <?= anchor("albums/view/{$song['albumId']}", $song['albumName']) ?> (<?= $song['year'] ?>)</p>
 | 
			
		||||
    <p><strong>Artist:</strong> <?= $song['artistName'] ?></p>
 | 
			
		||||
    <p><strong>Genre:</strong> <?= $song['genreName'] ?></p>
 | 
			
		||||
    <?php if(isset($song['jpeg']) && $song['jpeg'] != ''): ?>
 | 
			
		||||
        <img src="data:image/jpeg;base64,<?= base64_encode($song['jpeg']) ?>" alt="<?= $song['albumName'] ?> Cover">
 | 
			
		||||
    <?php endif; ?>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user