本文整理汇总了PHP中TemplateLoader::getPrefixedFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateLoader::getPrefixedFiles方法的具体用法?PHP TemplateLoader::getPrefixedFiles怎么用?PHP TemplateLoader::getPrefixedFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateLoader
的用法示例。
在下文中一共展示了TemplateLoader::getPrefixedFiles方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTemplateGroup
/**
* 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;
}
示例2: getNewsletterElementTemplates
/**
* Return all newsletter content element templates as array
* @return array
*/
public function getNewsletterElementTemplates()
{
$strPrefix = 'nl_';
$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'];
}
}
// 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;
}
示例3: getTemplateGroup
/**
* Return all template files of a particular group as array
*
* @param string $strPrefix The template name prefix (e.g. "ce_")
* @param integer $intTheme The ID of the theme
*
* @return array An array of template names
*/
public static function getTemplateGroup($strPrefix, $intTheme = 0)
{
$strTplFolder = 'templates';
$arrTemplates = \TemplateLoader::getPrefixedFiles($strPrefix);
// Check for a theme templates folder
if ($intTheme > 0) {
$objTheme = \ThemeModel::findByPk($intTheme);
if ($objTheme !== null && $objTheme->templates != '') {
$strTplFolder = $objTheme->templates;
}
}
// Scan the templates directory
$arrFiles = array_values(preg_grep('/^' . $strPrefix . '/', scan(TL_ROOT . '/' . $strTplFolder)));
if (!empty($arrFiles)) {
foreach ($arrFiles as $strFile) {
$arrTemplates[] = basename($strFile, strrchr($strFile, '.'));
}
}
natcasesort($arrTemplates);
$arrTemplates = array_values(array_unique($arrTemplates));
return $arrTemplates;
}
示例4: getTemplateGroup
public static function getTemplateGroup($strPrefix, $intThemeId = null)
{
$arrTemplates = array();
// Get the default templates
foreach (\TemplateLoader::getPrefixedFiles($strPrefix) as $strTemplate) {
$arrTemplates[$strTemplate] = $strTemplate;
}
$arrCustomized = glob(TL_ROOT . '/templates/' . $strPrefix . '*');
// Add the customized templates
if (is_array($arrCustomized)) {
foreach ($arrCustomized as $strFile) {
$strTemplate = basename($strFile, strrchr($strFile, '.'));
if (!isset($arrTemplates[$strTemplate])) {
$arrTemplates[$strTemplate] = $strTemplate;
}
}
}
// Do not look for back end templates in theme folders (see #5379)
if ($strPrefix == 'be_' || $strPrefix == 'mail_') {
return $arrTemplates;
}
$arrDefault = $arrTemplates;
$arrTemplates = array('safeTpl' => $arrDefault, 'unsafeTpl' => array());
// 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) {
return $arrTemplates;
}
while ($objTheme->next()) {
$strGroup = $objTheme->id == $intThemeId ? 'safeTpl' : 'unsafeTpl';
if ($objTheme->templates == '') {
continue;
}
$arrThemeTemplates = glob(TL_ROOT . '/' . $objTheme->templates . '/' . $strPrefix . '*');
if (!is_array($arrThemeTemplates)) {
continue;
}
foreach ($arrThemeTemplates as $strFile) {
$strTemplate = basename($strFile, strrchr($strFile, '.'));
if (!isset($arrTemplates[$strGroup][$strTemplate])) {
$arrTemplates[$strGroup][$strTemplate] = $strTemplate . ' (' . sprintf($GLOBALS['TL_LANG']['MSC']['templatesTheme'], $objTheme->name) . ')';
} else {
$arrTemplates[$strGroup][$strTemplate] .= ' (' . sprintf($GLOBALS['TL_LANG']['MSC']['templatesTheme'], $objTheme->name) . ')';
}
}
}
return $arrTemplates;
}
示例5: getTemplates
/**
* List template from all themes, show theme name
* @param string
* @param int
* @return array
*/
public static function getTemplates($strPrefix)
{
$arrTemplates = array();
// Get the default templates
foreach (\TemplateLoader::getPrefixedFiles($strPrefix) as $strTemplate) {
$arrTemplates[$strTemplate] = $strTemplate;
}
$arrCustomized = glob(TL_ROOT . '/templates/' . $strPrefix . '*');
// Add the customized templates
if (is_array($arrCustomized)) {
foreach ($arrCustomized as $strFile) {
$strTemplate = basename($strFile, strrchr($strFile, '.'));
if (!isset($arrTemplates[$strTemplate])) {
$arrTemplates[''][$strTemplate] = $strTemplate;
}
}
}
// Do not look for back end templates in theme folders (see #5379)
if ($strPrefix == 'be_') {
return $arrTemplates;
}
// Try to select the shop configs
try {
$objConfig = Config::findAll(array('order' => 'name'));
} catch (\Exception $e) {
$objConfig = null;
}
// Add the shop config templates
if (null !== $objConfig) {
while ($objConfig->next()) {
if ($objConfig->templateGroup != '') {
$strFolder = sprintf($GLOBALS['TL_LANG']['MSC']['templatesConfig'], $objConfig->name);
$arrConfigTemplates = glob(TL_ROOT . '/' . $objConfig->templateGroup . '/' . $strPrefix . '*');
if (is_array($arrConfigTemplates)) {
foreach ($arrConfigTemplates as $strFile) {
$strTemplate = basename($strFile, strrchr($strFile, '.'));
if (!isset($arrTemplates[''][$strTemplate])) {
$arrTemplates[$strFolder][$strTemplate] = $strTemplate;
}
}
}
}
}
}
// Try to select the themes (see #5210)
try {
$objTheme = \ThemeModel::findAll(array('order' => 'name'));
} catch (\Exception $e) {
$objTheme = null;
}
// Add the theme templates
if (null !== $objTheme) {
while ($objTheme->next()) {
if ($objTheme->templates != '') {
$strFolder = sprintf($GLOBALS['TL_LANG']['MSC']['templatesTheme'], $objTheme->name);
$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[$strFolder][$strTemplate] = $strTemplate;
}
}
}
}
}
}
return $arrTemplates;
}