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.

53 lines
1.4 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. public function display()
  25. {
  26. try {
  27. $this->init();
  28. try{
  29. $this->route = Load::router()->proccess(MJ_PATH);
  30. $action = new $this->route->action;
  31. $decorator = new $this->route->decorator;
  32. return $decorator->display($action);
  33. } catch (MJException $e) {
  34. return $e->terminate();
  35. }
  36. } catch (DynamicPageException $e) {
  37. $decorator_name = DEFAULT_DECORATOR;
  38. $decorator = new $decorator_name;
  39. $action_name = $e->getMessage();
  40. return $decorator->display(new $action_name);
  41. } catch (StaticPageException $e) {
  42. $decorator_name = DEFAULT_DECORATOR;
  43. $decorator = new $decorator_name;
  44. $action_name = DEFAULT_ACTION;
  45. return $decorator->display(new $action_name($e->getMessage()));
  46. } catch (Exception $e) {
  47. return $e->getMessage();
  48. }
  49. }
  50. }
  51. ?>