2024-06-10 09:52:24 +02:00
|
|
|
<h5>Filter Chansons</h5>
|
|
|
|
|
<button type="button" onclick="toggleFilterOptions()">Filter</button>
|
|
|
|
|
|
2024-06-17 18:43:13 +02:00
|
|
|
<div id="filter-options" class="filter-options" style="display:none;">
|
2024-06-10 09:52:24 +02:00
|
|
|
<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>
|
2024-06-17 18:43:13 +02:00
|
|
|
<button type="button" onclick="toggleCheckboxes('album')">Albums</button>
|
2024-06-10 09:52:24 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div id="genre-checkboxes" style="display:none;">
|
2024-06-17 18:43:13 +02:00
|
|
|
<?php foreach ($genres as $genre){ ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
<label>
|
|
|
|
|
<input type="checkbox" name="genre[]" value="<?= $genre->genreName; ?>">
|
|
|
|
|
<?= $genre->genreName; ?>
|
|
|
|
|
</label><br>
|
2024-06-17 18:43:13 +02:00
|
|
|
<?php } ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div id="artist-checkboxes" style="display:none;">
|
2024-06-17 18:43:13 +02:00
|
|
|
<?php foreach ($artists as $artist){ ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
<label>
|
|
|
|
|
<input type="checkbox" name="artist[]" value="<?= $artist->artistName; ?>">
|
|
|
|
|
<?= $artist->artistName; ?>
|
|
|
|
|
</label><br>
|
2024-06-17 18:43:13 +02:00
|
|
|
<?php } ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div id="year-checkboxes" style="display:none;">
|
2024-06-17 18:43:13 +02:00
|
|
|
<?php foreach ($years as $year){ ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
<label>
|
|
|
|
|
<input type="checkbox" name="year[]" value="<?= $year->year; ?>">
|
|
|
|
|
<?= $year->year; ?>
|
|
|
|
|
</label><br>
|
2024-06-17 18:43:13 +02:00
|
|
|
<?php } ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
</div>
|
|
|
|
|
|
2024-06-17 18:43:13 +02:00
|
|
|
<div id="album-checkboxes" style="display:none;">
|
|
|
|
|
<?php foreach ($albums as $album){ ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
<label>
|
|
|
|
|
<input type="checkbox" name="albums[]" value="<?= $album->albumName; ?>">
|
|
|
|
|
<?= $album->albumName; ?>
|
|
|
|
|
</label><br>
|
2024-06-17 18:43:13 +02:00
|
|
|
<?php } ?>
|
2024-06-10 09:52:24 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button type="submit">Apply Filters</button>
|
|
|
|
|
</form>
|
2024-06-17 18:43:13 +02:00
|
|
|
</div>
|
2024-06-10 09:52:24 +02:00
|
|
|
|
|
|
|
|
<h5>Sort Chansons</h5>
|
|
|
|
|
<button type="button" onclick="toggleSortButtons()">Sort</button>
|
2024-06-17 18:43:13 +02:00
|
|
|
<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>
|
2024-06-10 09:52:24 +02:00
|
|
|
</div>
|
|
|
|
|
|
2024-05-27 13:32:33 +02:00
|
|
|
<h5>Chansons list</h5>
|
|
|
|
|
<section class="list">
|
2024-06-16 19:05:37 +02:00
|
|
|
|
2024-06-17 18:43:13 +02:00
|
|
|
<?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);
|
2024-06-16 21:57:34 +02:00
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
}
|
2024-06-16 19:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
2024-06-17 18:43:13 +02:00
|
|
|
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>
|
2024-06-16 19:05:37 +02:00
|
|
|
|
2024-06-17 18:43:13 +02:00
|
|
|
|
|
|
|
|
<!-- 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>
|