Core classes finally moved
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@14 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
62
classes/Decorator.class.php
Normal file
62
classes/Decorator.class.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Родительский класс для всех декораторов. Содержит основной функционал.
|
||||
*
|
||||
* @copyright
|
||||
* @link
|
||||
* @package Majestic
|
||||
* @subpackage Decorator
|
||||
* @since
|
||||
* @version SVN: $Id$
|
||||
* @filesource $URL$
|
||||
*/
|
||||
abstract class Decorator
|
||||
{
|
||||
protected $layout = false;
|
||||
protected $action = false;
|
||||
protected $action_name = 'Action';
|
||||
|
||||
protected $templater = false;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
if (!$this->layout) {
|
||||
throw new MJException('$layout not set in '.get_class($this));
|
||||
}
|
||||
$this->templater = Load::templater();
|
||||
}
|
||||
|
||||
/**
|
||||
* Основной метод вывода
|
||||
*
|
||||
*/
|
||||
function display(Action $action)
|
||||
{
|
||||
$this->action = $action;
|
||||
$this->templater->assign($this->action_name, $this->action->display(), $this->layout);
|
||||
|
||||
$this->exec();
|
||||
|
||||
$this->templater->setPath(WRAPPERS_TPL_PATH);
|
||||
return $this->templater->fetch($this->layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавить данные на вывод
|
||||
*
|
||||
* @param string $var_name - имя переменной, в которую будет осуществлен вывод
|
||||
* @param Action $action - действие
|
||||
* @param Decorator $decorator - декоратор, в котором должно выполнится действие.
|
||||
*/
|
||||
function addOutput($var_name, Action $action, Decorator $decorator = null)
|
||||
{
|
||||
$this->templater->assign($var_name, $decorator ? $decorator->display($action) : $action->display(), $this->layout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Основной метод для дочерних декораторов
|
||||
*
|
||||
*/
|
||||
abstract function exec();
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user