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