1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-03 06:55:03 +03:00
ifhub.club/engine/classes/ActionPlugin.class.php

86 lines
2.7 KiB
PHP
Raw Normal View History

<?php
/*-------------------------------------------------------
*
* LiveStreet Engine Social Networking
* Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
* Official site: www.livestreet.ru
* Contact e-mail: rus.engine@gmail.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
require_once('Action.class.php');
/**
* Абстрактный класс экшена
*
*/
abstract class ActionPlugin extends Action {
/**
* Путь к шаблонам с учетом наличия соответствующего skin`a
*
* @var string
*/
protected $sTemplatePathAction=null;
2010-01-01 17:31:04 +02:00
/**
* Конструктор
*
* @param Engine $oEngine
* @param string $sAction
*/
public function __construct(Engine $oEngine, $sAction) {
parent::__construct($oEngine, $sAction);
$this->Viewer_Assign('sTemplateActionPath',$this->getTemplatePathAction());
}
public function getTemplatePathAction() {
if(is_null($this->sTemplatePathAction)) {
preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches);
/**
* Проверяем в списке шаблонов
*/
2010-01-05 12:38:22 +02:00
$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';
$this->sTemplatePathAction=Config::Get('path.root.server')."/plugins/{$aMatches[1]}/templates/skin/{$sTemplateName}";
}
return $this->sTemplatePathAction;
}
/**
* Устанавливает какой шаблон выводить
*
* @param string $sTemplate Путь до шаблона относительно каталога шаблонов экшена
*/
protected function SetTemplateAction($sTemplate) {
2010-01-11 19:17:50 +02:00
$this->sActionTemplate=preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches)
? $this->getTemplatePathAction().'/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->getTemplatePathAction().'/actions/Action'.ucfirst($aMatches[2]).'/'.$this->sCurrentEvent.'.tpl'
: null;
}
return $this->sActionTemplate;
}
}
?>