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