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.

36 lines
1.1 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. print $category;
  22. }
  23. if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'save') {
  24. $content = file_get_contents("php://input");
  25. $id = $customCategoryRepository->saveCategory($content);
  26. $customCategoryRepository->recordAccess($id);
  27. Header("Content-Type: text/plain; charset=utf-8");
  28. print $id;
  29. }