debut
This commit is contained in:
19
bd/README.md
Normal file
19
bd/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Base de données de musique
|
||||
La [base de données](./music.sql) est structuré de la manière suivante :
|
||||
|
||||
```
|
||||
album (id,name,year,#artistid,#genreid,#coverid)
|
||||
--
|
||||
artist (id,name)
|
||||
--
|
||||
track (id,#albumid,#songid,diskNumber,number,duration)
|
||||
--
|
||||
song(id,name)
|
||||
--
|
||||
genre(id,name)
|
||||
--
|
||||
cover(id,jpeg)
|
||||
--
|
||||
```
|
||||
|
||||
Vous aurez certainement besoin de rajouter des tables pour la gestion des playlists.
|
||||
BIN
bd/music.sql.gz
Normal file
BIN
bd/music.sql.gz
Normal file
Binary file not shown.
20
src/assets/style.css
Normal file
20
src/assets/style.css
Normal file
@@ -0,0 +1,20 @@
|
||||
section.list
|
||||
{
|
||||
display : flex;
|
||||
justify-content : space-between;
|
||||
flex-wrap:wrap;
|
||||
}
|
||||
section.list > div
|
||||
{
|
||||
width : 30%;
|
||||
}
|
||||
section.list img {
|
||||
display:inline-block;
|
||||
|
||||
}
|
||||
.short-text {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
18
src/controllers/Albums.php
Normal file
18
src/controllers/Albums.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Albums extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->load->model('model_music');
|
||||
}
|
||||
public function index(){
|
||||
$albums = $this->model_music->getAlbums();
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('albums_list',['albums'=>$albums]);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
20
src/models/Model_music.php
Normal file
20
src/models/Model_music.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Model_music extends CI_Model {
|
||||
public function __construct(){
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
public function getAlbums(){
|
||||
$query = $this->db->query(
|
||||
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
||||
FROM album
|
||||
JOIN artist ON album.artistid = artist.id
|
||||
JOIN genre ON genre.id = album.genreid
|
||||
JOIN cover ON cover.id = album.coverid
|
||||
ORDER BY year
|
||||
"
|
||||
);
|
||||
return $query->result();
|
||||
}
|
||||
}
|
||||
14
src/views/albums_list.php
Normal file
14
src/views/albums_list.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<h5>Albums list</h5>
|
||||
<section class="list">
|
||||
<?php
|
||||
foreach($albums as $album){
|
||||
echo "<div><article>";
|
||||
echo "<header class='short-text'>";
|
||||
echo anchor("albums/view/{$album->id}","{$album->name}");
|
||||
echo "</header>";
|
||||
echo '<img src="data:image/jpeg;base64,'.base64_encode($album->jpeg).'" />';
|
||||
echo "<footer class='short-text'>{$album->year} - {$album->artistName}</footer>
|
||||
</article></div>";
|
||||
}
|
||||
?>
|
||||
</section>
|
||||
3
src/views/layout/footer.php
Normal file
3
src/views/layout/footer.php
Normal file
@@ -0,0 +1,3 @@
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
25
src/views/layout/header.php
Normal file
25
src/views/layout/header.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<!doctype html>
|
||||
<html lang="en" class="has-navbar-fixed-top">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>MUSIC APP</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<?=link_tag('assets/style.css')?>
|
||||
</head>
|
||||
<body>
|
||||
<main class='container'>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><strong>Music APP</strong></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><?=anchor('albums','Albums');?></li>
|
||||
<li><?=anchor('artistes','Artistes');?></li>
|
||||
<li><?=anchor('playlist','Playlist');?></li>
|
||||
</ul>
|
||||
</nav>
|
||||
Reference in New Issue
Block a user