page_handlers.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * All page handler functions are bundled here
  4. */
  5. /**
  6. * The file_tools page handler
  7. *
  8. * @param array $page page elements
  9. *
  10. * @return bool
  11. */
  12. function file_tools_page_handler($page) {
  13. $include_file = false;
  14. switch ($page[0]) {
  15. case "list":
  16. if (elgg_is_xhr() && !empty($page[1])) {
  17. elgg_set_page_owner_guid($page[1]);
  18. if (get_input("folder_guid", false) !== false) {
  19. set_input("draw_page", false);
  20. }
  21. if (isset($page[2])) {
  22. set_input("folder_guid", $page[2]);
  23. }
  24. $include_file = dirname(dirname(__FILE__)) . "/pages/list.php";
  25. }
  26. break;
  27. case "folder":
  28. if ($page[1] == "new") {
  29. if (!empty($page[2])) {
  30. elgg_set_page_owner_guid($page[2]);
  31. }
  32. $include_file = dirname(dirname(__FILE__)) . "/pages/folder/new.php";
  33. } elseif ($page[1] == "edit") {
  34. if (!empty($page[2])) {
  35. set_input("folder_guid", $page[2]);
  36. $include_file = dirname(dirname(__FILE__)) . "/pages/folder/edit.php";
  37. }
  38. }
  39. break;
  40. case "file":
  41. if ($page[1] == "new") {
  42. if (!empty($page[2])) {
  43. elgg_set_page_owner_guid($page[2]);
  44. }
  45. $include_file = dirname(dirname(__FILE__)) . "/pages/file/new.php";
  46. } elseif ($page[1] == "download") {
  47. $include_file = dirname(dirname(__FILE__)) . "/pages/file/download.php";
  48. }
  49. break;
  50. case "proc":
  51. if (file_exists(dirname(dirname(__FILE__)) . "/procedures/" . $page[1] . "/" . $page[2] . ".php")) {
  52. $include_file = dirname(dirname(__FILE__)) . "/procedures/" . $page[1] . "/" . $page[2] . ".php";
  53. } else {
  54. echo json_encode(array("valid" => 0));
  55. exit;
  56. }
  57. break;
  58. }
  59. if (!empty($include_file)) {
  60. include($include_file);
  61. return true;
  62. } else {
  63. forward("file/all");
  64. }
  65. }