本文整理汇总了PHP中TemplateLoader::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateLoader::getPath方法的具体用法?PHP TemplateLoader::getPath怎么用?PHP TemplateLoader::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateLoader
的用法示例。
在下文中一共展示了TemplateLoader::getPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTemplate
/**
* Find a particular template file and return its path
*
* @param string $strTemplate The name of the template
* @param string $strFormat The file extension
*
* @return string The path to the template file
*
* @throws \Exception If $strFormat is unknown
*/
public static function getTemplate($strTemplate, $strFormat = 'html5')
{
$arrAllowed = trimsplit(',', $GLOBALS['TL_CONFIG']['templateFiles']);
array_push($arrAllowed, 'html5');
// see #3398
if (!in_array($strFormat, $arrAllowed)) {
throw new \Exception("Invalid output format {$strFormat}");
}
$strTemplate = basename($strTemplate);
// Check for a theme folder
if (TL_MODE == 'FE') {
global $objPage;
$strCustom = str_replace('../', '', $objPage->templateGroup);
if ($strCustom != '') {
return \TemplateLoader::getPath($strTemplate, $strFormat, $strCustom);
}
}
return \TemplateLoader::getPath($strTemplate, $strFormat);
}
示例2: getTemplate
/**
* Find a particular template file and return its path
*
* @param string $strTemplate The name of the template
* @param string $strFormat The file extension
*
* @return string The path to the template file
*
* @throws \InvalidArgumentException If $strFormat is unknown
* @throws \RuntimeException If the template group folder is insecure
*/
public static function getTemplate($strTemplate, $strFormat = 'html5')
{
$arrAllowed = trimsplit(',', \Config::get('templateFiles'));
array_push($arrAllowed, 'html5');
// see #3398
if (!in_array($strFormat, $arrAllowed)) {
throw new \InvalidArgumentException('Invalid output format ' . $strFormat);
}
$strTemplate = basename($strTemplate);
// Check for a theme folder
if (TL_MODE == 'FE') {
/** @var \PageModel $objPage */
global $objPage;
if ($objPage->templateGroup != '') {
if (\Validator::isInsecurePath($objPage->templateGroup)) {
throw new \RuntimeException('Invalid path ' . $objPage->templateGroup);
}
return \TemplateLoader::getPath($strTemplate, $strFormat, $objPage->templateGroup);
}
}
return \TemplateLoader::getPath($strTemplate, $strFormat);
}
示例3: loadDynamicTemplates
/**
*/
protected function loadDynamicTemplates()
{
// template settings
$originPath = \TemplateLoader::getPath('be_main', 'html5');
$defaultPath = TL_ROOT . '/system/modules/core/templates/backend/be_main.html5';
// only change be_main if no other be_main then the default one is chosen
// we use customized navigation templates so we do not need to load icons dynamically
if ($defaultPath == $originPath) {
if (version_compare(VERSION, '3.3', '>=')) {
$path = 'system/modules/font-awesome/templates/dynamic/3.3';
} else {
$path = 'system/modules/font-awesome/templates/dynamic/3.2';
}
\TemplateLoader::addFile('be_main', $path);
$GLOBALS['ICON_REPLACER']['navigation']['phpOnly'] = true;
}
\TemplateLoader::addFile('be_navigation', 'system/modules/font-awesome/templates/dynamic');
}
示例4: getTemplate
/**
* Find a particular template file and return its path
* @param string
* @param string
* @return string
* @throws Exception
*/
protected function getTemplate($strTemplate, $strFormat = 'html5', $blnFailIfNotFound = false)
{
$strTemplate = basename($strTemplate);
// Contao 3.X only.
if (version_compare(VERSION, '3.0', '>=')) {
// Check for a theme folder
if (TL_MODE == 'FE') {
global $objPage;
$strCustom = str_replace('../', '', $objPage->templateGroup);
if ($strCustom != '') {
return \TemplateLoader::getPath($strTemplate, $strFormat, $strCustom);
}
}
return \TemplateLoader::getPath($strTemplate, $strFormat);
}
// Contao 2.X from here on.
$strKey = $strFilename = $strTemplate . '.' . $strFormat;
// Check for a theme folder
if (TL_MODE == 'FE') {
global $objPage;
$strTemplateGroup = str_replace(array('../', 'templates/'), '', $objPage->templateGroup);
if ($strTemplateGroup != '') {
$strKey = $strTemplateGroup . '/' . $strKey;
}
}
$objCache = FileCache::getInstance('templates');
// Try to load the template path from the cache
if (!$GLOBALS['TL_CONFIG']['debugMode'] && isset($objCache->{$strKey})) {
if (file_exists(TL_ROOT . '/' . $objCache->{$strKey})) {
return TL_ROOT . '/' . $objCache->{$strKey};
} else {
unset($objCache->{$strKey});
}
}
$strPath = TL_ROOT . '/templates';
// Check the theme folder first
if (TL_MODE == 'FE' && $strTemplateGroup != '') {
$strFile = $strPath . '/' . $strTemplateGroup . '/' . $strFilename;
if (file_exists($strFile)) {
$objCache->{$strKey} = 'templates/' . $strTemplateGroup . '/' . $strFilename;
return $strFile;
}
}
// Then check the global templates directory
$strFile = $strPath . '/' . $strFilename;
if (file_exists($strFile)) {
$objCache->{$strKey} = 'templates/' . $strFilename;
return $strFile;
}
// At last browse all module folders in reverse order
foreach (array_reverse(Config::getInstance()->getActiveModules()) as $strModule) {
$strFile = TL_ROOT . '/system/modules/' . $strModule . '/templates/' . $strFilename;
if (file_exists($strFile)) {
$objCache->{$strKey} = 'system/modules/' . $strModule . '/templates/' . $strFilename;
return $strFile;
}
}
if ($blnFailIfNotFound) {
throw new Exception('Could not find template file "' . $strFilename . '"');
}
}
示例5: getTemplate
/**
* Find a particular template file and return its path.
*
* @param string $strTemplate Name of the template file.
*
* @param string $strFormat The format to search for.
*
* @param bool $blnFailIfNotFound Boolean flag telling if an Exception shall be thrown when the file can not
* be found.
*
* @throws \RuntimeException When the flag has been set and the file has not been found.
*
* @return string
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
protected function getTemplate($strTemplate, $strFormat = 'html5', $blnFailIfNotFound = false)
{
// FIXME: this could be cached and save two calls to file_exists() in \TemplateLoader::getPath().
$strTemplate = basename($strTemplate);
$strCustom = 'templates';
// Check for a theme folder.
if (TL_MODE == 'FE') {
$tmpDir = str_replace('../', '', $GLOBALS['objPage']->templateGroup);
if (!empty($tmpDir)) {
$strCustom = $tmpDir;
}
}
try {
return \TemplateLoader::getPath($strTemplate, $strFormat, $strCustom);
} catch (\Exception $exception) {
if ($blnFailIfNotFound) {
throw new \RuntimeException(sprintf('Could not find template %s.%s', $strTemplate, $strFormat), 1, $exception);
}
}
return null;
}