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