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.1 KiB

<?php
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage Layout
* @since 2010-02-25
* @version SVN: $Id$
* @filesource $URL$
*/
abstract class Layout
{
protected $template;
/**
* @var PHPView
*/
protected $view;
public function __construct()
{
$this->view = FrontController::getInstance()->getView();
}
/**
* @param string $name
* @param ViewAction $action
*/
protected function assign($name, $action)
{
$this->view->assign($name, $action->fetch());
}
abstract protected function execute();
/**
* @param ViewAction $action
*/
public function fetch($action)
{
$this->view->assign('content', $action->fetch());
$this->execute();
return $this->view->fetch($this->getTemplate());
}
protected function getTemplate()
{
$template = ($this->template) ? $this->template : substr(get_class($this), 0, -6/*strlen('Layout')*/);
return '/layouts/' . $template;
}
}