Code refactoring, #16

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@114 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
pzinovkin
2010-02-26 14:49:12 +00:00
parent 10075f88ab
commit 1b422d87ba
26 changed files with 688 additions and 1310 deletions

53
layout/Layout.php Normal file
View File

@ -0,0 +1,53 @@
<?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;
}
}