Skip to content

Commit

Permalink
Fix template selection list building in Helper class. See #396.
Browse files Browse the repository at this point in the history
  • Loading branch information
discordier committed Apr 8, 2014
1 parent 41f515b commit 491c7f7
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions src/system/modules/metamodels/MetaModels/Dca/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,31 +223,64 @@ public static function prepareLanguageAwareWidget(
public static function getTemplatesForBase($strBase)
{
$arrTemplates = array();
foreach (\Backend::getTemplateGroup($strBase) as $strTemplate)

// Add the templates root directory.
$arrThemeTemplates = glob(TL_ROOT . '/templates/' . $strBase . '*');
foreach ((array)$arrThemeTemplates as $strTemplate)
{
$strTemplate = basename($strTemplate, strrchr($strTemplate, '.'));

$arrTemplates[$strTemplate] = sprintf(
$GLOBALS['TL_LANG']['MSC']['template_in_theme'],
$strTemplate,
$GLOBALS['TL_LANG']['MSC']['no_theme']
);
}

$objThemes = \Database::getInstance()->prepare('SELECT id,name FROM tl_theme')->execute();
$objThemes = \Database::getInstance()
->prepare('SELECT id,name,templates FROM tl_theme')
->execute();

while ($objThemes->next())
{
foreach (\Backend::getTemplateGroup($strBase, $objThemes->id) as $strTemplate)
if ($objThemes->templates != '')
{
$arrThemeTemplates = glob(TL_ROOT . '/' . $objThemes->templates . '/' . $strBase . '*');
foreach ($arrThemeTemplates as $strTemplate)
{
if (!array_key_exists($strTemplate, $arrTemplates))
{
$strTemplate = basename($strTemplate, strrchr($strTemplate, '.'));

$arrTemplates[$strTemplate] = sprintf(
$GLOBALS['TL_LANG']['MSC']['template_in_theme'],
$strTemplate,
$objThemes->name
);
}
}
}
}

// Add the module templates folders if they exist.
foreach (\Config::getInstance()->getActiveModules() as $strModule)
{
$arrThemeTemplates = glob(TL_ROOT . '/system/modules/' . $strModule . '/templates' . $strBase . '*');
foreach ((array)$arrThemeTemplates as $strTemplate)
{
if (!array_key_exists($strTemplate, $arrTemplates))
{
$strTemplate = basename($strTemplate, strrchr($strTemplate, '.'));

$arrTemplates[$strTemplate] = sprintf(
$GLOBALS['TL_LANG']['MSC']['template_in_theme'],
$strTemplate,
$objThemes->name
$GLOBALS['TL_LANG']['MSC']['no_theme']
);
}
}
}

ksort($arrTemplates);

return array_unique($arrTemplates);
Expand Down

0 comments on commit 491c7f7

Please sign in to comment.