1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-29 04:55:02 +03:00
This commit is contained in:
kirsan 2011-07-05 13:33:59 +00:00
parent 4fb88243db
commit 23c189b7a6
3 changed files with 35 additions and 10 deletions

View file

@ -88,6 +88,12 @@ class Engine extends Object {
* @var int
*/
const CI_INHERIT = 128;
/**
* Имя блока
* @var int
*/
const CI_BLOCK = 256;
/**
* Префикс плагина
@ -122,10 +128,10 @@ class Engine extends Object {
/**
* Объекты
* CI_ACTION | CI_MAPPER | CI_HOOK | CI_PLUGIN | CI_ACTION | CI_MODULE | CI_ENTITY
* CI_ACTION | CI_MAPPER | CI_HOOK | CI_PLUGIN | CI_ACTION | CI_MODULE | CI_ENTITY | CI_BLOCK
* @var int
*/
const CI_OBJECT = 95;
const CI_OBJECT = 351 ;
static protected $oInstance=null;
@ -763,6 +769,12 @@ class Engine extends Object {
? $aMatches[1]
: null
;
}
if($iFlag & self::CI_BLOCK){
$aResult[self::CI_BLOCK] = preg_match('/^(?:Plugin[^_]+_|)Block([^_]+)$/',$sClassName,$aMatches)
? $aMatches[1]
: null
;
}
if($iFlag & self::CI_METHOD){
$sModuleName = isset($aResult[self::CI_MODULE])
@ -890,6 +902,18 @@ class Engine extends Object {
// Хук ядра
$sPath .= 'classes/hooks/Hook'.$aInfo[self::CI_HOOK].'.class.php';
}
}elseif($aInfo[self::CI_BLOCK]){
// Блок
if($aInfo[self::CI_PLUGIN]){
// Блок плагина
$sPath .= 'plugins/'.strtolower($aInfo[self::CI_PLUGIN])
.'/classes/blocks/Block'.$aInfo[self::CI_BLOCK]
.'.class.php';
;
}else{
// Блок ядра
$sPath .= 'classes/blocks/Block'.$aInfo[self::CI_BLOCK].'.class.php';
}
}elseif($aInfo[self::CI_PLUGIN]){
// Плагин
$sPath .= 'plugins/'.strtolower($aInfo[self::CI_PLUGIN])

View file

@ -50,7 +50,8 @@ class ModulePlugin extends Module {
'mapper' => array(),
'action' => array(),
'entity' => array(),
'template' => array()
'template' => array(),
'block' => array(),
);
/**
@ -418,10 +419,10 @@ class ModulePlugin extends Module {
* @param string $sFrom
* @return string
*/
public function GetDelegate($sType,$sFrom) {
public function GetDelegate($sType,$sFrom) {
if (isset($this->aDelegates[$sType][$sFrom]['delegate'])) {
return $this->aDelegates[$sType][$sFrom]['delegate'];
} elseif ($aInherit=$this->GetLastInherit($sFrom)) {
} elseif ($aInherit=$this->GetLastInherit($sFrom)) {
return $aInherit['inherit'];
}
return $sFrom;

View file

@ -36,14 +36,15 @@ function smarty_insert_block($aParams,&$oSmarty) {
require_once(Config::Get('path.root.server').'/engine/classes/ActionPlugin.class.php');
$sBlockTemplate = Plugin::GetTemplatePath($aParams['params']['plugin']).'/block.'.$aParams['block'].'.tpl';
$sBlockClass = Config::Get('path.root.server').'/plugins/'.$aParams['params']['plugin'].'/classes/blocks/Block'.$sBlock.'.class.php';
$sBlock ='Plugin'.ucfirst($aParams['params']['plugin']).'_'.$sBlock;
$sCmd='$oBlock=new Plugin'.ucfirst($aParams['params']['plugin']).'_Block'.$sBlock.'($aParamsBlock);';
} else {
$sBlockTemplate = Engine::getInstance()->Plugin_GetDelegate('template','block.'.$aParams['block'].'.tpl');
$sBlockClass = Config::Get('path.root.server').'/classes/blocks/Block'.$sBlock.'.class.php';
$sCmd='$oBlock=new Block'.$sBlock.'($aParamsBlock);';
}
$sBlock=Engine::getInstance()->Plugin_GetDelegate('block','Block'.$sBlock);
if (!isset($aParams['block']) or !$oSmarty->templateExists($sBlockTemplate)) {
$oSmarty->trigger_error("Not found template for block: ".$sBlockTemplate);
return ;
@ -58,8 +59,7 @@ function smarty_insert_block($aParams,&$oSmarty) {
/**
* Подключаем необходимый обработчик
*/
require_once($sBlockClass);
eval($sCmd);
$oBlock = new $sBlock($aParams);
/**
* Запускаем обработчик
*/