1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-01 14:05:07 +03:00

возможность передавать/получать параметры в блоки

This commit is contained in:
Mzhelskiy Maxim 2009-04-04 16:07:01 +00:00
parent 9cec8a49bc
commit 41242a9e68
2 changed files with 19 additions and 2 deletions

View file

@ -22,11 +22,21 @@
*/
abstract class Block extends Object {
protected $oEngine=null;
protected $aParams=array();
public function __construct() {
public function __construct($aParams) {
$this->aParams=$aParams;
$this->oEngine=Engine::getInstance();
}
protected function GetParam($sName,$def=null) {
if (isset($this->aParams[$sName])) {
return $this->aParams[$sName];
} else {
return $def;
}
}
public function __call($sName,$aArgs) {
return $this->oEngine->_CallModule($sName,$aArgs);
}

View file

@ -37,11 +37,18 @@ function smarty_insert_block($aParams,&$oSmarty) {
$sTemplate=$aParams['block'];
$aPath=pathinfo($sTemplate);
$sBlock=ucfirst($aPath['basename']);
/**
* параметры
*/
$aParamsBlock=array();
if (isset($aParams['params'])) {
$aParamsBlock=$aParams['params'];
}
/**
* Подключаем необходимый обработчик
*/
$result=require_once(DIR_SERVER_ROOT.'/classes/blocks/Block'.$sBlock.'.class.php');
$sCmd='$oBlock=new Block'.$sBlock.'();';
$sCmd='$oBlock=new Block'.$sBlock.'($aParamsBlock);';
eval($sCmd);
/**
* Запускаем обработчик