mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Возможность замены шаблонов налету (делегирование).
This commit is contained in:
parent
b0e8a7696a
commit
6cb7fcf686
|
@ -48,14 +48,15 @@ class LsPlugin extends Module {
|
|||
protected $aPluginsList=array();
|
||||
|
||||
/**
|
||||
* Список engine-rewrite`ов (модули, экшены, сущности)
|
||||
* Список engine-rewrite`ов (модули, экшены, сущности, шаблоны)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $aDelegate=array(
|
||||
'module' => array(),
|
||||
'action' => array(),
|
||||
'entity' => array()
|
||||
'entity' => array(),
|
||||
'template' => array()
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -207,7 +208,7 @@ class LsPlugin extends Module {
|
|||
* @param string $sTo
|
||||
*/
|
||||
public function Delegate($sType,$sFrom,$sTo) {
|
||||
if(!in_array($sType,array('module','action','entity')) or !$sFrom or !$sTo) return null;
|
||||
if(!in_array($sType,array_keys($this->aDelegate)) or !$sFrom or !$sTo) return null;
|
||||
$this->aDelegate[$sType][trim($sFrom)]=trim($sTo);
|
||||
}
|
||||
|
||||
|
@ -231,7 +232,7 @@ class LsPlugin extends Module {
|
|||
* @return bool
|
||||
*/
|
||||
public function isDelegated($sType,$sFrom) {
|
||||
if(!in_array($sType,array('module','action','entity')) or !$sFrom) return false;
|
||||
if(!in_array($sType,array_keys($this->aDelegate)) or !$sFrom) return false;
|
||||
return isset($this->aDelegate[$sType][$sFrom]);
|
||||
}
|
||||
|
||||
|
|
|
@ -263,10 +263,12 @@ class LsViewer extends Module {
|
|||
}
|
||||
/**
|
||||
* Если шаблон найден то выводим, иначе ошибка
|
||||
* Предварительно проверяем наличие делегата
|
||||
*/
|
||||
$sTemplate=$this->Plugin_GetDelegate('template',$sTemplate);
|
||||
if ($this->TemplateExists($sTemplate)) {
|
||||
$this->oSmarty->display($sTemplate);
|
||||
} else {
|
||||
} else {
|
||||
throw new Exception('Can not find the template: '.$sTemplate);
|
||||
}
|
||||
}
|
||||
|
@ -351,6 +353,10 @@ class LsViewer extends Module {
|
|||
* @return string
|
||||
*/
|
||||
public function Fetch($sTemplate) {
|
||||
/**
|
||||
* Проверяем наличие делегата
|
||||
*/
|
||||
$sTemplate=$this->Plugin_GetDelegate('template',$sTemplate);
|
||||
return $this->oSmarty->fetch($sTemplate);
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue