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