Viewer_Assign('sTemplateActionPath',$this->getTemplatePathPlugin()); } /** * Возвращает путь к шаблонам плагина * * @return string */ public function getTemplatePathPlugin() { if(is_null($this->sTemplatePathPlugin)) { preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches); /** * Проверяем в списке шаблонов */ $aMatches[1]=strtolower($aMatches[1]); $sTemplateName=in_array(Config::Get('view.skin'),array_map('basename',glob(Config::Get('path.root.server').'/plugins/'.$aMatches[1].'/templates/skin/*',GLOB_ONLYDIR))) ? Config::Get('view.skin') : 'default'; $sDir=Config::Get('path.root.server')."/plugins/{$aMatches[1]}/templates/skin/{$sTemplateName}"; $this->sTemplatePathPlugin = is_dir($sDir) ? $sDir : null; } return $this->sTemplatePathPlugin; } /** * Установить значение пути к директории шаблонов плагина * * @param string $sTemplatePath * @return bool */ public function setTemplatePathPlugin($sTemplatePath) { if(!is_dir($sTemplatePath)) return false; $this->sTemplatePathPlugin = $sTemplatePath; } /** * Устанавливает какой шаблон выводить * * @param string $sTemplate Путь до шаблона относительно каталога шаблонов экшена */ protected function SetTemplateAction($sTemplate) { $this->sActionTemplate=preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches) ? $this->getTemplatePathPlugin().'/actions/Action'.ucfirst($aMatches[2]).'/'.$sTemplate.'.tpl' : null; } /** * Получить шаблон * Если шаблон не определен то возвращаем дефолтный шаблон евента: action/{Action}.{event}.tpl * * @return unknown */ public function GetTemplate() { if (is_null($this->sActionTemplate)) { $this->sActionTemplate=preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches) ? $this->getTemplatePathPlugin().'/actions/Action'.ucfirst($aMatches[2]).'/'.$this->sCurrentEvent.'.tpl' : null; } return $this->sActionTemplate; } } ?>