本文整理汇总了PHP中TemplateLoader类的典型用法代码示例。如果您正苦于以下问题:PHP TemplateLoader类的具体用法?PHP TemplateLoader怎么用?PHP TemplateLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefaultRobots
public function getDefaultRobots()
{
$oldPath = craft()->path->getTemplatesPath();
$newPath = craft()->path->getPluginsPath() . 'seomatic/templates';
craft()->path->setTemplatesPath($newPath);
/* -- Return the robots.txt default template */
$templateName = '_robotsDefault';
$loader = new TemplateLoader();
$template = $loader->getSource($templateName);
craft()->path->setTemplatesPath($oldPath);
return $template;
}
示例2: parse
/**
* Parse the template file and return it as string
*
* @return string The template markup
*/
public function parse()
{
$strBuffer = '';
// Start with the template itself
$this->strParent = $this->strTemplate;
// Include the parent templates
while ($this->strParent !== null) {
$strCurrent = $this->strParent;
$strParent = $this->strDefault ?: $this->getTemplate($this->strParent, $this->strFormat);
// Reset the flags
$this->strParent = null;
$this->strDefault = null;
ob_start();
include $strParent;
// Capture the output of the root template
if ($this->strParent === null) {
$strBuffer = ob_get_contents();
} elseif ($this->strParent == $strCurrent) {
$this->strDefault = \TemplateLoader::getDefaultPath($this->strParent, $this->strFormat);
}
ob_end_clean();
}
// Reset the internal arrays
$this->arrBlocks = array();
// Add start and end markers in debug mode
if (\Config::get('debugMode')) {
$strRelPath = str_replace(TL_ROOT . '/', '', $this->getTemplate($this->strTemplate, $this->strFormat));
$strBuffer = "\n<!-- TEMPLATE START: {$strRelPath} -->\n{$strBuffer}\n<!-- TEMPLATE END: {$strRelPath} -->\n";
}
return $strBuffer;
}
示例3: 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;
}
示例4: initializeLayout
/**
* only load templates if bootstrap is activated, so diverent layouts will work instead of template changes
*
* @param \PageModel $page
* @param \LayoutModel $layout
*/
public function initializeLayout($page, \LayoutModel $layout)
{
static::$pageLayout = $layout;
if (!static::isEnabled()) {
return;
}
// reset default framework
static::$pageLayout->framework = null;
$templates = $GLOBALS['BOOTSTRAP']['templates']['dynamicLoad'];
// only load these templates if layout uses it because default templates are changed
foreach ($templates as $path => $templates) {
foreach ($templates as $template) {
\TemplateLoader::addFile($template, $path);
}
}
}
示例5: chooseTemplates
/**
* Choose the right template
*/
public function chooseTemplates()
{
// do not choose backend templates in the frontend see #27
if (TL_MODE == "FE") {
return;
}
// check theme for back end user
/** @var \BackendUser $objUser */
$objUser = \Controller::importStatic('BackendUser');
$loggedIn = $this->beUserLoggedIn($objUser);
$theme = $objUser->backendTheme;
if ($loggedIn === false && \Config::get('backendTheme') != "sb-admin" || $theme !== null && $theme != "sb-admin") {
return;
}
// modified templates
$arrTemplate = array('be_changelog', 'be_chart_panel', 'be_confirm', 'be_diff', 'be_error', 'be_forbidden', 'be_help', 'be_incomplete', 'be_install', 'be_login', 'be_main', 'be_navigation', 'be_no_active', 'be_no_forward', 'be_no_layout', 'be_no_page', 'be_no_root', 'be_pagination', 'be_password', 'be_picker', 'be_popup', 'be_purge_data', 'be_referer', 'be_switch', 'be_unavailable', 'be_welcome');
// Register the template
foreach ($arrTemplate as $value) {
\TemplateLoader::addFile($value, 'system/modules/sb-admin/templates/backend');
}
}
示例6: getTemplatePath
/**
* Find a particular template file and return its path
*
* @param string $strTemplate The name of the template
* @param string $strFormat The file extension
* @param boolean $blnDefault If true, the default template path is returned
*
* @return string The path to the template file
*/
protected function getTemplatePath($strTemplate, $strFormat = 'html5', $blnDefault = false)
{
if ($blnDefault) {
return \TemplateLoader::getDefaultPath($strTemplate, $strFormat);
}
return \Controller::getTemplate($strTemplate, $strFormat);
}
示例7:
<?php
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2014 Leo Feyer
*
* @package Newsletter
* @link https://contao.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
/**
* Register the classes
*/
ClassLoader::addClasses(array('Contao\\Newsletter' => 'system/modules/newsletter/classes/Newsletter.php', 'Contao\\NewsletterChannelModel' => 'system/modules/newsletter/models/NewsletterChannelModel.php', 'Contao\\NewsletterModel' => 'system/modules/newsletter/models/NewsletterModel.php', 'Contao\\NewsletterRecipientsModel' => 'system/modules/newsletter/models/NewsletterRecipientsModel.php', 'Contao\\ModuleNewsletterList' => 'system/modules/newsletter/modules/ModuleNewsletterList.php', 'Contao\\ModuleNewsletterReader' => 'system/modules/newsletter/modules/ModuleNewsletterReader.php', 'Contao\\ModuleSubscribe' => 'system/modules/newsletter/modules/ModuleSubscribe.php', 'Contao\\ModuleUnsubscribe' => 'system/modules/newsletter/modules/ModuleUnsubscribe.php'));
/**
* Register the templates
*/
TemplateLoader::addFiles(array('mod_newsletter' => 'system/modules/newsletter/templates/modules', 'mod_newsletter_list' => 'system/modules/newsletter/templates/modules', 'mod_newsletter_reader' => 'system/modules/newsletter/templates/modules', 'nl_default' => 'system/modules/newsletter/templates/newsletter'));
示例8:
<?php
/**
* The MetaModels extension allows the creation of multiple collections of custom items,
* each with its own unique set of selectable attributes, with attribute extendability.
* The Front-End modules allow you to build powerful listing and filtering of the
* data in each collection.
*
* PHP version 5
* @package MetaModels
* @subpackage AttributeNumeric
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Stefan Heimes <stefan_heimes@hotmail.com>
* @author Andreas Isaak <info@andreas-isaak.de>
* @author David Greminger <david.greminger@1up.io>
* @copyright The MetaModels team.
* @license LGPL.
* @filesource
*/
/**
* Register the templates
*/
TemplateLoader::addFiles(array('mm_attr_numeric' => 'system/modules/metamodelsattribute_numeric/templates'));
示例9:
<?php
/**
* Dropbox tools extension for Contao Open Source CMS
*
* Copyright (C) 2015 Davide Rocchi
*
* @package dropbox_tools
* @author Davide Rocchi <http://www.daviderocchi.it>
* @license LGPL
*/
/**
* Register the namespace
*/
ClassLoader::addNamespace('DropboxTools');
/**
* Register the classes
*/
ClassLoader::addClasses(array('DropboxTools\\DropboxClient' => 'system/modules/dropbox_tools/classes/DropboxClient.php', 'DropboxTools\\WidgetDropboxChooser' => 'system/modules/dropbox_tools/widgets/WidgetDropboxChooser.php', 'DropboxTools\\ContentDropboxDownloads' => 'system/modules/dropbox_tools/elements/ContentDropboxDownloads.php', 'DropboxTools\\ContentDropboxToolsTest' => 'system/modules/dropbox_tools/elements/ContentDropboxToolsTest.php'));
/**
* Register the templates
*/
TemplateLoader::addFiles(array('ce_dropbox_downloads' => 'system/modules/dropbox_tools/templates/elements', 'ce_dropboxtoolstest' => 'system/modules/dropbox_tools/templates/elements'));
示例10:
<?php
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2016 Leo Feyer
*
* @license LGPL-3.0+
*/
/**
* Register the namespaces
*/
ClassLoader::addNamespaces(array('Hofff'));
/**
* Register the classes
*/
ClassLoader::addClasses(array('Hofff\\Contao\\Calendarfield\\FormCalendarField' => 'system/modules/hofff_calendarfield/forms/FormCalendarField.php'));
/**
* Register the templates
*/
TemplateLoader::addFiles(array('form_calendarfield' => 'system/modules/hofff_calendarfield/templates/forms'));
示例11:
<?php
/**
* news_categories extension for Contao Open Source CMS
*
* Copyright (C) 2011-2014 Codefog
*
* @package news_categories
* @author Webcontext <http://webcontext.com>
* @author Codefog <info@codefog.pl>
* @author Kamil Kuzminski <kamil.kuzminski@codefog.pl>
* @license LGPL
*/
/**
* Register the namespace
*/
ClassLoader::addNamespace('NewsCategories');
/**
* Register the classes
*/
ClassLoader::addClasses(array('NewsCategories\\News' => 'system/modules/news_categories/classes/News.php', 'NewsCategories\\NewsCategories' => 'system/modules/news_categories/classes/NewsCategories.php', 'NewsCategories\\ContentNewsFilter' => 'system/modules/news_categories/elements/ContentNewsFilter.php', 'NewsCategories\\NewsCategoryModel' => 'system/modules/news_categories/models/NewsCategoryModel.php', 'NewsCategories\\NewsCategoryMultilingualModel' => 'system/modules/news_categories/models/NewsCategoryMultilingualModel.php', 'NewsCategories\\NewsModel' => 'system/modules/news_categories/models/NewsModel.php', 'NewsCategories\\ModuleNewsCategories' => 'system/modules/news_categories/modules/ModuleNewsCategories.php', 'NewsCategories\\ModuleNewsArchive' => 'system/modules/news_categories/modules/ModuleNewsArchive.php', 'NewsCategories\\ModuleNewsList' => 'system/modules/news_categories/modules/ModuleNewsList.php', 'NewsCategories\\ModuleNewsMenu' => 'system/modules/news_categories/modules/ModuleNewsMenu.php'));
/**
* Register the templates
*/
TemplateLoader::addFiles(array('mod_newscategories' => 'system/modules/news_categories/templates/modules', 'nav_newscategories' => 'system/modules/news_categories/templates/navigation'));
示例12:
<?php
/**
* Responsive Navigation Extension for Contao
*
* Copyright (c) 2016 Falko Schumann
*
* @package ResponsiveNavigation
* @link https://github.com/falkoschumann/contao-responsive-navigation
* @license http://opensource.org/licenses/MIT MIT
*/
/**
* Register the templates.
*/
TemplateLoader::addFiles(array('j_responsive_navigation' => 'system/modules/responsive-navigation/templates/jquery'));
示例13:
<?php
/**
* The MetaModels extension allows the creation of multiple collections of custom items,
* each with its own unique set of selectable attributes, with attribute extendability.
* The Front-End modules allow you to build powerful listing and filtering of the
* data in each collection.
*
* PHP version 5
*
* @package MetaModels
* @subpackage AttributeTranslatedLongtext
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @author Andreas Isaak <info@andreas-isaak.de>
* @author Christopher Boelter <christopher@boelter.eu>
* @copyright The MetaModels team.
* @license LGPL.
* @filesource
*/
/**
* Register the templates
*/
TemplateLoader::addFiles(array('mm_attr_translatedlongtext' => 'system/modules/metamodelsattribute_translatedlongtext/templates'));
示例14:
<?php
/**
* Extension for Contao Open Source CMS
*
* Copyright (C) 2009 - 2016 terminal42 gmbh
*
* @package easy_themes
* @link http://www.terminal42.ch
* @license http://opensource.org/licenses/lgpl-3.0.html LGPL
*/
/**
* Register the classes
*/
ClassLoader::addClasses(array('CheckBoxChooseAtLeastOne' => 'system/modules/easy_themes/CheckBoxChooseAtLeastOne.php', 'EasyThemes' => 'system/modules/easy_themes/EasyThemes.php'));
/**
* Register the templates
*/
TemplateLoader::addFiles(array('be_easythemes' => 'system/modules/easy_themes/templates'));
示例15:
<?php
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2015 Leo Feyer
*
* @package aparat
* @author Hamid Abbaszadeh
* @license GNU/GPL2
* @copyright respinar 2014-2015
*/
/**
* Register the namespaces
*/
ClassLoader::addNamespaces(array('aparat'));
/**
* Register the classes
*/
ClassLoader::addClasses(array('aparat\\ContentAparat' => 'system/modules/aparat/elements/ContentAparat.php'));
/**
* Register the templates
*/
TemplateLoader::addFiles(array('ce_aparat' => 'system/modules/aparat/templates/elements'));