You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

  1. <?php include "conf.php"; /* load a local configuration */ ?>
  2. <?php session_start(); ?>
  3. <?php require 'vendor/autoload.php'; /* composer includes */ ?>
  4. <?php include "modulekit/loader.php"; /* loads all php-includes */ ?>
  5. <?php call_hooks("ajax_start"); /* initialize submodules */ ?>
  6. <?php
  7. if (!isset($db)) {
  8. exit(0);
  9. }
  10. if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'list') {
  11. $result = $customCategoryRepository->list($_REQUEST);
  12. Header("Content-Type: application/json; charset=utf-8");
  13. print json_readable_encode($result);
  14. }
  15. if (isset($_REQUEST['id'])) {
  16. $category = $customCategoryRepository->getCategory($_REQUEST['id']);
  17. if ($category) {
  18. $customCategoryRepository->recordAccess($_REQUEST['id']);
  19. }
  20. Header("Content-Type: application/yaml; charset=utf-8");
  21. Header("Content-Disposition: inline; filename=\"{$_REQUEST['id']}.yaml\"");
  22. print $category;
  23. }
  24. if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'save') {
  25. $content = file_get_contents("php://input");
  26. $id = $customCategoryRepository->saveCategory($content);
  27. $customCategoryRepository->recordAccess($id);
  28. Header("Content-Type: text/plain; charset=utf-8");
  29. print $id;
  30. }