17 use Psr\Http\Message\ServerRequestInterface;
52 trigger_error(
'PageGenerator::renderContent() will be removed in TYPO3 v10.0. This logic is now built in TYPO3s Frontend RequestHandler.', E_USER_DEPRECATED);
57 $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
60 $timeTracker->incStackPointer();
61 $timeTracker->push($tsfe->sPre,
'PAGE');
62 $pageContent = $tsfe->cObj->cObjGet($tsfe->pSetup);
63 if ($tsfe->pSetup[
'wrap']) {
64 $pageContent = $tsfe->cObj->wrap($pageContent, $tsfe->pSetup[
'wrap']);
66 if ($tsfe->pSetup[
'stdWrap.']) {
67 $pageContent = $tsfe->cObj->stdWrap($pageContent, $tsfe->pSetup[
'stdWrap.']);
71 if ($tsfe->config[
'config'][
'disableAllHeaderCode']) {
72 $tsfe->content = $pageContent;
76 $timeTracker->pull($timeTracker->LR ? $tsfe->content :
'');
77 $timeTracker->decStackPointer();
88 trigger_error(
'PageGenerator::renderContentWithHeader() will be removed in TYPO3 v10.0. This logic is now built in TYPO3s Frontend RequestHandler.', E_USER_DEPRECATED);
93 $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
95 $pageRenderer = static::getPageRenderer();
96 if ($tsfe->config[
'config'][
'moveJsFromHeaderToFooter'] ??
false) {
97 $pageRenderer->enableMoveJsFromHeaderToFooter();
99 if ($tsfe->config[
'config'][
'pageRendererTemplateFile'] ??
false) {
101 $file = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($tsfe->config[
'config'][
'pageRendererTemplateFile']);
102 $pageRenderer->setTemplateFile($file);
107 $headerComment = $tsfe->config[
'config'][
'headerComment'] ??
null;
108 if (trim($headerComment)) {
109 $pageRenderer->addInlineComment(
"\t" . str_replace(LF, LF .
"\t", trim($headerComment)) . LF);
112 $theCharset = $tsfe->metaCharset;
115 $htmlTagAttributes = [];
116 $htmlLang = $tsfe->config[
'config'][
'htmlTag_langKey'] ?? ($tsfe->sys_language_isocode ?:
'en');
119 $direction = $tsfe->config[
'config'][
'htmlTag_dir'] ??
null;
120 if (self::getCurrentSiteLanguage()) {
125 $htmlTagAttributes[
'dir'] = htmlspecialchars($direction);
131 switch ((
string)($tsfe->config[
'config'][
'xmlprologue'] ??
'')) {
133 $xmlDocument =
false;
136 $docTypeParts[] =
'<?xml version="1.0" encoding="' . $theCharset .
'"?>';
139 $docTypeParts[] =
'<?xml version="1.1" encoding="' . $theCharset .
'"?>';
142 if ($tsfe->xhtmlVersion) {
143 $docTypeParts[] =
'<?xml version="1.0" encoding="' . $theCharset .
'"?>';
145 $xmlDocument =
false;
149 $docTypeParts[] = $tsfe->config[
'config'][
'xmlprologue'];
152 $doctype = $tsfe->config[
'config'][
'doctype'] ??
null;
156 $docTypeParts[] =
'<!DOCTYPE html
157 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
158 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
161 $docTypeParts[] =
'<!DOCTYPE html
162 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
163 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
166 $docTypeParts[] =
'<!DOCTYPE html
167 PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
168 "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
171 $docTypeParts[] =
'<!DOCTYPE html
172 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
173 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
175 case 'xhtml+rdfa_10':
176 $docTypeParts[] =
'<!DOCTYPE html
177 PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
178 "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">';
181 $docTypeParts[] =
'<!DOCTYPE html>';
183 $pageRenderer->setMetaCharsetTag(
'<meta charset="|" />');
185 $pageRenderer->setMetaCharsetTag(
'<meta charset="|">');
191 $docTypeParts[] = $doctype;
194 $docTypeParts[] =
'<!DOCTYPE html>';
196 $pageRenderer->setMetaCharsetTag(
'<meta charset="|" />');
198 $pageRenderer->setMetaCharsetTag(
'<meta charset="|">');
201 if ($tsfe->xhtmlVersion) {
202 $htmlTagAttributes[
'xml:lang'] = $htmlLang;
204 if ($tsfe->xhtmlVersion < 110 || $doctype ===
'html5') {
205 $htmlTagAttributes[
'lang'] = $htmlLang;
207 if ($tsfe->xhtmlVersion || $doctype ===
'html5' && $xmlDocument) {
209 $htmlTagAttributes[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
210 if (is_array($tsfe->config[
'config'][
'namespaces.'])) {
211 foreach ($tsfe->config[
'config'][
'namespaces.'] as $prefix => $uri) {
213 $htmlTagAttributes[
'xmlns:' . htmlspecialchars($prefix)] = $uri;
218 if ($tsfe->config[
'config'][
'doctypeSwitch'] ??
false) {
219 $docTypeParts = array_reverse($docTypeParts);
222 if (!empty($docTypeParts)) {
223 $pageRenderer->setXmlPrologAndDocType(implode(LF, $docTypeParts));
226 if (is_array($tsfe->config[
'config'][
'htmlTag.'][
'attributes.'] ??
null)) {
228 foreach ($tsfe->config[
'config'][
'htmlTag.'][
'attributes.'] as $attributeName => $value) {
229 $_attr .=
' ' . htmlspecialchars($attributeName) . ($value !==
'' ?
'="' . htmlspecialchars((
string)$value) .
'"' :
'');
231 if (isset($htmlTagAttributes[$attributeName])) {
232 unset($htmlTagAttributes[$attributeName]);
235 $_attr = GeneralUtility::implodeAttributes($htmlTagAttributes) . $_attr;
236 } elseif (($tsfe->config[
'config'][
'htmlTag_setParams'] ??
'') ===
'none') {
238 } elseif (isset($tsfe->config[
'config'][
'htmlTag_setParams'])) {
239 $_attr = $tsfe->config[
'config'][
'htmlTag_setParams'];
241 $_attr = GeneralUtility::implodeAttributes($htmlTagAttributes);
243 $htmlTag =
'<html' . ($_attr ?
' ' . $_attr :
'') .
'>';
244 if (isset($tsfe->config[
'config'][
'htmlTag_stdWrap.'])) {
245 $htmlTag = $tsfe->cObj->stdWrap($htmlTag, $tsfe->config[
'config'][
'htmlTag_stdWrap.']);
247 $pageRenderer->setHtmlTag($htmlTag);
249 $headTag = $tsfe->pSetup[
'headTag'] ??
'<head>';
250 if (isset($tsfe->pSetup[
'headTag.'])) {
251 $headTag = $tsfe->cObj->stdWrap($headTag, $tsfe->pSetup[
'headTag.']);
253 $pageRenderer->setHeadTag($headTag);
255 $pageRenderer->setCharSet($theCharset);
256 $pageRenderer->addInlineComment(
' This website is powered by TYPO3 - inspiring people to share!
257 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
258 TYPO3 is copyright ' . TYPO3_copyright_year .
' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
259 Information and contribution at ' . TYPO3_URL_GENERAL .
'
261 if ($tsfe->baseUrl) {
262 $pageRenderer->setBaseUrl($tsfe->baseUrl);
264 if ($tsfe->pSetup[
'shortcutIcon'] ??
false) {
266 $favIcon = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($tsfe->pSetup[
'shortcutIcon']);
268 if ($iconFileInfo->isFile()) {
269 $iconMimeType = $iconFileInfo->getMimeType();
271 $iconMimeType =
' type="' . $iconMimeType .
'"';
272 $pageRenderer->setIconMimeType($iconMimeType);
281 if (isset($tsfe->tmpl->setup[
'plugin.']) && is_array($tsfe->tmpl->setup[
'plugin.'])) {
282 $stylesFromPlugins =
'';
283 foreach ($tsfe->tmpl->setup[
'plugin.'] as $key => $iCSScode) {
284 if (is_array($iCSScode)) {
285 if ($iCSScode[
'_CSS_DEFAULT_STYLE'] && empty($tsfe->config[
'config'][
'removeDefaultCss'])) {
286 if (isset($iCSScode[
'_CSS_DEFAULT_STYLE.'])) {
287 $cssDefaultStyle = $tsfe->cObj->stdWrap($iCSScode[
'_CSS_DEFAULT_STYLE'], $iCSScode[
'_CSS_DEFAULT_STYLE.']);
289 $cssDefaultStyle = $iCSScode[
'_CSS_DEFAULT_STYLE'];
291 $stylesFromPlugins .=
'/* default styles for extension "' . substr($key, 0, -1) .
'" */' . LF . $cssDefaultStyle . LF;
293 if ($iCSScode[
'_CSS_PAGE_STYLE'] && empty($tsfe->config[
'config'][
'removePageCss'])) {
294 $cssPageStyle = implode(LF, $iCSScode[
'_CSS_PAGE_STYLE']);
295 if (isset($iCSScode[
'_CSS_PAGE_STYLE.'])) {
296 $cssPageStyle = $tsfe->cObj->stdWrap($cssPageStyle, $iCSScode[
'_CSS_PAGE_STYLE.']);
298 $cssPageStyle =
'/* specific page styles for extension "' . substr($key, 0, -1) .
'" */' . LF . $cssPageStyle;
303 if (!empty($stylesFromPlugins)) {
310 if (isset($tsfe->pSetup[
'includeCSS.']) && is_array($tsfe->pSetup[
'includeCSS.'])) {
311 foreach ($tsfe->pSetup[
'includeCSS.'] as $key => $CSSfile) {
312 if (!is_array($CSSfile)) {
313 $cssFileConfig = &$tsfe->pSetup[
'includeCSS.'][$key .
'.'];
314 if (isset($cssFileConfig[
'if.']) && !$tsfe->cObj->checkIf($cssFileConfig[
'if.'])) {
317 if ($cssFileConfig[
'external']) {
321 $ss = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($CSSfile);
327 if ($cssFileConfig[
'import']) {
328 if (!$cssFileConfig[
'external'] && $ss[0] !==
'/') {
330 $ss = GeneralUtility::dirname(GeneralUtility::getIndpEnv(
'SCRIPT_NAME')) .
'/' . $ss;
332 $pageRenderer->addCssInlineBlock(
'import_' . $key,
'@import url("' . htmlspecialchars($ss) .
'") ' . htmlspecialchars($cssFileConfig[
'media']) .
';', empty($cssFileConfig[
'disableCompression']), (
bool)$cssFileConfig[
'forceOnTop']);
334 $pageRenderer->addCssFile(
336 $cssFileConfig[
'alternate'] ?
'alternate stylesheet' :
'stylesheet',
337 $cssFileConfig[
'media'] ?:
'all',
338 $cssFileConfig[
'title'] ?:
'',
339 $cssFileConfig[
'external'] ?
false : empty($cssFileConfig[
'disableCompression']),
340 (
bool)$cssFileConfig[
'forceOnTop'],
341 $cssFileConfig[
'allWrap'],
342 (
bool)$cssFileConfig[
'excludeFromConcatenation'] || (
bool)$cssFileConfig[
'inline'],
343 $cssFileConfig[
'allWrap.'][
'splitChar'],
344 $cssFileConfig[
'inline']
346 unset($cssFileConfig);
352 if (isset($tsfe->pSetup[
'includeCSSLibs.']) && is_array($tsfe->pSetup[
'includeCSSLibs.'])) {
353 foreach ($tsfe->pSetup[
'includeCSSLibs.'] as $key => $CSSfile) {
354 if (!is_array($CSSfile)) {
355 $cssFileConfig = &$tsfe->pSetup[
'includeCSSLibs.'][$key .
'.'];
356 if (isset($cssFileConfig[
'if.']) && !$tsfe->cObj->checkIf($cssFileConfig[
'if.'])) {
359 if ($cssFileConfig[
'external']) {
363 $ss = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($CSSfile);
369 if ($cssFileConfig[
'import']) {
370 if (!$cssFileConfig[
'external'] && $ss[0] !==
'/') {
372 $ss = GeneralUtility::dirname(GeneralUtility::getIndpEnv(
'SCRIPT_NAME')) .
'/' . $ss;
374 $pageRenderer->addCssInlineBlock(
'import_' . $key,
'@import url("' . htmlspecialchars($ss) .
'") ' . htmlspecialchars($cssFileConfig[
'media']) .
';', empty($cssFileConfig[
'disableCompression']), (
bool)$cssFileConfig[
'forceOnTop']);
376 $pageRenderer->addCssLibrary(
378 $cssFileConfig[
'alternate'] ?
'alternate stylesheet' :
'stylesheet',
379 $cssFileConfig[
'media'] ?:
'all',
380 $cssFileConfig[
'title'] ?:
'',
381 $cssFileConfig[
'external'] ?
false : empty($cssFileConfig[
'disableCompression']),
382 (
bool)$cssFileConfig[
'forceOnTop'],
383 $cssFileConfig[
'allWrap'],
384 (
bool)$cssFileConfig[
'excludeFromConcatenation'] || (
bool)$cssFileConfig[
'inline'],
385 $cssFileConfig[
'allWrap.'][
'splitChar'],
386 $cssFileConfig[
'inline']
388 unset($cssFileConfig);
396 $style = trim($tsfe->pSetup[
'CSS_inlineStyle'] ??
'');
397 $style .= $tsfe->cObj->cObjGet($tsfe->pSetup[
'cssInline.'] ??
null,
'cssInline.');
402 if (isset($tsfe->pSetup[
'javascriptLibs.']) && is_array($tsfe->pSetup[
'javascriptLibs.'])) {
404 trigger_error(
'The setting page.javascriptLibs will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
407 if (!empty($tsfe->pSetup[
'javascriptLibs.'][
'jQuery'])) {
409 trigger_error(
'The setting page.javascriptLibs.jQuery will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
411 $jQueryTS = $tsfe->pSetup[
'javascriptLibs.'][
'jQuery.'];
413 $version = $jQueryTS[
'version'] ??
null;
414 $source = $jQueryTS[
'source'] ??
null;
416 if (!isset($jQueryTS[
'noConflict']) || !empty($jQueryTS[
'noConflict'])) {
417 $namespace =
'noConflict';
421 $pageRenderer->loadJquery($version, $source, $namespace,
true);
425 if (isset($tsfe->pSetup[
'includeJSLibs.']) && is_array($tsfe->pSetup[
'includeJSLibs.'])) {
426 foreach ($tsfe->pSetup[
'includeJSLibs.'] as $key => $JSfile) {
427 if (!is_array($JSfile)) {
428 if (isset($tsfe->pSetup[
'includeJSLibs.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJSLibs.'][$key .
'.'][
'if.'])) {
431 if ($tsfe->pSetup[
'includeJSLibs.'][$key .
'.'][
'external']) {
435 $ss = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($JSfile);
441 $jsFileConfig = &$tsfe->pSetup[
'includeJSLibs.'][$key .
'.'];
442 $type = $jsFileConfig[
'type'];
444 $type =
'text/javascript';
446 $crossorigin = $jsFileConfig[
'crossorigin'];
447 if (!$crossorigin && $jsFileConfig[
'integrity'] && $jsFileConfig[
'external']) {
448 $crossorigin =
'anonymous';
450 $pageRenderer->addJsLibrary(
454 $jsFileConfig[
'external'] ?
false : empty($jsFileConfig[
'disableCompression']),
455 (
bool)$jsFileConfig[
'forceOnTop'],
456 $jsFileConfig[
'allWrap'],
457 (
bool)$jsFileConfig[
'excludeFromConcatenation'],
458 $jsFileConfig[
'allWrap.'][
'splitChar'],
459 (
bool)$jsFileConfig[
'async'],
460 $jsFileConfig[
'integrity'],
461 (
bool)$jsFileConfig[
'defer'],
464 unset($jsFileConfig);
469 if (isset($tsfe->pSetup[
'includeJSFooterlibs.']) && is_array($tsfe->pSetup[
'includeJSFooterlibs.'])) {
470 foreach ($tsfe->pSetup[
'includeJSFooterlibs.'] as $key => $JSfile) {
471 if (!is_array($JSfile)) {
472 if (isset($tsfe->pSetup[
'includeJSFooterlibs.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJSFooterlibs.'][$key .
'.'][
'if.'])) {
475 if ($tsfe->pSetup[
'includeJSFooterlibs.'][$key .
'.'][
'external']) {
479 $ss = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($JSfile);
485 $jsFileConfig = &$tsfe->pSetup[
'includeJSFooterlibs.'][$key .
'.'];
486 $type = $jsFileConfig[
'type'];
488 $type =
'text/javascript';
490 $crossorigin = $jsFileConfig[
'crossorigin'];
491 if (!$crossorigin && $jsFileConfig[
'integrity'] && $jsFileConfig[
'external']) {
492 $crossorigin =
'anonymous';
494 $pageRenderer->addJsFooterLibrary(
498 $jsFileConfig[
'external'] ?
false : empty($jsFileConfig[
'disableCompression']),
499 (
bool)$jsFileConfig[
'forceOnTop'],
500 $jsFileConfig[
'allWrap'],
501 (
bool)$jsFileConfig[
'excludeFromConcatenation'],
502 $jsFileConfig[
'allWrap.'][
'splitChar'],
503 (
bool)$jsFileConfig[
'async'],
504 $jsFileConfig[
'integrity'],
505 (
bool)$jsFileConfig[
'defer'],
508 unset($jsFileConfig);
514 if (isset($tsfe->pSetup[
'includeJS.']) && is_array($tsfe->pSetup[
'includeJS.'])) {
515 foreach ($tsfe->pSetup[
'includeJS.'] as $key => $JSfile) {
516 if (!is_array($JSfile)) {
517 if (isset($tsfe->pSetup[
'includeJS.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJS.'][$key .
'.'][
'if.'])) {
520 if ($tsfe->pSetup[
'includeJS.'][$key .
'.'][
'external']) {
524 $ss = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($JSfile);
530 $jsConfig = &$tsfe->pSetup[
'includeJS.'][$key .
'.'];
531 $type = $jsConfig[
'type'];
533 $type =
'text/javascript';
535 $crossorigin = $jsConfig[
'crossorigin'];
536 if (!$crossorigin && $jsConfig[
'integrity'] && $jsConfig[
'external']) {
537 $crossorigin =
'anonymous';
539 $pageRenderer->addJsFile(
542 $jsConfig[
'external'] ?
false : empty($jsConfig[
'disableCompression']),
543 (
bool)$jsConfig[
'forceOnTop'],
544 $jsConfig[
'allWrap'],
545 (
bool)$jsConfig[
'excludeFromConcatenation'],
546 $jsConfig[
'allWrap.'][
'splitChar'],
547 (
bool)$jsConfig[
'async'],
548 $jsConfig[
'integrity'],
549 (
bool)$jsConfig[
'defer'],
557 if (isset($tsfe->pSetup[
'includeJSFooter.']) && is_array($tsfe->pSetup[
'includeJSFooter.'])) {
558 foreach ($tsfe->pSetup[
'includeJSFooter.'] as $key => $JSfile) {
559 if (!is_array($JSfile)) {
560 if (isset($tsfe->pSetup[
'includeJSFooter.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJSFooter.'][$key .
'.'][
'if.'])) {
563 if ($tsfe->pSetup[
'includeJSFooter.'][$key .
'.'][
'external']) {
567 $ss = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($JSfile);
573 $jsConfig = &$tsfe->pSetup[
'includeJSFooter.'][$key .
'.'];
574 $type = $jsConfig[
'type'];
576 $type =
'text/javascript';
578 $crossorigin = $jsConfig[
'crossorigin'];
579 if (!$crossorigin && $jsConfig[
'integrity'] && $jsConfig[
'external']) {
580 $crossorigin =
'anonymous';
582 $pageRenderer->addJsFooterFile(
585 $jsConfig[
'external'] ?
false : empty($jsConfig[
'disableCompression']),
586 (
bool)$jsConfig[
'forceOnTop'],
587 $jsConfig[
'allWrap'],
588 (
bool)$jsConfig[
'excludeFromConcatenation'],
589 $jsConfig[
'allWrap.'][
'splitChar'],
590 (
bool)$jsConfig[
'async'],
591 $jsConfig[
'integrity'],
592 (
bool)$jsConfig[
'defer'],
601 if (isset($tsfe->pSetup[
'headerData.']) && is_array($tsfe->pSetup[
'headerData.'])) {
602 $pageRenderer->addHeaderData($tsfe->cObj->cObjGet($tsfe->pSetup[
'headerData.'],
'headerData.'));
605 if (isset($tsfe->pSetup[
'footerData.']) && is_array($tsfe->pSetup[
'footerData.'])) {
606 $pageRenderer->addFooterData($tsfe->cObj->cObjGet($tsfe->pSetup[
'footerData.'],
'footerData.'));
608 $tsfe->generatePageTitle();
611 $_params = [
'page' => $tsfe->page];
613 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'TYPO3\CMS\Frontend\Page\PageGenerator'][
'generateMetaTags'] ?? [] as $_funcRef) {
614 GeneralUtility::callUserFunction($_funcRef, $_params, $_ref);
617 static::generateMetaTagHtml(
618 $tsfe->pSetup[
'meta.'] ?? [],
622 unset($tsfe->additionalHeaderData[
'JSCode']);
623 if (isset($tsfe->config[
'INTincScript']) && is_array($tsfe->config[
'INTincScript'])) {
624 $tsfe->additionalHeaderData[
'JSCode'] = $tsfe->JSCode;
626 $tsfe->config[
'INTincScript_ext'][
'divKey'] = $tsfe->uniqueHash();
627 $tsfe->config[
'INTincScript_ext'][
'additionalHeaderData'] = $tsfe->additionalHeaderData;
629 $tsfe->config[
'INTincScript_ext'][
'additionalFooterData'] = $tsfe->additionalFooterData;
631 $tsfe->config[
'INTincScript_ext'][
'additionalJavaScript'] = $tsfe->additionalJavaScript;
633 $tsfe->config[
'INTincScript_ext'][
'additionalCSS'] = $tsfe->additionalCSS;
635 $tsfe->additionalHeaderData = [
'<!--HD_' . $tsfe->config[
'INTincScript_ext'][
'divKey'] .
'-->'];
637 $tsfe->additionalFooterData = [
'<!--FD_' . $tsfe->config[
'INTincScript_ext'][
'divKey'] .
'-->'];
639 $tsfe->divSection .=
'<!--TDS_' . $tsfe->config[
'INTincScript_ext'][
'divKey'] .
'-->';
641 $tsfe->INTincScript_loadJSCode();
645 if ($tsfe->spamProtectEmailAddresses && $tsfe->spamProtectEmailAddresses !==
'ascii') {
647 // decrypt helper function
648 function decryptCharcode(n,start,end,offset) {
650 if (offset > 0 && n > end) {
651 n = start + (n - end - 1);
652 } else if (offset < 0 && n < start) {
653 n = end - (start - n - 1);
655 return String.fromCharCode(n);
658 function decryptString(enc,offset) {
660 var len = enc.length;
661 for(var i=0; i < len; i++) {
662 var n = enc.charCodeAt(i);
663 if (n >= 0x2B && n <= 0x3A) {
664 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
665 } else if (n >= 0x40 && n <= 0x5A) {
666 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
667 } else if (n >= 0x61 && n <= 0x7A) {
668 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
670 dec += enc.charAt(i);
675 // decrypt spam-protected emails
676 function linkTo_UnCryptMailto(s) {
677 location.href = decryptString(s,' . $tsfe->spamProtectEmailAddresses * -1 .
');
684 if (is_array($tsfe->inlineJS)) {
685 foreach ($tsfe->inlineJS as $key => $val) {
686 if (!is_array($val)) {
687 $inlineJS .= LF . $val . LF;
693 $inline = $tsfe->cObj->cObjGet($tsfe->pSetup[
'jsInline.'] ??
null,
'jsInline.');
695 $inlineJS .= LF . $inline . LF;
698 $inlineFooterJs = $tsfe->cObj->cObjGet($tsfe->pSetup[
'jsFooterInline.'] ??
null,
'jsFooterInline.');
700 if ($tsfe->config[
'config'][
'compressJs'] ??
false) {
701 $pageRenderer->enableCompressJavascript();
702 $minifyErrorScript = ($minifyErrorInline =
'');
703 $scriptJsCode = GeneralUtility::minifyJavaScript($scriptJsCode, $minifyErrorScript);
704 if ($minifyErrorScript) {
705 $timeTracker->setTSlogMessage($minifyErrorScript, 3);
708 $inlineJS = GeneralUtility::minifyJavaScript($inlineJS, $minifyErrorInline);
709 if ($minifyErrorInline) {
710 $timeTracker->setTSlogMessage($minifyErrorInline, 3);
713 if ($inlineFooterJs) {
714 $inlineFooterJs = GeneralUtility::minifyJavaScript($inlineFooterJs, $minifyErrorInline);
715 if ($minifyErrorInline) {
716 $timeTracker->setTSlogMessage($minifyErrorInline, 3);
720 if (!isset($tsfe->config[
'config'][
'removeDefaultJS']) || !$tsfe->config[
'config'][
'removeDefaultJS']) {
723 $pageRenderer->addJsInlineCode(
'_scriptCode', $scriptJsCode, $tsfe->config[
'config'][
'compressJs']);
726 $pageRenderer->addJsInlineCode(
'TS_inlineJS', $inlineJS, $tsfe->config[
'config'][
'compressJs']);
728 if ($inlineFooterJs) {
729 $pageRenderer->addJsFooterInlineCode(
'TS_inlineFooter', $inlineFooterJs, $tsfe->config[
'config'][
'compressJs']);
731 } elseif ($tsfe->config[
'config'][
'removeDefaultJS'] ===
'external') {
744 $pageRenderer->addJsInlineCode(
'TS_inlineJSint', $inlineJSint, $tsfe->config[
'config'][
'compressJs']);
746 if (trim($scriptJsCode . $inlineJS)) {
747 $pageRenderer->addJsFile(self::inline2TempFile($scriptJsCode . $inlineJS,
'js'),
'text/javascript', $tsfe->config[
'config'][
'compressJs']);
749 if ($inlineFooterJs) {
750 $inlineFooterJSint =
'';
752 if ($inlineFooterJSint) {
753 $pageRenderer->addJsFooterInlineCode(
'TS_inlineFooterJSint', $inlineFooterJSint, $tsfe->config[
'config'][
'compressJs']);
755 $pageRenderer->addJsFooterFile(self::inline2TempFile($inlineFooterJs,
'js'),
'text/javascript', $tsfe->config[
'config'][
'compressJs']);
760 $pageRenderer->addJsInlineCode(
'TS_inlineJS', $inlineJS, $tsfe->config[
'config'][
'compressJs']);
762 if ($inlineFooterJs) {
763 $pageRenderer->addJsFooterInlineCode(
'TS_inlineFooter', $inlineFooterJs, $tsfe->config[
'config'][
'compressJs']);
766 if (isset($tsfe->pSetup[
'inlineLanguageLabelFiles.']) && is_array($tsfe->pSetup[
'inlineLanguageLabelFiles.'])) {
767 foreach ($tsfe->pSetup[
'inlineLanguageLabelFiles.'] as $key => $languageFile) {
768 if (is_array($languageFile)) {
771 $languageFileConfig = &$tsfe->pSetup[
'inlineLanguageLabelFiles.'][$key .
'.'];
772 if (isset($languageFileConfig[
'if.']) && !$tsfe->cObj->checkIf($languageFileConfig[
'if.'])) {
775 $pageRenderer->addInlineLanguageLabelFile(
777 $languageFileConfig[
'selectionPrefix'] ?:
'',
778 $languageFileConfig[
'stripFromSelectionName'] ?:
''
782 if (isset($tsfe->pSetup[
'inlineSettings.']) && is_array($tsfe->pSetup[
'inlineSettings.'])) {
783 $pageRenderer->addInlineSettingArray(
'TS', $tsfe->pSetup[
'inlineSettings.']);
786 if ($tsfe->config[
'config'][
'compressCss'] ??
false) {
787 $pageRenderer->enableCompressCss();
789 if ($tsfe->config[
'config'][
'compressJs'] ??
false) {
790 $pageRenderer->enableCompressJavascript();
792 if ($tsfe->config[
'config'][
'concatenateCss'] ??
false) {
793 $pageRenderer->enableConcatenateCss();
795 if ($tsfe->config[
'config'][
'concatenateJs'] ??
false) {
796 $pageRenderer->enableConcatenateJavascript();
800 if ($tsfe->config[
'config'][
'concatenateJsAndCss'] ??
false) {
801 trigger_error(
'Setting config.concatenateJsAndCss is deprecated in favor of config.concatenateJs and config.concatenateCss, and will have no effect anymore in TYPO3 v10.0.', E_USER_DEPRECATED);
802 $pageRenderer->enableConcatenateCss();
803 $pageRenderer->enableConcatenateJavascript();
806 if ($tsfe->additionalHeaderData) {
807 $pageRenderer->addHeaderData(implode(LF, $tsfe->additionalHeaderData));
810 if ($tsfe->additionalFooterData) {
811 $pageRenderer->addFooterData(implode(LF, $tsfe->additionalFooterData));
815 if ($tsfe->config[
'config'][
'disableBodyTag'] ??
false) {
818 $defBT = (isset($tsfe->pSetup[
'bodyTagCObject']) && $tsfe->pSetup[
'bodyTagCObject'])
819 ? $tsfe->cObj->cObjGetSingle($tsfe->pSetup[
'bodyTagCObject'], $tsfe->pSetup[
'bodyTagCObject.'],
'bodyTagCObject')
821 $bodyTag = (isset($tsfe->pSetup[
'bodyTag']) && $tsfe->pSetup[
'bodyTag'])
822 ? $tsfe->pSetup[
'bodyTag']
824 if (trim($tsfe->pSetup[
'bodyTagAdd'] ??
'')) {
825 $bodyTag = preg_replace(
'/>$/',
'', trim($bodyTag)) .
' ' . trim($tsfe->pSetup[
'bodyTagAdd']) .
'>';
828 $pageRenderer->addBodyContent(LF . $bodyTag);
830 if ($tsfe->divSection) {
831 $pageRenderer->addBodyContent(LF . $tsfe->divSection);
834 $pageRenderer->addBodyContent(LF . $pageContent);
835 if (!empty($tsfe->config[
'INTincScript']) && is_array($tsfe->config[
'INTincScript'])) {
837 $tsfe->config[
'INTincScript_ext'][
'pageRenderer'] = serialize($pageRenderer);
839 $tsfe->content = $pageRenderer->renderPageWithUncachedObjects($tsfe->config[
'INTincScript_ext'][
'divKey']);
842 $tsfe->content = $pageRenderer->render();
862 preg_match_all(
'/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/', $searchString, $tempArray);
863 $searchString = preg_replace(
'/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/',
'', $searchString);
864 $intObjects = implode(
'', $tempArray[0]);
877 trigger_error(
'PageGenerator::inline2TempFile() will be removed in TYPO3 v10.0. This logic is now built in TYPO3s Frontend RequestHandler.', E_USER_DEPRECATED);
882 $script =
'typo3temp/assets/js/' . GeneralUtility::shortMD5($str) .
'.js';
885 $script =
'typo3temp/assets/css/' . GeneralUtility::shortMD5($str) .
'.css';
906 trigger_error(
'The method will be removed in TYPO3 v10.0, if needed outside of linkVar calculation, re-implement the method in your own extension.', E_USER_DEPRECATED);
909 if ($needle ===
'int' || $needle ===
'integer') {
913 } elseif (preg_match(
'/^\\/.+\\/[imsxeADSUXu]*$/', $needle)) {
915 if (@preg_match($needle, $haystack)) {
918 } elseif (strstr($needle,
'-')) {
921 $range = explode(
'-', $needle);
922 if ($range[0] <= $haystack && $range[1] >= $haystack) {
926 } elseif (strstr($needle,
'|')) {
929 $haystack = str_replace(
' ',
'', $haystack);
930 if (strstr(
'|' . $needle .
'|',
'|' . $haystack .
'|')) {
933 } elseif ((
string)$needle === (
string)$haystack) {
950 trigger_error(
'This method will be removed in TYPO3 v10.0. Use $TSFE->generatePageTitle() instead.', E_USER_DEPRECATED);
962 $pageRenderer = static::getPageRenderer();
965 $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
966 $conf = $typoScriptService->convertTypoScriptArrayToPlainArray($metaTagTypoScript);
967 foreach ($conf as $key => $properties) {
969 if (is_array($properties)) {
970 $nodeValue = $properties[
'_typoScriptNodeValue'] ??
'';
971 $value = trim($cObj->
stdWrap($nodeValue, $metaTagTypoScript[$key .
'.']));
972 if ($value ===
'' && !empty($properties[
'value'])) {
973 $value = $properties[
'value'];
977 $value = $properties;
981 if ((is_array($properties) && !empty($properties[
'httpEquivalent'])) || strtolower($key) ===
'refresh') {
982 $attribute =
'http-equiv';
984 if (is_array($properties) && !empty($properties[
'attribute'])) {
985 $attribute = $properties[
'attribute'];
987 if (is_array($properties) && !empty($properties[
'replace'])) {
991 if (!is_array($value)) {
992 $value = (array)$value;
994 foreach ($value as $subValue) {
995 if (trim($subValue) !==
'') {
996 $pageRenderer->setMetaTag($attribute, $key, $subValue, [], $replace);
1007 return GeneralUtility::makeInstance(PageRenderer::class);
1017 protected static function addCssToPageRenderer($cssStyles, $excludeFromConcatenation =
false, $inlineBlockName =
'TSFEinlineStyle')
1019 if (empty(
$GLOBALS[
'TSFE']->config[
'config'][
'inlineStyle2TempFile'])) {
1023 self::inline2TempFile($cssStyles,
'css'),
1027 (
bool)
$GLOBALS[
'TSFE']->config[
'config'][
'compressCss'],
1030 $excludeFromConcatenation
1043 &&
$GLOBALS[
'TYPO3_REQUEST'] instanceof ServerRequestInterface
1045 return $GLOBALS[
'TYPO3_REQUEST']->getAttribute(
'language');