vaujdui v2
This commit is contained in:
parent
6bfbf46dcc
commit
46e7b0d369
application
@ -7,6 +7,7 @@ class Artistes extends CI_Controller {
|
||||
$this->load->model('Model_artist');
|
||||
$this->load->model('Model_music');
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('session');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
@ -19,24 +20,39 @@ class Artistes extends CI_Controller {
|
||||
$config['base_url'] = site_url('artistes');
|
||||
$config['total_rows'] = $this->Model_artist->get_total_artists($genre, $query);
|
||||
$config['per_page'] = 16; // Nombre d'artistes par page
|
||||
$config['uri_segment'] = 2; // Segment de l'URI contenant le numéro de la page
|
||||
$config['page_query_string'] = TRUE;
|
||||
$config['reuse_query_string'] = TRUE;
|
||||
$config['query_string_segment'] = 'page';
|
||||
$config['full_tag_open'] = '<nav aria-label="Page navigation"><ul class="pagination">';
|
||||
$config['full_tag_close'] = '</ul></nav>';
|
||||
$config['first_link'] = 'First';
|
||||
$config['last_link'] = 'Last';
|
||||
$config['first_tag_open'] = '<li class="page-item">';
|
||||
$config['first_tag_close'] = '</li>';
|
||||
$config['prev_link'] = '«';
|
||||
$config['prev_tag_open'] = '<li class="page-item">';
|
||||
$config['prev_tag_close'] = '</li>';
|
||||
$config['next_link'] = '»';
|
||||
$config['next_tag_open'] = '<li class="page-item">';
|
||||
$config['next_tag_close'] = '</li>';
|
||||
$config['last_tag_open'] = '<li class="page-item">';
|
||||
$config['last_tag_close'] = '</li>';
|
||||
$config['cur_tag_open'] = '<li class="page-item active"><a href="#" class="page-link">';
|
||||
$config['cur_tag_close'] = '</a></li>';
|
||||
$config['num_tag_open'] = '<li class="page-item">';
|
||||
$config['num_tag_close'] = '</li>';
|
||||
$config['attributes'] = array('class' => 'page-link');
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
|
||||
|
||||
// Correction pour éviter l'erreur str_replace()
|
||||
$pagination_links = $this->pagination->create_links();
|
||||
if ($pagination_links === null) {
|
||||
$pagination_links = '';
|
||||
}
|
||||
$page = $this->input->get('page');
|
||||
$page = ($page) ? $page : 0;
|
||||
|
||||
$data = array(
|
||||
'artists' => $this->Model_artist->getArtists($genre, $order, $query, $config['per_page'], $page),
|
||||
'genres' => $this->Model_music->researchtype(),
|
||||
'pagination' => $pagination_links,
|
||||
'is_logged_in' => $this->session->userdata('logged_in')
|
||||
'is_logged_in' => $this->session->userdata('logged_in'),
|
||||
'pagination' => $this->pagination->create_links()
|
||||
);
|
||||
|
||||
$this->load->view('layout/header', $data);
|
||||
@ -46,8 +62,6 @@ class Artistes extends CI_Controller {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function view($artistId) {
|
||||
$artistDetails = $this->Model_artist->getArtistDetails($artistId);
|
||||
$albums = $this->Model_artist->getAlbumsByArtist($artistId);
|
||||
@ -66,5 +80,5 @@ class Artistes extends CI_Controller {
|
||||
$this->load->view('artist_details', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -11,8 +11,7 @@ class Connect extends CI_Controller {
|
||||
$this->load->helper(['url', 'form']);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
public function create() {
|
||||
$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|required');
|
||||
@ -23,6 +22,13 @@ class Connect extends CI_Controller {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create');
|
||||
$this->load->view('layout/footer');
|
||||
} else {
|
||||
$email = $this->input->post('email');
|
||||
if ($this->User_model->emailExists($email)) {
|
||||
$data['error'] = 'L\'adresse email est déjà utilisée.';
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('create', $data);
|
||||
$this->load->view('layout/footer');
|
||||
} else {
|
||||
$data = array(
|
||||
'nom' => $this->input->post('nom'),
|
||||
@ -41,6 +47,9 @@ class Connect extends CI_Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function login()
|
||||
{
|
||||
|
@ -26,9 +26,11 @@ class Playlist extends CI_Controller {
|
||||
}
|
||||
|
||||
public function add() {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$user_email = $this->session->userdata('email');
|
||||
$name = $this->input->post('name');
|
||||
$type = $this->input->post('type');
|
||||
$numSongs = $this->input->post('numSongs');
|
||||
@ -55,13 +57,16 @@ class Playlist extends CI_Controller {
|
||||
}
|
||||
|
||||
public function selectPlaylist() {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$itemId = $this->input->post('itemId');
|
||||
$itemType = $this->input->post('itemType');
|
||||
$playlists = $this->Model_playlist->getPlaylistsByUser($this->session->userdata('email'));
|
||||
|
||||
$data = array(
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'is_logged_in' => $this->session->userdata('logged_in'),
|
||||
'itemId' => $itemId,
|
||||
'itemType' => $itemType,
|
||||
'playlists' => $playlists
|
||||
@ -73,6 +78,10 @@ class Playlist extends CI_Controller {
|
||||
}
|
||||
|
||||
public function addItems() {
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$playlistId = $this->input->post('playlistId');
|
||||
$itemId = $this->input->post('itemId');
|
||||
$itemType = $this->input->post('itemType');
|
||||
@ -98,12 +107,15 @@ class Playlist extends CI_Controller {
|
||||
}
|
||||
|
||||
public function view($playlistId) {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$items = $this->Model_playlist->getPlaylistItems($playlistId);
|
||||
$itemCount = $this->Model_playlist->getPlaylistItemCount($playlistId);
|
||||
|
||||
$data = array(
|
||||
'is_logged_in' => $is_logged_in,
|
||||
'is_logged_in' => $this->session->userdata('logged_in'),
|
||||
'items' => $items,
|
||||
'itemCount' => $itemCount
|
||||
);
|
||||
@ -114,29 +126,36 @@ class Playlist extends CI_Controller {
|
||||
}
|
||||
|
||||
public function deleteItem($playlistId, $itemId) {
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$this->Model_playlist->deleteItem($playlistId, $itemId);
|
||||
redirect('playlist/view/' . $playlistId);
|
||||
}
|
||||
|
||||
public function delete($playlist_id) {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$this->Model_playlist->deletePlaylist($playlist_id);
|
||||
redirect('playlist');
|
||||
}
|
||||
|
||||
public function duplicate($playlist_id) {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$this->Model_playlist->duplicatePlaylist($playlist_id, $user_email);
|
||||
$this->Model_playlist->duplicatePlaylist($playlist_id);
|
||||
redirect('playlist');
|
||||
}
|
||||
|
||||
public function rename() {
|
||||
$is_logged_in = $this->session->userdata('logged_in');
|
||||
$user_email = $this->session->userdata('email');
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
redirect('connect/login');
|
||||
}
|
||||
|
||||
$playlistId = $this->input->post('playlistId');
|
||||
$newName = $this->input->post('newName');
|
||||
@ -145,3 +164,4 @@ class Playlist extends CI_Controller {
|
||||
redirect('playlist');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -109,7 +109,7 @@ class Model_playlist extends CI_Model {
|
||||
$this->db->insert('playlists', $data);
|
||||
$playlistId = $this->db->insert_id();
|
||||
|
||||
// Filtrage des chansons par genre
|
||||
// Filtrage des chansons par genre et sélection aléatoire
|
||||
$this->db->select('track.id');
|
||||
$this->db->from('track');
|
||||
$this->db->join('song', 'track.songid = song.id');
|
||||
@ -120,17 +120,13 @@ class Model_playlist extends CI_Model {
|
||||
$this->db->where('genre.name', $genre);
|
||||
}
|
||||
|
||||
$this->db->order_by('RAND()');
|
||||
$this->db->limit($numSongs);
|
||||
|
||||
$query = $this->db->get();
|
||||
$songs = $query->result();
|
||||
|
||||
if ($numSongs > count($songs)) {
|
||||
$numSongs = count($songs);
|
||||
}
|
||||
|
||||
// Sélection aléatoire de chansons
|
||||
$randomKeys = array_rand($songs, $numSongs);
|
||||
foreach ($randomKeys as $key) {
|
||||
$song = $songs[$key];
|
||||
foreach ($songs as $song) {
|
||||
$this->addItem($playlistId, $song->id, 'song');
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,12 @@ class User_model extends CI_Model {
|
||||
public function create_user($data) {
|
||||
return $this->db->insert('user', $data);
|
||||
}
|
||||
|
||||
public function emailExists($email) {
|
||||
$this->db->where('email', $email);
|
||||
$query = $this->db->get('user');
|
||||
return $query->num_rows() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -86,19 +86,19 @@
|
||||
padding: 8px 12px;
|
||||
margin: 0 2px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd;
|
||||
color: #333;
|
||||
border: 1px solid #b02dff; /* Couleur violet clair */
|
||||
color: #b02dff; /* Couleur violet clair */
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pagination a:hover {
|
||||
background-color: #f0f0f0;
|
||||
border-color: #bbb;
|
||||
background-color: #f3e8ff; /* Couleur violet très clair */
|
||||
border-color: #a86bff; /* Couleur violet moyen */
|
||||
}
|
||||
|
||||
.pagination .is-current {
|
||||
background-color: #3273dc;
|
||||
border-color: #3273dc;
|
||||
background-color: #8a4dff; /* Couleur violet de Bulma */
|
||||
border-color: #8a4dff; /* Couleur violet de Bulma */
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
@ -33,19 +33,19 @@
|
||||
padding: 8px 12px;
|
||||
margin: 0 2px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd;
|
||||
color: #333;
|
||||
border: 1px solid #b02dff; /* Couleur violet clair */
|
||||
color: #b02dff; /* Couleur violet clair */
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pagination a:hover {
|
||||
background-color: #f0f0f0;
|
||||
border-color: #bbb;
|
||||
background-color: #f3e8ff; /* Couleur violet très clair */
|
||||
border-color: #a86bff; /* Couleur violet moyen */
|
||||
}
|
||||
|
||||
.pagination .is-current {
|
||||
background-color: #3273dc;
|
||||
border-color: #3273dc;
|
||||
background-color: #8a4dff; /* Couleur violet de Bulma */
|
||||
border-color: #8a4dff; /* Couleur violet de Bulma */
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
@ -8,6 +8,11 @@
|
||||
<div class="column is-5">
|
||||
<div class="box">
|
||||
<h1 class="title is-1 has-text-centered">Inscription</h1>
|
||||
<?php if (isset($error)): ?>
|
||||
<div class="notification is-danger">
|
||||
<?= $error ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?=validation_errors(); ?>
|
||||
<?=form_open('connect/create')?>
|
||||
<div class="field">
|
||||
@ -27,6 +32,9 @@
|
||||
<div class="control">
|
||||
<input class="input is-dark" type="email" id="email" name="email" placeholder="Email" value="<?=set_value('email')?>" required>
|
||||
</div>
|
||||
<?php if (isset($error)): ?>
|
||||
<p class="help is-danger"><?= $error ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="password">Mot de passe</label>
|
||||
|
@ -38,7 +38,7 @@
|
||||
<a class="button is-light" href="<?= site_url('connect/logout') ?>">Déconnexion</a>
|
||||
<?php else: ?>
|
||||
<a class="button is-light" href="<?= site_url('connect/login') ?>">Connexion</a>
|
||||
<a class="button is-primary" href="<?= site_url('connect/create') ?>">Inscription</a>
|
||||
<a class="button is-signup" href="<?= site_url('connect/create') ?>">Inscription</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -64,5 +64,19 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.button.is-signup {
|
||||
background-color: #b02dff;
|
||||
border-color: #b02dff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.button.is-signup:hover {
|
||||
background-color: #9a29e6;
|
||||
border-color: #9a29e6;
|
||||
}
|
||||
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -37,28 +37,25 @@
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
.pagination a, .pagination span {
|
||||
padding: 8px 12px;
|
||||
margin: 0 2px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ddd;
|
||||
color: #333;
|
||||
border: 1px solid #b02dff; /* Couleur violet clair */
|
||||
color: #b02dff; /* Couleur violet clair */
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pagination a:hover {
|
||||
background-color: #f0f0f0;
|
||||
border-color: #bbb;
|
||||
background-color: #f3e8ff; /* Couleur violet très clair */
|
||||
border-color: #a86bff; /* Couleur violet moyen */
|
||||
}
|
||||
|
||||
.pagination .is-current {
|
||||
background-color: #3273dc;
|
||||
border-color: #3273dc;
|
||||
background-color: #8a4dff; /* Couleur violet de Bulma */
|
||||
border-color: #8a4dff; /* Couleur violet de Bulma */
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user