[BUGFIX] Respect different object mapping for scheduler tasks
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Page / PageGenerator.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Page;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Extbase\Service\TypoScriptService;
19 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
20
21 /**
22 * Class for starting TypoScript page generation
23 *
24 * The class is not instantiated as an objects but called directly with the "::" operator.
25 * eg: TSpagegen::pagegenInit()
26 *
27 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
28 */
29 class PageGenerator {
30
31 /**
32 * Do not render title tag
33 * Typoscript setting: [config][noPageTitle]
34 */
35 const NO_PAGE_TITLE = 2;
36
37 /**
38 * Setting some vars in TSFE, primarily based on TypoScript config settings.
39 *
40 * @return void
41 */
42 static public function pagegenInit() {
43 if ($GLOBALS['TSFE']->page['content_from_pid'] > 0) {
44 // make REAL copy of TSFE object - not reference!
45 $temp_copy_TSFE = clone $GLOBALS['TSFE'];
46 // Set ->id to the content_from_pid value - we are going to evaluate this pid as was it a given id for a page-display!
47 $temp_copy_TSFE->id = $GLOBALS['TSFE']->page['content_from_pid'];
48 $temp_copy_TSFE->MP = '';
49 $temp_copy_TSFE->getPageAndRootlineWithDomain($GLOBALS['TSFE']->config['config']['content_from_pid_allowOutsideDomain'] ? 0 : $GLOBALS['TSFE']->domainStartPage);
50 $GLOBALS['TSFE']->contentPid = (int)$temp_copy_TSFE->id;
51 unset($temp_copy_TSFE);
52 }
53 if ($GLOBALS['TSFE']->config['config']['MP_defaults']) {
54 $temp_parts = GeneralUtility::trimExplode('|', $GLOBALS['TSFE']->config['config']['MP_defaults'], TRUE);
55 foreach ($temp_parts as $temp_p) {
56 list($temp_idP, $temp_MPp) = explode(':', $temp_p, 2);
57 $temp_ids = GeneralUtility::intExplode(',', $temp_idP);
58 foreach ($temp_ids as $temp_id) {
59 $GLOBALS['TSFE']->MP_defaults[$temp_id] = $temp_MPp;
60 }
61 }
62 }
63 // Global vars...
64 $GLOBALS['TSFE']->indexedDocTitle = $GLOBALS['TSFE']->page['title'];
65 $GLOBALS['TSFE']->debug = '' . $GLOBALS['TSFE']->config['config']['debug'];
66 // Base url:
67 if (isset($GLOBALS['TSFE']->config['config']['baseURL'])) {
68 $GLOBALS['TSFE']->baseUrl = $GLOBALS['TSFE']->config['config']['baseURL'];
69 $GLOBALS['TSFE']->anchorPrefix = substr(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_URL')));
70 }
71 // Internal and External target defaults
72 $GLOBALS['TSFE']->intTarget = '' . $GLOBALS['TSFE']->config['config']['intTarget'];
73 $GLOBALS['TSFE']->extTarget = '' . $GLOBALS['TSFE']->config['config']['extTarget'];
74 $GLOBALS['TSFE']->fileTarget = '' . $GLOBALS['TSFE']->config['config']['fileTarget'];
75 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'] === 'ascii') {
76 $GLOBALS['TSFE']->spamProtectEmailAddresses = 'ascii';
77 } else {
78 $GLOBALS['TSFE']->spamProtectEmailAddresses = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'], -10, 10, 0);
79 }
80 $GLOBALS['TSFE']->absRefPrefix = $GLOBALS['TSFE']->config['config']['absRefPrefix'] ? trim($GLOBALS['TSFE']->config['config']['absRefPrefix']) : '';
81 if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) {
82 $tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, '_top', $GLOBALS['TSFE']->no_cache, '');
83 $GLOBALS['TSFE']->additionalJavaScript['JSCode'] .= 'if(!parent.' . trim($GLOBALS['TSFE']->sPre) . ' && !parent.view_frame) top.location.href="' . $GLOBALS['TSFE']->baseUrlWrap($tdlLD['totalURL']) . '"';
84 }
85 $GLOBALS['TSFE']->compensateFieldWidth = '' . $GLOBALS['TSFE']->config['config']['compensateFieldWidth'];
86 $GLOBALS['TSFE']->lockFilePath = '' . $GLOBALS['TSFE']->config['config']['lockFilePath'];
87 $GLOBALS['TSFE']->lockFilePath = $GLOBALS['TSFE']->lockFilePath ?: $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
88 $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'] = isset($GLOBALS['TSFE']->config['config']['noScaleUp']) ? '' . $GLOBALS['TSFE']->config['config']['noScaleUp'] : $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
89 $GLOBALS['TSFE']->TYPO3_CONF_VARS['GFX']['im_noScaleUp'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
90 $GLOBALS['TSFE']->ATagParams = trim($GLOBALS['TSFE']->config['config']['ATagParams']) ? ' ' . trim($GLOBALS['TSFE']->config['config']['ATagParams']) : '';
91 if ($GLOBALS['TSFE']->config['config']['setJS_mouseOver']) {
92 $GLOBALS['TSFE']->setJS('mouseOver');
93 }
94 if ($GLOBALS['TSFE']->config['config']['setJS_openPic']) {
95 $GLOBALS['TSFE']->setJS('openPic');
96 }
97 $GLOBALS['TSFE']->sWordRegEx = '';
98 $GLOBALS['TSFE']->sWordList = GeneralUtility::_GP('sword_list');
99 if (is_array($GLOBALS['TSFE']->sWordList)) {
100 $space = !empty($GLOBALS['TSFE']->config['config']['sword_standAlone']) ? '[[:space:]]' : '';
101 foreach ($GLOBALS['TSFE']->sWordList as $val) {
102 if (strlen(trim($val)) > 0) {
103 $GLOBALS['TSFE']->sWordRegEx .= $space . quotemeta($val) . $space . '|';
104 }
105 }
106 $GLOBALS['TSFE']->sWordRegEx = preg_replace('/\\|$/', '', $GLOBALS['TSFE']->sWordRegEx);
107 }
108 // linkVars
109 $GLOBALS['TSFE']->calculateLinkVars();
110 // dtdAllowsFrames indicates whether to use the target attribute in links
111 $GLOBALS['TSFE']->dtdAllowsFrames = FALSE;
112 if ($GLOBALS['TSFE']->config['config']['doctype']) {
113 if (in_array(
114 (string) $GLOBALS['TSFE']->config['config']['doctype'],
115 array('xhtml_trans', 'xhtml_frames', 'xhtml_basic', 'xhtml_2', 'html5'),
116 TRUE)
117 ) {
118 $GLOBALS['TSFE']->dtdAllowsFrames = TRUE;
119 }
120 } else {
121 $GLOBALS['TSFE']->dtdAllowsFrames = TRUE;
122 }
123 // Setting XHTML-doctype from doctype
124 if (!$GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
125 $GLOBALS['TSFE']->config['config']['xhtmlDoctype'] = $GLOBALS['TSFE']->config['config']['doctype'];
126 }
127 if ($GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
128 $GLOBALS['TSFE']->xhtmlDoctype = $GLOBALS['TSFE']->config['config']['xhtmlDoctype'];
129 // Checking XHTML-docytpe
130 switch ((string) $GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
131 case 'xhtml_trans':
132
133 case 'xhtml_strict':
134
135 case 'xhtml_frames':
136 $GLOBALS['TSFE']->xhtmlVersion = 100;
137 break;
138 case 'xhtml_basic':
139 $GLOBALS['TSFE']->xhtmlVersion = 105;
140 break;
141 case 'xhtml_11':
142
143 case 'xhtml+rdfa_10':
144 $GLOBALS['TSFE']->xhtmlVersion = 110;
145 break;
146 case 'xhtml_2':
147 $GLOBALS['TSFE']->xhtmlVersion = 200;
148 break;
149 default:
150 $GLOBALS['TSFE']->getPageRenderer()->setRenderXhtml(FALSE);
151 $GLOBALS['TSFE']->xhtmlDoctype = '';
152 $GLOBALS['TSFE']->xhtmlVersion = 0;
153 }
154 } else {
155 $GLOBALS['TSFE']->getPageRenderer()->setRenderXhtml(FALSE);
156 }
157 }
158
159 /**
160 * Returns an array with files to include. These files are the ones set up in TypoScript config.
161 *
162 * @return array Files to include. Paths are relative to PATH_site.
163 */
164 static public function getIncFiles() {
165 $incFilesArray = array();
166 // Get files from config.includeLibrary
167 $includeLibrary = trim('' . $GLOBALS['TSFE']->config['config']['includeLibrary']);
168 if ($includeLibrary) {
169 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($includeLibrary);
170 if ($incFile) {
171 $incFilesArray[] = $incFile;
172 }
173 }
174 if (is_array($GLOBALS['TSFE']->pSetup['includeLibs.'])) {
175 $incLibs = $GLOBALS['TSFE']->pSetup['includeLibs.'];
176 } else {
177 $incLibs = array();
178 }
179 if (is_array($GLOBALS['TSFE']->tmpl->setup['includeLibs.'])) {
180 // toplevel 'includeLibs' is added to the PAGE.includeLibs. In that way, PAGE-libs get first priority, because if the key already exist, it's not altered. (Due to investigation by me)
181 $incLibs += $GLOBALS['TSFE']->tmpl->setup['includeLibs.'];
182 }
183 if (count($incLibs)) {
184 foreach ($incLibs as $theLib) {
185 if (!is_array($theLib) && ($incFile = $GLOBALS['TSFE']->tmpl->getFileName($theLib))) {
186 $incFilesArray[] = $incFile;
187 }
188 }
189 }
190 return $incFilesArray;
191 }
192
193 /**
194 * Processing JavaScript handlers
195 *
196 * @return array Array with a) a JavaScript section with event handlers and variables set and b) an array with attributes for the body tag.
197 */
198 static public function JSeventFunctions() {
199 $functions = array();
200 $setEvents = array();
201 $setBody = array();
202 foreach ($GLOBALS['TSFE']->JSeventFuncCalls as $event => $handlers) {
203 if (count($handlers)) {
204 $functions[] = ' function T3_' . $event . 'Wrapper(e) { ' . implode(' ', $handlers) . ' }';
205 $setEvents[] = ' document.' . $event . '=T3_' . $event . 'Wrapper;';
206 if ($event == 'onload') {
207 // Dubiuos double setting breaks on some browser - do we need it?
208 $setBody[] = 'onload="T3_onloadWrapper();"';
209 }
210 }
211 }
212 return array(count($functions) ? implode(LF, $functions) . LF . implode(LF, $setEvents) : '', $setBody);
213 }
214
215 /**
216 * Rendering the page content
217 *
218 * @return void
219 */
220 static public function renderContent() {
221 // PAGE CONTENT
222 $GLOBALS['TT']->incStackPointer();
223 $GLOBALS['TT']->push($GLOBALS['TSFE']->sPre, 'PAGE');
224 $pageContent = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup);
225 if ($GLOBALS['TSFE']->pSetup['wrap']) {
226 $pageContent = $GLOBALS['TSFE']->cObj->wrap($pageContent, $GLOBALS['TSFE']->pSetup['wrap']);
227 }
228 if ($GLOBALS['TSFE']->pSetup['stdWrap.']) {
229 $pageContent = $GLOBALS['TSFE']->cObj->stdWrap($pageContent, $GLOBALS['TSFE']->pSetup['stdWrap.']);
230 }
231 // PAGE HEADER (after content - maybe JS is inserted!
232 // if 'disableAllHeaderCode' is set, all the header-code is discarded!
233 if ($GLOBALS['TSFE']->config['config']['disableAllHeaderCode']) {
234 $GLOBALS['TSFE']->content = $pageContent;
235 } else {
236 self::renderContentWithHeader($pageContent);
237 }
238 $GLOBALS['TT']->pull($GLOBALS['TT']->LR ? $GLOBALS['TSFE']->content : '');
239 $GLOBALS['TT']->decStackPointer();
240 }
241
242 /**
243 * Rendering normal HTML-page with header by wrapping the generated content ($pageContent) in body-tags and setting the header accordingly.
244 *
245 * @param string $pageContent The page content which TypoScript objects has generated
246 * @return void
247 */
248 static public function renderContentWithHeader($pageContent) {
249 /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
250 $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
251 if ($GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter']) {
252 $pageRenderer->enableMoveJsFromHeaderToFooter();
253 }
254 if ($GLOBALS['TSFE']->config['config']['pageRendererTemplateFile']) {
255 $file = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->config['config']['pageRendererTemplateFile']);
256 if ($file) {
257 $pageRenderer->setTemplateFile($file);
258 }
259 }
260 $headerComment = $GLOBALS['TSFE']->config['config']['headerComment'];
261 if (trim($headerComment)) {
262 $pageRenderer->addInlineComment(TAB . str_replace(LF, (LF . TAB), trim($headerComment)) . LF);
263 }
264 // Setting charset:
265 $theCharset = $GLOBALS['TSFE']->metaCharset;
266 // Reset the content variables:
267 $GLOBALS['TSFE']->content = '';
268 $htmlTagAttributes = array();
269 $htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ?: 'en';
270 // Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
271 if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
272 $htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
273 }
274 // Setting document type:
275 $docTypeParts = array();
276 $xmlDocument = TRUE;
277 // Part 1: XML prologue
278 switch ((string) $GLOBALS['TSFE']->config['config']['xmlprologue']) {
279 case 'none':
280 $xmlDocument = FALSE;
281 $GLOBALS['TSFE']->config['config']['xhtml_cleaning'] = 'none';
282 break;
283 case 'xml_10':
284 $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
285 break;
286 case 'xml_11':
287 $docTypeParts[] = '<?xml version="1.1" encoding="' . $theCharset . '"?>';
288 break;
289 case '':
290 if ($GLOBALS['TSFE']->xhtmlVersion) {
291 $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
292 }
293 break;
294 default:
295 $docTypeParts[] = $GLOBALS['TSFE']->config['config']['xmlprologue'];
296 }
297 // Part 2: DTD
298 $doctype = $GLOBALS['TSFE']->config['config']['doctype'];
299 if ($doctype) {
300 switch ($doctype) {
301 case 'xhtml_trans':
302 $docTypeParts[] = '<!DOCTYPE html
303 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
304 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
305 break;
306 case 'xhtml_strict':
307 $docTypeParts[] = '<!DOCTYPE html
308 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
309 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
310 break;
311 case 'xhtml_frames':
312 $docTypeParts[] = '<!DOCTYPE html
313 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
314 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
315 break;
316 case 'xhtml_basic':
317 $docTypeParts[] = '<!DOCTYPE html
318 PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
319 "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
320 break;
321 case 'xhtml_11':
322 $docTypeParts[] = '<!DOCTYPE html
323 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
324 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
325 break;
326 case 'xhtml_2':
327 $docTypeParts[] = '<!DOCTYPE html
328 PUBLIC "-//W3C//DTD XHTML 2.0//EN"
329 "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
330 break;
331 case 'xhtml+rdfa_10':
332 $docTypeParts[] = '<!DOCTYPE html
333 PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
334 "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">';
335 break;
336 case 'html5':
337 $docTypeParts[] = '<!DOCTYPE html>';
338 if ($xmlDocument) {
339 $pageRenderer->setMetaCharsetTag('<meta charset="|" />');
340 } else {
341 $pageRenderer->setMetaCharsetTag('<meta charset="|">');
342 }
343 break;
344 case 'none':
345 break;
346 default:
347 $docTypeParts[] = $doctype;
348 }
349 } else {
350 $docTypeParts[] = '<!DOCTYPE html>';
351 if ($xmlDocument){
352 $pageRenderer->setMetaCharsetTag('<meta charset="|" />');
353 } else {
354 $pageRenderer->setMetaCharsetTag('<meta charset="|">');
355 }
356 }
357 if ($GLOBALS['TSFE']->xhtmlVersion) {
358 $htmlTagAttributes['xml:lang'] = $htmlLang;
359 }
360 if ($GLOBALS['TSFE']->xhtmlVersion < 110 || $doctype === 'html5') {
361 $htmlTagAttributes['lang'] = $htmlLang;
362 }
363 if ($GLOBALS['TSFE']->xhtmlVersion || $doctype === 'html5' && $xmlDocument) {
364 // We add this to HTML5 to achieve a slightly better backwards compatibility
365 $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
366 if (is_array($GLOBALS['TSFE']->config['config']['namespaces.'])) {
367 foreach ($GLOBALS['TSFE']->config['config']['namespaces.'] as $prefix => $uri) {
368 // $uri gets htmlspecialchared later
369 $htmlTagAttributes['xmlns:' . htmlspecialchars($prefix)] = $uri;
370 }
371 }
372 }
373 // Swap XML and doctype order around (for MSIE / Opera standards compliance)
374 if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
375 $docTypeParts = array_reverse($docTypeParts);
376 }
377 // Adding doctype parts:
378 if (count($docTypeParts)) {
379 $pageRenderer->setXmlPrologAndDocType(implode(LF, $docTypeParts));
380 }
381 // Begin header section:
382 if ($GLOBALS['TSFE']->config['config']['htmlTag_setParams'] !== 'none') {
383 $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : GeneralUtility::implodeAttributes($htmlTagAttributes);
384 } else {
385 $_attr = '';
386 }
387 $htmlTag = '<html' . ($_attr ? ' ' . $_attr : '') . '>';
388 if (isset($GLOBALS['TSFE']->config['config']['htmlTag_stdWrap.'])) {
389 $htmlTag = $GLOBALS['TSFE']->cObj->stdWrap($htmlTag, $GLOBALS['TSFE']->config['config']['htmlTag_stdWrap.']);
390 }
391 $pageRenderer->setHtmlTag($htmlTag);
392 // Head tag:
393 $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ?: '<head>';
394 $pageRenderer->setHeadTag($headTag);
395 // Setting charset meta tag:
396 $pageRenderer->setCharSet($theCharset);
397 $pageRenderer->addInlineComment(' This website is powered by TYPO3 - inspiring people to share!
398 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
399 TYPO3 is copyright ' . TYPO3_copyright_year . ' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
400 Information and contribution at ' . TYPO3_URL_ORG . '
401 ');
402 if ($GLOBALS['TSFE']->baseUrl) {
403 $pageRenderer->setBaseUrl($GLOBALS['TSFE']->baseUrl);
404 }
405 if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
406 $favIcon = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
407 $iconMimeType = '';
408 if (function_exists('finfo_open')) {
409 if ($finfo = @finfo_open(FILEINFO_MIME)) {
410 $iconMimeType = ' type="' . finfo_file($finfo, (PATH_site . $favIcon)) . '"';
411 finfo_close($finfo);
412 $pageRenderer->setIconMimeType($iconMimeType);
413 }
414 }
415 $pageRenderer->setFavIcon(GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $favIcon);
416 }
417 // Including CSS files
418 if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
419 $temp_styleLines = array();
420 foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key => $iCSScode) {
421 if (is_array($iCSScode)) {
422 if ($iCSScode['_CSS_DEFAULT_STYLE'] && empty($GLOBALS['TSFE']->config['config']['removeDefaultCss'])) {
423 if (isset($iCSScode['_CSS_DEFAULT_STYLE.'])) {
424 $cssDefaultStyle = $GLOBALS['TSFE']->cObj->stdWrap($iCSScode['_CSS_DEFAULT_STYLE'], $iCSScode['_CSS_DEFAULT_STYLE.']);
425 } else {
426 $cssDefaultStyle = $iCSScode['_CSS_DEFAULT_STYLE'];
427 }
428 $temp_styleLines[] = '/* default styles for extension "' . substr($key, 0, -1) . '" */' . LF . $cssDefaultStyle;
429 }
430 if ($iCSScode['_CSS_PAGE_STYLE'] && empty($GLOBALS['TSFE']->config['config']['removePageCss'])) {
431 $cssPageStyle = implode(LF, $iCSScode['_CSS_PAGE_STYLE']);
432 if (isset($iCSScode['_CSS_PAGE_STYLE.'])) {
433 $cssPageStyle = $GLOBALS['TSFE']->cObj->stdWrap($cssPageStyle, $iCSScode['_CSS_PAGE_STYLE.']);
434 }
435 $temp_styleLines[] = '/* specific page styles for extension "' . substr($key, 0, -1) . '" */' . LF . $cssPageStyle;
436 }
437 }
438 }
439 if (count($temp_styleLines)) {
440 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
441 $pageRenderer->addCssFile(self::inline2TempFile(implode(LF, $temp_styleLines), 'css'));
442 } else {
443 $pageRenderer->addCssInlineBlock('TSFEinlineStyle', implode(LF, $temp_styleLines));
444 }
445 }
446 }
447 if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
448 $ss = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
449 if ($ss) {
450 $pageRenderer->addCssFile($ss);
451 }
452 }
453 /**********************************************************************/
454 /* config.includeCSS / config.includeCSSLibs
455 /**********************************************************************/
456 if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
457 foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key => $CSSfile) {
458 if (!is_array($CSSfile)) {
459 $cssFileConfig = &$GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.'];
460 if (isset($cssFileConfig['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($cssFileConfig['if.'])) {
461 continue;
462 }
463 $ss = $cssFileConfig['external'] ? $CSSfile : $GLOBALS['TSFE']->tmpl->getFileName($CSSfile);
464 if ($ss) {
465 if ($cssFileConfig['import']) {
466 if (!$cssFileConfig['external'] && $ss[0] !== '/') {
467 // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
468 $ss = GeneralUtility::dirname(GeneralUtility::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
469 }
470 $pageRenderer->addCssInlineBlock('import_' . $key, '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($cssFileConfig['media']) . ';', empty($cssFileConfig['disableCompression']), $cssFileConfig['forceOnTop'] ? TRUE : FALSE, '');
471 } else {
472 $pageRenderer->addCssFile(
473 $ss,
474 $cssFileConfig['alternate'] ? 'alternate stylesheet' : 'stylesheet',
475 $cssFileConfig['media'] ?: 'all',
476 $cssFileConfig['title'] ?: '',
477 empty($cssFileConfig['disableCompression']),
478 $cssFileConfig['forceOnTop'] ? TRUE : FALSE,
479 $cssFileConfig['allWrap'],
480 $cssFileConfig['excludeFromConcatenation'] ? TRUE : FALSE,
481 $cssFileConfig['allWrap.']['splitChar']
482 );
483 unset($cssFileConfig);
484 }
485 }
486 }
487 }
488 }
489 if (is_array($GLOBALS['TSFE']->pSetup['includeCSSLibs.'])) {
490 foreach ($GLOBALS['TSFE']->pSetup['includeCSSLibs.'] as $key => $CSSfile) {
491 if (!is_array($CSSfile)) {
492 $cssFileConfig = &$GLOBALS['TSFE']->pSetup['includeCSSLibs.'][$key . '.'];
493 if (isset($cssFileConfig['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($cssFileConfig['if.'])) {
494 continue;
495 }
496 $ss = $cssFileConfig['external'] ? $CSSfile : $GLOBALS['TSFE']->tmpl->getFileName($CSSfile);
497 if ($ss) {
498 if ($cssFileConfig['import']) {
499 if (!$cssFileConfig['external'] && $ss[0] !== '/') {
500 // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
501 $ss = GeneralUtility::dirname(GeneralUtility::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
502 }
503 $pageRenderer->addCssInlineBlock('import_' . $key, '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($cssFileConfig['media']) . ';', empty($cssFileConfig['disableCompression']), $cssFileConfig['forceOnTop'] ? TRUE : FALSE, '');
504 } else {
505 $pageRenderer->addCssLibrary(
506 $ss,
507 $cssFileConfig['alternate'] ? 'alternate stylesheet' : 'stylesheet',
508 $cssFileConfig['media'] ?: 'all',
509 $cssFileConfig['title'] ?: '',
510 empty($cssFileConfig['disableCompression']),
511 $cssFileConfig['forceOnTop'] ? TRUE : FALSE,
512 $cssFileConfig['allWrap'],
513 $cssFileConfig['excludeFromConcatenation'] ? TRUE : FALSE,
514 $cssFileConfig['allWrap.']['splitChar']
515 );
516 unset($cssFileConfig);
517 }
518 }
519 }
520 }
521 }
522
523 // Stylesheets
524 $style = '';
525 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
526 $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
527 $RTEclasses = $pageTSConfig['RTE.']['classes.'];
528 if (is_array($RTEclasses)) {
529 foreach ($RTEclasses as $RTEclassName => $RTEvalueArray) {
530 if ($RTEvalueArray['value']) {
531 $style .= '
532 .' . substr($RTEclassName, 0, -1) . ' {' . $RTEvalueArray['value'] . '}';
533 }
534 }
535 }
536 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
537 $mSOa_tList = GeneralUtility::trimExplode(',', strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']), TRUE);
538 foreach ($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'] as $mSOa_key => $mSOa_value) {
539 if (!is_array($mSOa_value) && (in_array('*', $mSOa_tList) || in_array($mSOa_key, $mSOa_tList))) {
540 $style .= '
541 ' . $mSOa_key . ' {' . $mSOa_value . '}';
542 }
543 }
544 }
545 }
546 // Setting body tag margins in CSS:
547 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
548 $margins = (int)$GLOBALS['TSFE']->pSetup['bodyTagMargins'];
549 $style .= '
550 BODY {margin: ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px;}';
551 }
552 if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
553 $style .= '
554
555 /* Default styles for the Admin Panel */
556 TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
557 TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
558 TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
559 TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
560 TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
561 TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
562 TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
563 TABLE.typo3-editPanel TD { border: 0px; }
564 ';
565 }
566 // CSS_inlineStyle from TS
567 $style .= trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']);
568 $style .= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['cssInline.'], 'cssInline.');
569 if (trim($style)) {
570 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
571 $pageRenderer->addCssFile(self::inline2TempFile($style, 'css'));
572 } else {
573 $pageRenderer->addCssInlineBlock('additionalTSFEInlineStyle', $style);
574 }
575 }
576 // Javascript Libraries
577 if (is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.'])) {
578 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG']) {
579 $pageRenderer->loadSvg();
580 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['debug']) {
581 $pageRenderer->enableSvgDebug();
582 }
583 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['forceFlash']) {
584 $pageRenderer->svgForceFlash();
585 }
586 }
587 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Prototype']) {
588 $pageRenderer->loadPrototype();
589 }
590 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous']) {
591 $modules = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] ?: '';
592 $pageRenderer->loadScriptaculous($modules);
593 }
594 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore']) {
595 $pageRenderer->loadExtCore();
596 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore.']['debug']) {
597 $pageRenderer->enableExtCoreDebug();
598 }
599 }
600 // Include jQuery into the page renderer
601 if (!empty($GLOBALS['TSFE']->pSetup['javascriptLibs.']['jQuery'])) {
602 $jQueryTS = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['jQuery.'];
603 // Check if version / source is set, if not set variable to "NULL" to use the default of the page renderer
604 $version = isset($jQueryTS['version']) ? $jQueryTS['version'] : NULL;
605 $source = isset($jQueryTS['source']) ? $jQueryTS['source'] : NULL;
606 // When "noConflict" is not set or "1" enable the default jQuery noConflict mode, otherwise disable the namespace
607 if (!isset($jQueryTS['noConflict']) || !empty($jQueryTS['noConflict'])) {
608 // Set namespace to the "noConflict.namespace" value if "noConflict.namespace" has a value
609 if (!empty($jQueryTS['noConflict.']['namespace'])) {
610 $namespace = $jQueryTS['noConflict.']['namespace'];
611 } else {
612 $namespace = \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT;
613 }
614 } else {
615 $namespace = \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_NONE;
616 }
617 $pageRenderer->loadJQuery($version, $source, $namespace);
618 }
619 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs']) {
620 $css = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['css'] ? TRUE : FALSE;
621 $theme = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['theme'] ? TRUE : FALSE;
622 $adapter = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] ?: '';
623 $pageRenderer->loadExtJs($css, $theme, $adapter);
624 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['debug']) {
625 $pageRenderer->enableExtJsDebug();
626 }
627 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['quickTips']) {
628 $pageRenderer->enableExtJSQuickTips();
629 }
630 }
631 }
632 // JavaScript library files
633 if (is_array($GLOBALS['TSFE']->pSetup['includeJSlibs.'])) {
634 foreach ($GLOBALS['TSFE']->pSetup['includeJSlibs.'] as $key => $JSfile) {
635 if (!is_array($JSfile)) {
636 if (isset($GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJSlibs.'][($key . '.')]['if.'])) {
637 continue;
638 }
639 $ss = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
640 if ($ss) {
641 $jsFileConfig = &$GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.'];
642 $type = $jsFileConfig['type'];
643 if (!$type) {
644 $type = 'text/javascript';
645 }
646
647 $pageRenderer->addJsLibrary(
648 $key,
649 $ss,
650 $type,
651 empty($jsFileConfig['disableCompression']),
652 $jsFileConfig['forceOnTop'] ? TRUE : FALSE,
653 $jsFileConfig['allWrap'],
654 $jsFileConfig['excludeFromConcatenation'] ? TRUE : FALSE,
655 $jsFileConfig['allWrap.']['splitChar']
656 );
657 unset($jsFileConfig);
658 }
659 }
660 }
661 }
662 if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'])) {
663 foreach ($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'] as $key => $JSfile) {
664 if (!is_array($JSfile)) {
665 if (isset($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][($key . '.')]['if.'])) {
666 continue;
667 }
668 $ss = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
669 if ($ss) {
670 $jsFileConfig = &$GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.'];
671 $type = $jsFileConfig['type'];
672 if (!$type) {
673 $type = 'text/javascript';
674 }
675 $pageRenderer->addJsFooterLibrary(
676 $key,
677 $ss,
678 $type,
679 empty($jsFileConfig['disableCompression']),
680 $jsFileConfig['forceOnTop'] ? TRUE : FALSE,
681 $jsFileConfig['allWrap'],
682 $jsFileConfig['excludeFromConcatenation'] ? TRUE : FALSE,
683 $jsFileConfig['allWrap.']['splitChar']
684 );
685 unset($jsFileConfig);
686 }
687 }
688 }
689 }
690 // JavaScript files
691 if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
692 foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key => $JSfile) {
693 if (!is_array($JSfile)) {
694 if (isset($GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJS.'][($key . '.')]['if.'])) {
695 continue;
696 }
697 $ss = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
698 if ($ss) {
699 $jsConfig = &$GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.'];
700 $type = $jsConfig['type'];
701 if (!$type) {
702 $type = 'text/javascript';
703 }
704 $pageRenderer->addJsFile(
705 $ss,
706 $type,
707 empty($jsConfig['disableCompression']),
708 $jsConfig['forceOnTop'] ? TRUE : FALSE,
709 $jsConfig['allWrap'],
710 $jsConfig['excludeFromConcatenation'] ? TRUE : FALSE,
711 $jsConfig['allWrap.']['splitChar']
712 );
713 unset($jsConfig);
714 }
715 }
716 }
717 }
718 if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooter.'])) {
719 foreach ($GLOBALS['TSFE']->pSetup['includeJSFooter.'] as $key => $JSfile) {
720 if (!is_array($JSfile)) {
721 if (isset($GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['if.']) && !$GLOBALS['TSFE']->cObj->checkIf($GLOBALS['TSFE']->pSetup['includeJSFooter.'][($key . '.')]['if.'])) {
722 continue;
723 }
724 $ss = $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
725 if ($ss) {
726 $jsConfig = &$GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.'];
727 $type = $jsConfig['type'];
728 if (!$type) {
729 $type = 'text/javascript';
730 }
731 $pageRenderer->addJsFooterFile(
732 $ss,
733 $type,
734 empty($jsConfig['disableCompression']),
735 $jsConfig['forceOnTop'] ? TRUE : FALSE,
736 $jsConfig['allWrap'],
737 $jsConfig['excludeFromConcatenation'] ? TRUE : FALSE,
738 $jsConfig['allWrap.']['splitChar']
739 );
740 unset($jsConfig);
741 }
742 }
743 }
744 }
745 // Headerdata
746 if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
747 $pageRenderer->addHeaderData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'], 'headerData.'));
748 }
749 // Footerdata
750 if (is_array($GLOBALS['TSFE']->pSetup['footerData.'])) {
751 $pageRenderer->addFooterData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['footerData.'], 'footerData.'));
752 }
753 static::generatePageTitle();
754
755 $metaTagsHtml = static::generateMetaTagHtml(
756 isset($GLOBALS['TSFE']->pSetup['meta.']) ? $GLOBALS['TSFE']->pSetup['meta.'] : array(),
757 $GLOBALS['TSFE']->xhtmlVersion,
758 $GLOBALS['TSFE']->cObj
759 );
760 foreach ($metaTagsHtml as $metaTag) {
761 $pageRenderer->addMetaTag($metaTag);
762 }
763
764 unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
765 if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
766 $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
767 // Storing the JSCode vars...
768 $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
769 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData;
770 // Storing the header-data array
771 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalFooterData'] = $GLOBALS['TSFE']->additionalFooterData;
772 // Storing the footer-data array
773 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript;
774 // Storing the JS-data array
775 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS;
776 // Storing the Style-data array
777 $GLOBALS['TSFE']->additionalHeaderData = array('<!--HD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->');
778 // Clearing the array
779 $GLOBALS['TSFE']->additionalFooterData = array('<!--FD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->');
780 // Clearing the array
781 $GLOBALS['TSFE']->divSection .= '<!--TDS_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->';
782 } else {
783 $GLOBALS['TSFE']->INTincScript_loadJSCode();
784 }
785 $JSef = self::JSeventFunctions();
786 $scriptJsCode = $JSef[0];
787
788 if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
789 $scriptJsCode .= '
790 // decrypt helper function
791 function decryptCharcode(n,start,end,offset) {
792 n = n + offset;
793 if (offset > 0 && n > end) {
794 n = start + (n - end - 1);
795 } else if (offset < 0 && n < start) {
796 n = end - (start - n - 1);
797 }
798 return String.fromCharCode(n);
799 }
800 // decrypt string
801 function decryptString(enc,offset) {
802 var dec = "";
803 var len = enc.length;
804 for(var i=0; i < len; i++) {
805 var n = enc.charCodeAt(i);
806 if (n >= 0x2B && n <= 0x3A) {
807 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
808 } else if (n >= 0x40 && n <= 0x5A) {
809 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
810 } else if (n >= 0x61 && n <= 0x7A) {
811 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
812 } else {
813 dec += enc.charAt(i);
814 }
815 }
816 return dec;
817 }
818 // decrypt spam-protected emails
819 function linkTo_UnCryptMailto(s) {
820 location.href = decryptString(s,' . $GLOBALS['TSFE']->spamProtectEmailAddresses * -1 . ');
821 }
822 ';
823 }
824 // Add inline JS
825 $inlineJS = '';
826 // defined in php
827 if (is_array($GLOBALS['TSFE']->inlineJS)) {
828 foreach ($GLOBALS['TSFE']->inlineJS as $key => $val) {
829 if (!is_array($val)) {
830 $inlineJS .= LF . $val . LF;
831 }
832 }
833 }
834 // defined in TS with page.inlineJS
835 // Javascript inline code
836 $inline = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsInline.'], 'jsInline.');
837 if ($inline) {
838 $inlineJS .= LF . $inline . LF;
839 }
840 // Javascript inline code for Footer
841 $inlineFooterJs = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsFooterInline.'], 'jsFooterInline.');
842 // Should minify?
843 if ($GLOBALS['TSFE']->config['config']['compressJs']) {
844 $pageRenderer->enableCompressJavascript();
845 $minifyErrorScript = ($minifyErrorInline = '');
846 $scriptJsCode = GeneralUtility::minifyJavaScript($scriptJsCode, $minifyErrorScript);
847 if ($minifyErrorScript) {
848 $GLOBALS['TT']->setTSlogMessage($minifyErrorScript, 3);
849 }
850 if ($inlineJS) {
851 $inlineJS = GeneralUtility::minifyJavaScript($inlineJS, $minifyErrorInline);
852 if ($minifyErrorInline) {
853 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
854 }
855 }
856 if ($inlineFooterJs) {
857 $inlineFooterJs = GeneralUtility::minifyJavaScript($inlineFooterJs, $minifyErrorInline);
858 if ($minifyErrorInline) {
859 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
860 }
861 }
862 }
863 if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
864 // inlude default and inlineJS
865 if ($scriptJsCode) {
866 $pageRenderer->addJsInlineCode('_scriptCode', $scriptJsCode, $GLOBALS['TSFE']->config['config']['compressJs']);
867 }
868 if ($inlineJS) {
869 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['compressJs']);
870 }
871 if ($inlineFooterJs) {
872 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['compressJs']);
873 }
874 } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS'] === 'external') {
875 /*
876 * This keeps inlineJS from *_INT Objects from being moved to external files.
877 * At this point in frontend rendering *_INT Objects only have placeholders instead
878 * of actual content so moving these placeholders to external files would
879 * a) break the JS file (syntax errors due to the placeholders)
880 * b) the needed JS would never get included to the page
881 * Therefore inlineJS from *_INT Objects must not be moved to external files but
882 * kept internal.
883 */
884 $inlineJSint = '';
885 self::stripIntObjectPlaceholder($inlineJS, $inlineJSint);
886 if ($inlineJSint) {
887 $pageRenderer->addJsInlineCode('TS_inlineJSint', $inlineJSint, $GLOBALS['TSFE']->config['config']['compressJs']);
888 }
889 if (trim($scriptJsCode . $inlineJS)) {
890 $pageRenderer->addJsFile(self::inline2TempFile($scriptJsCode . $inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['compressJs']);
891 }
892 if ($inlineFooterJs) {
893 $inlineFooterJSint = '';
894 self::stripIntObjectPlaceholder($inlineFooterJs, $inlineFooterJSint);
895 if ($inlineFooterJSint) {
896 $pageRenderer->addJsFooterInlineCode('TS_inlineFooterJSint', $inlineFooterJSint, $GLOBALS['TSFE']->config['config']['compressJs']);
897 }
898 $pageRenderer->addJsFooterFile(self::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['compressJs']);
899 }
900 } else {
901 // Include only inlineJS
902 if ($inlineJS) {
903 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['compressJs']);
904 }
905 if ($inlineFooterJs) {
906 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['compressJs']);
907 }
908 }
909 // ExtJS specific code
910 if (is_array($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.'])) {
911 $pageRenderer->addInlineLanguageLabelArray($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.']);
912 }
913 if (is_array($GLOBALS['TSFE']->pSetup['inlineSettings.'])) {
914 $pageRenderer->addInlineSettingArray('TS', $GLOBALS['TSFE']->pSetup['inlineSettings.']);
915 }
916 if (is_array($GLOBALS['TSFE']->pSetup['extOnReady.'])) {
917 $pageRenderer->addExtOnReadyCode($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['extOnReady.'], 'extOnReady.'));
918 }
919 // Compression and concatenate settings
920 if ($GLOBALS['TSFE']->config['config']['compressCss']) {
921 $pageRenderer->enableCompressCss();
922 }
923 if ($GLOBALS['TSFE']->config['config']['compressJs']) {
924 $pageRenderer->enableCompressJavascript();
925 }
926 if ($GLOBALS['TSFE']->config['config']['concatenateCss']) {
927 $pageRenderer->enableConcatenateCss();
928 }
929 if ($GLOBALS['TSFE']->config['config']['concatenateJs']) {
930 $pageRenderer->enableConcatenateJavascript();
931 }
932 // Backward compatibility for old configuration
933 if ($GLOBALS['TSFE']->config['config']['concatenateJsAndCss']) {
934 $pageRenderer->enableConcatenateFiles();
935 }
936 // Add header data block
937 if ($GLOBALS['TSFE']->additionalHeaderData) {
938 $pageRenderer->addHeaderData(implode(LF, $GLOBALS['TSFE']->additionalHeaderData));
939 }
940 // Add footer data block
941 if ($GLOBALS['TSFE']->additionalFooterData) {
942 $pageRenderer->addFooterData(implode(LF, $GLOBALS['TSFE']->additionalFooterData));
943 }
944 // Header complete, now add content
945 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
946 $fs = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\FramesetRenderer');
947 $pageRenderer->addBodyContent($fs->make($GLOBALS['TSFE']->pSetup['frameSet.']));
948 $pageRenderer->addBodyContent(LF . '<noframes>' . LF);
949 }
950 // Bodytag:
951 if ($GLOBALS['TSFE']->config['config']['disableBodyTag']) {
952 $bodyTag = '';
953 } else {
954 $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
955 if (!$defBT) {
956 $defBT = $GLOBALS['TSFE']->defaultBodyTag;
957 }
958 $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
959 if ($bgImg = $GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'], $GLOBALS['TSFE']->pSetup['bgImg.'])) {
960 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS['TSFE']->absRefPrefix . $bgImg[3] . '">';
961 }
962 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
963 $margins = (int)$GLOBALS['TSFE']->pSetup['bodyTagMargins'];
964 if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
965
966 } else {
967 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
968 }
969 }
970 if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
971 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
972 }
973 // Event functions
974 if (count($JSef[1])) {
975 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
976 }
977 }
978 $pageRenderer->addBodyContent(LF . $bodyTag);
979 // Div-sections
980 if ($GLOBALS['TSFE']->divSection) {
981 $pageRenderer->addBodyContent(LF . $GLOBALS['TSFE']->divSection);
982 }
983 // Page content
984 $pageRenderer->addBodyContent(LF . $pageContent);
985 if (!empty($GLOBALS['TSFE']->config['INTincScript']) && is_array($GLOBALS['TSFE']->config['INTincScript'])) {
986 // Store the serialized pageRenderer in configuration
987 $GLOBALS['TSFE']->config['INTincScript_ext']['pageRenderer'] = serialize($pageRenderer);
988 // Render complete page, keep placeholders for JavaScript and CSS
989 $GLOBALS['TSFE']->content = $pageRenderer->renderPageWithUncachedObjects($GLOBALS['TSFE']->config['INTincScript_ext']['divKey']);
990 } else {
991 // Render complete page
992 $GLOBALS['TSFE']->content = $pageRenderer->render();
993 }
994 // Ending page
995 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
996 $GLOBALS['TSFE']->content .= LF . '</noframes>';
997 }
998 }
999
1000 /*************************
1001 *
1002 * Helper functions
1003 * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
1004 *
1005 *************************/
1006 /**
1007 * Searches for placeholder created from *_INT cObjects, removes them from
1008 * $searchString and merges them to $intObjects
1009 *
1010 * @param string $searchString The String which should be cleaned from int-object markers
1011 * @param string $intObjects The String the found int-placeholders are moved to (for further processing)
1012 */
1013 static protected function stripIntObjectPlaceholder(&$searchString, &$intObjects) {
1014 $tempArray = array();
1015 preg_match_all('/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/', $searchString, $tempArray);
1016 $searchString = preg_replace('/\\<\\!--INT_SCRIPT.[a-z0-9]*--\\>/', '', $searchString);
1017 $intObjects = implode('', $tempArray[0]);
1018 }
1019
1020 /**
1021 * Writes string to a temporary file named after the md5-hash of the string
1022 *
1023 * @param string $str CSS styles / JavaScript to write to file.
1024 * @param string $ext Extension: "css" or "js
1025 * @return string <script> or <link> tag for the file.
1026 */
1027 static public function inline2TempFile($str, $ext) {
1028 // Create filename / tags:
1029 $script = '';
1030 switch ($ext) {
1031 case 'js':
1032 $script = 'typo3temp/javascript_' . substr(md5($str), 0, 10) . '.js';
1033 break;
1034 case 'css':
1035 $script = 'typo3temp/stylesheet_' . substr(md5($str), 0, 10) . '.css';
1036 break;
1037 }
1038 // Write file:
1039 if ($script) {
1040 if (!@is_file((PATH_site . $script))) {
1041 GeneralUtility::writeFile(PATH_site . $script, $str);
1042 }
1043 }
1044 return $script;
1045 }
1046
1047 /**
1048 * Checks if the value defined in "config.linkVars" contains an allowed value. Otherwise, return FALSE which means the value will not be added to any links.
1049 *
1050 * @param string $haystack The string in which to find $needle
1051 * @param string $needle The string to find in $haystack
1052 * @return boolean Returns TRUE if $needle matches or is found in $haystack
1053 */
1054 static public function isAllowedLinkVarValue($haystack, $needle) {
1055 $OK = FALSE;
1056 // Integer
1057 if ($needle == 'int' || $needle == 'integer') {
1058 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($haystack)) {
1059 $OK = TRUE;
1060 }
1061 } elseif (preg_match('/^\\/.+\\/[imsxeADSUXu]*$/', $needle)) {
1062 // Regular expression, only "//" is allowed as delimiter
1063 if (@preg_match($needle, $haystack)) {
1064 $OK = TRUE;
1065 }
1066 } elseif (strstr($needle, '-')) {
1067 // Range
1068 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($haystack)) {
1069 $range = explode('-', $needle);
1070 if ($range[0] <= $haystack && $range[1] >= $haystack) {
1071 $OK = TRUE;
1072 }
1073 }
1074 } elseif (strstr($needle, '|')) {
1075 // List
1076 // Trim the input
1077 $haystack = str_replace(' ', '', $haystack);
1078 if (strstr('|' . $needle . '|', '|' . $haystack . '|')) {
1079 $OK = TRUE;
1080 }
1081 } elseif ((string)$needle === (string)$haystack) {
1082 // String comparison
1083 $OK = TRUE;
1084 }
1085 return $OK;
1086 }
1087
1088 /**
1089 * Generate title for page.
1090 * Takes the settings ['config']['noPageTitle'], ['config']['pageTitleFirst'], ['config']['titleTagFunction']
1091 * and ['config']['noPageTitle'] into account.
1092 * Furthermore $GLOBALS['TSFE']->altPageTitle is observed.
1093 *
1094 * @return void
1095 */
1096 static public function generatePageTitle() {
1097 $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle(
1098 $GLOBALS['TSFE']->altPageTitle ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'],
1099 $GLOBALS['TSFE']->config['config']['noPageTitle'],
1100 $GLOBALS['TSFE']->config['config']['pageTitleFirst']
1101 );
1102 if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
1103 $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction(
1104 $GLOBALS['TSFE']->config['config']['titleTagFunction'],
1105 array(),
1106 $titleTagContent
1107 );
1108 }
1109 if ($titleTagContent !== '' && (int)$GLOBALS['TSFE']->config['config']['noPageTitle'] !== self::NO_PAGE_TITLE) {
1110 $GLOBALS['TSFE']->getPageRenderer()->setTitle($titleTagContent);
1111 }
1112 }
1113
1114 /**
1115 * Generate meta tags from meta tag TypoScript
1116 *
1117 * @param array $metaTagTypoScript TypoScript configuration for meta tags (e.g. $GLOBALS['TSFE']->pSetup['meta.'])
1118 * @param bool $xhtml Whether xhtml tag-style should be used. (e.g. pass $GLOBALS['TSFE']->xhtmlVersion here)
1119 * @param ContentObjectRenderer $cObj
1120 * @return array Array of HTML meta tags
1121 */
1122 static protected function generateMetaTagHtml(array $metaTagTypoScript, $xhtml, ContentObjectRenderer $cObj) {
1123 // Add ending slash only to documents rendered as xhtml
1124 $endingSlash = $xhtml ? ' /' : '';
1125
1126 $metaTags = array(
1127 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS"' . $endingSlash . '>'
1128 );
1129
1130 /** @var TypoScriptService $typoScriptService */
1131 $typoScriptService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService');
1132 $conf = $typoScriptService->convertTypoScriptArrayToPlainArray($metaTagTypoScript);
1133 foreach ($conf as $key => $properties) {
1134 if (is_array($properties)) {
1135 $nodeValue = isset($properties['_typoScriptNodeValue']) ? $properties['_typoScriptNodeValue'] : '';
1136 $value = trim($cObj->stdWrap($nodeValue, $metaTagTypoScript[$key . '.']));
1137 } else {
1138 $value = $properties;
1139 }
1140 if ($value !== '') {
1141 $attribute = 'name';
1142 if ( (is_array($properties) && !empty($properties['httpEquivalent'])) || strtolower($key) === 'refresh') {
1143 $attribute = 'http-equiv';
1144 }
1145 $metaTags[] = '<meta ' . $attribute . '="' . $key . '" content="' . htmlspecialchars($value) . '"' . $endingSlash . '>';
1146 }
1147 }
1148 return $metaTags;
1149 }
1150 }