ajout connexion,ajout playlist, ajout chanson dans playlist, ajout filtre et tri pour chanson et album
This commit is contained in:
@@ -6,23 +6,35 @@ class Albums extends CI_Controller {
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->helper('html');
|
||||
$this->load->helper('url');
|
||||
}
|
||||
public function index(){
|
||||
$genre = $this->input->get('genre');
|
||||
$artist = $this->input->get('artist');
|
||||
$year = $this->input->get('year');
|
||||
$sort = $this->input->get('sort');
|
||||
$order = $this->input->get('order');
|
||||
|
||||
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$albums = $this->model_music->get_filtered_albums($genre, $artist, $year, $sort, $order);
|
||||
$data['albums'] = $albums;
|
||||
}else{
|
||||
$recherche=filter_input(INPUT_GET,'recherche');
|
||||
$albums = $this->model_music->getSearchAlbums($recherche);
|
||||
$data['albums'] = $albums;
|
||||
}
|
||||
$this->load->view('layout/header');
|
||||
if ($albums == false){
|
||||
//$page = preg_split('/[\/]/',$_SERVER['HTTP_REFERER']);
|
||||
//$this->load->view('error',['page'=>$page[count($page)-1]]);
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
$this->load->view('error',['page'=>$page[count($page)-1]]);
|
||||
$albums = $this->model_music->get_filtered_albums($genre, $artist, $year, $sort, $order);
|
||||
$data['albums'] = $albums;
|
||||
}
|
||||
$this->load->view('albums_list',['albums'=>$albums]);
|
||||
|
||||
$data['genres'] = $this->model_music->get_all_genres();
|
||||
$data['artists'] = $this->model_music->get_all_artists();
|
||||
$data['years'] = $this->model_music->get_all_years();
|
||||
|
||||
$this->load->view('albums_list',$data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ class Artistes extends CI_Controller {
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->helper('html');
|
||||
$this->load->helper('url');
|
||||
}
|
||||
public function index(){
|
||||
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
|
||||
@@ -18,7 +16,7 @@ class Artistes extends CI_Controller {
|
||||
}
|
||||
$this->load->view('layout/header');
|
||||
if ($artistes == false){
|
||||
$page = preg_split('/[\/]/',$_SERVER['HTTP_REFERER']);
|
||||
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
$this->load->view('error',['page'=>$page[count($page)-1]]);
|
||||
$artistes = $this->model_music->getArtistes();
|
||||
}
|
||||
|
||||
@@ -6,25 +6,53 @@ class Chansons extends CI_Controller {
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->helper('html');
|
||||
$this->load->helper('url');
|
||||
$this->load->library('form_validation');
|
||||
}
|
||||
public function index(){
|
||||
$genre = $this->input->get('genre');
|
||||
$artist = $this->input->get('artist');
|
||||
$year = $this->input->get('year');
|
||||
$album = $this->input->get('albums');
|
||||
$sort = $this->input->get('sort');
|
||||
$order = $this->input->get('order');
|
||||
|
||||
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
|
||||
$chansons = $this->model_music->getChansons();
|
||||
$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){
|
||||
$page = preg_split('/[\/]/',$_SERVER['HTTP_REFERER']);
|
||||
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
$this->load->view('error',['page'=>$page[count($page)-1]]);
|
||||
$chansons = $this->model_music->getChansons();
|
||||
$chansons = $this->model_music->get_filtered_chansons($genre, $artist, $year, $album, $sort, $order);
|
||||
$data['chansons'] = $chansons;
|
||||
}
|
||||
$this->load->view('chansons_list',['chansons'=>$chansons]);
|
||||
$data['genres'] = $this->model_music->get_all_genres_chansons();
|
||||
$data['artists'] = $this->model_music->get_all_artists_chansons();
|
||||
$data['years'] = $this->model_music->get_all_years_chansons();
|
||||
$data['albums'] = $this->model_music->get_all_albums_chansons();
|
||||
|
||||
$this->load->view('chansons_list',$data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addSongtoPlaylist($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('addSongtoplaylist', ["playlists" => $playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$playlistId = $this->input->post('playlist_id');
|
||||
$this->model_music->AddSongtoPlaylist($playlistId,$id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
51
CodeIgniter-3.1.13/application/controllers/Playlist.php
Normal file
51
CodeIgniter-3.1.13/application/controllers/Playlist.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Playlist extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
$this->load->library('form_validation');
|
||||
}
|
||||
public function index(){
|
||||
if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
}else{
|
||||
$recherche=filter_input(INPUT_GET,'recherche');
|
||||
$playlists = $this->model_music->getSearchPlaylist($recherche);
|
||||
}
|
||||
$this->load->view('layout/header');
|
||||
if ($playlists == false){
|
||||
$page = preg_split('/[\/]/',$_SERVER['REQUEST_URI']);
|
||||
$this->load->view('error',['page'=>$page[count($page)-1]]);
|
||||
$playlists = $this->model_music->getPlaylist();
|
||||
}
|
||||
$this->load->view('playlist_list',['playlists'=>$playlists]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
public function addplaylist(){
|
||||
|
||||
|
||||
$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);
|
||||
redirect('playlist');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
76
CodeIgniter-3.1.13/application/controllers/User.php
Normal file
76
CodeIgniter-3.1.13/application/controllers/User.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class User extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
}
|
||||
|
||||
public function create(){
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('nom', 'Nom', 'required');
|
||||
$this->form_validation->set_rules('prenom', 'Prénom', 'required');
|
||||
$this->form_validation->set_rules('email', 'Adresse mail', 'valid_email');
|
||||
$this->form_validation->set_rules('password', 'current password', 'min_length[5]|required');
|
||||
$this->form_validation->set_rules('cpassword', 'confirm password', 'required|matches[password]');
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create_user');
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
|
||||
$user=array(
|
||||
"usernom" => $this->input->post("nom"),
|
||||
"userprenom" => $this->input->post("prenom"),
|
||||
"usermail" => $this->input->post("email"),
|
||||
"userpassword" => password_hash(($this->input->post("password")), PASSWORD_DEFAULT),
|
||||
);
|
||||
|
||||
$this->model_music->create_user($user);
|
||||
redirect("user/auth");
|
||||
}
|
||||
}
|
||||
|
||||
public function auth()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('email', 'Adresse mail', 'valid_email');
|
||||
$this->form_validation->set_rules('password', 'current password', 'min_length[5]|required');
|
||||
|
||||
if ($this->form_validation->run() == FALSE){
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('connexion_user');
|
||||
$this->load->view('layout/footer');
|
||||
}else{
|
||||
$email = $this->input->post('email');
|
||||
$MDP = $this->input->post('password');
|
||||
|
||||
$dataUtilisateur = $this->model_music->get_user_by_email($email);
|
||||
|
||||
if(password_verify($MDP, $dataUtilisateur->userpassword)){
|
||||
$dataUser = array(
|
||||
"userId" => $dataUtilisateur->userId,
|
||||
"userprenom" => $dataUtilisateur->userprenom,
|
||||
"usermail" => $dataUtilisateur->usermail,
|
||||
"userpassword" => $dataUtilisateur->userpassword,
|
||||
"logged_in" => TRUE
|
||||
);
|
||||
$this->session->set_userdata($dataUser);
|
||||
redirect("albums");
|
||||
}else{
|
||||
redirect("user/create");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function logout(){
|
||||
$this->session->sess_destroy();
|
||||
redirect("albums");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user