validateur validé
This commit is contained in:
@@ -68,7 +68,7 @@ class Albums extends CI_Controller {
|
||||
$playlistId = $this->input->post('playlist_id');
|
||||
$page = $this->input->get('page');
|
||||
$this->model_music->AddAlbumtoPlaylist($playlistId,$id);
|
||||
redirect($page);
|
||||
redirect(echo $page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class Chansons extends CI_Controller {
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('addSongtoplaylist', ["playlists" => $playlists]);
|
||||
$this->load->view('addSongtoplaylist', ["id" => $id, "playlists" => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$playlistId = $this->input->post('playlist_id');
|
||||
@@ -62,7 +62,7 @@ class Chansons extends CI_Controller {
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('deleteSongtoplaylist', ["playlists" => $playlists]);
|
||||
$this->load->view('deleteSongtoplaylist', ["id" => $id, "playlists" => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$playlistId = $this->input->post('playlist_id');
|
||||
|
||||
@@ -118,7 +118,8 @@ class Model_music extends CI_Model {
|
||||
}
|
||||
|
||||
public function get_filtered_sorted_chansons($genres = [], $artists = [], $years = [], $albums = [], $sort_column = 'id', $sort_order = 'asc', $limit = 100, $offset = 0) {
|
||||
$this->db->select('track.id as trackId, song.name,song.id,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName');
|
||||
$this->db->distinct('song.id');
|
||||
$this->db->select('track.id as trackId, song.name,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName');
|
||||
$this->db->from('song');
|
||||
$this->db->join('track', 'track.songId = song.id');
|
||||
$this->db->join('album', 'album.id = track.albumId');
|
||||
@@ -400,7 +401,52 @@ class Model_music extends CI_Model {
|
||||
if ($result->num_rows() > 0) {
|
||||
return true;
|
||||
}
|
||||
return $query = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function SongInThisPlaylist($idtrack,$idplaylist){
|
||||
if (!is_array($idtrack)) {
|
||||
$idtrack = array($idtrack);
|
||||
}
|
||||
|
||||
// Étape 1: Récupérer l'ID de la chanson à partir de l'un des IDs de piste fournis
|
||||
$this->db->select('song.id as songId');
|
||||
$this->db->from('track');
|
||||
$this->db->join('song', 'song.id = track.songId');
|
||||
$this->db->where_in('track.id', $idtrack);
|
||||
$query = $this->db->get();
|
||||
|
||||
// Vérifier si des résultats ont été trouvés
|
||||
if ($query->num_rows() == 0) {
|
||||
return false; // Si aucun résultat trouvé, retourner false
|
||||
}
|
||||
|
||||
// Récupérer le premier songId correspondant
|
||||
$result = $query->row();
|
||||
$songId = $result->songId;
|
||||
|
||||
// Étape 2: Récupérer tous les IDs de pistes associés à cette chanson
|
||||
$this->db->select('track.id as trackId');
|
||||
$this->db->from('track');
|
||||
$this->db->where('track.songId', $songId);
|
||||
$query = $this->db->get();
|
||||
$trackIds = array();
|
||||
foreach ($query->result() as $track) {
|
||||
$trackIds[] = $track->trackId;
|
||||
}
|
||||
|
||||
// Étape 3: Vérifier si l'une des pistes de cette chanson est dans la playlist
|
||||
$this->db->select('PlaylistSong.trackid as trackId');
|
||||
$this->db->from('PlaylistSong');
|
||||
$this->db->where_in('PlaylistSong.trackid', $trackIds);
|
||||
$this->db->where('PlaylistSong.playlistId',$idplaylist);
|
||||
$query = $this->db->get();
|
||||
|
||||
// Si on trouve au moins une piste de cette chanson dans la playlist, retourner true
|
||||
if ($query->num_rows() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function TrackidSonginPlaylist($id) {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<title>Ajouter un album à une playlist</title>
|
||||
<h6>Ajouter un album à une playlist</h6>
|
||||
|
||||
|
||||
<div class="trie">
|
||||
<h5>Playlists</h5>
|
||||
</div>
|
||||
|
||||
<section class="list">
|
||||
|
||||
<form method="post">
|
||||
<form method="post" action="your_form_action_url.php">
|
||||
<?php foreach ($playlists as $playlist): ?>
|
||||
<div class="playlist-option">
|
||||
<label>
|
||||
<input type="radio" name="playlist_id" value="<?= $playlist->playlistid ?>">
|
||||
<input type="radio" name="playlist_id" value="<?=$playlist->playlistid ?>">
|
||||
<?= $playlist->name ?>
|
||||
</label>
|
||||
</div>
|
||||
@@ -21,5 +21,3 @@
|
||||
</form>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<title>Ajouter toutes les musique d'un artiste à une playlist</title>
|
||||
<h6>Ajouter toutes les musique d'un artiste à une playlist</h6>
|
||||
|
||||
<div class="trie">
|
||||
<h5>Playlists</h5>
|
||||
</div>
|
||||
|
||||
<section class="list">
|
||||
|
||||
<form method="post">
|
||||
<?php foreach ($playlists as $playlist): ?>
|
||||
<div class="playlist-option">
|
||||
<label>
|
||||
<input type="radio" name="playlist_id" value="<?= $playlist->playlistid ?>">
|
||||
<input type="radio" name="playlist_id" value="<?=$playlist->playlistid ?>">
|
||||
<?= $playlist->name ?>
|
||||
</label>
|
||||
</div>
|
||||
@@ -20,6 +19,3 @@
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<title>Ajouter une chanson à une playlist</title>
|
||||
<h6>Ajouter une chanson à une playlist</h6>
|
||||
|
||||
<div class="trie">
|
||||
<h5>Playlists</h5>
|
||||
@@ -10,7 +10,7 @@
|
||||
<?php foreach ($playlists as $playlist): ?>
|
||||
<div class="playlist-option">
|
||||
<label>
|
||||
<?php if($this->model_music->SongInPlaylist($id) == false){ ?>
|
||||
<?php if($this->model_music->SongInThisPlaylist($id,$playlist->playlistid) == false){ ?>
|
||||
<input type="radio" name="playlist_id" value="<?= $playlist->playlistid ?>">
|
||||
<?= $playlist->name ?>
|
||||
<?php } ?>
|
||||
@@ -23,5 +23,3 @@
|
||||
</form>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,91 +1,88 @@
|
||||
<?php
|
||||
$page = preg_split('/[\/]/', $_SERVER['REQUEST_URI']);
|
||||
if ($page[count($page)-2] != 'viewAlbum'): ?>
|
||||
<h5>Filter Albums</h5>
|
||||
<button type="button" onclick="toggleFilterOptions()">Filter</button>
|
||||
|
||||
<div id="filter-options" class="filter-options">
|
||||
<form method="get">
|
||||
<div id="filter-buttons" class="filter-buttons">
|
||||
<button type="button" onclick="toggleCheckboxes('genre')">Genres</button>
|
||||
<button type="button" onclick="toggleCheckboxes('artist')">Artists</button>
|
||||
<button type="button" onclick="toggleCheckboxes('year')">Years</button>
|
||||
</div>
|
||||
|
||||
<?php $page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
if($page[count($page)-2] != 'viewAlbum'){ ?>
|
||||
<h5>Filter Albums</h5>
|
||||
<button type="button" onclick="toggleFilterOptions()">Filter</button>
|
||||
<div id="genre-checkboxes" style="display:none;">
|
||||
<?php foreach ($genres as $genre): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="genre[]" value="<?= $genre->genreName; ?>">
|
||||
<?= $genre->genreName; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div id="filter-options" class="filter-options">
|
||||
<form method="get">
|
||||
<div id="filter-buttons" class="filter-buttons">
|
||||
<button type="button" onclick="toggleCheckboxes('genre')">Genres</button>
|
||||
<button type="button" onclick="toggleCheckboxes('artist')">Artists</button>
|
||||
<button type="button" onclick="toggleCheckboxes('year')">Years</button>
|
||||
</div>
|
||||
<div id="artist-checkboxes" style="display:none;">
|
||||
<?php foreach ($artists as $artist): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="artist[]" value="<?= $artist->artistName; ?>">
|
||||
<?= $artist->artistName; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div id="genre-checkboxes" style="display:none;">
|
||||
<?php foreach ($genres as $genre): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="genre[]" value="<?= $genre->genreName; ?>">
|
||||
<?= $genre->genreName; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div id="year-checkboxes" style="display:none;">
|
||||
<?php foreach ($years as $year): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="year[]" value="<?= $year->year; ?>">
|
||||
<?= $year->year; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div id="artist-checkboxes" style="display:none;">
|
||||
<?php foreach ($artists as $artist): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="artist[]" value="<?= $artist->artistName; ?>">
|
||||
<?= $artist->artistName; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<button type="submit">Apply Filters</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="year-checkboxes" style="display:none;">
|
||||
<?php foreach ($years as $year): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="year[]" value="<?= $year->year; ?>">
|
||||
<?= $year->year; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<button type="submit">Apply Filters</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h5>Sort Albums</h5>
|
||||
<button type="button" onclick="toggleSortButtons()">Sort</button>
|
||||
<div id="sort-buttons" class="sort-buttons">
|
||||
<button onclick="sortAlbums('year', 'asc')">Sort by Year Asc</button>
|
||||
<button onclick="sortAlbums('year', 'desc')">Sort by Year Desc</button>
|
||||
<button onclick="sortAlbums('artistName', 'asc')">Sort by Artist Asc</button>
|
||||
<button onclick="sortAlbums('artistName', 'desc')">Sort by Artist Desc</button>
|
||||
<button onclick="sortAlbums('name', 'asc')">Sort by Album Name Asc</button>
|
||||
<button onclick="sortAlbums('name', 'desc')">Sort by Album Name Desc</button>
|
||||
<button onclick="sortAlbums('genreName', 'asc')">Sort by Genre Asc</button>
|
||||
<button onclick="sortAlbums('genreName', 'desc')">Sort by Genre Desc</button>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<h5>Sort Albums</h5>
|
||||
<button type="button" onclick="toggleSortButtons()">Sort</button>
|
||||
<div id="sort-buttons" class="sort-buttons">
|
||||
<button onclick="sortAlbums('year', 'asc')">Sort by Year Asc</button>
|
||||
<button onclick="sortAlbums('year', 'desc')">Sort by Year Desc</button>
|
||||
<button onclick="sortAlbums('artistName', 'asc')">Sort by Artist Asc</button>
|
||||
<button onclick="sortAlbums('artistName', 'desc')">Sort by Artist Desc</button>
|
||||
<button onclick="sortAlbums('name', 'asc')">Sort by Album Name Asc</button>
|
||||
<button onclick="sortAlbums('name', 'desc')">Sort by Album Name Desc</button>
|
||||
<button onclick="sortAlbums('genreName', 'asc')">Sort by Genre Asc</button>
|
||||
<button onclick="sortAlbums('genreName', 'desc')">Sort by Genre Desc</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h5>Albums list</h5>
|
||||
<section class="list">
|
||||
<?php
|
||||
$page = preg_split('/[\/]/', $_SERVER['REQUEST_URI']);
|
||||
$long_page = count($page) - 1;
|
||||
$valid_segments = ['albums', 'chansons'];
|
||||
$url = '';
|
||||
|
||||
for ($i = $long_page; $i >= 0; $i--) {
|
||||
if (in_array($page[$i], $valid_segments)) {
|
||||
$url = implode('/', array_slice($page, $i));
|
||||
break;
|
||||
}
|
||||
$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;
|
||||
$url = $page[$long_page].'/'.$url;
|
||||
}
|
||||
print_r($url);
|
||||
|
||||
foreach($albums as $album){
|
||||
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("albums/viewMusique/{$album->albumId}","{$album->name}");
|
||||
if($this->session->userdata('logged_in')){
|
||||
echo anchor("albums/addAlbumtoPlaylist/{$album->albumId}?page={$url}","<i class='fa fa-plus'></i>");
|
||||
}
|
||||
echo "</header>";
|
||||
echo '<img src="data:image/jpeg;base64,'.base64_encode($album->jpeg).'" />';
|
||||
echo "<nav class='short-text'>Genre: {$album->genreName}</nav>";
|
||||
echo "<footer class='short-text'>{$album->year} - {$album->artistName}</footer>
|
||||
</article></div>";
|
||||
}
|
||||
foreach ($albums as $album):
|
||||
?>
|
||||
<div>
|
||||
<article>
|
||||
<header class="short-text">
|
||||
<?= anchor("albums/viewMusique/{$album->albumId}", $album->name); ?>
|
||||
<?php if ($this->session->userdata('logged_in')): ?>
|
||||
<?= anchor("albums/addAlbumtoPlaylist/{$album->albumId}?page={$url}", "<i class='fa fa-plus'></i>"); ?>
|
||||
<?php endif; ?>
|
||||
</header>
|
||||
<img src="data:image/jpeg;base64,<?= base64_encode($album->jpeg); ?>" alt="cover de l'album" />
|
||||
<nav class="short-text">Genre: <?= $album->genreName; ?></nav>
|
||||
<footer class="short-text"><?= $album->year; ?> - <?= $album->artistName; ?></footer>
|
||||
</article>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
||||
@@ -4,46 +4,50 @@
|
||||
$url = $page[$long_page];
|
||||
while ($page[$long_page] != 'albums'){
|
||||
$long_page = $long_page - 1;
|
||||
$url = $page[$long_page];
|
||||
$url = $page[$long_page].'/'.$url;
|
||||
}
|
||||
print_r($url);
|
||||
?>
|
||||
<section class="album-details">
|
||||
<div class="album-content">
|
||||
<div class="album-image">
|
||||
<?php
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($albums->coverImage) . '" style="width: 300px; height: 300px;" />';
|
||||
echo '<img src="data:image/jpeg;base64,' . base64_encode($albums->coverImage) . '" style="width: 300px; height: 300px;" alt="Album cover"/>';
|
||||
?>
|
||||
<br>
|
||||
<br>
|
||||
<h4><?php echo $albums->name; ?></h4>
|
||||
<h8><?php echo " - Artiste : " . $albums->artist->name; ?></h8>
|
||||
<p><?php echo " - Année : " . $albums->year; ?></p>
|
||||
<p><?php echo "Artiste : " . $albums->artist->name; ?></p>
|
||||
<p><?php echo "Année : " . $albums->year; ?></p>
|
||||
</div>
|
||||
<div class="album-songs">
|
||||
<?php
|
||||
echo "<table>";
|
||||
echo "<thead>";
|
||||
echo "<tr>";
|
||||
echo "<th>Titre</th>";
|
||||
echo "<th>Durée</th>";
|
||||
echo "<th>Action</th>";
|
||||
echo "</tr>";
|
||||
echo "</thead>";
|
||||
echo "<tbody>";
|
||||
foreach ($albums->songs as $index => $song) {
|
||||
$artistName = $albums->artist->name;
|
||||
$duration = isset($albums->tracks[$index]->duration) ? convertirSecondesEnMinutes($albums->tracks[$index]->duration) : '';
|
||||
echo "<tr>";
|
||||
echo "<td>{$song}</td>";
|
||||
echo "<td>{$duration}</td>";
|
||||
echo "<td>" . $song . "</td>";
|
||||
echo "<td>" . $duration . "</td>";
|
||||
echo "<td>";
|
||||
if ($this->session->userdata('logged_in')){
|
||||
if($this->model_music->SongInPlaylist($albums->tracks[$index]->trackId)){
|
||||
echo anchor("chansons/deleteSongtoPlaylist/{$albums->tracks[$index]->trackId}","<i class='fa fa-trash'></i>");
|
||||
echo anchor("chansons/deleteSongtoPlaylist/{$albums->tracks[$index]->trackId}", "<i class='fa fa-trash'></i>", ['title' => 'Supprimer de la playlist']);
|
||||
}
|
||||
}
|
||||
echo anchor("chansons/addSongtoPlaylist/{$albums->tracks[$index]->trackId}","<i class='fa fa-plus'></i>");
|
||||
//echo "<a href='" . site_url('albums/select_playlist?track_id=' . $albums->tracks[$index]->trackId) . "' class='btn-plus'>+</a>";
|
||||
echo anchor("chansons/addSongtoPlaylist/{$albums->tracks[$index]->trackId}", "<i class='fa fa-plus'></i>", ['title' => 'Ajouter à la playlist']);
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</tbody>";
|
||||
echo "</table>";
|
||||
|
||||
function convertirSecondesEnMinutes($secondes) {
|
||||
|
||||
@@ -1,55 +1,3 @@
|
||||
|
||||
<script>
|
||||
var filterOptionsVisible = false;
|
||||
|
||||
function toggleFilterOptions() {
|
||||
var filterOptions = document.getElementById('filter-options');
|
||||
var filterButtons = document.getElementById('filter-buttons');
|
||||
|
||||
if (!filterOptionsVisible) {
|
||||
filterOptions.style.display = 'block';
|
||||
filterButtons.classList.add('show');
|
||||
filterOptionsVisible = true;
|
||||
} else {
|
||||
filterOptions.style.display = 'none';
|
||||
filterButtons.classList.remove('show');
|
||||
hideCheckboxes();
|
||||
filterOptionsVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCheckboxes(filterType) {
|
||||
var checkboxes = document.getElementById(filterType + '-checkboxes');
|
||||
if (checkboxes.style.display === 'none' || checkboxes.style.display === '') {
|
||||
checkboxes.style.display = 'block';
|
||||
} else {
|
||||
checkboxes.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function hideCheckboxes() {
|
||||
var checkboxes = document.querySelectorAll('.filter-checkboxes');
|
||||
checkboxes.forEach(function(checkbox) {
|
||||
checkbox.classList.remove('show');
|
||||
});
|
||||
}
|
||||
|
||||
function toggleSortButtons() {
|
||||
var sortButtons = document.getElementById('sort-buttons');
|
||||
if (sortButtons.style.display === 'none' || sortButtons.style.display === '') {
|
||||
sortButtons.style.display = 'block';
|
||||
} else {
|
||||
sortButtons.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function sortAlbums(column, order) {
|
||||
var url = "<?= site_url('artistes/index'); ?>";
|
||||
url += "?sort=" + column + "&order=" + order;
|
||||
window.location.href = url;
|
||||
}
|
||||
</script>
|
||||
|
||||
<h5>Filter Artiste</h5>
|
||||
<button type="button" onclick="toggleFilterOptions()">Filter</button>
|
||||
|
||||
@@ -62,8 +10,8 @@
|
||||
<div id="genre-checkboxes" style="display:none;">
|
||||
<?php foreach ($genres as $genre): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="genre[]" value="<?= $genre->genreName; ?>">
|
||||
<?= $genre->genreName; ?>
|
||||
<input type="checkbox" name="genre[]" value="<?= htmlspecialchars($genre->genreName); ?>">
|
||||
<?= htmlspecialchars($genre->genreName); ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@@ -75,22 +23,22 @@
|
||||
<h5>Sort Artiste</h5>
|
||||
<button type="button" onclick="toggleSortButtons()">Sort</button>
|
||||
<div id="sort-buttons" class="sort-buttons">
|
||||
<button onclick="sortAlbums('name', 'asc')">Sort by Artist Asc</button>
|
||||
<button onclick="sortAlbums('name', 'desc')">Sort by Artist Desc</button>
|
||||
<button type="button" onclick="sortAlbums('name', 'asc')">Sort by Artist Asc</button>
|
||||
<button type="button" onclick="sortAlbums('name', 'desc')">Sort by Artist Desc</button>
|
||||
</div>
|
||||
|
||||
<h5>Artiste list</h5>
|
||||
<section class="list">
|
||||
<?php
|
||||
foreach($artistes as $artistes){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("albums/viewAlbum/{$artistes->Id}","{$artistes->name}");
|
||||
foreach($artistes as $artiste){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("albums/viewAlbum/{$artiste->Id}", $artiste->name);
|
||||
if($this->session->userdata('logged_in')){
|
||||
echo anchor("artistes/addArtistestoPlaylist/{$artistes->Id}","<i class='fa fa-plus'></i>");
|
||||
echo anchor("artistes/addArtistestoPlaylist/{$artiste->Id}", "<i class='fa fa-plus'></i>");
|
||||
}
|
||||
echo "</header>";
|
||||
echo "</article></div>";
|
||||
echo "</header>";
|
||||
echo "</article></div>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
@@ -1,52 +1,49 @@
|
||||
<link rel="stylesheet" type="text/css" href="<?= base_url('assets/styles.css'); ?>">
|
||||
<script src="<?= base_url('assets/scripts.js'); ?>"></script>
|
||||
|
||||
<h5>Filter Chansons</h5>
|
||||
<button type="button" onclick="toggleFilterOptions()">Filter</button>
|
||||
|
||||
<div id="filter-options" class="filter-options">
|
||||
<div id="filter-options" class="filter-options" style="display:none;">
|
||||
<form method="get">
|
||||
<div id="filter-buttons" class="filter-buttons">
|
||||
<button type="button" onclick="toggleCheckboxes('genre')">Genres</button>
|
||||
<button type="button" onclick="toggleCheckboxes('artist')">Artists</button>
|
||||
<button type="button" onclick="toggleCheckboxes('year')">Years</button>
|
||||
<button type="button" onclick="toggleCheckboxes('album')">Albums</button>
|
||||
<button type="button" onclick="toggleCheckboxes('album')">Albums</button>
|
||||
</div>
|
||||
|
||||
<div id="genre-checkboxes" style="display:none;">
|
||||
<?php foreach ($genres as $genre): ?>
|
||||
<?php foreach ($genres as $genre){ ?>
|
||||
<label>
|
||||
<input type="checkbox" name="genre[]" value="<?= $genre->genreName; ?>">
|
||||
<?= $genre->genreName; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div id="artist-checkboxes" style="display:none;">
|
||||
<?php foreach ($artists as $artist): ?>
|
||||
<?php foreach ($artists as $artist){ ?>
|
||||
<label>
|
||||
<input type="checkbox" name="artist[]" value="<?= $artist->artistName; ?>">
|
||||
<?= $artist->artistName; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div id="year-checkboxes" style="display:none;">
|
||||
<?php foreach ($years as $year): ?>
|
||||
<?php foreach ($years as $year){ ?>
|
||||
<label>
|
||||
<input type="checkbox" name="year[]" value="<?= $year->year; ?>">
|
||||
<?= $year->year; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div id="album-checkboxes" style="display:none;">
|
||||
<?php foreach ($albums as $album): ?>
|
||||
<div id="album-checkboxes" style="display:none;">
|
||||
<?php foreach ($albums as $album){ ?>
|
||||
<label>
|
||||
<input type="checkbox" name="albums[]" value="<?= $album->albumName; ?>">
|
||||
<?= $album->albumName; ?>
|
||||
</label><br>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<button type="submit">Apply Filters</button>
|
||||
@@ -55,23 +52,37 @@
|
||||
|
||||
<h5>Sort Chansons</h5>
|
||||
<button type="button" onclick="toggleSortButtons()">Sort</button>
|
||||
<div id="sort-buttons" class="sort-buttons">
|
||||
<button onclick="sortAlbums('year', 'asc')">Sort by Year Asc</button>
|
||||
<button onclick="sortAlbums('year', 'desc')">Sort by Year Desc</button>
|
||||
<button onclick="sortAlbums('artistName', 'asc')">Sort by Artist Asc</button>
|
||||
<button onclick="sortAlbums('artistName', 'desc')">Sort by Artist Desc</button>
|
||||
<button onclick="sortAlbums('name', 'asc')">Sort by Chanson Name Asc</button>
|
||||
<button onclick="sortAlbums('name', 'desc')">Sort by Chanson Name Desc</button>
|
||||
<button onclick="sortAlbums('albumName', 'asc')">Sort by Album Name Asc</button>
|
||||
<button onclick="sortAlbums('albumName', 'desc')">Sort by Album Name Desc</button>
|
||||
<button onclick="sortAlbums('genreName', 'asc')">Sort by Genre Asc</button>
|
||||
<button onclick="sortAlbums('genreName', 'desc')">Sort by Genre Desc</button>
|
||||
<div id="sort-buttons" class="sort-buttons" style="display:none;">
|
||||
<button type="button" onclick="sortAlbums('year', 'asc')">Sort by Year Asc</button>
|
||||
<button type="button" onclick="sortAlbums('year', 'desc')">Sort by Year Desc</button>
|
||||
<button type="button" onclick="sortAlbums('artistName', 'asc')">Sort by Artist Asc</button>
|
||||
<button type="button" onclick="sortAlbums('artistName', 'desc')">Sort by Artist Desc</button>
|
||||
<button type="button" onclick="sortAlbums('name', 'asc')">Sort by Chanson Name Asc</button>
|
||||
<button type="button" onclick="sortAlbums('name', 'desc')">Sort by Chanson Name Desc</button>
|
||||
<button type="button" onclick="sortAlbums('albumName', 'asc')">Sort by Album Name Asc</button>
|
||||
<button type="button" onclick="sortAlbums('albumName', 'desc')">Sort by Album Name Desc</button>
|
||||
<button type="button" onclick="sortAlbums('genreName', 'asc')">Sort by Genre Asc</button>
|
||||
<button type="button" onclick="sortAlbums('genreName', 'desc')">Sort by Genre Desc</button>
|
||||
</div>
|
||||
|
||||
<h5>Chansons list</h5>
|
||||
<section class="list">
|
||||
<?php
|
||||
|
||||
<?php
|
||||
// Pagination setup
|
||||
$items_per_page = 51; // Number of items to display per page
|
||||
$total_chansons = count($chansons); // Total number of chansons
|
||||
$total_pages = ceil($total_chansons / $items_per_page); // Total number of pages
|
||||
|
||||
// Get current page from URL, default is page 1
|
||||
$current_page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
$current_page = max(1, min($total_pages, $current_page)); // Ensure the current page is within valid range
|
||||
|
||||
// Calculate the offset for the SQL query
|
||||
$offset = ($current_page - 1) * $items_per_page;
|
||||
|
||||
// Fetch chansons for the current page
|
||||
$chansons_for_current_page = array_slice($chansons, $offset, $items_per_page);
|
||||
|
||||
$page = preg_split('/[\/]/', $_SERVER['REQUEST_URI']);
|
||||
$long_page = count($page) - 1;
|
||||
@@ -85,22 +96,55 @@ for ($i = $long_page; $i >= 0; $i--) {
|
||||
}
|
||||
}
|
||||
|
||||
foreach($chansons as $chanson){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("chansons/view/{$chanson->id}","{$chanson->name}");
|
||||
if($this->session->userdata('logged_in')){
|
||||
if($this->model_music->SongInPlaylist($chanson->trackId)){
|
||||
echo anchor("chansons/deleteSongtoPlaylist/{$chanson->trackId}?page={$url}","<i class='fa fa-trash'></i>");
|
||||
}
|
||||
echo anchor("chansons/addSongtoPlaylist/{$chanson->trackId}?page={$url}","<i class='fa fa-plus'></i>");
|
||||
}
|
||||
echo "</header>";
|
||||
echo "<nav class='short-text'>Nom album: {$chanson->albumName}</nav>";
|
||||
echo "<nav class='short-text'>Genre: {$chanson->genreName}</nav>";
|
||||
echo "<footer class='short-text'>{$chanson->year} - {$chanson->artistName}</footer>
|
||||
</article></div>";
|
||||
}
|
||||
|
||||
?>
|
||||
foreach($chansons_for_current_page as $chanson): ?>
|
||||
<div>
|
||||
<article>
|
||||
<header class='short-text'>
|
||||
<h6> <?php echo $chanson->name; ?> </h6>
|
||||
<?php if($this->session->userdata('logged_in')): ?>
|
||||
<?php if($this->model_music->SongInPlaylist($chanson->trackId)): ?>
|
||||
<?= anchor("chansons/deleteSongtoPlaylist/{$chanson->trackId}?page={$url}", "<i class='fa fa-trash'></i>"); ?>
|
||||
<?php endif; ?>
|
||||
<?= anchor("chansons/addSongtoPlaylist/{$chanson->trackId}?page={$url}", "<i class='fa fa-plus'></i>"); ?>
|
||||
<?php endif; ?>
|
||||
</header>
|
||||
<nav class='short-text'>Nom album: <?= $chanson->albumName; ?></nav>
|
||||
<nav class='short-text'>Genre: <?= $chanson->genreName; ?></nav>
|
||||
<footer class='short-text'><?= $chanson->year; ?> - <?= $chanson->artistName; ?></footer>
|
||||
</article>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Pagination Controls -->
|
||||
<div class="pagination">
|
||||
<?php if ($current_page > 1): ?>
|
||||
<a href="?page=<?= $current_page - 1 ?>">« Previous</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
// Determine the start and end page numbers
|
||||
$start_page = max(1, $current_page - 2);
|
||||
$end_page = min($total_pages, $current_page + 2);
|
||||
|
||||
// Adjust the start and end page if at the boundaries
|
||||
if ($start_page === 1) {
|
||||
$end_page = min(5, $total_pages);
|
||||
}
|
||||
if ($end_page === $total_pages) {
|
||||
$start_page = max(1, $total_pages - 4);
|
||||
}
|
||||
|
||||
for ($i = $start_page; $i <= $end_page; $i++): ?>
|
||||
<?php if ($i == $current_page): ?>
|
||||
<span><?= $i ?></span>
|
||||
<?php else: ?>
|
||||
<a href="?page=<?= $i ?>"><?= $i ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php if ($current_page < $total_pages): ?>
|
||||
<a href="?page=<?= $current_page + 1 ?>">Next »</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -1,14 +1,11 @@
|
||||
|
||||
<form method="post">
|
||||
<!-- Markup example 2: input is after label -->
|
||||
<label for="name">Nom de la playlist</label>
|
||||
<input type="text" id="name" name="name" placeholder="name" required>
|
||||
<div class="grid">
|
||||
<label for="text">Déscription
|
||||
<input type="text" id="Description" name="Description" placeholder="Description" >
|
||||
</label>
|
||||
</div>
|
||||
<!-- Button -->
|
||||
<div class="grid">
|
||||
<label for="Description">Déscription
|
||||
<input type="text" id="Description" name="Description" placeholder="Description" >
|
||||
</label>
|
||||
</div>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -6,23 +6,23 @@
|
||||
<!-- Markup example 1: input is inside label -->
|
||||
<label for="prenom">
|
||||
Prénom
|
||||
<input type="text" id="prenom" name="prenom" placeholder="Prénom" value="<?=set_value('prenom')?>"required>
|
||||
<input type="text" id="prenom" name="prenom" placeholder="Prénom" required>
|
||||
</label>
|
||||
|
||||
<label for="nom">
|
||||
Nom
|
||||
<input type="text" id="nom" name="nom" placeholder="nom" value="<?=set_value('nom')?>" required>
|
||||
<input type="text" id="nom" name="nom" placeholder="nom" required>
|
||||
</label>
|
||||
</div>
|
||||
<!-- Markup example 2: input is after label -->
|
||||
<label for="email">Adresse mail</label>
|
||||
<input type="email" id="email" name="email" placeholder="Email" value="<?=set_value('email')?>" required>
|
||||
<input type="email" id="email" name="email" placeholder="Email" required>
|
||||
<div class="grid">
|
||||
<label for="password">Password
|
||||
<input type="password" id="password" name="password" placeholder="Password" value="<?=set_value('password')?>" required>
|
||||
<input type="password" id="password" name="password" placeholder="Password" required>
|
||||
</label>
|
||||
<label for="password">Confirmation password
|
||||
<input type="password" id="cpassword" name="cpassword" placeholder="Password" value="<?=set_value('cpassword')?>" required>
|
||||
<label for="cpassword">Confirmation password
|
||||
<input type="password" id="cpassword" name="cpassword" placeholder="Password" required>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<title>Supprimer une chanson à une playlist</title>
|
||||
<h6>Supprimer une chanson à une playlist</h6>
|
||||
|
||||
<div class="trie">
|
||||
<h5>Playlists</h5>
|
||||
@@ -7,19 +7,18 @@
|
||||
<section class="list">
|
||||
|
||||
<form method="post">
|
||||
<?php foreach ($playlists as $playlist): ?>
|
||||
<?php foreach ($playlists as $playlist){ ?>
|
||||
<div class="playlist-option">
|
||||
<label>
|
||||
<?php if($this->model_music->SongInThisPlaylist($id,$playlist->playlistid)){ ?>
|
||||
<input type="radio" name="playlist_id" value="<?= $playlist->playlistid ?>">
|
||||
<?= $playlist->name ?>
|
||||
<?php } ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
<div class="submit-button">
|
||||
<button type="submit" class="btn btn-primary">Supprimer de la playlist</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +1,2 @@
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,40 +1,37 @@
|
||||
<!doctype html>
|
||||
<html lang="en" class="has-navbar-fixed-top">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>MUSIC APP</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||
/>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>MUSIC APP</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<?= link_tag('assets/style.css'); ?>
|
||||
<script type="text/javascript" src="<?= base_url('assets/script.js'); ?>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
<nav>
|
||||
<ul>
|
||||
<li><strong class="appli">Music APP</strong></li>
|
||||
</ul>
|
||||
<?php
|
||||
$page = preg_split('/[\/]/', $_SERVER['REQUEST_URI']);
|
||||
if ($page[count($page) - 1] != 'auth' && $page[count($page) - 1] != 'create') { ?>
|
||||
<form method="GET">
|
||||
<input type="text" name="recherche" placeholder="Recherche... ">
|
||||
</form>
|
||||
<?php } ?>
|
||||
<ul>
|
||||
<li><?= anchor('albums', 'Albums'); ?></li>
|
||||
<li><?= anchor('artistes', 'Artistes'); ?></li>
|
||||
<li><?= anchor('chansons', 'Chansons'); ?></li>
|
||||
<?php if ($this->session->userdata('logged_in')) { ?>
|
||||
<li><?= anchor('playlist', 'Playlist'); ?></li>
|
||||
<li class="déconnexion"><?= anchor('user/logout', 'Déconnexion'); ?></li>
|
||||
<?php } else { ?>
|
||||
<li class="connexion"><?= anchor('user/auth', 'Connexion'); ?></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<?=link_tag('assets/style.css');?>
|
||||
<script type="text/javascript" src="<?= base_url('assets/script.js'); ?>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<main class='container'>
|
||||
<nav>
|
||||
<ul>
|
||||
<li ><strong class= 'apliiiiiii'>Music APP</strong></li>
|
||||
<?php $page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
if($page[count($page)-1]!='auth' && $page[count($page)-1]!='create'){ ?>
|
||||
<form method='GET'>
|
||||
<input type='text' name='recherche' placeholder='Recherche... '>
|
||||
</form>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?=anchor('albums','Albums');?></li>
|
||||
<li><?=anchor('artistes','Artistes');?></li>
|
||||
<li><?=anchor('chansons','Chansons');?></li>
|
||||
<?php if($this->session->userdata('logged_in')){ ?>
|
||||
<li><?=anchor('playlist','Playlist');?></li>
|
||||
<li name='déconnexion'><?=anchor('user/logout','Déconnexion');?></li>
|
||||
<?php }else{ ?>
|
||||
<li name='connexion'><?=anchor('user/auth','Connexion');?></li>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
@@ -1,42 +1,13 @@
|
||||
|
||||
<style>
|
||||
.filter-buttons {
|
||||
display: block;
|
||||
}
|
||||
.filter-buttons.show {
|
||||
display: inline-block;
|
||||
}
|
||||
.filter-checkboxes {
|
||||
display: none;
|
||||
}
|
||||
.filter-checkboxes.show {
|
||||
display: block;
|
||||
}
|
||||
.show-buttons .sort-buttons {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
function toggleCheckboxes(filterType) {
|
||||
var checkboxes = document.getElementById(filterType + '-checkboxes');
|
||||
if (checkboxes.style.display === 'none' || checkboxes.style.display === '') {
|
||||
checkboxes.style.display = 'block';
|
||||
} else {
|
||||
checkboxes.style.display = 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<h5>Différents critères</h5>
|
||||
|
||||
<form method="post">
|
||||
<div id="filter-buttons" class="filter-buttons">
|
||||
<button type="button" onclick="toggleCheckboxes('genre')">Genres</button>
|
||||
<button type="button" onclick="toggleCheckboxes('artist')">Artists</button>
|
||||
<button type="button" onclick="toggleCheckboxes('year')">Years</button>
|
||||
<div id="filter-buttons-playlist" class="filter-buttons-playlist">
|
||||
<button type="button" onclick="toggleCheckboxesPlaylist('genre')">Genres</button>
|
||||
<button type="button" onclick="toggleCheckboxesPlaylist('artist')">Artists</button>
|
||||
<button type="button" onclick="toggleCheckboxesPlaylist('year')">Years</button>
|
||||
</div>
|
||||
|
||||
<div id="genre-checkboxes" style="display:none;">
|
||||
<div id="genre-checkboxes-playlist" style="display:none;">
|
||||
<?php foreach ($genres as $genre): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="genre[]" value="<?= $genre->genreName; ?>">
|
||||
@@ -45,7 +16,7 @@
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div id="artist-checkboxes" style="display:none;">
|
||||
<div id="artist-checkboxes-playlist" style="display:none;">
|
||||
<?php foreach ($artists as $artist): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="artist[]" value="<?= $artist->artistName; ?>">
|
||||
@@ -54,7 +25,7 @@
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div id="year-checkboxes" style="display:none;">
|
||||
<div id="year-checkboxes-playlist" style="display:none;">
|
||||
<?php foreach ($years as $year): ?>
|
||||
<label>
|
||||
<input type="checkbox" name="year[]" value="<?= $year->year; ?>">
|
||||
@@ -67,10 +38,9 @@
|
||||
<label for="name">Nom de la playlist</label>
|
||||
<input type="text" id="name" name="name" placeholder="name" required>
|
||||
<div class="grid">
|
||||
<label for="text">Déscription
|
||||
<label for="Description">Déscription
|
||||
<input type="text" id="Description" name="Description" placeholder="Description" >
|
||||
</label>
|
||||
</div>
|
||||
<!-- Button -->
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
@@ -47,3 +47,12 @@ function sortAlbums(column, order) {
|
||||
url += "?sort=" + column + "&order=" + order;
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
function toggleCheckboxesPlaylist(filterType) {
|
||||
var checkboxes = document.getElementById(filterType + '-checkboxes-playlist');
|
||||
if (checkboxes.style.display === 'none' || checkboxes.style.display === '') {
|
||||
checkboxes.style.display = 'block';
|
||||
} else {
|
||||
checkboxes.style.display = 'none';
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ section.list img {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
color: #2a2a2a;
|
||||
}
|
||||
|
||||
.recherche {
|
||||
@@ -29,6 +30,12 @@ section.list img {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.appli{
|
||||
width : 100px;
|
||||
height : 75px;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.apliiiiiii{
|
||||
width : 75px;
|
||||
height : 24px;
|
||||
@@ -39,21 +46,47 @@ section.list img {
|
||||
display: none;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.filter-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.filter-buttons.show {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.filter-checkboxes {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.filter-checkboxes.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sort-buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.show-buttons .sort-buttons {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.filter-buttons-playlist {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.filter-buttons-playlist.show {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.filter-checkboxes-playlist {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.filter-checkboxes-playlist.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.show-buttons .sort-buttons {
|
||||
display: block;
|
||||
}
|
||||
@@ -104,7 +137,7 @@ body {
|
||||
.album-songs {
|
||||
flex-grow: 2;
|
||||
padding: 20px;
|
||||
background-color: #13171;
|
||||
background-color: #13171b;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user