2009-12-28 13:43:56 +02:00
|
|
|
|
<?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 {
|
|
|
|
|
/**
|
2009-12-31 22:20:17 +02:00
|
|
|
|
* Путь к шаблонам с учетом наличия соответствующего skin`a
|
|
|
|
|
*
|
2009-12-28 13:43:56 +02:00
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2010-01-15 20:17:23 +02:00
|
|
|
|
protected $sTemplatePathPlugin=null;
|
2009-12-28 13:43:56 +02:00
|
|
|
|
|
2010-01-01 17:31:04 +02:00
|
|
|
|
/**
|
|
|
|
|
* Конструктор
|
|
|
|
|
*
|
|
|
|
|
* @param Engine $oEngine
|
|
|
|
|
* @param string $sAction
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(Engine $oEngine, $sAction) {
|
|
|
|
|
parent::__construct($oEngine, $sAction);
|
2010-04-25 22:17:38 +03:00
|
|
|
|
$this->Viewer_Assign('sTemplatePathPlugin',rtrim($this->getTemplatePathPlugin(),'/'));
|
2010-06-05 14:18:07 +03:00
|
|
|
|
$this->Viewer_Assign('sTemplateWebPathPlugin',Plugin::GetTemplateWebPath(get_class($this)));
|
2010-01-01 17:31:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-16 17:40:55 +02:00
|
|
|
|
/**
|
|
|
|
|
* Возвращает путь к шаблонам плагина
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-01-15 19:44:59 +02:00
|
|
|
|
public function getTemplatePathPlugin() {
|
2010-04-04 12:37:04 +03:00
|
|
|
|
if(is_null($this->sTemplatePathPlugin)) {
|
2009-12-31 22:20:17 +02:00
|
|
|
|
preg_match('/^Plugin([\w]+)_Action([\w]+)$/i',$this->GetActionClass(),$aMatches);
|
|
|
|
|
/**
|
|
|
|
|
* Проверяем в списке шаблонов
|
|
|
|
|
*/
|
2010-01-05 12:38:22 +02:00
|
|
|
|
$aMatches[1]=strtolower($aMatches[1]);
|
2010-04-17 18:12:10 +03:00
|
|
|
|
$aPaths=glob(Config::Get('path.root.server').'/plugins/'.$aMatches[1].'/templates/skin/*/actions/Action'.ucfirst($aMatches[2]),GLOB_ONLYDIR);
|
|
|
|
|
$sTemplateName=($aPaths and in_array(
|
2010-03-14 21:01:02 +02:00
|
|
|
|
Config::Get('view.skin'),
|
|
|
|
|
array_map(
|
|
|
|
|
create_function(
|
|
|
|
|
'$sPath',
|
|
|
|
|
'preg_match("/skin\/([\w]+)\/actions/i",$sPath,$aMatches); return $aMatches[1];'
|
|
|
|
|
),
|
2010-04-17 18:12:10 +03:00
|
|
|
|
$aPaths
|
2010-03-14 21:01:02 +02:00
|
|
|
|
)
|
2010-04-17 18:12:10 +03:00
|
|
|
|
))
|
2009-12-31 22:20:17 +02:00
|
|
|
|
? Config::Get('view.skin')
|
|
|
|
|
: 'default';
|
|
|
|
|
|
2010-03-14 21:01:02 +02:00
|
|
|
|
$sDir=Config::Get('path.root.server')."/plugins/{$aMatches[1]}/templates/skin/{$sTemplateName}/";
|
2010-01-15 20:17:23 +02:00
|
|
|
|
$this->sTemplatePathPlugin = is_dir($sDir) ? $sDir : null;
|
2009-12-31 00:27:54 +02:00
|
|
|
|
}
|
2009-12-31 22:20:17 +02:00
|
|
|
|
|
2010-01-15 20:17:23 +02:00
|
|
|
|
return $this->sTemplatePathPlugin;
|
2009-12-28 13:43:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-16 17:40:55 +02:00
|
|
|
|
/**
|
|
|
|
|
* Установить значение пути к директории шаблонов плагина
|
|
|
|
|
*
|
|
|
|
|
* @param string $sTemplatePath
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function setTemplatePathPlugin($sTemplatePath) {
|
|
|
|
|
if(!is_dir($sTemplatePath)) return false;
|
|
|
|
|
$this->sTemplatePathPlugin = $sTemplatePath;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-28 13:43:56 +02:00
|
|
|
|
}
|
|
|
|
|
?>
|