duplication playlist
This commit is contained in:
@@ -6,6 +6,7 @@ class Albums extends CI_Controller {
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->library('form_validation');
|
||||
}
|
||||
public function index(){
|
||||
$genre = $this->input->get('genre');
|
||||
@@ -54,5 +55,21 @@ class Albums extends CI_Controller {
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addAlbumtoPlaylist($id) {
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
|
||||
$this->form_validation->set_rules('playlist_id', 'playlist_id', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('addAlbumtoplaylist', ["playlists" => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$playlistId = $this->input->post('playlist_id');
|
||||
$page = $this->input->get('page');
|
||||
$this->model_music->AddAlbumtoPlaylist($playlistId,$id);
|
||||
redirect($page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ class Artistes extends CI_Controller {
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->library('form_validation');
|
||||
}
|
||||
public function index(){
|
||||
$genre = $this->input->get('genre');
|
||||
@@ -35,5 +36,21 @@ class Artistes extends CI_Controller {
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addArtistestoPlaylist($id) {
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
|
||||
$this->form_validation->set_rules('playlist_id', 'playlist_id', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('addArtistestoplaylist', ["playlists" => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$playlistId = $this->input->post('playlist_id');
|
||||
$this->model_music->AddArtistestoPlaylist($playlistId,$id);
|
||||
redirect('artistes');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,21 +15,20 @@ class Chansons extends CI_Controller {
|
||||
$album = $this->input->get('albums');
|
||||
$sort = $this->input->get('sort');
|
||||
$order = $this->input->get('order');
|
||||
$recherche = $this->input->get('recherche', true);
|
||||
|
||||
if (empty($recherche)) {
|
||||
$data['chansons'] = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
|
||||
} else {
|
||||
$data['chansons'] = $this->model_music->getSearchChansons($recherche);
|
||||
}
|
||||
|
||||
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
|
||||
$chansons = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
|
||||
$data['chansons'] = $chansons;
|
||||
}else{
|
||||
$recherche=filter_input(INPUT_GET,'recherche');
|
||||
$chansons = $this->model_music->getSearchChansons($recherche);
|
||||
$data['chansons'] = $chansons;
|
||||
}
|
||||
$this->load->view('layout/header');
|
||||
if ($chansons == false){
|
||||
|
||||
if ($data['chansons'] == false){
|
||||
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
$this->load->view('error',['page'=>$page[count($page)-1]]);
|
||||
$chansons = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
|
||||
$data['chansons'] = $chansons;
|
||||
$data['chansons'] = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
|
||||
}
|
||||
$data['genres'] = $this->model_music->get_all_genres_chansons();
|
||||
$data['artists'] = $this->model_music->get_all_artists_chansons();
|
||||
|
||||
@@ -48,4 +48,30 @@ class Playlist extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function duplicatePlaylist($id){
|
||||
$this->form_validation->set_rules('name', 'name', 'required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create_playlist');
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$nom = $this->input->post('name');
|
||||
$description = $this->input->post('Description');
|
||||
$userId = $this->session->userdata('userId');
|
||||
$playlist = array(
|
||||
'name'=>$nom,
|
||||
'description'=>$description,
|
||||
'userId'=>$userId,
|
||||
);
|
||||
$this->model_music->addPlayliste($playlist);
|
||||
$this->model_music->DuplicatePlaylist($id, $nom);
|
||||
redirect('playlist');
|
||||
}
|
||||
}
|
||||
|
||||
public function deletePlaylist($id){
|
||||
$this->model_music->DeletePlaylist($id);
|
||||
redirect('playlist');
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ class Model_music extends CI_Model {
|
||||
public function __construct(){
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
|
||||
public function get_filtered_albums($genre = [], $artist = [], $year = [], $sort = null, $order = null) {
|
||||
$this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg ');
|
||||
$this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg');
|
||||
$this->db->from('album');
|
||||
$this->db->join('genre', 'album.genreId = genre.Id');
|
||||
$this->db->join('artist', 'album.artistId = artist.Id');
|
||||
@@ -116,6 +116,31 @@ class Model_music extends CI_Model {
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
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->from('song');
|
||||
$this->db->join('track', 'track.songId = song.id');
|
||||
$this->db->join('album', 'album.id = track.albumId');
|
||||
$this->db->join('artist', 'album.artistId = artist.Id');
|
||||
$this->db->join('genre', 'genre.id = album.genreid');
|
||||
|
||||
if (!empty($genres)) {
|
||||
$this->db->where_in('genreName', $genres);
|
||||
}
|
||||
if (!empty($artists)) {
|
||||
$this->db->where_in('artistName', $artists);
|
||||
}
|
||||
if (!empty($years)) {
|
||||
$this->db->where_in('year', $years);
|
||||
}
|
||||
if (!empty($albums)) {
|
||||
$this->db->where_in('albumName', $albums);
|
||||
}
|
||||
$this->db->order_by($sort_column, $sort_order);
|
||||
$this->db->limit($limit, $offset);
|
||||
return $this->db->get()->result();
|
||||
}
|
||||
|
||||
public function get_all_genres_chansons() {
|
||||
$this->db->distinct();
|
||||
@@ -314,11 +339,16 @@ class Model_music extends CI_Model {
|
||||
}
|
||||
|
||||
public function getPlaylistIdSong($id){
|
||||
$result = $this->model_music->TrackidSonginPlaylist($id);
|
||||
|
||||
$track = $result->row();
|
||||
$trackId = $track->trackId;
|
||||
|
||||
$query = $this->db->query(
|
||||
"SELECT Playlist.name, Playlist.playlistid
|
||||
FROM Playlist
|
||||
JOIN PlaylistSong ON Playlist.playlistid = PlaylistSong.playlistid
|
||||
WHERE PlaylistSong.trackId = $id
|
||||
WHERE PlaylistSong.trackId = $trackId
|
||||
ORDER BY Playlist.name
|
||||
"
|
||||
);
|
||||
@@ -338,6 +368,11 @@ class Model_music extends CI_Model {
|
||||
}
|
||||
|
||||
public function DeleteSongtoPlaylist($idplaylist, $trackId){
|
||||
$result = $this->model_music->TrackidSonginPlaylist($trackId);
|
||||
|
||||
$track = $result->row();
|
||||
$trackId = $track->trackId;
|
||||
|
||||
$tupple = array(
|
||||
"playlistId"=> $idplaylist,
|
||||
"trackId"=> $trackId);
|
||||
@@ -353,23 +388,111 @@ class Model_music extends CI_Model {
|
||||
$this->db->join('album', 'album.id = track.albumId');
|
||||
$this->db->join('artist', 'album.artistId = artist.Id');
|
||||
$this->db->join('genre', 'genre.id = album.genreid');
|
||||
$this->db->where('PlaylistSong.playlistId', $id);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function SongInPlaylist($id){
|
||||
$query = $this->db->query(
|
||||
"SELECT PlaylistSong.trackId, Playlist.playlistId
|
||||
FROM Playlist
|
||||
JOIN PlaylistSong ON Playlist.playlistid = PlaylistSong.playlistid
|
||||
WHERE PlaylistSong.trackid = $id
|
||||
ORDER BY Playlist.name
|
||||
"
|
||||
);
|
||||
$query->result();
|
||||
if ($query->num_rows() > 0){
|
||||
return $query = true;
|
||||
$result = $this->model_music->TrackidSonginPlaylist($id);
|
||||
|
||||
// Si on trouve au moins une piste de cette chanson dans la playlist, retourner true
|
||||
if ($result->num_rows() > 0) {
|
||||
return true;
|
||||
}
|
||||
return $query = false;
|
||||
}
|
||||
|
||||
public function TrackidSonginPlaylist($id) {
|
||||
if (!is_array($id)) {
|
||||
$id = array($id);
|
||||
}
|
||||
|
||||
// É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', $id);
|
||||
$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);
|
||||
$query = $this->db->get();
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function AddAlbumtoPlaylist($idplaylist, $albumId){
|
||||
$this->db->select('track.id as trackId');
|
||||
$this->db->from('album');
|
||||
$this->db->join('track', 'album.id = track.albumId');
|
||||
$this->db->where('track.albumId', $albumId);
|
||||
$query = $this->db->get();
|
||||
foreach($query->result() as $tab){
|
||||
if($this->model_music->SongInPlaylist($tab->trackId) == false){
|
||||
$this->model_music->AddSongtoPlaylist($idplaylist,$tab->trackId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function AddArtistestoPlaylist($idplaylist, $artisteId){
|
||||
$this->db->select('track.id as trackId');
|
||||
$this->db->from('artist');
|
||||
$this->db->join('album', 'album.artistId=artist.id');
|
||||
$this->db->join('track', 'album.id = track.albumId');
|
||||
$this->db->where('artist.id', $artisteId);
|
||||
$query = $this->db->get();
|
||||
foreach($query->result() as $tab){
|
||||
if($this->model_music->SongInPlaylist($tab->trackId) == false){
|
||||
$this->model_music->AddSongtoPlaylist($idplaylist,$tab->trackId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function DuplicatePlaylist($idplaylist,$nomplaylist){
|
||||
$this->db->select('Playlist.playlistId');
|
||||
$this->db->from('Playlist');
|
||||
$this->db->where('name', $nomplaylist);
|
||||
$query = $this->db->get();
|
||||
$result = $query->row();
|
||||
$id = $result->playlistId;
|
||||
print_r($id);
|
||||
|
||||
$this->db->select('PlaylistSong.trackId');
|
||||
$this->db->from('PlaylistSong');
|
||||
$this->db->where('PlaylistSong.playlistId', $idplaylist);
|
||||
$query = $this->db->get();
|
||||
foreach($query->result() as $row){
|
||||
print_r($row->trackId);
|
||||
$this->model_music->AddSongtoPlaylist($id,$row->trackId);
|
||||
}
|
||||
}
|
||||
|
||||
public function DeletePlaylist($idplaylist){
|
||||
$this->db->where('playlistId',$idplaylist);
|
||||
$this->db->delete("PlaylistSong");
|
||||
|
||||
$this->db->where('playlistId',$idplaylist);
|
||||
$this->db->delete("Playlist");
|
||||
}
|
||||
}
|
||||
|
||||
25
CodeIgniter-3.1.13/application/views/addAlbumtoplaylist.php
Normal file
25
CodeIgniter-3.1.13/application/views/addAlbumtoplaylist.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<title>Ajouter un album à une playlist</title>
|
||||
|
||||
<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 ?>">
|
||||
<?= $playlist->name ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="submit-button">
|
||||
<button type="submit" class="btn btn-primary">Ajouter à la playlist</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
<title>Ajouter toutes les musique d'un artiste à une playlist</title>
|
||||
|
||||
<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 ?>">
|
||||
<?= $playlist->name ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="submit-button">
|
||||
<button type="submit" class="btn btn-primary">Ajouter à la playlist</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -10,8 +10,10 @@
|
||||
<?php foreach ($playlists as $playlist): ?>
|
||||
<div class="playlist-option">
|
||||
<label>
|
||||
<?php if($this->model_music->SongInPlaylist($id) == false){ ?>
|
||||
<input type="radio" name="playlist_id" value="<?= $playlist->playlistid ?>">
|
||||
<?= $playlist->name ?>
|
||||
<?php } ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
<style>
|
||||
.filter-options {
|
||||
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; / Afficher les boutons de tri lorsque la classe show-buttons est appliquée */
|
||||
}
|
||||
</style>
|
||||
.filter-options {
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var filterOptionsVisible = false;
|
||||
|
||||
@@ -133,13 +133,22 @@ if($page[count($page)-2] != 'viewAlbum'){ ?>
|
||||
<h5>Albums list</h5>
|
||||
<section class="list">
|
||||
<?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;
|
||||
$url = $page[$long_page] . '/' . $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>";
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
?>
|
||||
<br>
|
||||
<br>
|
||||
<?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;
|
||||
$url = $page[$long_page];
|
||||
}
|
||||
?>
|
||||
<h4><?php echo $albums->name; ?></h4>
|
||||
|
||||
<h8> <?php echo " - Artiste : " . $albums->artist->name; ?></h8>
|
||||
@@ -44,12 +53,12 @@
|
||||
if ($this->session->userdata('logged_in')){
|
||||
if($this->model_music->SongInPlaylist($albums->tracks[$index]->trackId)){
|
||||
echo "<td>";
|
||||
echo anchor("chansons/deleteSongtoPlaylist/{$albums->tracks[$index]->trackId}","<i class='fa-solid fa-trash'></i>");
|
||||
echo anchor("chansons/deleteSongtoPlaylist/{$albums->tracks[$index]->trackId}?page={$url}","<i class='fa fa-trash'></i>");
|
||||
echo "</td>";
|
||||
}
|
||||
}
|
||||
echo "<td>";
|
||||
echo anchor("chansons/addSongtoPlaylist/{$albums->tracks[$index]->trackId}","<i class='fa fa-plus'></i>");
|
||||
echo "</td>";
|
||||
echo anchor("chansons/addSongtoPlaylist/{$albums->tracks[$index]->trackId}?page={$url}","<i class='fa fa-plus'></i>");
|
||||
echo "</td>";
|
||||
}
|
||||
echo "<th></th>";
|
||||
echo "<th></th>";
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
<style>
|
||||
.filter-options {
|
||||
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; / Afficher les boutons de tri lorsque la classe show-buttons est appliquée */
|
||||
}
|
||||
</style>
|
||||
.filter-options {
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var filterOptionsVisible = false;
|
||||
|
||||
@@ -109,6 +109,9 @@ foreach($artistes as $artistes){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("albums/viewAlbum/{$artistes->Id}","{$artistes->name}");
|
||||
if($this->session->userdata('logged_in')){
|
||||
echo anchor("artistes/addArtistestoPlaylist/{$artistes->Id}","<i class='fa fa-plus'></i>");
|
||||
}
|
||||
echo "</header>";
|
||||
echo "</article></div>";
|
||||
}
|
||||
|
||||
@@ -1,77 +1,5 @@
|
||||
<style>
|
||||
.filter-options {
|
||||
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; / Afficher les boutons de tri lorsque la classe show-buttons est appliquée */
|
||||
}
|
||||
</style>
|
||||
<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('chansons/index'); ?>";
|
||||
url += "?sort=" + column + "&order=" + order;
|
||||
window.location.href = url;
|
||||
}
|
||||
</script>
|
||||
<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>
|
||||
@@ -143,15 +71,25 @@
|
||||
<h5>Chansons list</h5>
|
||||
<section class="list">
|
||||
<?php
|
||||
ini_set('memory_limit', '512M');
|
||||
|
||||
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
$long_page = count($page)-1;
|
||||
$url = $page[$long_page];
|
||||
while ($page[$long_page] != 'albums' && $page[$long_page] != 'chansons'){
|
||||
$long_page = $long_page - 1;
|
||||
$url = $page[$long_page];
|
||||
}
|
||||
|
||||
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}","<i class='fa-solid fa-trash'></i>");
|
||||
echo anchor("chansons/deleteSongtoPlaylist/{$chanson->trackId}?page={$url}","<i class='fa fa-trash'></i>");
|
||||
}
|
||||
echo anchor("chansons/addSongtoPlaylist/{$chanson->trackId}","<i class='fa fa-plus'></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>";
|
||||
@@ -159,5 +97,9 @@ foreach($chansons as $chanson){
|
||||
echo "<footer class='short-text'>{$chanson->year} - {$chanson->artistName}</footer>
|
||||
</article></div>";
|
||||
}
|
||||
|
||||
echo "<div class='pagination-links'>";
|
||||
echo "<?= $pagination; ?>";
|
||||
echo "</div>";
|
||||
?>
|
||||
</section>
|
||||
@@ -8,6 +8,10 @@ foreach($playlists as $playlist){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("chansons/view/{$playlist->playlistid}","{$playlist->name}");
|
||||
if($this->session->userdata('logged_in')){
|
||||
echo anchor("playlist/deletePlaylist/{$playlist->playlistid}","<i class='fa fa-trash'></i>");
|
||||
echo anchor("playlist/duplicatePlaylist/{$playlist->playlistid}","<i class='fa fa-clone'></i>");
|
||||
}
|
||||
echo "</header>";
|
||||
echo "</article></div>";
|
||||
}
|
||||
|
||||
4
CodeIgniter-3.1.13/application/views/toto.php
Normal file
4
CodeIgniter-3.1.13/application/views/toto.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
var_dump($toto);
|
||||
var_dump($id);
|
||||
49
CodeIgniter-3.1.13/assets/script.js
Normal file
49
CodeIgniter-3.1.13/assets/script.js
Normal file
@@ -0,0 +1,49 @@
|
||||
// assets/js/scripts.js
|
||||
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('chansons/index'); ?>";
|
||||
url += "?sort=" + column + "&order=" + order;
|
||||
window.location.href = url;
|
||||
}
|
||||
@@ -35,3 +35,25 @@ section.list img {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.filter-options {
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user