From 90b3efeeb9d939303ff80b180725e06e2e57af79 Mon Sep 17 00:00:00 2001 From: polo Date: Thu, 13 Apr 2023 03:02:57 +0200 Subject: =?UTF-8?q?=C3=A9diteur=20page=20album?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/Image.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'model/Image.php') diff --git a/model/Image.php b/model/Image.php index 1cc0e22..d71b96a 100644 --- a/model/Image.php +++ b/model/Image.php @@ -4,6 +4,7 @@ class Image { private $page; + private $folder; private $ajax; // vaut true avec le ckeditor public $reponseAjax; @@ -13,18 +14,25 @@ class Image public $pathInfos; public $erreur; - public function __construct($ajax) + public function __construct(string $page, string $folder, bool $ajax) { - // get envoyé avec le javascript $this->ajax = $ajax; - $this->page = $_GET['page']; - $this->path = 'data/' . $this->page . '/images/'; - $this->pathMini = 'data/' . $this->page . '/images-mini/'; + $this->page = $page; + $this->folder = $folder; + $this->path = 'data/' . $this->folder . '/images/'; + $this->pathMini = 'data/' . $this->folder . '/images-mini/'; } // GET // SET + public function setFolder(string $folder) + { + $this->folder = $folder; + $this->path = 'data/' . $this->folder . '/images/'; + $this->pathMini = 'data/' . $this->folder . '/images-mini/'; + } + public function upload() { @@ -55,7 +63,7 @@ class Image if($this->ajax && empty($Image->erreur)) { // chemin en JSON attendu par l'éditeur - $this->reponseAjax = '{"url": "data/' . $this->page . '/images/' . $_FILES['upload']['name'] . '"}'; + $this->reponseAjax = '{"url": "data/' . $this->folder . '/images/' . $_FILES['upload']['name'] . '"}'; } } @@ -108,7 +116,7 @@ class Image // message d'erreur $_SESSION['erreur'] = addslashes("Echec de la création d'une miniature. Vérifier le fichier config.php"); - header('Location: index.php?page=' . $this->page . '&erreur=dependance_bibli_images'); + header('Location: index.php?page=' . $this->folder . '&erreur=dependance_bibli_images'); exit(); } } -- cgit v1.2.3