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