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