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