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