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