/** * Return all template files of a particular group as array * * @param string $strPrefix The template name prefix (e.g. "ce_") * * @return array An array of template names */ public static function getTemplateGroup($strPrefix) { $arrTemplates = array(); // Get the default templates foreach (\TemplateLoader::getPrefixedFiles($strPrefix) as $strTemplate) { $arrTemplates[$strTemplate][] = 'root'; } $arrCustomized = glob(TL_ROOT . '/templates/' . $strPrefix . '*'); // Add the customized templates if (is_array($arrCustomized)) { foreach ($arrCustomized as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); $arrTemplates[$strTemplate][] = $GLOBALS['TL_LANG']['MSC']['global']; } } // Do not look for back end templates in theme folders (see #5379) if ($strPrefix != 'be_' && $strPrefix != 'mail_') { // Try to select the themes (see #5210) try { $objTheme = \ThemeModel::findAll(array('order' => 'name')); } catch (\Exception $e) { $objTheme = null; } // Add the theme templates if ($objTheme !== null) { while ($objTheme->next()) { if ($objTheme->templates != '') { $arrThemeTemplates = glob(TL_ROOT . '/' . $objTheme->templates . '/' . $strPrefix . '*'); if (is_array($arrThemeTemplates)) { foreach ($arrThemeTemplates as $strFile) { $strTemplate = basename($strFile, strrchr($strFile, '.')); if (!isset($arrTemplates[$strTemplate])) { $arrTemplates[$strTemplate][] = $objTheme->name; } else { $arrTemplates[$strTemplate][] = $objTheme->name; } } } } } } } // Show the template sources (see #6875) foreach ($arrTemplates as $k => $v) { $v = array_filter($v, function ($a) { return $a != 'root'; }); if (empty($v)) { $arrTemplates[$k] = $k; } else { $arrTemplates[$k] = $k . ' (' . implode(', ', $v) . ')'; } } // Sort the template names ksort($arrTemplates); return $arrTemplates; }