c7e23036375f28a97d3b4f9bdb719496e16510ad
[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 : 'fileadmin/';
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']['pageRenderTemplateFile']) {
352 $file = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->config['config']['pageRenderTemplateFile']);
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 $ss = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
675 if ($ss) {
676 $type = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['type'];
677 if (! $type) {
678 $type = 'text/javascript';
679 }
680 $pageRenderer->addJsLibrary(
681 htmlspecialchars($key),
682 htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
683 htmlspecialchars($type),
684 $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
685 $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
686 $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['allWrap']
687 );
688 }
689
690 }
691 }
692
693 if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'])) {
694 foreach ($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'] as $key => $JSfile) {
695 $ss = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
696 if ($ss) {
697 $type = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['type'];
698 if (! $type) {
699 $type = 'text/javascript';
700 }
701 $pageRenderer->addJsFooterLibrary(
702 htmlspecialchars($key),
703 htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
704 htmlspecialchars($type),
705 $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
706 $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
707 $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['allWrap']
708 );
709 }
710
711 }
712 }
713
714 // JavaScript files
715 if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
716 foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key => $JSfile) {
717 if (!is_array($JSfile)) {
718 $ss = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
719 if ($ss) {
720 $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['type'];
721 if (! $type) {
722 $type = 'text/javascript';
723 }
724 $pageRenderer->addJsFile(
725 htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
726 htmlspecialchars($type),
727 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['compress'] ? TRUE : FALSE,
728 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
729 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap']
730 );
731 }
732 }
733 }
734 }
735
736 if (is_array($GLOBALS['TSFE']->pSetup['includeFooterJS.'])) {
737 foreach ($GLOBALS['TSFE']->pSetup['includeFooterJS.'] as $key => $JSfile) {
738 if (!is_array($JSfile)) {
739 $ss = $GLOBALS['TSFE']->pSetup['includeFooterJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
740 if ($ss) {
741 $type = $GLOBALS['TSFE']->pSetup['includeFooterJS.'][$key . '.']['type'];
742 if (! $type) {
743 $type = 'text/javascript';
744 }
745 $pageRenderer->addJsFooterFile(
746 htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss),
747 htmlspecialchars($type),
748 $GLOBALS['TSFE']->pSetup['includeFooterJS.'][$key . '.']['compress'] ? TRUE : FALSE,
749 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
750 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap']
751 );
752 }
753 }
754 }
755 }
756
757 // Headerdata
758 if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
759 $pageRenderer->addHeaderData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'], 'headerData.'));
760 }
761
762 // Footerdata
763 if (is_array($GLOBALS['TSFE']->pSetup['footerData.'])) {
764 $pageRenderer->addFooterData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['footerData.'], 'footerData.'));
765 }
766
767 // Title
768 $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']);
769 if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
770 $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array (), $titleTagContent);
771 }
772
773 if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle']) !== 2) {
774 $pageRenderer->setTitle($titleTagContent);
775 }
776
777 $pageRenderer->addMetaTag('<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS" />');
778
779 $conf = $GLOBALS['TSFE']->pSetup['meta.'];
780 if (is_array($conf)) {
781 foreach ($conf as $theKey => $theValue) {
782 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
783 if (strstr($theKey, '.')) {
784 $theKey = substr($theKey, 0, - 1);
785 }
786 $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey], $conf[$theKey . '.']);
787 $key = $theKey;
788 if (trim($val)) {
789 $a = 'name';
790 if (strtolower($key) == 'refresh') {
791 $a = 'http-equiv';
792 }
793 $pageRenderer->addMetaTag('<meta ' . $a . '="' . $key . '" content="' . htmlspecialchars(trim($val)) . '" />');
794 }
795 }
796 }
797 }
798
799 unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
800 unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
801
802 if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
803 // Storing the JSCode and JSImgCode vars...
804 $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
805 $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
806 $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
807 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
808 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
809 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
810
811
812 $GLOBALS['TSFE']->additionalHeaderData = array ('<!--HD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->'); // Clearing the array
813 $GLOBALS['TSFE']->divSection .= '<!--TDS_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->';
814 } else {
815 $GLOBALS['TSFE']->INTincScript_loadJSCode();
816 }
817 $JSef = TSpagegen::JSeventFunctions();
818
819 // Adding default Java Script:
820 $scriptJsCode = '
821 var browserName = navigator.appName;
822 var browserVer = parseInt(navigator.appVersion);
823 var version = "";
824 var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
825 if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
826 // Blurring links:
827 function blurLink(theObject) { //
828 if (msie4) {theObject.blur();}
829 }
830 ' . $JSef[0];
831
832 if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
833 $scriptJsCode .= '
834 // decrypt helper function
835 function decryptCharcode(n,start,end,offset) {
836 n = n + offset;
837 if (offset > 0 && n > end) {
838 n = start + (n - end - 1);
839 } else if (offset < 0 && n < start) {
840 n = end - (start - n - 1);
841 }
842 return String.fromCharCode(n);
843 }
844 // decrypt string
845 function decryptString(enc,offset) {
846 var dec = "";
847 var len = enc.length;
848 for(var i=0; i < len; i++) {
849 var n = enc.charCodeAt(i);
850 if (n >= 0x2B && n <= 0x3A) {
851 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
852 } else if (n >= 0x40 && n <= 0x5A) {
853 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
854 } else if (n >= 0x61 && n <= 0x7A) {
855 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
856 } else {
857 dec += enc.charAt(i);
858 }
859 }
860 return dec;
861 }
862 // decrypt spam-protected emails
863 function linkTo_UnCryptMailto(s) {
864 location.href = decryptString(s,' . ($GLOBALS['TSFE']->spamProtectEmailAddresses * - 1) . ');
865 }
866 ';
867 }
868
869 //add inline JS
870 $inlineJS = '';
871
872 // defined in php
873 if (is_array($GLOBALS['TSFE']->inlineJS)) {
874 foreach ($GLOBALS['TSFE']->inlineJS as $key => $val) {
875 if (! is_array($val)) {
876 $inlineJS .= chr(10) . $val . chr(10);
877 }
878 }
879 }
880
881 // defined in TS with page.inlineJS
882 // Javascript inline code
883 $inline = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsInline.'], 'jsInline.');
884 if ($inline) {
885 $inlineJS .= chr(10) . $inline . chr(10);
886 }
887
888 // Javascript inline code for Footer
889 $inlineFooterJs = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsFooterInline.'], 'jsFooterInline.');
890
891 // Should minify?
892 if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
893 $pageRenderer->enableCompressJavascript();
894 $minifyErrorScript = $minifyErrorInline = '';
895 $scriptJsCode = t3lib_div::minifyJavaScript($scriptJsCode, $minifyErrorScript);
896 if ($minifyErrorScript) {
897 $GLOBALS['TT']->setTSlogMessage($minifyErrorScript, 3);
898 }
899 if ($inlineJS) {
900 $inlineJS = t3lib_div::minifyJavaScript($inlineJS, $minifyErrorInline);
901 if ($minifyErrorInline) {
902 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
903 }
904 }
905 if ($inlineFooterJs) {
906 $inlineFooterJs = t3lib_div::minifyJavaScript($inlineFooterJs, $minifyErrorInline);
907 if ($minifyErrorInline) {
908 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
909 }
910 }
911
912 }
913
914 if (! $GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
915 // inlude default and inlineJS
916 if ($scriptJsCode) {
917 $pageRenderer->addJsInlineCode('_scriptCode', $scriptJsCode, $GLOBALS['TSFE']->config['config']['minifyJS']);
918 }
919 if ($inlineJS) {
920 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
921 }
922 if ($inlineFooterJs) {
923 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
924 }
925 } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS'] === 'external') {
926 // put default and inlineJS in external file
927 $pageRenderer->addJsFile(TSpagegen::inline2TempFile($scriptJsCode . $inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
928 if ($inlineFooterJs) {
929 $pageRenderer->addJsFooterFile(TSpagegen::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
930 }
931 } else {
932 // include only inlineJS
933 if ($inlineJS) {
934 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
935 }
936 if ($inlineFooterJs) {
937 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
938 }
939 }
940
941 // ExtJS specific code
942 if (is_array($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.'])) {
943 $pageRenderer->addInlineLanguageLabelArray($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.']);
944 }
945
946 if (is_array($GLOBALS['TSFE']->pSetup['inlineSettings.'])) {
947 $pageRenderer->addInlineSettingArray('TS', $GLOBALS['TSFE']->pSetup['inlineSettings.']);
948 }
949
950 if (is_array($GLOBALS['TSFE']->pSetup['extOnReady.'])) {
951 $pageRenderer->addExtOnReadyCode($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['extOnReady.'], 'extOnReady.'));
952 }
953
954 // compression and concatenate settings
955 if ($GLOBALS['TSFE']->config['config']['minifyCSS']) {
956 $pageRenderer->enableCompressCss();
957 }
958 if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
959 $pageRenderer->enableCompressJavascript();
960 }
961 if ($GLOBALS['TSFE']->config['config']['concatenateJsAndCss']) {
962 $pageRenderer->enableConcatenateFiles();
963 }
964
965 // add header data block
966 if ($GLOBALS['TSFE']->additionalHeaderData) {
967 $pageRenderer->addHeaderData(implode(chr(10), $GLOBALS['TSFE']->additionalHeaderData));
968 }
969
970 // add footer data block
971 if ($GLOBALS['TSFE']->additionalFooterData) {
972 $pageRenderer->addFooterData(implode(chr(10), $GLOBALS['TSFE']->additionalFooterData));
973 }
974
975 // Header complete, now add content
976
977
978 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
979 $fs = t3lib_div::makeInstance('tslib_frameset');
980 $pageRenderer->addBodyContent($fs->make($GLOBALS['TSFE']->pSetup['frameSet.']));
981 $pageRenderer->addBodyContent(chr(10) . '<noframes>' . chr(10));
982 }
983
984 // Bodytag:
985 $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
986 if (! $defBT)
987 $defBT = $GLOBALS['TSFE']->defaultBodyTag;
988 $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
989 if ($bgImg = $GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'], $GLOBALS['TSFE']->pSetup['bgImg.'])) {
990 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS["TSFE"]->absRefPrefix . $bgImg[3] . '">';
991 }
992
993 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
994 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
995 if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
996 // Setting margins in CSS, see above
997 } else {
998 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
999 }
1000 }
1001
1002 if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
1003 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
1004 }
1005
1006 if (count($JSef[1])) { // Event functions:
1007 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
1008 }
1009 $pageRenderer->addBodyContent(chr(10) . $bodyTag);
1010
1011 // Div-sections
1012 if ($GLOBALS['TSFE']->divSection) {
1013 $pageRenderer->addBodyContent(chr(10) . $GLOBALS['TSFE']->divSection);
1014 }
1015
1016 // Page content
1017 $pageRenderer->addBodyContent(chr(10) . $pageContent);
1018
1019 // Render complete page
1020 $GLOBALS['TSFE']->content = $pageRenderer->render();
1021
1022 // Ending page
1023 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
1024 $GLOBALS['TSFE']->content .= chr(10) . '</noframes>';
1025 }
1026
1027 }
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041 /*************************
1042 *
1043 * Helper functions
1044 * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
1045 *
1046 *************************/
1047
1048 /**
1049 * Writes string to a temporary file named after the md5-hash of the string
1050 *
1051 * @param string CSS styles / JavaScript to write to file.
1052 * @param string Extension: "css" or "js"
1053 * @return string <script> or <link> tag for the file.
1054 */
1055 public static function inline2TempFile($str, $ext) {
1056
1057 // Create filename / tags:
1058 $script = '';
1059 switch ($ext) {
1060 case 'js' :
1061 $script = 'typo3temp/javascript_' . substr(md5($str), 0, 10) . '.js';
1062 $output = $GLOBALS['TSFE']->absRefPrefix . $script;
1063 break;
1064 case 'css' :
1065 $script = 'typo3temp/stylesheet_' . substr(md5($str), 0, 10) . '.css';
1066 $output = $GLOBALS['TSFE']->absRefPrefix . $script;
1067 break;
1068 }
1069
1070 // Write file:
1071 if ($script) {
1072 if (! @is_file(PATH_site . $script)) {
1073 t3lib_div::writeFile(PATH_site . $script, $str);
1074 }
1075 }
1076
1077 return $output;
1078 }
1079
1080 /**
1081 * 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.
1082 *
1083 * @param string The string in which to find $needle
1084 * @param string The string to find in $haystack
1085 * @return boolean Returns true if $needle matches or is found in $haystack
1086 */
1087 public static function isAllowedLinkVarValue($haystack,$needle) {
1088 $OK = false;
1089
1090 if ($needle=='int' || $needle=='integer') { // Integer
1091
1092 if (t3lib_div::testInt($haystack)) {
1093 $OK = true;
1094 }
1095
1096 } elseif (preg_match('/^\/.+\/[imsxeADSUXu]*$/', $needle)) { // Regular expression, only "//" is allowed as delimiter
1097
1098 if (@preg_match($needle, $haystack)) {
1099 $OK = true;
1100 }
1101
1102 } elseif (strstr($needle,'-')) { // Range
1103
1104 if (t3lib_div::testInt($haystack)) {
1105 $range = explode('-',$needle);
1106 if ($range[0] <= $haystack && $range[1] >= $haystack) {
1107 $OK = true;
1108 }
1109 }
1110
1111 } elseif (strstr($needle,'|')) { // List
1112
1113 $haystack = str_replace(' ','',$haystack); // Trim the input
1114 if (strstr('|'.$needle.'|', '|'.$haystack.'|')) {
1115 $OK = true;
1116 }
1117
1118 } elseif (!strcmp($needle,$haystack)) { // String comparison
1119 $OK = true;
1120 }
1121
1122 return $OK;
1123 }
1124 }
1125
1126 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']) {
1127 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']);
1128 }
1129
1130
1131
1132 /**
1133 * Class for fetching record relations for the frontend.
1134 *
1135 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
1136 * @package TYPO3
1137 * @subpackage tslib
1138 * @see tslib_cObj::RECORDS()
1139 */
1140 class FE_loadDBGroup extends t3lib_loadDBGroup {
1141 var $fromTC = 0; // Means that everything is returned instead of only uid and label-field
1142 }
1143
1144 ?>