<?php
/**
 *
 *
 * @copyright
 * @link
 * @package Majestic
 * @subpackage PageController
 * @since
 * @version SVN: $Id$
 * @filesource $URL$
 */
final class PageController
{

    /**
     * Вывод в браузер всего сайта.
     *
     */
    public function display()
    {
        try {
            try{
                $this->route = Load::router()->proccess(MJ_PATH);
                $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();
        }
    }
}
?>