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