diff options
Diffstat (limited to 'model/Album.php')
-rw-r--r-- | model/Album.php | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/model/Album.php b/model/Album.php new file mode 100644 index 0000000..2254c10 --- /dev/null +++ b/model/Album.php | |||
@@ -0,0 +1,75 @@ | |||
1 | <?php | ||
2 | // model/Album.php | ||
3 | |||
4 | class Album extends Page // classe "objet" | ||
5 | { | ||
6 | public function __construct($page) | ||
7 | { | ||
8 | $this->page = $page; | ||
9 | $this->format = 'json'; // vaut 'html' dans la classe mère | ||
10 | $this->time = time(); | ||
11 | } | ||
12 | |||
13 | // GET | ||
14 | |||
15 | // SET | ||
16 | |||
17 | // fonctions CRUD | ||
18 | |||
19 | // create | ||
20 | public function createVignette($titre, $annee, $pochette) | ||
21 | { | ||
22 | $this->format = 'json'; | ||
23 | |||
24 | if($pochette != '') | ||
25 | { | ||
26 | // télécharger la pochette | ||
27 | require('model/Image.php'); | ||
28 | $Image = new Image(false); | ||
29 | $Image->upload(); | ||
30 | |||
31 | /*$erreur = $Image->getError(); | ||
32 | if(!empty($erreur)) | ||
33 | {}*/ | ||
34 | } | ||
35 | |||
36 | $albumJSON = json_encode([$titre, $annee, $pochette]); | ||
37 | |||
38 | $nom_fichier = 'data/' . $this->page . '/' . $this->format . '/' . $this->time . '.' . $this->format; | ||
39 | |||
40 | $fichier = fopen($nom_fichier, 'w'); // w pour créer ou écraser | ||
41 | fputs($fichier, $albumJSON); | ||
42 | fclose($fichier); | ||
43 | chmod($nom_fichier, 0666); | ||
44 | } | ||
45 | |||
46 | // read | ||
47 | public function getVignette() | ||
48 | { | ||
49 | return(file_get_contents($this->fileName)); | ||
50 | } | ||
51 | |||
52 | // page de l'album | ||
53 | public static function readOneAlbum($albumCode) | ||
54 | { | ||
55 | return(file_get_contents('data/discographie/html/' . $albumCode . '.html')); | ||
56 | } | ||
57 | |||
58 | // pour afficher des dates | ||
59 | /*public function getDate($fileNumber) | ||
60 | { | ||
61 | // le 2è paramètre exclut le suffixe .html | ||
62 | $timestamp = basename($this->files[$fileNumber], '.html'); | ||
63 | return getdate($timestamp); | ||
64 | }*/ | ||
65 | |||
66 | // update | ||
67 | public function updateVignette() | ||
68 | {} | ||
69 | |||
70 | // delete | ||
71 | public function delete() | ||
72 | { | ||
73 | unlink($this->fileName); | ||
74 | } | ||
75 | } | ||