diff options
Diffstat (limited to 'controller/ckeditor.php')
-rw-r--r-- | controller/ckeditor.php | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/controller/ckeditor.php b/controller/ckeditor.php index 3765261..7b4f1bb 100644 --- a/controller/ckeditor.php +++ b/controller/ckeditor.php | |||
@@ -31,6 +31,29 @@ function preparationCKeditor($html) | |||
31 | return($html); | 31 | return($html); |
32 | } | 32 | } |
33 | 33 | ||
34 | // utilisée par submitCKeditor() | ||
35 | function getFileCodeFromHTTPReferrer(): string | ||
36 | { | ||
37 | if(isset($_SERVER['HTTP_REFERER'])) | ||
38 | { | ||
39 | $referrer = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY); | ||
40 | $pattern = '#file_code=#'; | ||
41 | $split = preg_split($pattern, $referrer); | ||
42 | if(isset($split[1]) && is_numeric($split[1])) | ||
43 | { | ||
44 | return $split[1]; | ||
45 | } | ||
46 | else | ||
47 | { | ||
48 | return ''; | ||
49 | } | ||
50 | } | ||
51 | else | ||
52 | { | ||
53 | return ''; | ||
54 | } | ||
55 | } | ||
56 | |||
34 | // réception du HTML créé par l'éditeur | 57 | // réception du HTML créé par l'éditeur |
35 | function submitCKeditor() | 58 | function submitCKeditor() |
36 | { | 59 | { |
@@ -66,11 +89,12 @@ function submitCKeditor() | |||
66 | if($_GET['page'] === 'discographie' || $_GET['page'] === 'album') | 89 | if($_GET['page'] === 'discographie' || $_GET['page'] === 'album') |
67 | { | 90 | { |
68 | $Album = new Album($_GET['page'], 'discographie'); | 91 | $Album = new Album($_GET['page'], 'discographie'); |
92 | |||
93 | $Album->fileCode = getFileCodeFromHTTPReferrer(); | ||
69 | 94 | ||
70 | // on retrouve les données si nécessaire | 95 | // on retrouve les données si nécessaire |
71 | if(isset($_SESSION['file_code']) && $_SESSION['file_code'] != '') | 96 | if($Album->fileCode != '') |
72 | { | 97 | { |
73 | $Album->fileCode = $_SESSION['file_code']; | ||
74 | $Album->readOne(); | 98 | $Album->readOne(); |
75 | } | 99 | } |
76 | 100 | ||
@@ -87,7 +111,6 @@ function submitCKeditor() | |||
87 | $Image->setThumbnailWidth(201); | 111 | $Image->setThumbnailWidth(201); |
88 | 112 | ||
89 | $nouvellePochette = $nomFichier; | 113 | $nouvellePochette = $nomFichier; |
90 | /*$nouvellePochetteMini = pathinfo($_FILES['upload']['name'], PATHINFO_FILENAME) . '-mini.' . pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION);*/ | ||
91 | $nouvellePochetteMini = pathinfo($nomFichier, PATHINFO_FILENAME) . '-mini.' . pathinfo($nomFichier, PATHINFO_EXTENSION); | 114 | $nouvellePochetteMini = pathinfo($nomFichier, PATHINFO_FILENAME) . '-mini.' . pathinfo($nomFichier, PATHINFO_EXTENSION); |
92 | 115 | ||
93 | $Image->upload(); | 116 | $Image->upload(); |
@@ -104,11 +127,9 @@ function submitCKeditor() | |||
104 | $nouvellePochette = ''; | 127 | $nouvellePochette = ''; |
105 | $nouvellePochetteMini = ''; | 128 | $nouvellePochetteMini = ''; |
106 | } | 129 | } |
107 | |||
108 | //var_dump($nouvellePochetteMini); die(); | ||
109 | 130 | ||
110 | // enregistrement du texte JSON | 131 | // enregistrement du texte JSON |
111 | if(!isset($_SESSION['file_code']) || $_SESSION['file_code'] == '') | 132 | if($Album->fileCode === '') |
112 | { | 133 | { |
113 | // page disco | 134 | // page disco |
114 | $Album->createVignetteJSON($nouveauTitre, $nouvelleAnnee, $nouvellePochette, $nouvellePochetteMini); | 135 | $Album->createVignetteJSON($nouveauTitre, $nouvelleAnnee, $nouvellePochette, $nouvellePochetteMini); |
@@ -123,8 +144,6 @@ function submitCKeditor() | |||
123 | // modification | 144 | // modification |
124 | else | 145 | else |
125 | { | 146 | { |
126 | $Album->albumCode = $_SESSION['file_code']; | ||
127 | |||
128 | // page disco | 147 | // page disco |
129 | $Album->format = 'json'; | 148 | $Album->format = 'json'; |
130 | 149 | ||
@@ -142,7 +161,9 @@ function submitCKeditor() | |||
142 | { | 161 | { |
143 | $Article = new Article($_GET['page'], $_GET['page']); | 162 | $Article = new Article($_GET['page'], $_GET['page']); |
144 | 163 | ||
145 | if(!isset($_SESSION['file_code']) || $_SESSION['file_code'] === '') | 164 | $Article->fileCode = getFileCodeFromHTTPReferrer(); |
165 | |||
166 | if($Article->fileCode === '') | ||
146 | { | 167 | { |
147 | $Article->create($html); | 168 | $Article->create($html); |
148 | 169 | ||
@@ -150,16 +171,12 @@ function submitCKeditor() | |||
150 | } | 171 | } |
151 | else | 172 | else |
152 | { | 173 | { |
153 | $Article->fileCode = $_SESSION['file_code']; // erreur ici? | ||
154 | $Article->update($html); | 174 | $Article->update($html); |
155 | 175 | ||
156 | // update html-mini | 176 | // update html-mini |
157 | } | 177 | } |
158 | } | 178 | } |
159 | 179 | ||
160 | // nettoyage | ||
161 | unset($_SESSION['file_code']); | ||
162 | |||
163 | if($_GET['page'] === 'discographie' || $_GET['page'] === 'album') | 180 | if($_GET['page'] === 'discographie' || $_GET['page'] === 'album') |
164 | { | 181 | { |
165 | if($html === '') | 182 | if($html === '') |