mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Частичная смена функционала работы с [skin_name]
This commit is contained in:
parent
9c4f597786
commit
f01d8c1d38
|
@ -138,7 +138,7 @@ class PluginProfiler_ActionProfiler extends ActionPlugin {
|
|||
$this->Viewer_Assign('aPaging',$aPaging);
|
||||
$this->Viewer_Assign('aReports',$aReports);
|
||||
$this->Viewer_Assign('aDatabaseStat',($aData=$this->PluginProfiler_Profiler_GetDatabaseStat())?$aData:array('max_date'=>'','count'=>''));
|
||||
$this->Viewer_AddBlock('right','profiler/templates/skin/'.parent::SKIN_NAME_KEY.'/actions/ActionProfiler/sidebar.tpl',array('plugin'=>'profiler'));
|
||||
$this->Viewer_AddBlock('right',$this->getTemplatePathAction().'/actions/ActionProfiler/sidebar.tpl',array('plugin'=>'profiler'));
|
||||
$this->Viewer_AddHtmlTitle($this->Lang_Get('profiler_report_page_title'));
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ class PluginProfiler_ActionProfiler extends ActionPlugin {
|
|||
? 'level'
|
||||
: 'tree')
|
||||
:'report';
|
||||
$this->Viewer_AssignAjax('sReportText',$oViewerLocal->Fetch("profiler/templates/skin/".parent::SKIN_NAME_KEY."/actions/ActionProfiler/ajax/{$sTemplateName}.tpl", 'profiler'));
|
||||
$this->Viewer_AssignAjax('sReportText',$oViewerLocal->Fetch($this->getTemplatePathAction()."/actions/ActionProfiler/ajax/{$sTemplateName}.tpl", 'profiler'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,7 +253,7 @@ class PluginProfiler_ActionProfiler extends ActionPlugin {
|
|||
$oViewerLocal->Assign('oReport',$oReport);
|
||||
|
||||
$sTemplateName=($sAction=='tree')?'tree':'report';
|
||||
$this->Viewer_AssignAjax('sReportText',$oViewerLocal->Fetch("profiler/templates/skin/".parent::SKIN_NAME_KEY."/actions/ActionProfiler/ajax/{$sTemplateName}.tpl", "profiler"));
|
||||
$this->Viewer_AssignAjax('sReportText',$oViewerLocal->Fetch($this->getTemplatePathAction()."/actions/ActionProfiler/ajax/{$sTemplateName}.tpl", "profiler"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,20 +22,26 @@ require_once('Action.class.php');
|
|||
*/
|
||||
abstract class ActionPlugin extends Action {
|
||||
/**
|
||||
* Путь к шаблонам с учетом наличия соответствующего skin`a
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SKIN_NAME_KEY = '[skin_name]';
|
||||
protected $sTemplatePathAction=null;
|
||||
|
||||
/**
|
||||
* Устанавливает какой шаблон выводить
|
||||
*
|
||||
* @param string $sTemplate Путь до шаблона относительно общего каталога шаблонов
|
||||
*/
|
||||
protected function SetTemplate($sTemplate) {
|
||||
$this->sActionTemplate=$sTemplate;
|
||||
if(preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches)) {
|
||||
$this->sActionTemplate=$this->Viewer_ReplacePluginSkinName($this->sActionTemplate,$aMatches[1]);
|
||||
public function getTemplatePathAction() {
|
||||
if(is_null($this->sTemplatePathAction)) {
|
||||
preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches);
|
||||
/**
|
||||
* Проверяем в списке шаблонов
|
||||
*/
|
||||
$sTemplateName=in_array(Config::Get('view.skin'),array_map('basename',glob(Config::Get('path.root.server').'/classes/plugins/'.$aMatches[1].'/templates/skin/*',GLOB_ONLYDIR)))
|
||||
? Config::Get('view.skin')
|
||||
: 'default';
|
||||
|
||||
$this->sTemplatePathAction=Config::Get('path.root.server')."/classes/plugins/{$aMatches[1]}/templates/skin/{$sTemplateName}";
|
||||
}
|
||||
|
||||
return $this->sTemplatePathAction;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,12 +51,8 @@ abstract class ActionPlugin extends Action {
|
|||
*/
|
||||
protected function SetTemplateAction($sTemplate) {
|
||||
$this->sActionTemplate==preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches)
|
||||
? strtolower($aMatches[1]).'/templates/skin/'.self::SKIN_NAME_KEY.'/actions/Action'.ucfirst($aMatches[2]).'/'.$sTemplate.'.tpl'
|
||||
? $this->getTemplatePathAction().'/actions/Action'.ucfirst($aMatches[2]).'/'.$sTemplate.'.tpl'
|
||||
: null;
|
||||
|
||||
if(preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches)) {
|
||||
$this->sActionTemplate=$this->Viewer_ReplacePluginSkinName($this->sActionTemplate,$aMatches[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,13 +64,10 @@ abstract class ActionPlugin extends Action {
|
|||
public function GetTemplate() {
|
||||
if (is_null($this->sActionTemplate)) {
|
||||
$this->sActionTemplate=preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches)
|
||||
? strtolower($aMatches[1]).'/templates/skin/'.self::SKIN_NAME_KEY.'/actions/Action'.ucfirst($aMatches[2]).'/'.$this->sCurrentEvent.'.tpl'
|
||||
? $this->getTemplatePathAction().'/actions/Action'.ucfirst($aMatches[2]).'/'.$this->sCurrentEvent.'.tpl'
|
||||
: null;
|
||||
}
|
||||
|
||||
if(preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches)) {
|
||||
$this->sActionTemplate=$this->Viewer_ReplacePluginSkinName($this->sActionTemplate,$aMatches[1]);
|
||||
}
|
||||
|
||||
return $this->sActionTemplate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ class LsViewer extends Module {
|
|||
* @return string('block','template','undefined')
|
||||
*/
|
||||
protected function DefineTypeBlock($sName,$sPlugin=null) {
|
||||
if ($this->TemplateExists(($sPlugin)?$this->ReplacePluginSkinName($sPlugin.'/templates/skin/'.ActionPlugin::SKIN_NAME_KEY.'/block'.$sName.'.tpl',$sPlugin):'block.'.$sName.'.tpl')) {
|
||||
if ($this->TemplateExists(($sPlugin)?$this->ReplacePluginSkinName($sPlugin.'/templates/skin/[skin_name]/block'.$sName.'.tpl',$sPlugin):'block.'.$sName.'.tpl')) {
|
||||
/**
|
||||
* Если найден шаблон вида block.name.tpl то считаем что тип 'block'
|
||||
*/
|
||||
|
@ -1127,7 +1127,7 @@ class LsViewer extends Module {
|
|||
* @return string
|
||||
*/
|
||||
public function ReplacePluginSkinName($sTemplate,$sPlugin) {
|
||||
if(substr_count($sTemplate,ActionPlugin::SKIN_NAME_KEY)==0) return $sTemplate;
|
||||
if(substr_count($sTemplate,'[skin_name]')==0) return $sTemplate;
|
||||
|
||||
/**
|
||||
* Проверяем в списке шаблонов
|
||||
|
@ -1136,7 +1136,7 @@ class LsViewer extends Module {
|
|||
? Config::Get('view.skin')
|
||||
: 'default';
|
||||
|
||||
return str_replace(ActionPlugin::SKIN_NAME_KEY,$sReplaceName,$sTemplate);
|
||||
return str_replace('[skin_name]',$sReplaceName,$sTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue