当前位置: 首页>>代码示例>>PHP>>正文


PHP TemplateLoader::getPath方法代码示例

本文整理汇总了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);
 }
开发者ID:rikaix,项目名称:core,代码行数:29,代码来源:Controller.php

示例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);
 }
开发者ID:StephenGWills,项目名称:sample-contao-app,代码行数:33,代码来源:Controller.php

示例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');
 }
开发者ID:netzmacht,项目名称:contao-font-awesome,代码行数:20,代码来源:FontAwesome.php

示例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 . '"');
     }
 }
开发者ID:amenk,项目名称:MetaModels-core,代码行数:68,代码来源:MetaModelTemplate.php

示例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;
 }
开发者ID:zonky2,项目名称:core,代码行数:38,代码来源:Template.php


注:本文中的TemplateLoader::getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。