[BUGFIX] Add stdWrap for excludeUidList for HMENU.
[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 $pageRenderer->setMetaCharsetTag('<meta charset="|" />');
439 break;
440 case 'none' :
441 break;
442 default :
443 $docTypeParts[] = $doctype;
444 }
445 } else {
446 $docTypeParts[] = '<!DOCTYPE html
447 PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
448 }
449
450 if ($GLOBALS['TSFE']->xhtmlVersion) {
451 $htmlTagAttributes['xml:lang'] = $htmlLang;
452 }
453 if ($GLOBALS['TSFE']->xhtmlVersion < 110 || $doctype === 'html5') {
454 $htmlTagAttributes['lang'] = $htmlLang;
455 }
456 if ($GLOBALS['TSFE']->xhtmlVersion || $doctype === 'html5') {
457 $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml'; // We add this to HTML5 to achieve a slightly better backwards compatibility
458 if (is_array($GLOBALS['TSFE']->config['config']['namespaces.'])) {
459 foreach ($GLOBALS['TSFE']->config['config']['namespaces.'] as $prefix => $uri) {
460 $htmlTagAttributes['xmlns:' . htmlspecialchars($prefix)] = $uri; // $uri gets htmlspecialchared later
461 }
462 }
463 }
464
465 // Swap XML and doctype order around (for MSIE / Opera standards compliance)
466 if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
467 $docTypeParts = array_reverse($docTypeParts);
468 }
469
470 // Adding doctype parts:
471 if (count($docTypeParts)) {
472 $pageRenderer->setXmlPrologAndDocType(implode(LF, $docTypeParts));
473 }
474
475 // Begin header section:
476 if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'], 'none')) {
477 $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : t3lib_div::implodeAttributes($htmlTagAttributes);
478 } else {
479 $_attr = '';
480 }
481 $pageRenderer->setHtmlTag('<html' . ($_attr ? ' ' . $_attr : '') . '>');
482
483 // Head tag:
484 $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : '<head>';
485 $pageRenderer->setHeadTag($headTag);
486
487 // Setting charset meta tag:
488 $pageRenderer->setCharSet($theCharset);
489
490 $pageRenderer->addInlineComment(' This website is powered by TYPO3 - inspiring people to share!
491 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
492 TYPO3 is copyright ' . TYPO3_copyright_year . ' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
493 Information and contribution at ' . TYPO3_URL_GENERAL . ' and ' . TYPO3_URL_ORG . '
494 ');
495
496 if ($GLOBALS['TSFE']->baseUrl) {
497 $pageRenderer->setBaseUrl($GLOBALS['TSFE']->baseUrl);
498 }
499
500 if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
501 $favIcon = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
502 $iconMimeType = '';
503 if (function_exists('finfo_open')) {
504 if (($finfo = @finfo_open(FILEINFO_MIME))) {
505 $iconMimeType = ' type="' . finfo_file($finfo, PATH_site . $favIcon) . '"';
506 finfo_close($finfo);
507 $pageRenderer->setIconMimeType($iconMimeType);
508 }
509 }
510 $pageRenderer->setFavIcon(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $favIcon);
511
512 }
513
514 // Including CSS files
515 if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
516 $temp_styleLines = array ();
517 foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key => $iCSScode) {
518 if (is_array($iCSScode) && $iCSScode['_CSS_DEFAULT_STYLE']) {
519 $temp_styleLines[] = '/* default styles for extension "' . substr($key, 0, - 1) . '" */' . LF . $iCSScode['_CSS_DEFAULT_STYLE'];
520 }
521 }
522 if (count($temp_styleLines)) {
523 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
524 $pageRenderer->addCssFile(TSpagegen::inline2TempFile(implode(LF, $temp_styleLines), 'css'));
525 } else {
526 $pageRenderer->addCssInlineBlock('TSFEinlineStyle', implode(LF, $temp_styleLines));
527 }
528 }
529 }
530
531 if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
532 $ss = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
533 if ($ss) {
534 $pageRenderer->addCssFile($ss);
535 }
536 }
537
538 /**********************************************************************/
539 /* includeCSS
540 /* config.includeCSS {
541 /*
542 /* }
543 /**********************************************************************/
544
545 if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
546 foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key => $CSSfile) {
547 if (!is_array($CSSfile)) {
548 $ss = $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['external'] ? $CSSfile : $GLOBALS['TSFE']->tmpl->getFileName($CSSfile);
549 if ($ss) {
550 if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['import']) {
551 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)
552 $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
553 }
554 $pageRenderer->addCssInlineBlock(
555 'import_' . $key,
556 '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media']) . ';',
557 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['compress'] ? TRUE : FALSE,
558 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
559 ''
560 );
561 } else {
562 $pageRenderer->addCssFile(
563 $ss,
564 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['alternate'] ? 'alternate stylesheet' : 'stylesheet',
565 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] : 'all',
566 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] : '',
567 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['compress'] ? TRUE : FALSE,
568 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
569 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['allWrap']);
570
571 }
572 }
573 }
574 }
575 }
576
577 // Stylesheets
578 $style = '';
579 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
580 $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
581 $RTEclasses = $pageTSConfig['RTE.']['classes.'];
582 if (is_array($RTEclasses)) {
583 foreach ($RTEclasses as $RTEclassName => $RTEvalueArray) {
584 if ($RTEvalueArray['value']) {
585 $style .= '
586 .' . substr($RTEclassName, 0, - 1) . ' {' . $RTEvalueArray['value'] . '}';
587 }
588 }
589 }
590
591 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
592 $mSOa_tList = t3lib_div::trimExplode(',', strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']), 1);
593 foreach ($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'] as $mSOa_key => $mSOa_value) {
594 if (! is_array($mSOa_value) && (in_array('*', $mSOa_tList) || in_array($mSOa_key, $mSOa_tList))) {
595 $style .= '
596 ' . $mSOa_key . ' {' . $mSOa_value . '}';
597 }
598 }
599 }
600 }
601
602 // Setting body tag margins in CSS:
603 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
604 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
605 $style .= '
606 BODY {margin: ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px;}';
607 }
608
609 if ($GLOBALS['TSFE']->pSetup['noLinkUnderline']) {
610 $GLOBALS['TSFE']->logDeprecatedTyposcript('config.noLinkUnderline');
611 $style .= '
612 A:link {text-decoration: none}
613 A:visited {text-decoration: none}
614 A:active {text-decoration: none}';
615 }
616 if (trim($GLOBALS['TSFE']->pSetup['hover'])) {
617 $GLOBALS['TSFE']->logDeprecatedTyposcript('config.hover');
618 $style .= '
619 A:hover {color: ' . trim($GLOBALS['TSFE']->pSetup['hover']) . ';}';
620 }
621 if (trim($GLOBALS['TSFE']->pSetup['hoverStyle'])) {
622 $GLOBALS['TSFE']->logDeprecatedTyposcript('config.hoverStyle');
623 $style .= '
624 A:hover {' . trim($GLOBALS['TSFE']->pSetup['hoverStyle']) . '}';
625 }
626 if ($GLOBALS['TSFE']->pSetup['smallFormFields']) {
627 $GLOBALS['TSFE']->logDeprecatedTyposcript('config.smallFormFields');
628 $style .= '
629 SELECT { font-family: Verdana, Arial, Helvetica; font-size: 10px }
630 TEXTAREA { font-family: Verdana, Arial, Helvetica; font-size: 10px}
631 INPUT { font-family: Verdana, Arial, Helvetica; font-size: 10px }';
632 }
633 if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
634 $style .= '
635
636 /* Default styles for the Admin Panel */
637 TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
638 TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
639 TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
640 TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
641 TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
642 TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
643 TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
644 TABLE.typo3-editPanel TD { border: 0px; }
645 ';
646 }
647 // CSS_inlineStyle from TS
648 $style .= trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']);
649 $style .= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['cssInline.'], 'cssInline.');
650
651 if (trim($style)) {
652 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
653 $pageRenderer->addCssFile(TSpagegen::inline2TempFile($style, 'css'));
654 } else {
655 $pageRenderer->addCssInlineBlock('additionalTSFEInlineStyle', $style);
656 }
657 }
658
659 // Javascript Libraries
660 if (is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.'])) {
661 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG']) {
662 $pageRenderer->loadSvg();
663 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['debug']) {
664 $pageRenderer->enableSvgDebug();
665 }
666 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['forceFlash']) {
667 $pageRenderer->svgForceFlash();
668 }
669 }
670
671 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Prototype']) {
672 $pageRenderer->loadPrototype();
673 }
674 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous']) {
675 $modules = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] : '';
676 $pageRenderer->loadScriptaculous($modules);
677 }
678 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore']) {
679 $pageRenderer->loadExtCore();
680 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore.']['debug']) {
681 $pageRenderer->enableExtCoreDebug();
682 }
683 }
684 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs']) {
685 $css = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['css'] ? TRUE : FALSE;
686 $theme = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['theme'] ? TRUE : FALSE;
687 $adapter = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] : '';
688 $pageRenderer->loadExtJs($css, $theme, $adapter);
689 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['debug']) {
690 $pageRenderer->enableExtJsDebug();
691 }
692 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['quickTips']) {
693 $pageRenderer->enableExtJSQuickTips();
694 }
695 }
696 }
697
698 // JavaScript library files
699 if (is_array($GLOBALS['TSFE']->pSetup['includeJSlibs.'])) {
700 foreach ($GLOBALS['TSFE']->pSetup['includeJSlibs.'] as $key => $JSfile) {
701 if (!is_array($JSfile)) {
702 $ss = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
703 if ($ss) {
704 $type = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['type'];
705 if (! $type) {
706 $type = 'text/javascript';
707 }
708 $pageRenderer->addJsLibrary(
709 $key,
710 $ss,
711 $type,
712 $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
713 $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
714 $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['allWrap']
715 );
716 }
717 }
718 }
719 }
720
721 if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'])) {
722 foreach ($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'] as $key => $JSfile) {
723 if (!is_array($JSfile)) {
724 $ss = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
725 if ($ss) {
726 $type = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['type'];
727 if (! $type) {
728 $type = 'text/javascript';
729 }
730 $pageRenderer->addJsFooterLibrary(
731 $key,
732 $ss,
733 $type,
734 $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
735 $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
736 $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['allWrap']
737 );
738 }
739 }
740 }
741 }
742
743 // JavaScript files
744 if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
745 foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key => $JSfile) {
746 if (!is_array($JSfile)) {
747 $ss = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
748 if ($ss) {
749 $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['type'];
750 if (! $type) {
751 $type = 'text/javascript';
752 }
753 $pageRenderer->addJsFile(
754 $ss,
755 $type,
756 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['compress'] ? TRUE : FALSE,
757 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
758 $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap']
759 );
760 }
761 }
762 }
763 }
764
765 if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooter.'])) {
766 foreach ($GLOBALS['TSFE']->pSetup['includeJSFooter.'] as $key => $JSfile) {
767 if (!is_array($JSfile)) {
768 $ss = $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
769 if ($ss) {
770 $type = $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['type'];
771 if (! $type) {
772 $type = 'text/javascript';
773 }
774 $pageRenderer->addJsFooterFile(
775 $ss,
776 $type,
777 $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['compress'] ? TRUE : FALSE,
778 $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
779 $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['allWrap']
780 );
781 }
782 }
783 }
784 }
785
786 // Headerdata
787 if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
788 $pageRenderer->addHeaderData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'], 'headerData.'));
789 }
790
791 // Footerdata
792 if (is_array($GLOBALS['TSFE']->pSetup['footerData.'])) {
793 $pageRenderer->addFooterData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['footerData.'], 'footerData.'));
794 }
795
796 // Title
797 $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']);
798 if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
799 $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array (), $titleTagContent);
800 }
801
802 if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle']) !== 2) {
803 $pageRenderer->setTitle($titleTagContent);
804 }
805
806 // add ending slash only to documents rendered as xhtml
807 $endingSlash = $GLOBALS['TSFE']->xhtmlVersion ? ' /' : '';
808
809 $pageRenderer->addMetaTag('<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS"' . $endingSlash . '>');
810
811 $conf = $GLOBALS['TSFE']->pSetup['meta.'];
812 if (is_array($conf)) {
813 foreach ($conf as $theKey => $theValue) {
814 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
815 if (strstr($theKey, '.')) {
816 $theKey = substr($theKey, 0, - 1);
817 }
818 $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey], $conf[$theKey . '.']);
819 $key = $theKey;
820 if (trim($val)) {
821 $a = 'name';
822 if (strtolower($key) == 'refresh') {
823 $a = 'http-equiv';
824 }
825 $pageRenderer->addMetaTag('<meta ' . $a . '="' . $key . '" content="' . htmlspecialchars(trim($val)) . '"' . $endingSlash . '>');
826 }
827 }
828 }
829 }
830
831 unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
832 unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
833
834 if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
835 // Storing the JSCode and JSImgCode vars...
836 $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
837 $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
838 $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
839 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
840 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
841 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
842
843
844 $GLOBALS['TSFE']->additionalHeaderData = array ('<!--HD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->'); // Clearing the array
845 $GLOBALS['TSFE']->divSection .= '<!--TDS_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->';
846 } else {
847 $GLOBALS['TSFE']->INTincScript_loadJSCode();
848 }
849 $JSef = TSpagegen::JSeventFunctions();
850
851 // Adding default Java Script:
852 $scriptJsCode = '
853 var browserName = navigator.appName;
854 var browserVer = parseInt(navigator.appVersion);
855 var version = "";
856 var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
857 if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
858 // Blurring links:
859 function blurLink(theObject) { //
860 if (msie4) {theObject.blur();}
861 }
862 ' . $JSef[0];
863
864 if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
865 $scriptJsCode .= '
866 // decrypt helper function
867 function decryptCharcode(n,start,end,offset) {
868 n = n + offset;
869 if (offset > 0 && n > end) {
870 n = start + (n - end - 1);
871 } else if (offset < 0 && n < start) {
872 n = end - (start - n - 1);
873 }
874 return String.fromCharCode(n);
875 }
876 // decrypt string
877 function decryptString(enc,offset) {
878 var dec = "";
879 var len = enc.length;
880 for(var i=0; i < len; i++) {
881 var n = enc.charCodeAt(i);
882 if (n >= 0x2B && n <= 0x3A) {
883 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
884 } else if (n >= 0x40 && n <= 0x5A) {
885 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
886 } else if (n >= 0x61 && n <= 0x7A) {
887 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
888 } else {
889 dec += enc.charAt(i);
890 }
891 }
892 return dec;
893 }
894 // decrypt spam-protected emails
895 function linkTo_UnCryptMailto(s) {
896 location.href = decryptString(s,' . ($GLOBALS['TSFE']->spamProtectEmailAddresses * - 1) . ');
897 }
898 ';
899 }
900
901 //add inline JS
902 $inlineJS = '';
903
904 // defined in php
905 if (is_array($GLOBALS['TSFE']->inlineJS)) {
906 foreach ($GLOBALS['TSFE']->inlineJS as $key => $val) {
907 if (! is_array($val)) {
908 $inlineJS .= LF . $val . LF;
909 }
910 }
911 }
912
913 // defined in TS with page.inlineJS
914 // Javascript inline code
915 $inline = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsInline.'], 'jsInline.');
916 if ($inline) {
917 $inlineJS .= LF . $inline . LF;
918 }
919
920 // Javascript inline code for Footer
921 $inlineFooterJs = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsFooterInline.'], 'jsFooterInline.');
922
923 // Should minify?
924 if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
925 $pageRenderer->enableCompressJavascript();
926 $minifyErrorScript = $minifyErrorInline = '';
927 $scriptJsCode = t3lib_div::minifyJavaScript($scriptJsCode, $minifyErrorScript);
928 if ($minifyErrorScript) {
929 $GLOBALS['TT']->setTSlogMessage($minifyErrorScript, 3);
930 }
931 if ($inlineJS) {
932 $inlineJS = t3lib_div::minifyJavaScript($inlineJS, $minifyErrorInline);
933 if ($minifyErrorInline) {
934 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
935 }
936 }
937 if ($inlineFooterJs) {
938 $inlineFooterJs = t3lib_div::minifyJavaScript($inlineFooterJs, $minifyErrorInline);
939 if ($minifyErrorInline) {
940 $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
941 }
942 }
943
944 }
945
946 if (! $GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
947 // inlude default and inlineJS
948 if ($scriptJsCode) {
949 $pageRenderer->addJsInlineCode('_scriptCode', $scriptJsCode, $GLOBALS['TSFE']->config['config']['minifyJS']);
950 }
951 if ($inlineJS) {
952 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
953 }
954 if ($inlineFooterJs) {
955 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
956 }
957 } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS'] === 'external') {
958 /*
959 This keeps inlineJS from *_INT Objects from being moved to external files.
960 At this point in frontend rendering *_INT Objects only have placeholders instead
961 of actual content so moving these placeholders to external files would
962 a) break the JS file (syntax errors due to the placeholders)
963 b) the needed JS would never get included to the page
964 Therefore inlineJS from *_INT Objects must not be moved to external files but
965 kept internal.
966 */
967 $inlineJSint = '';
968 self::stripIntObjectPlaceholder($inlineJS, $inlineJSint);
969 if ($inlineJSint) {
970 $pageRenderer->addJsInlineCode('TS_inlineJSint', $inlineJSint, $GLOBALS['TSFE']->config['config']['minifyJS']);
971 }
972 $pageRenderer->addJsFile(TSpagegen::inline2TempFile($scriptJsCode . $inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
973
974 if ($inlineFooterJs) {
975 $inlineFooterJSint = '';
976 self::stripIntObjectPlaceholder($inlineFooterJs, $inlineFooterJSint);
977 if ($inlineFooterJSint) {
978 $pageRenderer->addJsFooterInlineCode('TS_inlineFooterJSint', $inlineFooterJSint, $GLOBALS['TSFE']->config['config']['minifyJS']);
979 }
980 $pageRenderer->addJsFooterFile(TSpagegen::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
981 }
982 } else {
983 // include only inlineJS
984 if ($inlineJS) {
985 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
986 }
987 if ($inlineFooterJs) {
988 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
989 }
990 }
991
992 // ExtJS specific code
993 if (is_array($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.'])) {
994 $pageRenderer->addInlineLanguageLabelArray($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.']);
995 }
996
997 if (is_array($GLOBALS['TSFE']->pSetup['inlineSettings.'])) {
998 $pageRenderer->addInlineSettingArray('TS', $GLOBALS['TSFE']->pSetup['inlineSettings.']);
999 }
1000
1001 if (is_array($GLOBALS['TSFE']->pSetup['extOnReady.'])) {
1002 $pageRenderer->addExtOnReadyCode($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['extOnReady.'], 'extOnReady.'));
1003 }
1004
1005 // compression and concatenate settings
1006 if ($GLOBALS['TSFE']->config['config']['minifyCSS']) {
1007 $pageRenderer->enableCompressCss();
1008 }
1009 if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
1010 $pageRenderer->enableCompressJavascript();
1011 }
1012 if ($GLOBALS['TSFE']->config['config']['concatenateJsAndCss']) {
1013 $pageRenderer->enableConcatenateFiles();
1014 }
1015
1016 // add header data block
1017 if ($GLOBALS['TSFE']->additionalHeaderData) {
1018 $pageRenderer->addHeaderData(implode(LF, $GLOBALS['TSFE']->additionalHeaderData));
1019 }
1020
1021 // add footer data block
1022 if ($GLOBALS['TSFE']->additionalFooterData) {
1023 $pageRenderer->addFooterData(implode(LF, $GLOBALS['TSFE']->additionalFooterData));
1024 }
1025
1026 // Header complete, now add content
1027
1028
1029 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
1030 $fs = t3lib_div::makeInstance('tslib_frameset');
1031 $pageRenderer->addBodyContent($fs->make($GLOBALS['TSFE']->pSetup['frameSet.']));
1032 $pageRenderer->addBodyContent(LF . '<noframes>' . LF);
1033 }
1034
1035 // Bodytag:
1036 $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
1037 if (! $defBT)
1038 $defBT = $GLOBALS['TSFE']->defaultBodyTag;
1039 $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
1040 if ($bgImg = $GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'], $GLOBALS['TSFE']->pSetup['bgImg.'])) {
1041 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS["TSFE"]->absRefPrefix . $bgImg[3] . '">';
1042 }
1043
1044 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
1045 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
1046 if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
1047 // Setting margins in CSS, see above
1048 } else {
1049 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
1050 }
1051 }
1052
1053 if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
1054 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
1055 }
1056
1057 if (count($JSef[1])) { // Event functions:
1058 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
1059 }
1060 $pageRenderer->addBodyContent(LF . $bodyTag);
1061
1062 // Div-sections
1063 if ($GLOBALS['TSFE']->divSection) {
1064 $pageRenderer->addBodyContent(LF . $GLOBALS['TSFE']->divSection);
1065 }
1066
1067 // Page content
1068 $pageRenderer->addBodyContent(LF . $pageContent);
1069
1070 // Render complete page
1071 $GLOBALS['TSFE']->content = $pageRenderer->render();
1072
1073 // Ending page
1074 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
1075 $GLOBALS['TSFE']->content .= LF . '</noframes>';
1076 }
1077
1078 }
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092 /*************************
1093 *
1094 * Helper functions
1095 * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
1096 *
1097 *************************/
1098
1099 /**
1100 * Searches for placeholder created from *_INT cObjects, removes them from
1101 * $searchString and merges them to $intObjects
1102 *
1103 * @param string $searchString: the String which should be cleaned from int-object markers
1104 * @param string $intObjects: the String the found int-placeholders are moved to (for further processing)
1105 */
1106 protected static function stripIntObjectPlaceholder(&$searchString, &$intObjects) {
1107 $tempArray = array();
1108 preg_match_all('/\<\!--INT_SCRIPT.[a-z0-9]*--\>/', $searchString, $tempArray);
1109 $searchString = preg_replace('/\<\!--INT_SCRIPT.[a-z0-9]*--\>/', '', $searchString);
1110 $intObjects = implode('', $tempArray[0]);
1111 }
1112
1113 /**
1114 * Writes string to a temporary file named after the md5-hash of the string
1115 *
1116 * @param string CSS styles / JavaScript to write to file.
1117 * @param string Extension: "css" or "js"
1118 * @return string <script> or <link> tag for the file.
1119 */
1120 public static function inline2TempFile($str, $ext) {
1121
1122 // Create filename / tags:
1123 $script = '';
1124 switch ($ext) {
1125 case 'js' :
1126 $script = 'typo3temp/javascript_' . substr(md5($str), 0, 10) . '.js';
1127 $output = $GLOBALS['TSFE']->absRefPrefix . $script;
1128 break;
1129 case 'css' :
1130 $script = 'typo3temp/stylesheet_' . substr(md5($str), 0, 10) . '.css';
1131 $output = $GLOBALS['TSFE']->absRefPrefix . $script;
1132 break;
1133 }
1134
1135 // Write file:
1136 if ($script) {
1137 if (! @is_file(PATH_site . $script)) {
1138 t3lib_div::writeFile(PATH_site . $script, $str);
1139 }
1140 }
1141
1142 return $output;
1143 }
1144
1145 /**
1146 * 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.
1147 *
1148 * @param string The string in which to find $needle
1149 * @param string The string to find in $haystack
1150 * @return boolean Returns true if $needle matches or is found in $haystack
1151 */
1152 public static function isAllowedLinkVarValue($haystack,$needle) {
1153 $OK = false;
1154
1155 if ($needle=='int' || $needle=='integer') { // Integer
1156
1157 if (t3lib_div::testInt($haystack)) {
1158 $OK = true;
1159 }
1160
1161 } elseif (preg_match('/^\/.+\/[imsxeADSUXu]*$/', $needle)) { // Regular expression, only "//" is allowed as delimiter
1162
1163 if (@preg_match($needle, $haystack)) {
1164 $OK = true;
1165 }
1166
1167 } elseif (strstr($needle,'-')) { // Range
1168
1169 if (t3lib_div::testInt($haystack)) {
1170 $range = explode('-',$needle);
1171 if ($range[0] <= $haystack && $range[1] >= $haystack) {
1172 $OK = true;
1173 }
1174 }
1175
1176 } elseif (strstr($needle,'|')) { // List
1177
1178 $haystack = str_replace(' ','',$haystack); // Trim the input
1179 if (strstr('|'.$needle.'|', '|'.$haystack.'|')) {
1180 $OK = true;
1181 }
1182
1183 } elseif (!strcmp($needle,$haystack)) { // String comparison
1184 $OK = true;
1185 }
1186
1187 return $OK;
1188 }
1189 }
1190
1191 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php'])) {
1192 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']);
1193 }
1194
1195
1196
1197 /**
1198 * Class for fetching record relations for the frontend.
1199 *
1200 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
1201 * @package TYPO3
1202 * @subpackage tslib
1203 * @see tslib_cObj::RECORDS()
1204 */
1205 class FE_loadDBGroup extends t3lib_loadDBGroup {
1206 var $fromTC = 0; // Means that everything is returned instead of only uid and label-field
1207 }
1208
1209 ?>