Skip to content

Commit

Permalink
Поддержка компонентов для плагинов
Browse files Browse the repository at this point in the history
  • Loading branch information
mzhelskiy committed Dec 24, 2014
1 parent 83492dc commit e688449
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
18 changes: 15 additions & 3 deletions classes/modules/component/Component.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,20 @@ public function GetPath($sName)
list($sPlugin, $sName) = $this->ParserName($sName);
$sPath = 'components/' . $sName;
if ($sPlugin) {
// todo: компоненты плагинов
/**
* Проверяем наличие компонента в каталоге текущего шаблона плагина
*/
$sPathTemplate = Config::Get('path.application.plugins.server') . "/{$sPlugin}/frontend/skin/" . Config::Get('view.skin');
if (file_exists($sPathTemplate . '/' . $sPath)) {
return $sPathTemplate . '/' . $sPath;
}
/**
* Проверяем наличие компонента в общем каталоге плагина
*/
$sPathTemplate = Config::Get('path.application.plugins.server') . "/{$sPlugin}/frontend";
if (file_exists($sPathTemplate . '/' . $sPath)) {
return $sPathTemplate . '/' . $sPath;
}
} else {
/**
* Проверяем наличие компонента в каталоге текущего шаблона
Expand Down Expand Up @@ -237,9 +250,8 @@ public function GetTemplatePath($sNameFull, $sTemplate = null, $bCheckDelegate =
if ($bCheckDelegate) {
/**
* Базовое название компонента
* todo: нужно учитывать компоненты плагинов, возможно так - component/{plugin}/name или plugin:component.name.template
*/
$sNameBase = "component.{$sName}.{$sTemplate}";
$sNameBase = ($sPlugin ? "{$sPlugin}:" : '') . "component.{$sName}.{$sTemplate}";
/**
* Проверяем наследование по базовому имени
*/
Expand Down
11 changes: 7 additions & 4 deletions libs/application/SmartyLS/smarty_internal_template_ls.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ public function __construct(
*/
if (!preg_match("#^\.tpl$#i", $sTpl)) {
$aPath = explode('.', $sTpl);
if (count($aPath) == 3 and $aPath[0] == 'component') {
// todo: нужно учесть компоненты плагинов
$sParentTemplate = Engine::getInstance()->Component_GetTemplatePath($aPath[1], $aPath[2],
false);
if (count($aPath) == 3 and preg_match('#^([\w\_]+\:)?component$#i', $aPath[0], $aMatch2)) {
$sPrefix = '';
if (isset($aMatch2[1])) {
$sPrefix = $aMatch2[1];
}
$sParentTemplate = Engine::getInstance()->Component_GetTemplatePath($sPrefix . $aPath[1],
$aPath[2], false);
}
}
}
Expand Down

0 comments on commit e688449

Please sign in to comment.