From abd968a1c573b1862bd0728f0b7b6a88e307900a Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 28 Feb 2022 02:15:31 +0100 Subject: sauvegarde zip --- model/Album.php | 33 +++++++++++++++++++++++++-------- model/Article.php | 8 ++++++-- model/Image.php | 5 +++-- 3 files changed, 34 insertions(+), 12 deletions(-) (limited to 'model') diff --git a/model/Album.php b/model/Album.php index 9c90a6b..3f13939 100644 --- a/model/Album.php +++ b/model/Album.php @@ -7,16 +7,32 @@ class Album extends Article public function __construct($page) { + $this->format = 'json'; // vaut 'html' dans la classe mère + // pour: page, fileCode, time et makeFileList() parent::__construct($page); - //$this->page = $page; - //$this->fileCode = ''; // désigne un fichier json et un html - $this->format = 'json'; // vaut 'html' dans la classe mère - //$this->time = time(); - //$this->makeFileList(); } // GET + public function getAllJSON() // pour la page album + { + // mettre le JSON dans fileList[$i]['content'] + parent::readAll(); + + $this->format = 'html'; + + for($i = 0; $i < $this->fileListCount; $i++) + { + $content = json_decode($this->fileList[$i]['content'], true); + $this->fileList[$i]['titre'] = $content[0]; + $this->fileList[$i]['annee'] = $content[1]; + $this->fileList[$i]['pochette'] = $content[2]; + $this->fileList[$i]['pochetteMini'] = $content[3]; + } + + // on remet comme avant + $this->format = 'json'; + } // SET @@ -70,6 +86,7 @@ class Album extends Article // permet de ne pas la remplacer par la nouvelle $this->format = 'html'; + for($i = 0; $i < $this->fileListCount; $i++) { // ajout du JSON @@ -103,7 +120,7 @@ class Album extends Article { for($i = 0; $i < $this->fileListCount; $i++) { - if($_SESSION['target'] == $this->fileList[$i]['fileCode']) + if($this->fileCode == $this->fileList[$i]['fileCode']) { // json $this->oneAlbum['fileCode'] = $this->fileList[$i]['fileCode']; @@ -127,7 +144,7 @@ class Album extends Article } // page d'un album - public static function readOneHTML($fileCode) + /*public static function readOneHTML($fileCode) { if(file_exists('data/discographie/html/' . $fileCode . '.html')) { @@ -137,7 +154,7 @@ class Album extends Article { return(''); } - } + }*/ public function getVignetteJSON() { diff --git a/model/Article.php b/model/Article.php index fa9fce1..4ef3a5b 100644 --- a/model/Article.php +++ b/model/Article.php @@ -18,6 +18,12 @@ // $fileList[$fileCode] => [$fileName => 'code', $content => 'contenu'], etc +// ma struture est mauvaise, elle n'est pas très orientée objet +// créer une classe structure de données +// celle-ci sera instanciée dans la première (ou pas du tout) +// et accesssible avec des GET et des SET + + class Article { // pour tous les articles @@ -25,8 +31,6 @@ class Article public $format = 'html'; // vaut 'html' ou 'json' public $fileListCount; public $fileList; // = toutes les données - //protected $articles; // contenu de toute la page - //protected $nbArticles; // un fichier = un article // pour un article (ou album) spécifique //public $fileName = ''; // = $_SESSION['nomFichier'] diff --git a/model/Image.php b/model/Image.php index ac05f24..793bd8d 100644 --- a/model/Image.php +++ b/model/Image.php @@ -3,7 +3,6 @@ class Image { - private const MAX_WEIGHT = 2000000; // à adapter au php.ini private $page; private $ajax; // vaut true avec le ckeditor public $path; @@ -26,10 +25,12 @@ class Image public function upload() { + global $maxWeight; + // traitement et enregistrement de l'image if (isset($_FILES['upload']) AND $_FILES['upload']['error'] == 0) // 0 signifie ok { - if ($_FILES['upload']['size'] <= self::MAX_WEIGHT) + if ($_FILES['upload']['size'] <= $maxWeight) { $this->pathInfos = pathinfo($_FILES['upload']['name']); $extension = $this->pathInfos['extension']; -- cgit v1.2.3