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.
60 lines
1.5 KiB
60 lines
1.5 KiB
<?php
|
|
/**
|
|
*
|
|
*
|
|
* @copyright NetMonsters <team@netmonsters.ru>
|
|
* @link
|
|
* @package Majestic
|
|
* @subpackage PageController
|
|
* @since
|
|
* @version SVN: $Id$
|
|
* @filesource $URL$
|
|
*/
|
|
class PageController
|
|
{
|
|
|
|
/**
|
|
* Действия на инициализацию.
|
|
*
|
|
*/
|
|
protected function init() {}
|
|
|
|
/**
|
|
* Действия после разбора роута.
|
|
*
|
|
*/
|
|
protected function onDispatch() {}
|
|
|
|
/**
|
|
* Вывод в браузер всего сайта.
|
|
*
|
|
*/
|
|
public function display()
|
|
{
|
|
try {
|
|
$this->init();
|
|
try{
|
|
$this->route = Load::router()->proccess(MJ_PATH);
|
|
$this->onDispatch();
|
|
$action = new $this->route->action;
|
|
$decorator = new $this->route->decorator;
|
|
return $decorator->display($action);
|
|
} catch (MJException $e) {
|
|
return $e->terminate();
|
|
}
|
|
} catch (DynamicPageException $e) {
|
|
$decorator_name = DEFAULT_DECORATOR;
|
|
$decorator = new $decorator_name;
|
|
$action_name = $e->getMessage();
|
|
return $decorator->display(new $action_name);
|
|
} catch (StaticPageException $e) {
|
|
$decorator_name = DEFAULT_DECORATOR;
|
|
$decorator = new $decorator_name;
|
|
$action_name = DEFAULT_ACTION;
|
|
return $decorator->display(new $action_name($e->getMessage()));
|
|
} catch (Exception $e) {
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
}
|
|
?>
|