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