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