diff options
Diffstat (limited to 'model/Album.php')
-rw-r--r-- | model/Album.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/model/Album.php b/model/Album.php index 386a50f..e716a99 100644 --- a/model/Album.php +++ b/model/Album.php | |||
@@ -21,7 +21,7 @@ class Album extends Article | |||
21 | // fonctions CRUD | 21 | // fonctions CRUD |
22 | 22 | ||
23 | // create | 23 | // create |
24 | public function createVignette($titre, $annee, $pochette) | 24 | public function createVignette($titre, $annee, $pochette, $pochetteMini) |
25 | { | 25 | { |
26 | //$this->format = 'json'; | 26 | //$this->format = 'json'; |
27 | 27 | ||
@@ -33,6 +33,7 @@ class Album extends Article | |||
33 | require('model/Image.php'); | 33 | require('model/Image.php'); |
34 | $Image = new Image(false); | 34 | $Image = new Image(false); |
35 | $Image->upload(); | 35 | $Image->upload(); |
36 | $Image->makeThumbnail(); | ||
36 | 37 | ||
37 | $erreur = $Image->erreur; | 38 | $erreur = $Image->erreur; |
38 | if(!empty($erreur)) | 39 | if(!empty($erreur)) |
@@ -40,7 +41,7 @@ class Album extends Article | |||
40 | } | 41 | } |
41 | 42 | ||
42 | // encodage avec un tableau simple | 43 | // encodage avec un tableau simple |
43 | $albumJSON = json_encode([$titre, $annee, $pochette]); | 44 | $albumJSON = json_encode([$titre, $annee, $pochette, $pochetteMini]); |
44 | //var_dump($albumJSON); die(); | 45 | //var_dump($albumJSON); die(); |
45 | 46 | ||
46 | // encodage avec un tableau associatif | 47 | // encodage avec un tableau associatif |
@@ -66,15 +67,13 @@ class Album extends Article | |||
66 | for($i = 0; $i < $this->fileListCount; $i++) | 67 | for($i = 0; $i < $this->fileListCount; $i++) |
67 | { | 68 | { |
68 | // ajout du JSON | 69 | // ajout du JSON |
69 | /*$content = file_get_contents($this->fileList[$i]['fileName']); | ||
70 | $content = json_decode($content, true);*/ | ||
71 | $content = json_decode($this->fileList[$i]['content'], true); | 70 | $content = json_decode($this->fileList[$i]['content'], true); |
72 | //var_dump($content); die(); | ||
73 | 71 | ||
74 | // lecture de $content étant un tableau simple | 72 | // lecture de $content étant un tableau simple |
75 | $this->fileList[$i]['titre'] = $content[0]; | 73 | $this->fileList[$i]['titre'] = $content[0]; |
76 | $this->fileList[$i]['annee'] = $content[1]; | 74 | $this->fileList[$i]['annee'] = $content[1]; |
77 | $this->fileList[$i]['pochette'] = $content[2]; | 75 | $this->fileList[$i]['pochette'] = $content[2]; |
76 | $this->fileList[$i]['pochetteMini'] = $content[3]; | ||
78 | 77 | ||
79 | // ajout du HTML si il existe | 78 | // ajout du HTML si il existe |
80 | if(file_exists('data/' . $this->page . '/' . $this->format . '/' . $this->fileList[$i]['fileCode'] . '.' . $this->format)) | 79 | if(file_exists('data/' . $this->page . '/' . $this->format . '/' . $this->fileList[$i]['fileCode'] . '.' . $this->format)) |
@@ -107,6 +106,7 @@ class Album extends Article | |||
107 | $this->oneAlbum['titre'] = $content[0]; | 106 | $this->oneAlbum['titre'] = $content[0]; |
108 | $this->oneAlbum['annee'] = $content[1]; | 107 | $this->oneAlbum['annee'] = $content[1]; |
109 | $this->oneAlbum['pochette'] = $content[2]; | 108 | $this->oneAlbum['pochette'] = $content[2]; |
109 | $this->oneAlbum['pochetteMini'] = $content[3]; | ||
110 | 110 | ||
111 | // html | 111 | // html |
112 | $this->format = 'html'; | 112 | $this->format = 'html'; |
@@ -138,14 +138,18 @@ class Album extends Article | |||
138 | } | 138 | } |
139 | 139 | ||
140 | // update | 140 | // update |
141 | public function updateVignetteJSON($titre, $annee, $pochette) | 141 | public function updateVignetteJSON($titre, $annee, $pochette, $pochetteMini) |
142 | { | 142 | { |
143 | // garder l'ancienne image | 143 | // garder l'image si aucune n'est sélectionnée |
144 | // (on ne peut pas préremplir un <input type="file">) | ||
144 | $albumJSON = self::getVignetteJSON(); | 145 | $albumJSON = self::getVignetteJSON(); |
146 | /*var_dump($pochette); var_dump($pochetteMini); | ||
147 | var_dump($albumJSON); die();*/ | ||
145 | 148 | ||
146 | if($pochette == '') | 149 | if($pochette == '') |
147 | { | 150 | { |
148 | $pochette = $albumJSON[2]; | 151 | $pochette = $albumJSON[2]; |
152 | $pochetteMini = $albumJSON[3]; | ||
149 | } | 153 | } |
150 | else | 154 | else |
151 | { | 155 | { |
@@ -153,6 +157,7 @@ class Album extends Article | |||
153 | require('model/Image.php'); | 157 | require('model/Image.php'); |
154 | $Image = new Image(false); | 158 | $Image = new Image(false); |
155 | $Image->upload(); | 159 | $Image->upload(); |
160 | $Image->makeThumbnail(); | ||
156 | $erreur = $Image->erreur; | 161 | $erreur = $Image->erreur; |
157 | if(!empty($erreur)) | 162 | if(!empty($erreur)) |
158 | { | 163 | { |
@@ -161,7 +166,7 @@ class Album extends Article | |||
161 | } | 166 | } |
162 | } | 167 | } |
163 | 168 | ||
164 | $albumJSON = json_encode([$titre, $annee, $pochette]); | 169 | $albumJSON = json_encode([$titre, $annee, $pochette, $pochetteMini]); |
165 | 170 | ||
166 | // écriture | 171 | // écriture |
167 | $nom_fichier = 'data/discographie/json/' . $this->albumCode . '.json'; | 172 | $nom_fichier = 'data/discographie/json/' . $this->albumCode . '.json'; |