diff options
Diffstat (limited to 'model/Image.php')
-rw-r--r-- | model/Image.php | 22 |
1 files changed, 15 insertions, 7 deletions
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 @@ | |||
4 | class Image | 4 | class Image |
5 | { | 5 | { |
6 | private $page; | 6 | private $page; |
7 | private $folder; | ||
7 | 8 | ||
8 | private $ajax; // vaut true avec le ckeditor | 9 | private $ajax; // vaut true avec le ckeditor |
9 | public $reponseAjax; | 10 | public $reponseAjax; |
@@ -13,18 +14,25 @@ class Image | |||
13 | public $pathInfos; | 14 | public $pathInfos; |
14 | public $erreur; | 15 | public $erreur; |
15 | 16 | ||
16 | public function __construct($ajax) | 17 | public function __construct(string $page, string $folder, bool $ajax) |
17 | { | 18 | { |
18 | // get envoyé avec le javascript | ||
19 | $this->ajax = $ajax; | 19 | $this->ajax = $ajax; |
20 | $this->page = $_GET['page']; | 20 | $this->page = $page; |
21 | $this->path = 'data/' . $this->page . '/images/'; | 21 | $this->folder = $folder; |
22 | $this->pathMini = 'data/' . $this->page . '/images-mini/'; | 22 | $this->path = 'data/' . $this->folder . '/images/'; |
23 | $this->pathMini = 'data/' . $this->folder . '/images-mini/'; | ||
23 | } | 24 | } |
24 | 25 | ||
25 | // GET | 26 | // GET |
26 | 27 | ||
27 | // SET | 28 | // SET |
29 | public function setFolder(string $folder) | ||
30 | { | ||
31 | $this->folder = $folder; | ||
32 | $this->path = 'data/' . $this->folder . '/images/'; | ||
33 | $this->pathMini = 'data/' . $this->folder . '/images-mini/'; | ||
34 | } | ||
35 | |||
28 | 36 | ||
29 | public function upload() | 37 | public function upload() |
30 | { | 38 | { |
@@ -55,7 +63,7 @@ class Image | |||
55 | if($this->ajax && empty($Image->erreur)) | 63 | if($this->ajax && empty($Image->erreur)) |
56 | { | 64 | { |
57 | // chemin en JSON attendu par l'éditeur | 65 | // chemin en JSON attendu par l'éditeur |
58 | $this->reponseAjax = '{"url": "data/' . $this->page . '/images/' . $_FILES['upload']['name'] . '"}'; | 66 | $this->reponseAjax = '{"url": "data/' . $this->folder . '/images/' . $_FILES['upload']['name'] . '"}'; |
59 | } | 67 | } |
60 | } | 68 | } |
61 | 69 | ||
@@ -108,7 +116,7 @@ class Image | |||
108 | 116 | ||
109 | // message d'erreur | 117 | // message d'erreur |
110 | $_SESSION['erreur'] = addslashes("Echec de la création d'une miniature. Vérifier le fichier config.php"); | 118 | $_SESSION['erreur'] = addslashes("Echec de la création d'une miniature. Vérifier le fichier config.php"); |
111 | header('Location: index.php?page=' . $this->page . '&erreur=dependance_bibli_images'); | 119 | header('Location: index.php?page=' . $this->folder . '&erreur=dependance_bibli_images'); |
112 | exit(); | 120 | exit(); |
113 | } | 121 | } |
114 | } | 122 | } |