page_handlers.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * All page handlers are bundled here
  4. */
  5. /**
  6. * Handles all question pages
  7. *
  8. * @param array $segments
  9. *
  10. * @return bool
  11. */
  12. function questions_page_handler($segments) {
  13. elgg_push_breadcrumb(elgg_echo('questions'), 'questions/all');
  14. $pages = dirname(dirname(__FILE__)) . '/pages/questions';
  15. switch ($segments[0]) {
  16. case 'all':
  17. include "$pages/all.php";
  18. break;
  19. case 'todo':
  20. if (isset($segments[1]) && is_numeric($segments[1])) {
  21. set_input('group_guid', $segments[1]);
  22. }
  23. include "$pages/todo.php";
  24. break;
  25. case 'owner':
  26. if (isset($segments[1]) && is_numeric($segments[1])) {
  27. elgg_set_page_owner_guid($segments[1]);
  28. }
  29. include "$pages/owner.php";
  30. break;
  31. case 'view':
  32. set_input('guid', $segments[1]);
  33. include "$pages/view.php";
  34. break;
  35. case 'add':
  36. elgg_gatekeeper();
  37. include "$pages/add.php";
  38. break;
  39. case 'edit':
  40. elgg_gatekeeper();
  41. set_input('guid', $segments[1]);
  42. include "$pages/edit.php";
  43. break;
  44. case 'group':
  45. elgg_group_gatekeeper();
  46. include "$pages/owner.php";
  47. break;
  48. case 'experts':
  49. if (isset($segments[1]) && is_numeric($segments[1])) {
  50. elgg_set_page_owner_guid($segments[1]);
  51. }
  52. include "$pages/experts.php";
  53. break;
  54. default:
  55. forward('questions/all');
  56. return false;
  57. }
  58. return true;
  59. }
  60. /**
  61. * Handles all answer pages
  62. *
  63. * @param array $segments
  64. *
  65. * @return bool
  66. */
  67. function answers_page_handler($segments) {
  68. elgg_push_breadcrumb(elgg_echo('questions'), 'questions/all');
  69. $pages = dirname(dirname(__FILE__)) . '/pages/answers';
  70. switch ($segments[0]) {
  71. case 'edit':
  72. elgg_gatekeeper();
  73. set_input('guid', $segments[1]);
  74. include "$pages/edit.php";
  75. break;
  76. default:
  77. forward('questions/all');
  78. return false;
  79. }
  80. return true;
  81. }