- commit
- 9cd7ff8b7236cee0a13572bce44ea22df7c7eee5
- parent
- 890f92ac8e277c61067149ae4123a19ce6f9e9bf
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-10-14 09:56
split views
Diffstat
| M | index.php | 75 | +++++++++++++++++++++++++++++++++++++------------------------ |
1 files changed, 46 insertions, 29 deletions
diff --git a/index.php b/index.php
@@ -160,38 +160,38 @@ class Pupupu 160 160 } 161 161 } 162 162163 -1 $pupupu = new Pupupu('..', '..');-1 163 function uploadView($pupupu, $twig) -1 164 { -1 165 if ($_SERVER['REQUEST_METHOD'] == 'GET') { -1 166 echo $twig->render('uploads.html', array( -1 167 'files' => $pupupu->getUploads(), -1 168 )); -1 169 } elseif (isset($_FILES['file'])) { -1 170 $pupupu->upload($_FILES['file']); -1 171 header("Location: ", true, 302); -1 172 } else { -1 173 $pupupu->rmUpload($_POST['file']); -1 174 header("Location: ", true, 302); -1 175 } -1 176 } 164 177165 -1 if (isset($_SERVER['REQUEST_METHOD'])) {166 -1 $loader = new Twig_Loader_Filesystem('templates');167 -1 $twig = new Twig_Environment($loader);-1 178 function siteView($pupupu, $twig) -1 179 { -1 180 if ($_SERVER['REQUEST_METHOD'] == 'GET') { -1 181 echo $twig->render('site.html', array( -1 182 'yml' => $pupupu->get('', 'site.yml'), -1 183 )); -1 184 } else { -1 185 $pupupu->put('', 'site.yml', $_POST['yml']); -1 186 $pupupu->renderAll(); -1 187 header("Location: ", true, 302); -1 188 } -1 189 } 168 190169 -1 if (empty($_GET['path']) && $_GET['path'] !== '') {170 -1 header('Location: ?path=', true, 302);171 -1 } elseif (isset($_GET['add'])) {-1 191 function pageView($pupupu, $twig) -1 192 { -1 193 if (isset($_GET['add'])) { 172 194 header("Location: ?path=${_GET['path']}/${_GET['add']}", true, 302);173 -1 } elseif ($_GET['path'] === '_site') {174 -1 if ($_SERVER['REQUEST_METHOD'] == 'GET') {175 -1 echo $twig->render('site.html', array(176 -1 'yml' => $pupupu->get('', 'site.yml'),177 -1 ));178 -1 } else {179 -1 $pupupu->put('', 'site.yml', $_POST['yml']);180 -1 $pupupu->renderAll();181 -1 header("Location: ", true, 302);182 -1 }183 -1 } elseif ($_GET['path'] === '_uploads') {184 -1 if ($_SERVER['REQUEST_METHOD'] == 'GET') {185 -1 echo $twig->render('uploads.html', array(186 -1 'files' => $pupupu->getUploads(),187 -1 ));188 -1 } elseif (isset($_FILES['file'])) {189 -1 $pupupu->upload($_FILES['file']);190 -1 header("Location: ", true, 302);191 -1 } else {192 -1 $pupupu->rmUpload($_POST['file']);193 -1 header("Location: ", true, 302);194 -1 }195 195 } else { 196 196 $path = validatePath($_GET['path']); 197 197 @@ -218,6 +218,23 @@ if (isset($_SERVER['REQUEST_METHOD'])) { 218 218 header('Location: ', true, 302); 219 219 } 220 220 } -1 221 } -1 222 -1 223 $pupupu = new Pupupu('..', '..'); -1 224 -1 225 if (isset($_SERVER['REQUEST_METHOD'])) { -1 226 $loader = new Twig_Loader_Filesystem('templates'); -1 227 $twig = new Twig_Environment($loader); -1 228 -1 229 if (empty($_GET['path']) && $_GET['path'] !== '') { -1 230 header('Location: ?path=', true, 302); -1 231 } elseif ($_GET['path'] === '_site') { -1 232 siteView($pupupu, $twig); -1 233 } elseif ($_GET['path'] === '_uploads') { -1 234 uploadView($pupupu, $twig); -1 235 } else { -1 236 pageView($pupupu, $twig); -1 237 } 221 238 } else { 222 239 $pupupu->renderAll(true); 223 240 }