PageHandler.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace ColdTrick\SiteAnnouncements;
  3. class PageHandler {
  4. /**
  5. * Handler /announcements pages
  6. *
  7. * @param array $page url elements
  8. *
  9. * @return bool
  10. */
  11. public static function announcements($page) {
  12. $includefile = false;
  13. $pages_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/pages/';
  14. switch ($page[0]) {
  15. case 'all':
  16. $includefile = "{$pages_path}all.php";
  17. break;
  18. case 'archive':
  19. $includefile = "{$pages_path}archive.php";
  20. break;
  21. case 'scheduled':
  22. $includefile = "{$pages_path}scheduled.php";
  23. break;
  24. case 'editors':
  25. $includefile = "{$pages_path}editors.php";
  26. break;
  27. case 'add':
  28. $includefile = "{$pages_path}add.php";
  29. break;
  30. case 'edit':
  31. if (isset($page[1])) {
  32. set_input('guid', (int) $page[1]);
  33. }
  34. $includefile = "{$pages_path}edit.php";
  35. break;
  36. default:
  37. forward('announcements/all');
  38. break;
  39. }
  40. if (!empty($includefile)) {
  41. include($includefile);
  42. return true;
  43. }
  44. return false;
  45. }
  46. }