本文整理汇总了PHP中TYPO3\CMS\Core\Page\PageRenderer::setTemplateFile方法的典型用法代码示例。如果您正苦于以下问题:PHP PageRenderer::setTemplateFile方法的具体用法?PHP PageRenderer::setTemplateFile怎么用?PHP PageRenderer::setTemplateFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Page\PageRenderer
的用法示例。
在下文中一共展示了PageRenderer::setTemplateFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPageRenderer
/**
* Gets instance of PageRenderer
*
* @return \TYPO3\CMS\Core\Page\PageRenderer
*/
public function getPageRenderer()
{
if (!isset($this->pageRenderer)) {
$this->pageRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer');
$this->pageRenderer->setTemplateFile('EXT:frontend/Resources/Private/Templates/MainPage.html');
$this->pageRenderer->setBackPath(TYPO3_mainDir);
}
return $this->pageRenderer;
}
示例2: getPageRenderer
/**
* Gets instance of PageRenderer
*
* @return \TYPO3\CMS\Core\Page\PageRenderer
*/
public function getPageRenderer()
{
if (!isset($this->pageRenderer)) {
$this->pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer');
$this->pageRenderer->setTemplateFile(PATH_tslib . 'templates/tslib_page_frontend.html');
$this->pageRenderer->setBackPath(TYPO3_mainDir);
}
return $this->pageRenderer;
}
示例3: getConfigArray
/**
* Checks if config-array exists already but if not, gets it
*
* @throws ServiceUnavailableException
* @return void
*/
public function getConfigArray()
{
// If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
$timeTracker = $this->getTimeTracker();
$timeTracker->push('Parse template', '');
// Force parsing, if set?:
$this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
// Start parsing the TS template. Might return cached version.
$this->tmpl->start($this->rootLine);
$timeTracker->pull();
if ($this->tmpl->loaded) {
$timeTracker->push('Setting the config-array', '');
// toplevel - objArrayName
$this->sPre = $this->tmpl->setup['types.'][$this->type];
$this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
if (!is_array($this->pSetup)) {
$message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
if ($this->checkPageUnavailableHandler()) {
$this->pageUnavailableAndExit($message);
} else {
$explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
throw new ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
}
} else {
if (!isset($this->config['config'])) {
$this->config['config'] = array();
}
// Filling the config-array, first with the main "config." part
if (is_array($this->tmpl->setup['config.'])) {
ArrayUtility::mergeRecursiveWithOverrule($this->tmpl->setup['config.'], $this->config['config']);
$this->config['config'] = $this->tmpl->setup['config.'];
}
// override it with the page/type-specific "config."
if (is_array($this->pSetup['config.'])) {
ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
}
if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
$this->config['config']['typolinkCheckRootline'] = true;
}
// Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
if (!isset($this->config['config']['removeDefaultJS'])) {
$this->config['config']['removeDefaultJS'] = 'external';
}
if (!isset($this->config['config']['inlineStyle2TempFile'])) {
$this->config['config']['inlineStyle2TempFile'] = 1;
}
if (!isset($this->config['config']['compressJs'])) {
$this->config['config']['compressJs'] = 0;
}
// Processing for the config_array:
$this->config['rootLine'] = $this->tmpl->rootLine;
$this->config['mainScript'] = trim($this->config['config']['mainScript']) ?: 'index.php';
// Class for render Header and Footer parts
if ($this->pSetup['pageHeaderFooterTemplateFile']) {
$file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
if ($file) {
$this->pageRenderer->setTemplateFile($file);
}
}
}
$timeTracker->pull();
} else {
if ($this->checkPageUnavailableHandler()) {
$this->pageUnavailableAndExit('No TypoScript template found!');
} else {
$message = 'No TypoScript template found!';
GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
throw new ServiceUnavailableException($message, 1294587218);
}
}
}
// No cache
// Set $this->no_cache TRUE if the config.no_cache value is set!
if ($this->config['config']['no_cache']) {
$this->set_no_cache('config.no_cache is set');
}
// Merge GET with defaultGetVars
if (!empty($this->config['config']['defaultGetVars.'])) {
$modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
GeneralUtility::_GETset($modifiedGetVars);
}
// Hook for postProcessing the configuration array
if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
$params = array('config' => &$this->config['config']);
foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
GeneralUtility::callUserFunction($funcRef, $params, $this);
}
}
}
示例4: startPage
/**
* Returns page start
* This includes the proper header with charset, title, meta tag and beginning body-tag.
*
* @param string $title HTML Page title for the header
* @return string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
* @see endPage()
*/
public function startPage($title)
{
// hook pre start page
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
$preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
if (is_array($preStartPageHook)) {
$hookParameters = array('title' => &$title);
foreach ($preStartPageHook as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
}
// alternative template for Header and Footer
if ($this->pageHeaderFooterTemplateFile) {
$file = GeneralUtility::getFileAbsFileName($this->pageHeaderFooterTemplateFile, true);
if ($file) {
$this->pageRenderer->setTemplateFile($file);
}
}
// Disable rendering of XHTML tags
$this->pageRenderer->setRenderXhtml(false);
$languageCode = $this->pageRenderer->getLanguage() === 'default' ? 'en' : $this->pageRenderer->getLanguage();
$this->pageRenderer->setHtmlTag('<html lang="' . $languageCode . '">');
$headerStart = '<!DOCTYPE html>';
$this->pageRenderer->setXmlPrologAndDocType($headerStart);
$this->pageRenderer->setHeadTag('<head>' . LF . '<!-- TYPO3 Script ID: ' . htmlspecialchars($this->scriptID) . ' -->');
header('Content-Type:text/html;charset=utf-8');
$this->pageRenderer->setCharSet('utf-8');
$this->pageRenderer->addMetaTag($this->generator());
$this->pageRenderer->addMetaTag('<meta name="robots" content="noindex,follow">');
$this->pageRenderer->addMetaTag('<meta charset="utf-8">');
$this->pageRenderer->addMetaTag('<meta name="viewport" content="width=device-width, initial-scale=1">');
$this->pageRenderer->setFavIcon($this->getBackendFavicon());
if ($this->useCompatibilityTag) {
$this->pageRenderer->addMetaTag($this->xUaCompatible($this->xUaCompatibilityVersion));
}
$this->pageRenderer->setTitle($title);
// add docstyles
$this->docStyle();
if ($this->extDirectStateProvider) {
$this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('backend') . 'Resources/Public/JavaScript/ExtDirect.StateProvider.js');
}
$this->pageRenderer->addHeaderData($this->JScode);
foreach ($this->JScodeArray as $name => $code) {
$this->pageRenderer->addJsInlineCode($name, $code, false);
}
if (!empty($this->JScodeLibArray)) {
GeneralUtility::deprecationLog('DocumentTemplate->JScodeLibArray is deprecated since TYPO3 CMS 7. Use the functionality within pageRenderer directly');
foreach ($this->JScodeLibArray as $library) {
$this->pageRenderer->addHeaderData($library);
}
}
if ($this->extJScode) {
$this->pageRenderer->addExtOnReadyCode($this->extJScode);
}
// Load jquery and twbs JS libraries on every backend request
$this->pageRenderer->loadJquery();
// Note: please do not reference "bootstrap" outside of the TYPO3 Core (not in your own extensions)
// as this is preliminary as long as Twitter bootstrap does not support AMD modules
// this logic will be changed once Twitter bootstrap 4 is included
$this->pageRenderer->addJsFile(ExtensionManagementUtility::extRelPath('core') . 'Resources/Public/JavaScript/Contrib/bootstrap/bootstrap.js');
// hook for additional headerData
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) {
$preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'];
if (is_array($preHeaderRenderHook)) {
$hookParameters = array('pageRenderer' => &$this->pageRenderer);
foreach ($preHeaderRenderHook as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
}
// Construct page header.
$str = $this->pageRenderer->render(PageRenderer::PART_HEADER);
$this->JScode = $this->extJScode = '';
$this->JScodeArray = array();
$this->endOfPageJsBlock = $this->pageRenderer->render(PageRenderer::PART_FOOTER);
$str .= $this->docBodyTagBegin() . ($this->divClass ? '
<!-- Wrapping DIV-section for whole page BEGIN -->
<div class="' . $this->divClass . '">
' : '') . trim($this->form);
return $str;
}
示例5: startPage
/**
* Returns page start
* This includes the proper header with charset, title, meta tag and beginning body-tag.
*
* @param string $title HTML Page title for the header
* @param boolean $includeCsh flag for including CSH
* @return string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
* @see endPage()
* @todo Define visibility
*/
public function startPage($title, $includeCsh = TRUE)
{
// hook pre start page
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
$preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
if (is_array($preStartPageHook)) {
$hookParameters = array('title' => &$title);
foreach ($preStartPageHook as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
}
$this->pageRenderer->backPath = $this->backPath;
// alternative template for Header and Footer
if ($this->pageHeaderFooterTemplateFile) {
$file = GeneralUtility::getFileAbsFileName($this->pageHeaderFooterTemplateFile, TRUE);
if ($file) {
$this->pageRenderer->setTemplateFile($file);
}
}
// Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
header('Content-Type:text/html;charset=' . $this->charset);
// Standard HTML tag
$htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
switch ($this->docType) {
case 'html_3':
$headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
$htmlTag = '<html>';
// Disable rendering of XHTML tags
$this->pageRenderer->setRenderXhtml(FALSE);
break;
case 'xhtml_strict':
$headerStart = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
break;
case 'xhtml_frames':
$headerStart = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
break;
case 'xhtml_trans':
$headerStart = '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
break;
case 'html5':
default:
// The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
$headerStart = '<!DOCTYPE html>' . LF;
$htmlTag = '<html>';
// Disable rendering of XHTML tags
$this->pageRenderer->setRenderXhtml(FALSE);
}
$this->pageRenderer->setHtmlTag($htmlTag);
// This loads the tabulator-in-textarea feature. It automatically modifies
// every textarea which is found.
if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea']) {
$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/tab.js');
}
// Include the JS for the Context Sensitive Help
if ($includeCsh) {
$this->loadCshJavascript();
}
// Get the browser info
$browserInfo = \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo(GeneralUtility::getIndpEnv('HTTP_USER_AGENT'));
// Set the XML prologue
$xmlPrologue = '<?xml version="1.0" encoding="' . $this->charset . '"?>';
// Set the XML stylesheet
$xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
// Add the XML prologue for XHTML doctypes
if (strpos($this->docType, 'xhtml') !== FALSE) {
// Put the XML prologue before or after the doctype declaration according to browser
if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
$headerStart = $headerStart . LF . $xmlPrologue;
} else {
$headerStart = $xmlPrologue . LF . $headerStart;
}
// Add the xml stylesheet according to doctype
if ($this->docType !== 'xhtml_frames') {
$headerStart = $headerStart . LF . $xmlStylesheet;
}
}
$this->pageRenderer->setXmlPrologAndDocType($headerStart);
$this->pageRenderer->setHeadTag('<head>' . LF . '<!-- TYPO3 Script ID: ' . htmlspecialchars($this->scriptID) . ' -->');
$this->pageRenderer->setCharSet($this->charset);
$this->pageRenderer->addMetaTag($this->generator());
$this->pageRenderer->addMetaTag('<meta name="robots" content="noindex,follow" />');
$this->pageRenderer->setFavIcon($this->getBackendFavicon());
if ($this->useCompatibilityTag) {
//.........这里部分代码省略.........
示例6: startPage
/**
* Returns page start
* This includes the proper header with charset, title, meta tag and beginning body-tag.
*
* @param string $title HTML Page title for the header
* @param bool $includeCsh flag for including CSH
* @return string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
* @see endPage()
*/
public function startPage($title, $includeCsh = TRUE)
{
// hook pre start page
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
$preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
if (is_array($preStartPageHook)) {
$hookParameters = array('title' => &$title);
foreach ($preStartPageHook as $hookFunction) {
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
}
$this->pageRenderer->backPath = $this->backPath;
// alternative template for Header and Footer
if ($this->pageHeaderFooterTemplateFile) {
$file = GeneralUtility::getFileAbsFileName($this->pageHeaderFooterTemplateFile, TRUE);
if ($file) {
$this->pageRenderer->setTemplateFile($file);
}
}
// Disable rendering of XHTML tags
$this->pageRenderer->setRenderXhtml(FALSE);
$languageCode = $this->pageRenderer->getLanguage() === 'default' ? 'en' : $this->pageRenderer->getLanguage();
$this->pageRenderer->setHtmlTag('<html lang="' . $languageCode . '">');
// Include the JS for the Context Sensitive Help
// @todo: right now this is a hard dependency on csh manual, as the whole help system should be moved to
// the extension. The core provides a API for adding help, and rendering help, but the rendering
// should be up to the extension itself
if ($includeCsh && ExtensionManagementUtility::isLoaded('cshmanual')) {
$this->loadCshJavascript();
}
$headerStart = '<!DOCTYPE html>';
$this->pageRenderer->setXmlPrologAndDocType($headerStart);
$this->pageRenderer->setHeadTag('<head>' . LF . '<!-- TYPO3 Script ID: ' . htmlspecialchars($this->scriptID) . ' -->');
header('Content-Type:text/html;charset=utf-8');
$this->pageRenderer->setCharSet('utf-8');
$this->pageRenderer->addMetaTag($this->generator());
$this->pageRenderer->addMetaTag('<meta name="robots" content="noindex,follow">');
$this->pageRenderer->addMetaTag('<meta charset="utf-8">');
$this->pageRenderer->addMetaTag('<meta name="viewport" content="width=device-width, initial-scale=1">');
$this->pageRenderer->setFavIcon($this->getBackendFavicon());
if ($this->useCompatibilityTag) {
$this->pageRenderer->addMetaTag($this->xUaCompatible($this->xUaCompatibilityVersion));
}
$this->pageRenderer->setTitle($title);
// add docstyles
$this->docStyle();
if ($this->extDirectStateProvider) {
$this->pageRenderer->addJsFile($this->backPath . 'sysext/backend/Resources/Public/JavaScript/ExtDirect.StateProvider.js');
}
// Add jsCode for overriding the console with a debug panel connection
$this->pageRenderer->addJsInlineCode('consoleOverrideWithDebugPanel', 'if (typeof top.Ext === "object") {
top.Ext.onReady(function() {
if (typeof console === "undefined") {
if (top && top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.DebugConsole) {
console = top.TYPO3.Backend.DebugConsole;
} else {
console = {
log: Ext.log,
info: Ext.log,
warn: Ext.log,
error: Ext.log
};
}
}
});
}
', FALSE);
$this->pageRenderer->addHeaderData($this->JScode);
foreach ($this->JScodeArray as $name => $code) {
$this->pageRenderer->addJsInlineCode($name, $code, FALSE);
}
if (count($this->JScodeLibArray)) {
GeneralUtility::deprecationLog('DocumentTemplate->JScodeLibArray is deprecated since TYPO3 CMS 7. Use the functionality within pageRenderer directly');
foreach ($this->JScodeLibArray as $library) {
$this->pageRenderer->addHeaderData($library);
}
}
if ($this->extJScode) {
$this->pageRenderer->addExtOnReadyCode($this->extJScode);
}
// Load jquery and twbs JS libraries on every backend request
$this->pageRenderer->loadJquery();
// Note: please do not reference "bootstrap" outside of the TYPO3 Core (not in your own extensions)
// as this is preliminary as long as Twitter bootstrap does not support AMD modules
// this logic will be changed once Twitter bootstrap 4 is included
$this->pageRenderer->addJsFile($this->backPath . 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap/bootstrap.js');
// hook for additional headerData
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) {
$preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'];
if (is_array($preHeaderRenderHook)) {
//.........这里部分代码省略.........
示例7: getPageRenderer
/**
* Gets instance of PageRenderer
*
* @return t3lib_PageRenderer
*/
public function getPageRenderer()
{
if (!isset($this->pageRenderer)) {
if ($GLOBALS['TSFE']->isINTincScript()) {
// We use an instance of t3lib_PageRenderer to render additional header data
// because this script is invoked after header has been rendered by $GLOBALS['TSFE']->getPageRenderer()
$this->pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer');
$this->pageRenderer->setTemplateFile($this->extHttpPath . 'templates/rtehtmlarea_pageheader_frontend.html');
} else {
$this->pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
}
$this->pageRenderer->setBackPath(TYPO3_mainDir);
}
return $this->pageRenderer;
}