image.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. $app->get('/image', function ($request, $response, $args) {
  3. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  4. if ($Organizr->qualifyRequest(1, true)) {
  5. $GLOBALS['api']['response']['data'] = $Organizr->getImages();
  6. }
  7. $response->getBody()->write(jsonE($GLOBALS['api']));
  8. return $response
  9. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  10. ->withStatus($GLOBALS['responseCode']);
  11. });
  12. $app->get('/image/select', function ($request, $response, $args) {
  13. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  14. if ($Organizr->qualifyRequest(1, true)) {
  15. $GLOBALS['api']['response']['data'] = $Organizr->getImagesSelect();
  16. }
  17. $response->getBody()->write(jsonE($GLOBALS['api']));
  18. return $response
  19. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  20. ->withStatus($GLOBALS['responseCode']);
  21. });
  22. $app->delete('/image/{image}', function ($request, $response, $args) {
  23. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  24. if ($Organizr->qualifyRequest(1, true)) {
  25. $Organizr->removeImage($args['image']);
  26. }
  27. $response->getBody()->write(jsonE($GLOBALS['api']));
  28. return $response
  29. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  30. ->withStatus($GLOBALS['responseCode']);
  31. });
  32. $app->post('/image', function ($request, $response, $args) {
  33. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  34. if ($Organizr->qualifyRequest(1, true)) {
  35. $Organizr->uploadImage();
  36. }
  37. $response->getBody()->write(jsonE($GLOBALS['api']));
  38. return $response
  39. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  40. ->withStatus($GLOBALS['responseCode']);
  41. });