Files
SAE_PHP_2024/CodeIgniter-3.1.13/application/controllers/Artistes.php

57 lines
1.9 KiB
PHP
Raw Normal View History

2024-05-22 12:04:00 +02:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Artistes extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('model_music');
2024-06-16 19:05:37 +02:00
$this->load->library('form_validation');
2024-05-22 12:04:00 +02:00
}
public function index(){
2024-06-10 12:26:53 +02:00
$genre = $this->input->get('genre');
$sort = $this->input->get('sort');
$order = $this->input->get('order');
2024-05-29 10:50:49 +02:00
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
$artistes = $this->model_music->getArtistes();
2024-06-10 12:26:53 +02:00
$artistes = $this->model_music->get_filtered_artistes($genre, $sort, $order);
$data['artistes'] = $artistes;
2024-05-29 10:50:49 +02:00
}else{
2024-05-29 11:08:54 +02:00
$recherche=filter_input(INPUT_GET,'recherche');
2024-05-29 10:50:49 +02:00
$artistes = $this->model_music->getSearchArtistes($recherche);
2024-06-10 12:26:53 +02:00
$data['artistes'] = $artistes;
2024-05-29 10:50:49 +02:00
}
2024-05-22 12:04:00 +02:00
$this->load->view('layout/header');
2024-05-29 10:50:49 +02:00
if ($artistes == false){
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
2024-05-29 10:50:49 +02:00
$this->load->view('error',['page'=>$page[count($page)-1]]);
$artistes = $this->model_music->getArtistes();
2024-06-10 12:26:53 +02:00
$artistes = $this->model_music->get_filtered_artistes($genre, $sort, $order);
$data['artistes'] = $artistes;
2024-05-29 10:50:49 +02:00
}
2024-06-10 12:26:53 +02:00
$data['genres'] = $this->model_music->get_all_genres_artistes();
$this->load->view('artistes_list',$data);
2024-05-22 12:04:00 +02:00
$this->load->view('layout/footer');
}
2024-06-16 19:05:37 +02:00
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');
}
}
2024-05-22 12:04:00 +02:00
}