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