Files
SAE_PHP_2024/CodeIgniter-3.1.13/application/views/albums_view.php

61 lines
2.4 KiB
PHP
Raw Normal View History

2024-06-16 21:57:34 +02:00
<?php
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
$long_page = count($page)-1;
$url = $page[$long_page];
while ($page[$long_page] != 'albums'){
$long_page = $long_page - 1;
2024-06-17 18:43:13 +02:00
$url = $page[$long_page].'/'.$url;
2024-06-16 21:57:34 +02:00
}
2024-06-17 18:43:13 +02:00
print_r($url);
2024-06-16 21:57:34 +02:00
?>
<section class="album-details">
<div class="album-content">
<div class="album-image">
<?php
2024-06-17 18:43:13 +02:00
echo '<img src="data:image/jpeg;base64,' . base64_encode($albums->coverImage) . '" style="width: 300px; height: 300px;" alt="Album cover"/>';
?>
<br>
<br>
2024-06-16 21:57:34 +02:00
<h4><?php echo $albums->name; ?></h4>
2024-06-17 18:43:13 +02:00
<p><?php echo "Artiste : " . $albums->artist->name; ?></p>
<p><?php echo "Année : " . $albums->year; ?></p>
</div>
2024-06-16 21:57:34 +02:00
<div class="album-songs">
<?php
2024-06-16 21:57:34 +02:00
echo "<table>";
2024-06-17 18:43:13 +02:00
echo "<thead>";
2024-06-16 21:57:34 +02:00
echo "<tr>";
echo "<th>Titre</th>";
echo "<th>Durée</th>";
echo "<th>Action</th>";
echo "</tr>";
2024-06-17 18:43:13 +02:00
echo "</thead>";
echo "<tbody>";
2024-06-16 21:57:34 +02:00
foreach ($albums->songs as $index => $song) {
$artistName = $albums->artist->name;
$duration = isset($albums->tracks[$index]->duration) ? convertirSecondesEnMinutes($albums->tracks[$index]->duration) : '';
echo "<tr>";
2024-06-17 18:43:13 +02:00
echo "<td>" . $song . "</td>";
echo "<td>" . $duration . "</td>";
2024-06-16 21:57:34 +02:00
echo "<td>";
if ($this->session->userdata('logged_in')){
if($this->model_music->SongInPlaylist($albums->tracks[$index]->trackId)){
2024-06-17 18:43:13 +02:00
echo anchor("chansons/deleteSongtoPlaylist/{$albums->tracks[$index]->trackId}", "<i class='fa fa-trash'></i>", ['title' => 'Supprimer de la playlist']);
2024-06-16 21:57:34 +02:00
}
}
2024-06-17 18:43:13 +02:00
echo anchor("chansons/addSongtoPlaylist/{$albums->tracks[$index]->trackId}", "<i class='fa fa-plus'></i>", ['title' => 'Ajouter à la playlist']);
2024-06-16 21:57:34 +02:00
echo "</td>";
echo "</tr>";
}
2024-06-17 18:43:13 +02:00
echo "</tbody>";
2024-06-16 21:57:34 +02:00
echo "</table>";
2024-06-16 21:57:34 +02:00
function convertirSecondesEnMinutes($secondes) {
$minutes = floor($secondes / 60);
$secondesRestantes = $secondes % 60;
return sprintf('%02d:%02d', $minutes, $secondesRestantes);
}
?>
</div>
</div>
2024-06-17 18:43:13 +02:00
</section>