From b97a68343ec5c4ff1fae25ff5dc41f1a2ce6a17f Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 26 Nov 2021 04:29:10 +0100 Subject: =?UTF-8?q?disco=20modif/suppr=20d=C3=A9sordre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/Album.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 model/Album.php (limited to 'model/Album.php') 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 @@ +page = $page; + $this->format = 'json'; // vaut 'html' dans la classe mère + $this->time = time(); + } + + // GET + + // SET + + // fonctions CRUD + + // create + public function createVignette($titre, $annee, $pochette) + { + $this->format = 'json'; + + if($pochette != '') + { + // télécharger la pochette + require('model/Image.php'); + $Image = new Image(false); + $Image->upload(); + + /*$erreur = $Image->getError(); + if(!empty($erreur)) + {}*/ + } + + $albumJSON = json_encode([$titre, $annee, $pochette]); + + $nom_fichier = 'data/' . $this->page . '/' . $this->format . '/' . $this->time . '.' . $this->format; + + $fichier = fopen($nom_fichier, 'w'); // w pour créer ou écraser + fputs($fichier, $albumJSON); + fclose($fichier); + chmod($nom_fichier, 0666); + } + + // read + public function getVignette() + { + return(file_get_contents($this->fileName)); + } + + // page de l'album + public static function readOneAlbum($albumCode) + { + return(file_get_contents('data/discographie/html/' . $albumCode . '.html')); + } + + // pour afficher des dates + /*public function getDate($fileNumber) + { + // le 2è paramètre exclut le suffixe .html + $timestamp = basename($this->files[$fileNumber], '.html'); + return getdate($timestamp); + }*/ + + // update + public function updateVignette() + {} + + // delete + public function delete() + { + unlink($this->fileName); + } +} -- cgit v1.2.3