From 787d03e48471ba62cd830379428f04d996f0b74b Mon Sep 17 00:00:00 2001 From: polo Date: Thu, 17 Feb 2022 18:13:00 +0100 Subject: model update --- model/Page.php | 104 --------------------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 model/Page.php (limited to 'model/Page.php') diff --git a/model/Page.php b/model/Page.php deleted file mode 100644 index 63730d8..0000000 --- a/model/Page.php +++ /dev/null @@ -1,104 +0,0 @@ -page = $page; - $this->time = time(); - $this->makeFileList(); - } - - // tableaux des noms des fichiers - public function makeFileList() - { - $this->fileList = glob('data/' . $this->page . '/' . $this->format . '/*.' . $this->format); - //$this->files = glob('*.' . $this->format); - } - /*public function makeFilePath() - {}*/ - - // nom d'un fichier - public function findFileName($numArticle) - { - if($numArticle > 0) - { - $this->fileName = $this->fileList[$numArticle - 1]; - } - } - - public function setFileName() - { - if(file_exists('data/' . $this->page . '/' . $this->format . '/' . $this->albumCode . '.' . $this->format)) - { - $this->fileName = 'data/' . $this->page . '/' . $this->format . '/' . $this->albumCode . '.' . $this->format; - } - } - - // GET - - // SET - - // fonctions CRUD (create - read - update - delete) - - // create - public function create($content) - { - //$format = 'html'; - - // nommer les fichiers avec le timestamp pour: - // - les trier par ordre chronologique - // - rendre quasi impossible d'avoir deux fois le même nom (à la condition de gérer la "concurrence") - $nom_fichier = 'data/' . $this->page . '/' . $format . '/' . $this->time . '.' . $format; - - $fichier = fopen($nom_fichier, 'w'); // w pour créer ou écraser - fputs($fichier, $content); - fclose($fichier); - chmod($nom_fichier, 0666); - } - - // read - public function readAll() - { - $i = 0; - $articles = []; - foreach ($this->fileList as $oneFile) - { - $articles[$i] = file_get_contents($oneFile); - $i++; - } - //print_r($articles); - return $articles; - } - public function readOne() - { - return(file_get_contents($this->fileName)); - } - - // update - public function update($content) - { - $file = fopen($this->fileName, 'w'); // crée ou écrase - fputs($file, $content); - fclose($file); - //chown($this->fileName, 'http'); - chmod($this->fileName, 0666); - } - - // delete - public function delete() - { - unlink($this->fileName); - } -} \ No newline at end of file -- cgit v1.2.3