2 namespace TYPO3\CMS\Frontend\Page;
46 public static function pagegenInit()
50 if ($tsfe->page[
'content_from_pid'] > 0) {
52 $temp_copy_TSFE = clone $tsfe;
54 $temp_copy_TSFE->id = $tsfe->page[
'content_from_pid'];
55 $temp_copy_TSFE->MP =
'';
56 $temp_copy_TSFE->getPageAndRootlineWithDomain($tsfe->config[
'config'][
'content_from_pid_allowOutsideDomain'] ? 0 : $tsfe->domainStartPage);
57 $tsfe->contentPid = (int)$temp_copy_TSFE->id;
58 unset($temp_copy_TSFE);
60 if ($tsfe->config[
'config'][
'MP_defaults']) {
62 foreach ($temp_parts as $temp_p) {
63 list($temp_idP, $temp_MPp) = explode(
':', $temp_p, 2);
65 foreach ($temp_ids as $temp_id) {
66 $tsfe->MP_defaults[$temp_id] = $temp_MPp;
71 $tsfe->indexedDocTitle = $tsfe->page[
'title'];
72 $tsfe->debug =
'' . $tsfe->config[
'config'][
'debug'];
74 if (isset($tsfe->config[
'config'][
'baseURL'])) {
75 $tsfe->baseUrl = $tsfe->config[
'config'][
'baseURL'];
80 $tsfe->intTarget =
'' . $tsfe->config[
'config'][
'intTarget'];
81 $tsfe->extTarget =
'' . $tsfe->config[
'config'][
'extTarget'];
82 $tsfe->fileTarget =
'' . $tsfe->config[
'config'][
'fileTarget'];
83 if ($tsfe->config[
'config'][
'spamProtectEmailAddresses'] ===
'ascii') {
84 $tsfe->spamProtectEmailAddresses =
'ascii';
89 if (!empty($tsfe->config[
'config'][
'absRefPrefix'])) {
90 $absRefPrefix = trim($tsfe->config[
'config'][
'absRefPrefix']);
91 if ($absRefPrefix ===
'auto') {
94 $tsfe->absRefPrefix = $absRefPrefix;
97 $tsfe->absRefPrefix =
'';
99 if ($tsfe->type && $tsfe->config[
'config'][
'frameReloadIfNotInFrameset']) {
100 $tdlLD = $tsfe->tmpl->linkData($tsfe->page,
'_top', $tsfe->no_cache,
'');
101 $tsfe->additionalJavaScript[
'JSCode'] .=
'if(!parent.' . trim($tsfe->sPre) .
' && !parent.view_frame) top.location.href="' . $tsfe->baseUrlWrap($tdlLD[
'totalURL']) .
'"';
103 $tsfe->compensateFieldWidth =
'' . $tsfe->config[
'config'][
'compensateFieldWidth'];
104 $tsfe->lockFilePath =
'' . $tsfe->config[
'config'][
'lockFilePath'];
105 $tsfe->lockFilePath = $tsfe->lockFilePath ?:
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'];
106 $GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_noScaleUp'] = isset($tsfe->config[
'config'][
'noScaleUp']) ?
'' . $tsfe->config[
'config'][
'noScaleUp'] :
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_noScaleUp'];
107 $tsfe->TYPO3_CONF_VARS[
'GFX'][
'im_noScaleUp'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_noScaleUp'];
108 $tsfe->ATagParams = trim($tsfe->config[
'config'][
'ATagParams']) ?
' ' . trim($tsfe->config[
'config'][
'ATagParams']) :
'';
109 if ($tsfe->config[
'config'][
'setJS_mouseOver']) {
110 $tsfe->setJS(
'mouseOver');
112 if ($tsfe->config[
'config'][
'setJS_openPic']) {
113 $tsfe->setJS(
'openPic');
115 static::initializeSearchWordDataInTsfe();
117 $tsfe->calculateLinkVars();
119 $tsfe->dtdAllowsFrames =
false;
120 if ($tsfe->config[
'config'][
'doctype']) {
122 (
string)$tsfe->config[
'config'][
'doctype'],
123 array(
'xhtml_trans',
'xhtml_frames',
'xhtml_basic',
'xhtml_2',
'html5'),
126 $tsfe->dtdAllowsFrames =
true;
129 $tsfe->dtdAllowsFrames =
true;
132 if (!$tsfe->config[
'config'][
'xhtmlDoctype']) {
133 $tsfe->config[
'config'][
'xhtmlDoctype'] = $tsfe->config[
'config'][
'doctype'];
135 if ($tsfe->config[
'config'][
'xhtmlDoctype']) {
136 $tsfe->xhtmlDoctype = $tsfe->config[
'config'][
'xhtmlDoctype'];
138 switch ((
string)$tsfe->config[
'config'][
'xhtmlDoctype']) {
144 $tsfe->xhtmlVersion = 100;
147 $tsfe->xhtmlVersion = 105;
151 case 'xhtml+rdfa_10':
152 $tsfe->xhtmlVersion = 110;
156 $tsfe->xhtmlVersion = 200;
159 static::getPageRenderer()->setRenderXhtml(
false);
160 $tsfe->xhtmlDoctype =
'';
161 $tsfe->xhtmlVersion = 0;
164 static::getPageRenderer()->setRenderXhtml(
false);
176 $functions = array();
177 $setEvents = array();
179 foreach (
$GLOBALS[
'TSFE']->JSeventFuncCalls as $event => $handlers) {
180 if (!empty($handlers)) {
182 $functions[] =
' function T3_' . $event .
'Wrapper(e) { ' . implode(
' ', $handlers) .
' }';
183 $setEvents[] =
' document.' . $event .
'=T3_' . $event .
'Wrapper;';
184 if ($event ==
'onload') {
186 $setBody[] =
'onload="T3_onloadWrapper();"';
190 return array(!empty($functions) ? implode(LF, $functions) . LF . implode(LF, $setEvents) :
'', $setBody);
198 public static function renderContent()
207 $timeTracker->incStackPointer();
208 $timeTracker->push($tsfe->sPre,
'PAGE');
209 $pageContent = $tsfe->cObj->cObjGet($tsfe->pSetup);
210 if ($tsfe->pSetup[
'wrap']) {
211 $pageContent = $tsfe->cObj->wrap($pageContent, $tsfe->pSetup[
'wrap']);
213 if ($tsfe->pSetup[
'stdWrap.']) {
214 $pageContent = $tsfe->cObj->stdWrap($pageContent, $tsfe->pSetup[
'stdWrap.']);
218 if ($tsfe->config[
'config'][
'disableAllHeaderCode']) {
219 $tsfe->content = $pageContent;
221 self::renderContentWithHeader($pageContent);
223 $timeTracker->pull($timeTracker->LR ? $tsfe->content :
'');
224 $timeTracker->decStackPointer();
233 public static function renderContentWithHeader($pageContent)
241 $pageRenderer = static::getPageRenderer();
242 if ($tsfe->config[
'config'][
'moveJsFromHeaderToFooter']) {
243 $pageRenderer->enableMoveJsFromHeaderToFooter();
245 if ($tsfe->config[
'config'][
'pageRendererTemplateFile']) {
246 $file = $tsfe->tmpl->getFileName($tsfe->config[
'config'][
'pageRendererTemplateFile']);
248 $pageRenderer->setTemplateFile($file);
251 $headerComment = $tsfe->config[
'config'][
'headerComment'];
252 if (trim($headerComment)) {
253 $pageRenderer->addInlineComment(TAB . str_replace(LF, (LF . TAB), trim($headerComment)) . LF);
256 $theCharset = $tsfe->metaCharset;
259 $htmlTagAttributes = array();
260 $htmlLang = $tsfe->config[
'config'][
'htmlTag_langKey'] ?: ($tsfe->sys_language_isocode ?:
'en');
262 if ($tsfe->config[
'config'][
'htmlTag_dir']) {
263 $htmlTagAttributes[
'dir'] = htmlspecialchars($tsfe->config[
'config'][
'htmlTag_dir']);
266 $docTypeParts = array();
269 switch ((
string)$tsfe->config[
'config'][
'xmlprologue']) {
271 $xmlDocument =
false;
274 $docTypeParts[] =
'<?xml version="1.0" encoding="' . $theCharset .
'"?>';
277 $docTypeParts[] =
'<?xml version="1.1" encoding="' . $theCharset .
'"?>';
280 if ($tsfe->xhtmlVersion) {
281 $docTypeParts[] =
'<?xml version="1.0" encoding="' . $theCharset .
'"?>';
283 $xmlDocument =
false;
287 $docTypeParts[] = $tsfe->config[
'config'][
'xmlprologue'];
290 $doctype = $tsfe->config[
'config'][
'doctype'];
294 $docTypeParts[] =
'<!DOCTYPE html
295 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
296 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
299 $docTypeParts[] =
'<!DOCTYPE html
300 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
301 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
304 $docTypeParts[] =
'<!DOCTYPE html
305 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
306 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
309 $docTypeParts[] =
'<!DOCTYPE html
310 PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
311 "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
314 $docTypeParts[] =
'<!DOCTYPE html
315 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
316 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
319 $docTypeParts[] =
'<!DOCTYPE html
320 PUBLIC "-//W3C//DTD XHTML 2.0//EN"
321 "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
323 case 'xhtml+rdfa_10':
324 $docTypeParts[] =
'<!DOCTYPE html
325 PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
326 "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">';
329 $docTypeParts[] =
'<!DOCTYPE html>';
331 $pageRenderer->setMetaCharsetTag(
'<meta charset="|" />');
333 $pageRenderer->setMetaCharsetTag(
'<meta charset="|">');
339 $docTypeParts[] = $doctype;
342 $docTypeParts[] =
'<!DOCTYPE html>';
344 $pageRenderer->setMetaCharsetTag(
'<meta charset="|" />');
346 $pageRenderer->setMetaCharsetTag(
'<meta charset="|">');
349 if ($tsfe->xhtmlVersion) {
350 $htmlTagAttributes[
'xml:lang'] = $htmlLang;
352 if ($tsfe->xhtmlVersion < 110 || $doctype ===
'html5') {
353 $htmlTagAttributes[
'lang'] = $htmlLang;
355 if ($tsfe->xhtmlVersion || $doctype ===
'html5' && $xmlDocument) {
357 $htmlTagAttributes[
'xmlns'] =
'http://www.w3.org/1999/xhtml';
358 if (is_array($tsfe->config[
'config'][
'namespaces.'])) {
359 foreach ($tsfe->config[
'config'][
'namespaces.'] as $prefix => $uri) {
361 $htmlTagAttributes[
'xmlns:' . htmlspecialchars($prefix)] = $uri;
366 if ($tsfe->config[
'config'][
'doctypeSwitch']) {
367 $docTypeParts = array_reverse($docTypeParts);
370 if (!empty($docTypeParts)) {
371 $pageRenderer->setXmlPrologAndDocType(implode(LF, $docTypeParts));
374 if ($tsfe->config[
'config'][
'htmlTag_setParams'] !==
'none') {
379 $htmlTag =
'<html' . ($_attr ?
' ' . $_attr :
'') .
'>';
380 if (isset($tsfe->config[
'config'][
'htmlTag_stdWrap.'])) {
381 $htmlTag = $tsfe->cObj->stdWrap($htmlTag, $tsfe->config[
'config'][
'htmlTag_stdWrap.']);
383 $pageRenderer->setHtmlTag($htmlTag);
385 $headTag = $tsfe->pSetup[
'headTag'] ?:
'<head>';
386 if (isset($tsfe->pSetup[
'headTag.'])) {
387 $headTag = $tsfe->cObj->stdWrap($headTag, $tsfe->pSetup[
'headTag.']);
389 $pageRenderer->setHeadTag($headTag);
391 $pageRenderer->setCharSet($theCharset);
392 $pageRenderer->addInlineComment(
' This website is powered by TYPO3 - inspiring people to share!
393 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
394 TYPO3 is copyright ' . TYPO3_copyright_year .
' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
395 Information and contribution at ' . TYPO3_URL_GENERAL .
'
397 if ($tsfe->baseUrl) {
398 $pageRenderer->setBaseUrl($tsfe->baseUrl);
400 if ($tsfe->pSetup[
'shortcutIcon']) {
401 $favIcon = $tsfe->tmpl->getFileName($tsfe->pSetup[
'shortcutIcon']);
403 if ($iconFileInfo->isFile()) {
404 $iconMimeType = $iconFileInfo->getMimeType();
406 $iconMimeType =
' type="' . $iconMimeType .
'"';
407 $pageRenderer->setIconMimeType($iconMimeType);
413 if (is_array($tsfe->tmpl->setup[
'plugin.'])) {
414 $stylesFromPlugins =
'';
415 foreach ($tsfe->tmpl->setup[
'plugin.'] as $key => $iCSScode) {
416 if (is_array($iCSScode)) {
417 if ($iCSScode[
'_CSS_DEFAULT_STYLE'] && empty($tsfe->config[
'config'][
'removeDefaultCss'])) {
418 if (isset($iCSScode[
'_CSS_DEFAULT_STYLE.'])) {
419 $cssDefaultStyle = $tsfe->cObj->stdWrap($iCSScode[
'_CSS_DEFAULT_STYLE'], $iCSScode[
'_CSS_DEFAULT_STYLE.']);
421 $cssDefaultStyle = $iCSScode[
'_CSS_DEFAULT_STYLE'];
423 $stylesFromPlugins .=
'/* default styles for extension "' . substr($key, 0, -1) .
'" */' . LF . $cssDefaultStyle . LF;
425 if ($iCSScode[
'_CSS_PAGE_STYLE'] && empty($tsfe->config[
'config'][
'removePageCss'])) {
426 $cssPageStyle = implode(LF, $iCSScode[
'_CSS_PAGE_STYLE']);
427 if (isset($iCSScode[
'_CSS_PAGE_STYLE.'])) {
428 $cssPageStyle = $tsfe->cObj->stdWrap($cssPageStyle, $iCSScode[
'_CSS_PAGE_STYLE.']);
430 $cssPageStyle =
'/* specific page styles for extension "' . substr($key, 0, -1) .
'" */' . LF . $cssPageStyle;
431 self::addCssToPageRenderer($cssPageStyle,
true);
435 if (!empty($stylesFromPlugins)) {
436 self::addCssToPageRenderer($stylesFromPlugins);
439 if ($tsfe->pSetup[
'stylesheet']) {
440 $ss = $tsfe->tmpl->getFileName($tsfe->pSetup[
'stylesheet']);
442 $pageRenderer->addCssFile($ss);
448 if (is_array($tsfe->pSetup[
'includeCSS.'])) {
449 foreach ($tsfe->pSetup[
'includeCSS.'] as $key => $CSSfile) {
450 if (!is_array($CSSfile)) {
451 $cssFileConfig = &$tsfe->pSetup[
'includeCSS.'][$key .
'.'];
452 if (isset($cssFileConfig[
'if.']) && !$tsfe->cObj->checkIf($cssFileConfig[
'if.'])) {
455 $ss = $cssFileConfig[
'external'] ? $CSSfile : $tsfe->tmpl->getFileName($CSSfile);
457 if ($cssFileConfig[
'import']) {
458 if (!$cssFileConfig[
'external'] && $ss[0] !==
'/') {
462 $pageRenderer->addCssInlineBlock(
'import_' . $key,
'@import url("' . htmlspecialchars($ss) .
'") ' . htmlspecialchars($cssFileConfig[
'media']) .
';', empty($cssFileConfig[
'disableCompression']), (
bool)$cssFileConfig[
'forceOnTop'],
'');
464 $pageRenderer->addCssFile(
466 $cssFileConfig[
'alternate'] ?
'alternate stylesheet' :
'stylesheet',
467 $cssFileConfig[
'media'] ?:
'all',
468 $cssFileConfig[
'title'] ?:
'',
469 empty($cssFileConfig[
'disableCompression']),
470 (
bool)$cssFileConfig[
'forceOnTop'],
471 $cssFileConfig[
'allWrap'],
472 (
bool)$cssFileConfig[
'excludeFromConcatenation'],
473 $cssFileConfig[
'allWrap.'][
'splitChar']
475 unset($cssFileConfig);
481 if (is_array($tsfe->pSetup[
'includeCSSLibs.'])) {
482 foreach ($tsfe->pSetup[
'includeCSSLibs.'] as $key => $CSSfile) {
483 if (!is_array($CSSfile)) {
484 $cssFileConfig = &$tsfe->pSetup[
'includeCSSLibs.'][$key .
'.'];
485 if (isset($cssFileConfig[
'if.']) && !$tsfe->cObj->checkIf($cssFileConfig[
'if.'])) {
488 $ss = $cssFileConfig[
'external'] ? $CSSfile : $tsfe->tmpl->getFileName($CSSfile);
490 if ($cssFileConfig[
'import']) {
491 if (!$cssFileConfig[
'external'] && $ss[0] !==
'/') {
495 $pageRenderer->addCssInlineBlock(
'import_' . $key,
'@import url("' . htmlspecialchars($ss) .
'") ' . htmlspecialchars($cssFileConfig[
'media']) .
';', empty($cssFileConfig[
'disableCompression']), (
bool)$cssFileConfig[
'forceOnTop'],
'');
497 $pageRenderer->addCssLibrary(
499 $cssFileConfig[
'alternate'] ?
'alternate stylesheet' :
'stylesheet',
500 $cssFileConfig[
'media'] ?:
'all',
501 $cssFileConfig[
'title'] ?:
'',
502 empty($cssFileConfig[
'disableCompression']),
503 (
bool)$cssFileConfig[
'forceOnTop'],
504 $cssFileConfig[
'allWrap'],
505 (
bool)$cssFileConfig[
'excludeFromConcatenation'],
506 $cssFileConfig[
'allWrap.'][
'splitChar']
508 unset($cssFileConfig);
517 if ($tsfe->pSetup[
'insertClassesFromRTE']) {
518 $pageTSConfig = $tsfe->getPagesTSconfig();
519 $RTEclasses = $pageTSConfig[
'RTE.'][
'classes.'];
520 if (is_array($RTEclasses)) {
521 foreach ($RTEclasses as $RTEclassName => $RTEvalueArray) {
522 if ($RTEvalueArray[
'value']) {
524 .' . substr($RTEclassName, 0, -1) .
' {' . $RTEvalueArray[
'value'] .
'}';
528 if ($tsfe->pSetup[
'insertClassesFromRTE.'][
'add_mainStyleOverrideDefs'] && is_array($pageTSConfig[
'RTE.'][
'default.'][
'mainStyleOverride_add.'])) {
529 $mSOa_tList =
GeneralUtility::trimExplode(
',', strtoupper($tsfe->pSetup[
'insertClassesFromRTE.'][
'add_mainStyleOverrideDefs']),
true);
530 foreach ($pageTSConfig[
'RTE.'][
'default.'][
'mainStyleOverride_add.'] as $mSOa_key => $mSOa_value) {
531 if (!is_array($mSOa_value) && (in_array(
'*', $mSOa_tList) || in_array($mSOa_key, $mSOa_tList))) {
533 ' . $mSOa_key .
' {' . $mSOa_value .
'}';
539 if (isset($tsfe->pSetup[
'bodyTagMargins']) && $tsfe->pSetup[
'bodyTagMargins.'][
'useCSS']) {
540 $margins = (int)$tsfe->pSetup[
'bodyTagMargins'];
542 BODY {margin: ' . $margins .
'px ' . $margins .
'px ' . $margins .
'px ' . $margins .
'px;}';
545 $style .= trim($tsfe->pSetup[
'CSS_inlineStyle']);
546 $style .= $tsfe->cObj->cObjGet($tsfe->pSetup[
'cssInline.'],
'cssInline.');
548 self::addCssToPageRenderer($style,
true,
'additionalTSFEInlineStyle');
551 if (is_array($tsfe->pSetup[
'javascriptLibs.'])) {
553 if (!empty($tsfe->pSetup[
'javascriptLibs.'][
'jQuery'])) {
554 $jQueryTS = $tsfe->pSetup[
'javascriptLibs.'][
'jQuery.'];
556 $version = isset($jQueryTS[
'version']) ? $jQueryTS[
'version'] : null;
557 $source = isset($jQueryTS[
'source']) ? $jQueryTS[
'source'] : null;
559 if (!isset($jQueryTS[
'noConflict']) || !empty($jQueryTS[
'noConflict'])) {
561 if (!empty($jQueryTS[
'noConflict.'][
'namespace'])) {
562 $namespace = $jQueryTS[
'noConflict.'][
'namespace'];
569 $pageRenderer->loadJQuery($version, $source, $namespace);
571 if ($tsfe->pSetup[
'javascriptLibs.'][
'ExtJs']) {
572 $css = (bool)$tsfe->pSetup[
'javascriptLibs.'][
'ExtJs.'][
'css'];
573 $theme = (
bool)$tsfe->pSetup[
'javascriptLibs.'][
'ExtJs.'][
'theme'];
574 $pageRenderer->loadExtJs($css, $theme);
575 if ($tsfe->pSetup[
'javascriptLibs.'][
'ExtJs.'][
'debug']) {
576 $pageRenderer->enableExtJsDebug();
581 if (is_array($tsfe->pSetup[
'includeJSlibs.']) || is_array($tsfe->pSetup[
'includeJSLibs.'])) {
582 if (!is_array($tsfe->pSetup[
'includeJSlibs.'])) {
583 $tsfe->pSetup[
'includeJSlibs.'] = array();
585 GeneralUtility::deprecationLog(
'The property page.includeJSlibs is marked for deprecation and will be removed in TYPO3 CMS 8. Please use page.includeJSLibs (with an uppercase L) instead.');
587 if (!is_array($tsfe->pSetup[
'includeJSLibs.'])) {
588 $tsfe->pSetup[
'includeJSLibs.'] = array();
591 $tsfe->pSetup[
'includeJSLibs.'],
592 $tsfe->pSetup[
'includeJSlibs.']
594 unset($tsfe->pSetup[
'includeJSlibs.']);
595 foreach ($tsfe->pSetup[
'includeJSLibs.'] as $key => $JSfile) {
596 if (!is_array($JSfile)) {
597 if (isset($tsfe->pSetup[
'includeJSLibs.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJSLibs.'][($key .
'.')][
'if.'])) {
600 $ss = $tsfe->pSetup[
'includeJSLibs.'][$key .
'.'][
'external'] ? $JSfile : $tsfe->tmpl->getFileName($JSfile);
602 $jsFileConfig = &$tsfe->pSetup[
'includeJSLibs.'][$key .
'.'];
603 $type = $jsFileConfig[
'type'];
605 $type =
'text/javascript';
608 $pageRenderer->addJsLibrary(
612 empty($jsFileConfig[
'disableCompression']),
613 (
bool)$jsFileConfig[
'forceOnTop'],
614 $jsFileConfig[
'allWrap'],
615 (
bool)$jsFileConfig[
'excludeFromConcatenation'],
616 $jsFileConfig[
'allWrap.'][
'splitChar'],
617 (
bool)$jsFileConfig[
'async'],
618 $jsFileConfig[
'integrity']
620 unset($jsFileConfig);
625 if (is_array($tsfe->pSetup[
'includeJSFooterlibs.'])) {
626 foreach ($tsfe->pSetup[
'includeJSFooterlibs.'] as $key => $JSfile) {
627 if (!is_array($JSfile)) {
628 if (isset($tsfe->pSetup[
'includeJSFooterlibs.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJSFooterlibs.'][($key .
'.')][
'if.'])) {
631 $ss = $tsfe->pSetup[
'includeJSFooterlibs.'][$key .
'.'][
'external'] ? $JSfile : $tsfe->tmpl->getFileName($JSfile);
633 $jsFileConfig = &$tsfe->pSetup[
'includeJSFooterlibs.'][$key .
'.'];
634 $type = $jsFileConfig[
'type'];
636 $type =
'text/javascript';
638 $pageRenderer->addJsFooterLibrary(
642 empty($jsFileConfig[
'disableCompression']),
643 (
bool)$jsFileConfig[
'forceOnTop'],
644 $jsFileConfig[
'allWrap'],
645 (
bool)$jsFileConfig[
'excludeFromConcatenation'],
646 $jsFileConfig[
'allWrap.'][
'splitChar'],
647 (
bool)$jsFileConfig[
'async'],
648 $jsFileConfig[
'integrity']
650 unset($jsFileConfig);
656 if (is_array($tsfe->pSetup[
'includeJS.'])) {
657 foreach ($tsfe->pSetup[
'includeJS.'] as $key => $JSfile) {
658 if (!is_array($JSfile)) {
659 if (isset($tsfe->pSetup[
'includeJS.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJS.'][($key .
'.')][
'if.'])) {
662 $ss = $tsfe->pSetup[
'includeJS.'][$key .
'.'][
'external'] ? $JSfile : $tsfe->tmpl->getFileName($JSfile);
664 $jsConfig = &$tsfe->pSetup[
'includeJS.'][$key .
'.'];
665 $type = $jsConfig[
'type'];
667 $type =
'text/javascript';
669 $pageRenderer->addJsFile(
672 empty($jsConfig[
'disableCompression']),
673 (
bool)$jsConfig[
'forceOnTop'],
674 $jsConfig[
'allWrap'],
675 (
bool)$jsConfig[
'excludeFromConcatenation'],
676 $jsConfig[
'allWrap.'][
'splitChar'],
677 (
bool)$jsConfig[
'async'],
678 $jsConfig[
'integrity']
685 if (is_array($tsfe->pSetup[
'includeJSFooter.'])) {
686 foreach ($tsfe->pSetup[
'includeJSFooter.'] as $key => $JSfile) {
687 if (!is_array($JSfile)) {
688 if (isset($tsfe->pSetup[
'includeJSFooter.'][$key .
'.'][
'if.']) && !$tsfe->cObj->checkIf($tsfe->pSetup[
'includeJSFooter.'][($key .
'.')][
'if.'])) {
691 $ss = $tsfe->pSetup[
'includeJSFooter.'][$key .
'.'][
'external'] ? $JSfile : $tsfe->tmpl->getFileName($JSfile);
693 $jsConfig = &$tsfe->pSetup[
'includeJSFooter.'][$key .
'.'];
694 $type = $jsConfig[
'type'];
696 $type =
'text/javascript';
698 $pageRenderer->addJsFooterFile(
701 empty($jsConfig[
'disableCompression']),
702 (
bool)$jsConfig[
'forceOnTop'],
703 $jsConfig[
'allWrap'],
704 (
bool)$jsConfig[
'excludeFromConcatenation'],
705 $jsConfig[
'allWrap.'][
'splitChar'],
706 (
bool)$jsConfig[
'async'],
707 $jsConfig[
'integrity']
715 if (is_array($tsfe->pSetup[
'headerData.'])) {
716 $pageRenderer->addHeaderData($tsfe->cObj->cObjGet($tsfe->pSetup[
'headerData.'],
'headerData.'));
719 if (is_array($tsfe->pSetup[
'footerData.'])) {
720 $pageRenderer->addFooterData($tsfe->cObj->cObjGet($tsfe->pSetup[
'footerData.'],
'footerData.'));
722 static::generatePageTitle();
724 $metaTagsHtml = static::generateMetaTagHtml(
725 isset($tsfe->pSetup[
'meta.']) ? $tsfe->pSetup[
'meta.'] : array(),
729 foreach ($metaTagsHtml as $metaTag) {
730 $pageRenderer->addMetaTag($metaTag);
733 unset($tsfe->additionalHeaderData[
'JSCode']);
734 if (is_array($tsfe->config[
'INTincScript'])) {
735 $tsfe->additionalHeaderData[
'JSCode'] = $tsfe->JSCode;
737 $tsfe->config[
'INTincScript_ext'][
'divKey'] = $tsfe->uniqueHash();
738 $tsfe->config[
'INTincScript_ext'][
'additionalHeaderData'] = $tsfe->additionalHeaderData;
740 $tsfe->config[
'INTincScript_ext'][
'additionalFooterData'] = $tsfe->additionalFooterData;
742 $tsfe->config[
'INTincScript_ext'][
'additionalJavaScript'] = $tsfe->additionalJavaScript;
744 $tsfe->config[
'INTincScript_ext'][
'additionalCSS'] = $tsfe->additionalCSS;
746 $tsfe->additionalHeaderData = array(
'<!--HD_' . $tsfe->config[
'INTincScript_ext'][
'divKey'] .
'-->');
748 $tsfe->additionalFooterData = array(
'<!--FD_' . $tsfe->config[
'INTincScript_ext'][
'divKey'] .
'-->');
750 $tsfe->divSection .=
'<!--TDS_' . $tsfe->config[
'INTincScript_ext'][
'divKey'] .
'-->';
752 $tsfe->INTincScript_loadJSCode();
754 $JSef = self::JSeventFunctions();
755 $scriptJsCode = $JSef[0];
757 if ($tsfe->spamProtectEmailAddresses && $tsfe->spamProtectEmailAddresses !==
'ascii') {
759 // decrypt helper function
760 function decryptCharcode(n,start,end,offset) {
762 if (offset > 0 && n > end) {
763 n = start + (n - end - 1);
764 } else if (offset < 0 && n < start) {
765 n = end - (start - n - 1);
767 return String.fromCharCode(n);
770 function decryptString(enc,offset) {
772 var len = enc.length;
773 for(var i=0; i < len; i++) {
774 var n = enc.charCodeAt(i);
775 if (n >= 0x2B && n <= 0x3A) {
776 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
777 } else if (n >= 0x40 && n <= 0x5A) {
778 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
779 } else if (n >= 0x61 && n <= 0x7A) {
780 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
782 dec += enc.charAt(i);
787 // decrypt spam-protected emails
788 function linkTo_UnCryptMailto(s) {
789 location.href = decryptString(s,' . $tsfe->spamProtectEmailAddresses * -1 .
');
796 if (is_array($tsfe->inlineJS)) {
797 foreach ($tsfe->inlineJS as $key => $val) {
798 if (!is_array($val)) {
799 $inlineJS .= LF . $val . LF;
805 $inline = $tsfe->cObj->cObjGet($tsfe->pSetup[
'jsInline.'],
'jsInline.');
807 $inlineJS .= LF . $inline . LF;
810 $inlineFooterJs = $tsfe->cObj->cObjGet($tsfe->pSetup[
'jsFooterInline.'],
'jsFooterInline.');
812 if ($tsfe->config[
'config'][
'compressJs']) {
813 $pageRenderer->enableCompressJavascript();
814 $minifyErrorScript = ($minifyErrorInline =
'');
816 if ($minifyErrorScript) {
817 $timeTracker->setTSlogMessage($minifyErrorScript, 3);
821 if ($minifyErrorInline) {
822 $timeTracker->setTSlogMessage($minifyErrorInline, 3);
825 if ($inlineFooterJs) {
827 if ($minifyErrorInline) {
828 $timeTracker->setTSlogMessage($minifyErrorInline, 3);
832 if (!$tsfe->config[
'config'][
'removeDefaultJS']) {
835 $pageRenderer->addJsInlineCode(
'_scriptCode', $scriptJsCode, $tsfe->config[
'config'][
'compressJs']);
838 $pageRenderer->addJsInlineCode(
'TS_inlineJS', $inlineJS, $tsfe->config[
'config'][
'compressJs']);
840 if ($inlineFooterJs) {
841 $pageRenderer->addJsFooterInlineCode(
'TS_inlineFooter', $inlineFooterJs, $tsfe->config[
'config'][
'compressJs']);
843 }
elseif ($tsfe->config[
'config'][
'removeDefaultJS'] ===
'external') {
854 self::stripIntObjectPlaceholder($inlineJS, $inlineJSint);
856 $pageRenderer->addJsInlineCode(
'TS_inlineJSint', $inlineJSint, $tsfe->config[
'config'][
'compressJs']);
858 if (trim($scriptJsCode . $inlineJS)) {
859 $pageRenderer->addJsFile(self::inline2TempFile($scriptJsCode . $inlineJS,
'js'),
'text/javascript', $tsfe->config[
'config'][
'compressJs']);
861 if ($inlineFooterJs) {
862 $inlineFooterJSint =
'';
863 self::stripIntObjectPlaceholder($inlineFooterJs, $inlineFooterJSint);
864 if ($inlineFooterJSint) {
865 $pageRenderer->addJsFooterInlineCode(
'TS_inlineFooterJSint', $inlineFooterJSint, $tsfe->config[
'config'][
'compressJs']);
867 $pageRenderer->addJsFooterFile(self::inline2TempFile($inlineFooterJs,
'js'),
'text/javascript', $tsfe->config[
'config'][
'compressJs']);
872 $pageRenderer->addJsInlineCode(
'TS_inlineJS', $inlineJS, $tsfe->config[
'config'][
'compressJs']);
874 if ($inlineFooterJs) {
875 $pageRenderer->addJsFooterInlineCode(
'TS_inlineFooter', $inlineFooterJs, $tsfe->config[
'config'][
'compressJs']);
878 if (is_array($tsfe->pSetup[
'inlineLanguageLabelFiles.'])) {
879 foreach ($tsfe->pSetup[
'inlineLanguageLabelFiles.'] as $key => $languageFile) {
880 if (is_array($languageFile)) {
883 $languageFileConfig = &$tsfe->pSetup[
'inlineLanguageLabelFiles.'][$key .
'.'];
884 if (isset($languageFileConfig[
'if.']) && !$tsfe->cObj->checkIf($languageFileConfig[
'if.'])) {
887 $pageRenderer->addInlineLanguageLabelFile(
889 $languageFileConfig[
'selectionPrefix'] ?:
'',
890 $languageFileConfig[
'stripFromSelectionName'] ?:
'',
891 $languageFileConfig[
'errorMode'] ? (
int)$languageFileConfig[
'errorMode'] : 0
896 if (is_array($tsfe->pSetup[
'inlineLanguageLabel.'])) {
897 $pageRenderer->addInlineLanguageLabelArray($tsfe->pSetup[
'inlineLanguageLabel.'],
true);
899 if (is_array($tsfe->pSetup[
'inlineSettings.'])) {
900 $pageRenderer->addInlineSettingArray(
'TS', $tsfe->pSetup[
'inlineSettings.']);
902 if (is_array($tsfe->pSetup[
'extOnReady.'])) {
903 $pageRenderer->addExtOnReadyCode($tsfe->cObj->cObjGet($tsfe->pSetup[
'extOnReady.'],
'extOnReady.'));
906 if ($tsfe->config[
'config'][
'compressCss']) {
907 $pageRenderer->enableCompressCss();
909 if ($tsfe->config[
'config'][
'compressJs']) {
910 $pageRenderer->enableCompressJavascript();
912 if ($tsfe->config[
'config'][
'concatenateCss']) {
913 $pageRenderer->enableConcatenateCss();
915 if ($tsfe->config[
'config'][
'concatenateJs']) {
916 $pageRenderer->enableConcatenateJavascript();
919 if ($tsfe->config[
'config'][
'concatenateJsAndCss']) {
920 $pageRenderer->enableConcatenateFiles();
923 if ($tsfe->additionalHeaderData) {
924 $pageRenderer->addHeaderData(implode(LF, $tsfe->additionalHeaderData));
927 if ($tsfe->additionalFooterData) {
928 $pageRenderer->addFooterData(implode(LF, $tsfe->additionalFooterData));
931 if ($tsfe->pSetup[
'frameSet.']) {
933 $pageRenderer->addBodyContent($fs->make($tsfe->pSetup[
'frameSet.']));
934 $pageRenderer->addBodyContent(LF .
'<noframes>' . LF);
937 if ($tsfe->config[
'config'][
'disableBodyTag']) {
940 $defBT = $tsfe->pSetup[
'bodyTagCObject'] ? $tsfe->cObj->cObjGetSingle($tsfe->pSetup[
'bodyTagCObject'], $tsfe->pSetup[
'bodyTagCObject.'],
'bodyTagCObject') :
'';
942 $defBT = $tsfe->defaultBodyTag;
944 $bodyTag = $tsfe->pSetup[
'bodyTag'] ? $tsfe->pSetup[
'bodyTag'] : $defBT;
945 if ($bgImg = $tsfe->cObj->getImgResource($tsfe->pSetup[
'bgImg'], $tsfe->pSetup[
'bgImg.'])) {
947 $bodyTag = preg_replace(
'/>$/',
'', trim($bodyTag)) .
' background="' . $tsfe->absRefPrefix . $bgImg[3] .
'">';
949 if (isset($tsfe->pSetup[
'bodyTagMargins'])) {
950 $margins = (int)$tsfe->pSetup[
'bodyTagMargins'];
951 if ($tsfe->pSetup[
'bodyTagMargins.'][
'useCSS']) {
953 $bodyTag = preg_replace(
'/>$/',
'', trim($bodyTag)) .
' leftmargin="' . $margins .
'" topmargin="' . $margins .
'" marginwidth="' . $margins .
'" marginheight="' . $margins .
'">';
956 if (trim($tsfe->pSetup[
'bodyTagAdd'])) {
957 $bodyTag = preg_replace(
'/>$/',
'', trim($bodyTag)) .
' ' . trim($tsfe->pSetup[
'bodyTagAdd']) .
'>';
960 if (!empty($JSef[1])) {
961 $bodyTag = preg_replace(
'/>$/',
'', trim($bodyTag)) .
' ' . trim(implode(
' ', $JSef[1])) .
'>';
964 $pageRenderer->addBodyContent(LF . $bodyTag);
966 if ($tsfe->divSection) {
967 $pageRenderer->addBodyContent(LF . $tsfe->divSection);
970 $pageRenderer->addBodyContent(LF . $pageContent);
971 if (!empty($tsfe->config[
'INTincScript']) && is_array($tsfe->config[
'INTincScript'])) {
973 $tsfe->config[
'INTincScript_ext'][
'pageRenderer'] = serialize($pageRenderer);
975 $tsfe->content = $pageRenderer->renderPageWithUncachedObjects($tsfe->config[
'INTincScript_ext'][
'divKey']);
978 $tsfe->content = $pageRenderer->render();
981 if ($tsfe->pSetup[
'frameSet.']) {
982 $tsfe->content .= LF .
'</noframes>';
1001 $tempArray = array();
1002 preg_match_all(
'/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/', $searchString, $tempArray);
1003 $searchString = preg_replace(
'/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/',
'', $searchString);
1004 $intObjects = implode(
'', $tempArray[0]);
1020 $script =
'typo3temp/Assets/' . substr(md5($str), 0, 10) .
'.js';
1023 $script =
'typo3temp/Assets/' . substr(md5($str), 0, 10) .
'.css';
1028 if (!@is_file(PATH_site . $script)) {
1046 if ($needle ==
'int' || $needle ==
'integer') {
1050 }
elseif (preg_match(
'/^\\/.+\\/[imsxeADSUXu]*$/', $needle)) {
1052 if (@preg_match($needle, $haystack)) {
1055 }
elseif (strstr($needle,
'-')) {
1058 $range = explode(
'-', $needle);
1059 if ($range[0] <= $haystack && $range[1] >= $haystack) {
1063 }
elseif (strstr($needle,
'|')) {
1066 $haystack = str_replace(
' ',
'', $haystack);
1067 if (strstr(
'|' . $needle .
'|',
'|' . $haystack .
'|')) {
1070 }
elseif ((
string)$needle === (
string)$haystack) {
1085 public static function generatePageTitle()
1090 $pageTitleSeparator =
'';
1093 if (isset($tsfe->config[
'config'][
'pageTitleSeparator']) && $tsfe->config[
'config'][
'pageTitleSeparator'] !==
'') {
1094 $pageTitleSeparator = $tsfe->config[
'config'][
'pageTitleSeparator'];
1096 if (isset($tsfe->config[
'config'][
'pageTitleSeparator.']) && is_array($tsfe->config[
'config'][
'pageTitleSeparator.'])) {
1097 $pageTitleSeparator = $tsfe->cObj->stdWrap($pageTitleSeparator, $tsfe->config[
'config'][
'pageTitleSeparator.']);
1099 $pageTitleSeparator .=
' ';
1103 $titleTagContent = $tsfe->tmpl->printTitle(
1104 $tsfe->altPageTitle ?: $tsfe->page[
'title'],
1105 $tsfe->config[
'config'][
'noPageTitle'],
1106 $tsfe->config[
'config'][
'pageTitleFirst'],
1109 if ($tsfe->config[
'config'][
'titleTagFunction']) {
1110 $titleTagContent = $tsfe->cObj->callUserFunction(
1111 $tsfe->config[
'config'][
'titleTagFunction'],
1117 if (isset($tsfe->config[
'config'][
'pageTitle.']) && is_array($tsfe->config[
'config'][
'pageTitle.'])) {
1118 $titleTagContent = $tsfe->cObj->stdWrap($titleTagContent, $tsfe->config[
'config'][
'pageTitle.']);
1120 if ($titleTagContent !==
'' && (
int)$tsfe->config[
'config'][
'noPageTitle'] !== self::NO_PAGE_TITLE) {
1121 static::getPageRenderer()->setTitle($titleTagContent);
1133 protected static function generateMetaTagHtml(array $metaTagTypoScript, $xhtml, ContentObjectRenderer $cObj)
1136 $endingSlash = $xhtml ?
' /' :
'';
1139 '<meta name="generator" content="TYPO3 CMS"' . $endingSlash .
'>'
1144 $conf = $typoScriptService->convertTypoScriptArrayToPlainArray($metaTagTypoScript);
1145 foreach ($conf as $key => $properties) {
1146 if (is_array($properties)) {
1147 $nodeValue = isset($properties[
'_typoScriptNodeValue']) ? $properties[
'_typoScriptNodeValue'] :
'';
1148 $value = trim($cObj->stdWrap($nodeValue, $metaTagTypoScript[$key .
'.']));
1149 if ($value ===
'' && !empty($properties[
'value'])) {
1150 $value = $properties[
'value'];
1153 $value = $properties;
1156 $attribute =
'name';
1157 if ((is_array($properties) && !empty($properties[
'httpEquivalent'])) || strtolower($key) ===
'refresh') {
1158 $attribute =
'http-equiv';
1160 if (is_array($properties) && !empty($properties[
'attribute'])) {
1161 $attribute = $properties[
'attribute'];
1164 if (!is_array($value)) {
1165 $value = (array)$value;
1167 foreach ($value as $subValue) {
1168 if (trim($subValue) !==
'') {
1169 $metaTags[] =
'<meta ' . $attribute .
'="' . $key .
'" content="' . htmlspecialchars($subValue) .
'"' . $endingSlash .
'>';
1183 protected static function initializeSearchWordDataInTsfe()
1188 $tsfe->sWordRegEx =
'';
1190 if (is_array($tsfe->sWordList)) {
1191 $space = !empty($tsfe->config[
'config'][
'sword_standAlone']) ?
'[[:space:]]' :
'';
1192 foreach ($tsfe->sWordList as $val) {
1193 if (trim($val) !==
'') {
1194 $tsfe->sWordRegEx .= $space . preg_quote($val,
'/') . $space .
'|';
1197 $tsfe->sWordRegEx = rtrim($tsfe->sWordRegEx,
'|');
1216 protected static function addCssToPageRenderer($cssStyles, $excludeFromConcatenation =
false, $inlineBlockName =
'TSFEinlineStyle')
1218 if (empty(
$GLOBALS[
'TSFE']->config[
'config'][
'inlineStyle2TempFile'])) {
1219 self::getPageRenderer()->addCssInlineBlock($inlineBlockName, $cssStyles, !empty(
$GLOBALS[
'TSFE']->config[
'config'][
'compressCss']));
1221 self::getPageRenderer()->addCssFile(
1222 self::inline2TempFile($cssStyles,
'css'),
1226 (
bool)
$GLOBALS[
'TSFE']->config[
'config'][
'compressCss'],
1229 $excludeFromConcatenation