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