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