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.

59 lines
1.5 KiB

  1. <?php
  2. /**
  3. *
  4. *
  5. * @copyright NetMonsters <team@netmonsters.ru>
  6. * @link
  7. * @package Majestic
  8. * @subpackage PageController
  9. * @since
  10. * @version SVN: $Id$
  11. * @filesource $URL$
  12. */
  13. class PageController
  14. {
  15. /**
  16. * Действия на инициализацию.
  17. *
  18. */
  19. protected function init() {}
  20. /**
  21. * Действия после разбора роута.
  22. *
  23. */
  24. protected function onDispatch() {}
  25. /**
  26. * Вывод в браузер всего сайта.
  27. *
  28. */
  29. public function display()
  30. {
  31. try {
  32. $this->init();
  33. try{
  34. $this->route = Load::router()->proccess(MJ_PATH);
  35. $this->onDispatch();
  36. $action = new $this->route->action;
  37. $decorator = new $this->route->decorator;
  38. return $decorator->display($action);
  39. } catch (MJException $e) {
  40. return $e->terminate();
  41. }
  42. } catch (DynamicPageException $e) {
  43. $decorator_name = DEFAULT_DECORATOR;
  44. $decorator = new $decorator_name;
  45. $action_name = $e->getMessage();
  46. return $decorator->display(new $action_name);
  47. } catch (StaticPageException $e) {
  48. $decorator_name = DEFAULT_DECORATOR;
  49. $decorator = new $decorator_name;
  50. $action_name = DEFAULT_ACTION;
  51. return $decorator->display(new $action_name($e->getMessage()));
  52. } catch (Exception $e) {
  53. return $e->getMessage();
  54. }
  55. }
  56. }
  57. ?>