b54f6f001d6c65c061926794155d5deeaaa0965f
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_pagegen.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Libraries for pagegen.php
29 * The script "pagegen.php" is included by "index_ts.php" when a page is not cached but needs to be rendered.
30 *
31 * $Id$
32 * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
33 * XHTML compliant
34 *
35 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 */
37 /**
38 * [CLASS/FUNCTION INDEX of SCRIPT]
39 *
40 *
41 *
42 * 88: class TSpagegen
43 * 95: function pagegenInit()
44 * 271: function getIncFiles()
45 * 304: function JSeventFunctions()
46 * 338: function renderContent()
47 * 365: function renderContentWithHeader($pageContent)
48 *
49 * SECTION: Helper functions
50 * 827: function inline2TempFile($str,$ext)
51 *
52 *
53 * 881: class FE_loadDBGroup extends t3lib_loadDBGroup
54 *
55 * TOTAL FUNCTIONS: 6
56 * (This index is automatically created/updated by the extension "extdeveval")
57 *
58 */
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 /**
79 * Class for starting TypoScript page generation
80 *
81 * The class is not instantiated as an objects but called directly with the "::" operator.
82 * eg: TSpagegen::pagegenInit()
83 *
84 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
85 * @package TYPO3
86 * @subpackage tslib
87 */
88 class TSpagegen {
89
90 /**
91 * Setting some vars in TSFE, primarily based on TypoScript config settings.
92 *
93 * @return void
94 */
95 function pagegenInit() {
96 if ($GLOBALS['TSFE']->page['content_from_pid']>0) {
97 $temp_copy_TSFE = clone($GLOBALS['TSFE']); // make REAL copy of TSFE object - not reference!
98 $temp_copy_TSFE->id = $GLOBALS['TSFE']->page['content_from_pid']; // Set ->id to the content_from_pid value - we are going to evaluate this pid as was it a given id for a page-display!
99 $temp_copy_TSFE->getPageAndRootlineWithDomain($GLOBALS['TSFE']->config['config']['content_from_pid_allowOutsideDomain']?0:$GLOBALS['TSFE']->domainStartPage);
100 $GLOBALS['TSFE']->contentPid = intval($temp_copy_TSFE->id);
101 unset($temp_copy_TSFE);
102 }
103 if ($GLOBALS['TSFE']->config['config']['MP_defaults']) {
104 $temp_parts = t3lib_div::trimExplode('|',$GLOBALS['TSFE']->config['config']['MP_defaults'],1);
105 reset($temp_parts);
106 while(list(,$temp_p)=each($temp_parts)) {
107 list($temp_idP,$temp_MPp) = explode(':',$temp_p,2);
108 $temp_ids=t3lib_div::intExplode(',',$temp_idP);
109 reset($temp_ids);
110 while(list(,$temp_id)=each($temp_ids)) {
111 $GLOBALS['TSFE']->MP_defaults[$temp_id]=$temp_MPp;
112 }
113 }
114 }
115 if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP']) {
116 $temp_parts = t3lib_div::trimExplode(',',$GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP'],1);
117 foreach ($temp_parts as $temp_p) {
118 $GLOBALS['TSFE']->pEncAllowedParamNames[$temp_p]=1;
119 }
120 }
121
122
123 // Global vars...
124 $GLOBALS['TSFE']->indexedDocTitle = $GLOBALS['TSFE']->page['title'];
125 $GLOBALS['TSFE']->debug = ''.$GLOBALS['TSFE']->config['config']['debug'];
126
127 // Base url:
128 if ($GLOBALS['TSFE']->config['config']['baseURL']) {
129 if ($GLOBALS['TSFE']->config['config']['baseURL']==='1') {
130 // Deprecated property, going to be dropped.
131 $error = 'Unsupported TypoScript property was found in this template: "config.baseURL="1"
132
133 This setting has been deprecated in TYPO 3.8.1 due to security concerns.
134 You need to change this value to the URL of your website root, otherwise TYPO3 will not work!
135
136 See <a href="http://wiki.typo3.org/index.php/TYPO3_3.8.1" target="_blank">wiki.typo3.org/index.php/TYPO3_3.8.1</a> for more information.';
137
138 $GLOBALS['TSFE']->printError(nl2br($error));
139 exit;
140 } else {
141 $GLOBALS['TSFE']->baseUrl = $GLOBALS['TSFE']->config['config']['baseURL'];
142 }
143 $GLOBALS['TSFE']->anchorPrefix = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
144 }
145
146 // Internal and External target defaults
147 $GLOBALS['TSFE']->intTarget = ''.$GLOBALS['TSFE']->config['config']['intTarget'];
148 $GLOBALS['TSFE']->extTarget = ''.$GLOBALS['TSFE']->config['config']['extTarget'];
149 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'] === 'ascii') {
150 $GLOBALS['TSFE']->spamProtectEmailAddresses = 'ascii';
151 } else {
152 $GLOBALS['TSFE']->spamProtectEmailAddresses = t3lib_div::intInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'],-10,10,0);
153 }
154
155
156 $GLOBALS['TSFE']->absRefPrefix = trim(''.$GLOBALS['TSFE']->config['config']['absRefPrefix']);
157 if ((!strcmp($GLOBALS['TSFE']->config['config']['simulateStaticDocuments'],'PATH_INFO') || $GLOBALS['TSFE']->absRefPrefix_force)
158 && !$GLOBALS['TSFE']->absRefPrefix) {
159 $GLOBALS['TSFE']->absRefPrefix=t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
160 } // Force absRefPrefix to this value is PATH_INFO is used.
161
162 if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) {
163 $tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'_top',$GLOBALS['TSFE']->no_cache,'');
164 $GLOBALS['TSFE']->JSCode = 'if(!parent.'.trim($GLOBALS['TSFE']->sPre).' && !parent.view_frame) top.location.href="'.$GLOBALS['TSFE']->baseUrlWrap($tdlLD['totalURL']).'"';
165 }
166 $GLOBALS['TSFE']->compensateFieldWidth = ''.$GLOBALS['TSFE']->config['config']['compensateFieldWidth'];
167 $GLOBALS['TSFE']->lockFilePath = ''.$GLOBALS['TSFE']->config['config']['lockFilePath'];
168 $GLOBALS['TSFE']->lockFilePath = $GLOBALS['TSFE']->lockFilePath ? $GLOBALS['TSFE']->lockFilePath : 'fileadmin/';
169 $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'];
170 $GLOBALS['TSFE']->TYPO3_CONF_VARS['GFX']['im_noScaleUp'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
171
172 $GLOBALS['TSFE']->ATagParams = trim($GLOBALS['TSFE']->config['config']['ATagParams']) ? ' '.trim($GLOBALS['TSFE']->config['config']['ATagParams']) : '';
173 if ($GLOBALS['TSFE']->config['config']['setJS_mouseOver']) $GLOBALS['TSFE']->setJS('mouseOver');
174 if ($GLOBALS['TSFE']->config['config']['setJS_openPic']) $GLOBALS['TSFE']->setJS('openPic');
175
176 $GLOBALS['TSFE']->sWordRegEx='';
177 $GLOBALS['TSFE']->sWordList = t3lib_div::_GP('sword_list');
178 if (is_array($GLOBALS['TSFE']->sWordList)) {
179 $standAlone = trim(''.$GLOBALS['TSFE']->config['config']['sword_standAlone']);
180 $noMixedCase = trim(''.$GLOBALS['TSFE']->config['config']['sword_noMixedCase']);
181
182 $space = ($standAlone) ? '[[:space:]]' : '';
183 reset($GLOBALS['TSFE']->sWordList);
184 while (list($key,$val) = each($GLOBALS['TSFE']->sWordList)) {
185 if (trim($val)) {
186 if (!$noMixedCase) {
187 $GLOBALS['TSFE']->sWordRegEx.= $space.sql_regcase(quotemeta($val)).$space.'|';
188 } else {
189 $GLOBALS['TSFE']->sWordRegEx.= $space.quotemeta($val).$space.'|';
190 }
191 }
192 }
193 $GLOBALS['TSFE']->sWordRegEx = ereg_replace('\|$','',$GLOBALS['TSFE']->sWordRegEx);
194 }
195
196 // linkVars
197 $GLOBALS['TSFE']->linkVars = ''.$GLOBALS['TSFE']->config['config']['linkVars'];
198 if ($GLOBALS['TSFE']->linkVars) {
199 $linkVarArr = explode(',',$GLOBALS['TSFE']->linkVars);
200 $GLOBALS['TSFE']->linkVars='';
201 reset($linkVarArr);
202 while(list(,$val)=each($linkVarArr)) {
203 $val=trim($val);
204 $GET = t3lib_div::_GET();
205 if ($val && isset($GET[$val])) {
206 if (!is_array($GET[$val])) {
207 $GLOBALS['TSFE']->linkVars.='&'.$val.'='.rawurlencode($GET[$val]);
208 } else {
209 $GLOBALS['TSFE']->linkVars.=t3lib_div::implodeArrayForUrl($val,$GET[$val]);
210 }
211 }
212 }
213 } else {
214 $GLOBALS['TSFE']->linkVars='';
215 }
216
217 // Setting XHTML-doctype from doctype
218 if (!$GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
219 $GLOBALS['TSFE']->config['config']['xhtmlDoctype'] = $GLOBALS['TSFE']->config['config']['doctype'];
220 }
221
222 if ($GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
223 $GLOBALS['TSFE']->xhtmlDoctype = $GLOBALS['TSFE']->config['config']['xhtmlDoctype'];
224
225 // Checking XHTML-docytpe
226 switch((string)$GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
227 case 'xhtml_trans':
228 case 'xhtml_strict':
229 case 'xhtml_frames':
230 $GLOBALS['TSFE']->xhtmlVersion = 100;
231 break;
232 case 'xhtml_basic':
233 $GLOBALS['TSFE']->xhtmlVersion = 105;
234 break;
235 case 'xhtml_11':
236 $GLOBALS['TSFE']->xhtmlVersion = 110;
237 break;
238 case 'xhtml_2':
239 $GLOBALS['TSFE']->xhtmlVersion = 200;
240 break;
241 default:
242 $GLOBALS['TSFE']->xhtmlDoctype = '';
243 $GLOBALS['TSFE']->xhtmlVersion = 0;
244 }
245 }
246 }
247
248 /**
249 * Returns an array with files to include. These files are the ones set up in TypoScript config.
250 *
251 * @return array Files to include. Paths are relative to PATH_site.
252 */
253 function getIncFiles() {
254 $incFilesArray = array();
255 // Get files from config.includeLibrary
256 $includeLibrary = trim(''.$GLOBALS['TSFE']->config['config']['includeLibrary']);
257 if ($includeLibrary) {
258 $incFile=$GLOBALS['TSFE']->tmpl->getFileName($includeLibrary);
259 if ($incFile) {
260 $incFilesArray[] = $incFile;
261 }
262 }
263
264 if (is_array($GLOBALS['TSFE']->pSetup['includeLibs.'])) {$incLibs=$GLOBALS['TSFE']->pSetup['includeLibs.'];} else {$incLibs=array();}
265 if (is_array($GLOBALS['TSFE']->tmpl->setup['includeLibs.'])) {$incLibs+=$GLOBALS['TSFE']->tmpl->setup['includeLibs.'];} // toplevel 'includeLibs' is added to the PAGE.includeLibs. In that way, PAGE-libs get first priority, because if the key already exist, it's not altered. (Due to investigation by me)
266 if (count($incLibs)) {
267 reset($incLibs);
268 while(list(,$theLib)=each($incLibs)) {
269 if (!is_array($theLib) && $incFile=$GLOBALS['TSFE']->tmpl->getFileName($theLib)) {
270 $incFilesArray[] = $incFile;
271 }
272 }
273 }
274 // Include HTML mail library?
275 if ($GLOBALS['TSFE']->config['config']['incT3Lib_htmlmail']) {
276 $incFilesArray[] = 't3lib/class.t3lib_htmlmail.php';
277 }
278 return $incFilesArray;
279 }
280
281 /**
282 * Processing JavaScript handlers
283 *
284 * @return array Array with a) a JavaScript section with event handlers and variables set and b) an array with attributes for the body tag.
285 */
286 function JSeventFunctions() {
287 $functions=array();
288 $setEvents=array();
289 $setBody=array();
290
291 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'])) {
292 $functions[]=' function T3_onmousemoveWrapper(e) { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']).' }';
293 $setEvents[]=' document.onmousemove=T3_onmousemoveWrapper;';
294 }
295 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onmouseup']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'])) {
296 $functions[]=' function T3_onmouseupWrapper(e) { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onmouseup']).' }';
297 $setEvents[]=' document.onmouseup=T3_onmouseupWrapper;';
298 }
299 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onload']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onload'])) {
300 $functions[]=' function T3_onloadWrapper() { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onload']).' }';
301 $setEvents[]=' document.onload=T3_onloadWrapper;';
302 $setBody[]='onload="T3_onloadWrapper();"';
303 }
304
305 return Array(count($functions)?'
306 <script type="text/javascript">
307 /*<![CDATA[*/
308 '.implode(chr(10),$functions).'
309 '.implode(chr(10),$setEvents).'
310 /*]]>*/
311 </script>
312 ':'',$setBody);
313 }
314
315 /**
316 * Rendering the page content
317 *
318 * @return void
319 */
320 function renderContent() {
321 // PAGE CONTENT
322 $GLOBALS['TT']->incStackPointer();
323 $GLOBALS['TT']->push($GLOBALS['TSFE']->sPre, 'PAGE');
324 $pageContent = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup);
325
326 if ($GLOBALS['TSFE']->pSetup['wrap']) {$pageContent = $GLOBALS['TSFE']->cObj->wrap($pageContent, $GLOBALS['TSFE']->pSetup['wrap']);}
327 if ($GLOBALS['TSFE']->pSetup['stdWrap.']) {$pageContent = $GLOBALS['TSFE']->cObj->stdWrap($pageContent, $GLOBALS['TSFE']->pSetup['stdWrap.']);}
328
329 // PAGE HEADER (after content - maybe JS is inserted!
330
331 // if 'disableAllHeaderCode' is set, all the header-code is discarded!
332 if ($GLOBALS['TSFE']->config['config']['disableAllHeaderCode']) {
333 $GLOBALS['TSFE']->content = $pageContent;
334 } else {
335 TSpagegen::renderContentWithHeader($pageContent);
336 }
337 $GLOBALS['TT']->pull($GLOBALS['TT']->LR?$GLOBALS['TSFE']->content:'');
338 $GLOBALS['TT']->decStackPointer();
339 }
340
341 /**
342 * Rendering normal HTML-page with header by wrapping the generated content ($pageContent) in body-tags and setting the header accordingly.
343 *
344 * @param string The page content which TypoScript objects has generated
345 * @return void
346 */
347 function renderContentWithHeader($pageContent) {
348 $customContent = $GLOBALS['TSFE']->config['config']['headerComment'];
349 if (trim($customContent)) {
350 $customContent = chr(10).$customContent;
351 } else $customContent='';
352
353 // Setting charset:
354 $theCharset = $GLOBALS['TSFE']->metaCharset;
355
356 // Reset the content variables:
357 $GLOBALS['TSFE']->content='';
358 $htmlTagAttributes = array();
359 $htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ? $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] : 'en';
360
361 // Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
362 if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
363 $htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
364 }
365
366 // Setting document type:
367 $docTypeParts = array();
368 // Part 1: XML prologue
369 switch((string)$GLOBALS['TSFE']->config['config']['xmlprologue']) {
370 case 'none':
371 break;
372 case 'xml_10':
373 $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
374 break;
375 case 'xml_11':
376 $docTypeParts[]='<?xml version="1.1" encoding="'.$theCharset.'"?>';
377 break;
378 case '':
379 if ($GLOBALS['TSFE']->xhtmlVersion) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
380 break;
381 default:
382 $docTypeParts[]=$GLOBALS['TSFE']->config['config']['xmlprologue'];
383 }
384 // Part 2: DTD
385 if ($GLOBALS['TSFE']->config['config']['doctype']) {
386 switch((string)$GLOBALS['TSFE']->config['config']['doctype']) {
387 case 'xhtml_trans':
388 $docTypeParts[]='<!DOCTYPE html
389 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
390 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
391 break;
392 case 'xhtml_strict':
393 $docTypeParts[]='<!DOCTYPE html
394 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
395 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
396 break;
397 case 'xhtml_frames':
398 $docTypeParts[]='<!DOCTYPE html
399 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
400 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
401 break;
402 case 'xhtml_basic':
403 $docTypeParts[]='<!DOCTYPE html
404 PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
405 "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
406 break;
407 case 'xhtml_11':
408 $docTypeParts[]='<!DOCTYPE html
409 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
410 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
411 break;
412 case 'xhtml_2':
413 $docTypeParts[]='<!DOCTYPE html
414 PUBLIC "-//W3C//DTD XHTML 2.0//EN"
415 "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
416 break;
417 case 'none':
418 break;
419 default:
420 $docTypeParts[] = $GLOBALS['TSFE']->config['config']['doctype'];
421 }
422 } else {
423 $docTypeParts[]='<!DOCTYPE html
424 PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
425 }
426
427 if ($GLOBALS['TSFE']->xhtmlVersion) {
428
429 // Setting <html> tag attributes:
430 $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
431 $htmlTagAttributes['xml:lang'] = $htmlLang;
432 if ($GLOBALS['TSFE']->xhtmlVersion < 110) {
433 $htmlTagAttributes['lang'] = $htmlLang;
434 }
435 }
436
437 // Swap XML and doctype order around (for MSIE / Opera standards compliance)
438 if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
439 $docTypeParts = array_reverse($docTypeParts);
440 }
441
442 // Adding doctype parts:
443 $GLOBALS['TSFE']->content.= count($docTypeParts) ? implode(chr(10),$docTypeParts).chr(10) : '';
444
445 // Begin header section:
446 if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'],'none')) {
447 $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : t3lib_div::implodeAttributes($htmlTagAttributes);
448 } else {
449 $_attr = '';
450 }
451 $GLOBALS['TSFE']->content.='<html'.($_attr ? ' '.$_attr : '').'>';
452
453 // Head tag:
454 $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : '<head>';
455 $GLOBALS['TSFE']->content.= chr(10).$headTag;
456
457 // Setting charset meta tag:
458 $GLOBALS['TSFE']->content.='
459 <meta http-equiv="Content-Type" content="text/html; charset='.$theCharset.'" />';
460
461 $GLOBALS['TSFE']->content.='
462
463 <!-- '.($customContent?$customContent.chr(10):'').'
464 This website is powered by TYPO3 - inspiring people to share!
465 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
466 TYPO3 is copyright 1998-2006 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
467 Information and contribution at http://typo3.com/ and http://typo3.org/
468 -->
469 ';
470
471
472 if ($GLOBALS['TSFE']->baseUrl) {
473 $GLOBALS['TSFE']->content.='
474 <base href="'.htmlspecialchars($GLOBALS['TSFE']->baseUrl).'" />';
475 }
476
477 if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
478 $ss=$path.$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
479 $GLOBALS['TSFE']->content.='
480 <link rel="SHORTCUT ICON" href="'.htmlspecialchars($ss).'" />';
481 }
482
483 // Including CSS files
484 if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
485 $temp_styleLines=array();
486 foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key=>$iCSScode) {
487 if (is_array($iCSScode) && $iCSScode['_CSS_DEFAULT_STYLE']) {
488 $temp_styleLines[]='/* default styles for extension "'.substr($key,0,-1).'" */'.chr(10).$iCSScode['_CSS_DEFAULT_STYLE'];
489 }
490 }
491 if (count($temp_styleLines)) {
492 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
493 $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile(implode(chr(10),$temp_styleLines),'css');
494 } else {
495 $GLOBALS['TSFE']->content.='
496 <style type="text/css">
497 /*<![CDATA[*/
498 <!--
499 '.implode(chr(10),$temp_styleLines).'
500 -->
501 /*]]>*/
502 </style>';
503 }
504 }
505 }
506
507 if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
508 $ss=$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
509 if ($ss) {
510 $GLOBALS['TSFE']->content.='
511 <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($ss).'" />';
512 }
513 }
514 if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
515 foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key=>$iCSSfile) {
516 if (!is_array($iCSSfile)) {
517 $ss=$GLOBALS['TSFE']->tmpl->getFileName($iCSSfile);
518 if ($ss) {
519 if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['import']) {
520 if (substr($ss,0,1)!='/') { // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
521 $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/'.$ss;
522 }
523 $GLOBALS['TSFE']->content.='
524 <style type="text/css">
525 <!--
526 @import url("'.htmlspecialchars($ss).'") '.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media']).';
527 -->
528 </style>
529 ';
530 } else {
531 $GLOBALS['TSFE']->content.='
532 <link rel="'.($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['alternate'] ? 'alternate stylesheet' : 'stylesheet').'" type="text/css" href="'.htmlspecialchars($ss).'"'.
533 ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title'] ? ' title="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title']).'"' : '').
534 ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media'] ? ' media="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media']).'"' : '').
535 ' />';
536 }
537 }
538 }
539 }
540 }
541
542 // Stylesheets
543 $style='';
544 $style.=trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']).chr(10);
545
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 $style.='
578 A:link {text-decoration: none}
579 A:visited {text-decoration: none}
580 A:active {text-decoration: none}';
581 }
582 if (trim($GLOBALS['TSFE']->pSetup['hover'])) {
583 $style.='
584 A:hover {color: '.trim($GLOBALS['TSFE']->pSetup['hover']).';}';
585 }
586 if (trim($GLOBALS['TSFE']->pSetup['hoverStyle'])) {
587 $style.='
588 A:hover {'.trim($GLOBALS['TSFE']->pSetup['hoverStyle']).'}';
589 }
590 if ($GLOBALS['TSFE']->pSetup['smallFormFields']) {
591 $style.='
592 SELECT { font-family: Verdana, Arial, Helvetica; font-size: 10px }
593 TEXTAREA { font-family: Verdana, Arial, Helvetica; font-size: 10px}
594 INPUT { font-family: Verdana, Arial, Helvetica; font-size: 10px }';
595 }
596 if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
597 $style.='
598
599 /* Default styles for the Admin Panel */
600 TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
601 TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
602 TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
603 TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
604 TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
605 TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
606 TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
607 TABLE.typo3-editPanel TD { border: 0px; }
608 ';
609 }
610
611 if (trim($style)) {
612 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
613 $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($style, 'css');
614 } else {
615 $GLOBALS['TSFE']->content.='
616 <style type="text/css">
617 /*<![CDATA[*/
618 <!--'.$style.'
619 -->
620 /*]]>*/
621 </style>';
622 }
623 }
624
625 // JavaScript files
626 if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
627 foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key=>$JSfile) {
628 if (!is_array($JSfile)) {
629 $ss = $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
630 if ($ss) {
631 $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['type'];
632 if (!$type) $type = 'text/javascript';
633
634 $GLOBALS['TSFE']->content.='
635 <script src="'.htmlspecialchars($ss).'" type="'.htmlspecialchars($type).'"></script>';
636 }
637 }
638 }
639 }
640
641
642
643
644
645 // Headerdata
646 if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
647 $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'],'headerData.');
648 }
649
650 // Title
651 $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle(
652 $GLOBALS['TSFE']->altPageTitle?$GLOBALS['TSFE']->altPageTitle:$GLOBALS['TSFE']->page['title'],
653 $GLOBALS['TSFE']->config['config']['noPageTitle'],
654 $GLOBALS['TSFE']->config['config']['pageTitleFirst']
655 );
656 if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
657 $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array(), $titleTagContent);
658 }
659
660 if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle'])!==2) {
661 $GLOBALS['TSFE']->content.='
662 <title>'.htmlspecialchars($titleTagContent).'</title>';
663 }
664 $GLOBALS['TSFE']->content.='
665 <meta name="generator" content="TYPO3 '.TYPO3_branch.' CMS" />';
666
667 $conf=$GLOBALS['TSFE']->pSetup['meta.'];
668 if (is_array($conf)) {
669 reset($conf);
670 while(list($theKey,$theValue)=each($conf)) {
671 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
672 if (strstr($theKey,'.')) {
673 $theKey = substr($theKey,0,-1);
674 }
675 $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey],$conf[$theKey.'.']);
676 $key = $theKey;
677 if (trim($val)) {
678 $a='name';
679 if (strtolower($key)=='refresh') {$a='http-equiv';}
680 $GLOBALS['TSFE']->content.= '
681 <meta '.$a.'="'.$key.'" content="'.htmlspecialchars(trim($val)).'" />';
682 }
683 }
684 }
685 }
686
687 unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
688 unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
689
690 if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
691 // Storing the JSCode and JSImgCode vars...
692 $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
693 $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
694 $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
695 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
696 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
697 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
698
699 $GLOBALS['TSFE']->additionalHeaderData = array('<!--HD_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->'); // Clearing the array
700 $GLOBALS['TSFE']->divSection.= '<!--TDS_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->';
701 } else {
702 $GLOBALS['TSFE']->INTincScript_loadJSCode();
703 }
704 $JSef = TSpagegen::JSeventFunctions();
705
706 // Adding default Java Script:
707 $_scriptCode = '
708 var browserName = navigator.appName;
709 var browserVer = parseInt(navigator.appVersion);
710 var version = "";
711 var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
712 if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
713 // Blurring links:
714 function blurLink(theObject) { //
715 if (msie4) {theObject.blur();}
716 }
717 ';
718
719 if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
720 $_scriptCode.= '
721 // decrypt helper function
722 function decryptCharcode(n,start,end,offset) {
723 n = n + offset;
724 if (offset > 0 && n > end) {
725 n = start + (n - end - 1);
726 } else if (offset < 0 && n < start) {
727 n = end - (start - n - 1);
728 }
729 return String.fromCharCode(n);
730 }
731 // decrypt string
732 function decryptString(enc,offset) {
733 var dec = "";
734 var len = enc.length;
735 for(var i=0; i < len; i++) {
736 var n = enc.charCodeAt(i);
737 if (n >= 0x2B && n <= 0x3A) {
738 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
739 } else if (n >= 0x40 && n <= 0x5A) {
740 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
741 } else if (n >= 0x61 && n <= 0x7A) {
742 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
743 } else {
744 dec += enc.charAt(i);
745 }
746 }
747 return dec;
748 }
749 // decrypt spam-protected emails
750 function linkTo_UnCryptMailto(s) {
751 location.href = decryptString(s,'.($GLOBALS['TSFE']->spamProtectEmailAddresses*-1).');
752 }
753 ';
754 }
755
756 if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
757 // NOTICE: The following code must be kept synchronized with "tslib/default.js"!!!
758 $GLOBALS['TSFE']->content.='
759 <script type="text/javascript">
760 /*<![CDATA[*/
761 <!--'.$_scriptCode.'
762 // -->
763 /*]]>*/
764 </script>';
765 } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS']==='external') {
766 $GLOBALS['TSFE']->content.= TSpagegen::inline2TempFile($_scriptCode, 'js');
767 }
768
769 $GLOBALS['TSFE']->content.= chr(10).implode($GLOBALS['TSFE']->additionalHeaderData,chr(10)).'
770 '.$JSef[0].'
771 </head>';
772 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
773 $fs = t3lib_div::makeInstance('tslib_frameset');
774 $GLOBALS['TSFE']->content.= $fs->make($GLOBALS['TSFE']->pSetup['frameSet.']);
775 $GLOBALS['TSFE']->content.= chr(10).'<noframes>'.chr(10);
776 }
777
778 // Bodytag:
779 $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'],$GLOBALS['TSFE']->pSetup['bodyTagCObject.'],'bodyTagCObject') : '';
780 if (!$defBT) $defBT = $GLOBALS['TSFE']->defaultBodyTag;
781 $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
782 if ($bgImg=$GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'],$GLOBALS['TSFE']->pSetup['bgImg.'])) {
783 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' background="'.$GLOBALS["TSFE"]->absRefPrefix.$bgImg[3].'">';
784 }
785
786 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
787 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
788 if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
789 // Setting margins in CSS, see above
790 } else {
791 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' leftmargin="'.$margins.'" topmargin="'.$margins.'" marginwidth="'.$margins.'" marginheight="'.$margins.'">';
792 }
793 }
794
795 if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
796 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']).'>';
797 }
798
799 if (count($JSef[1])) { // Event functions:
800 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim(implode(' ',$JSef[1])).'>';
801 }
802 $GLOBALS['TSFE']->content.= chr(10).$bodyTag;
803
804
805 // Div-sections
806 if ($GLOBALS['TSFE']->divSection) {
807 $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->divSection;
808 }
809
810 // Page content
811 $GLOBALS['TSFE']->content.= chr(10).$pageContent;
812
813 // Ending page
814 $GLOBALS['TSFE']->content.= chr(10).'</body>';
815 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
816 $GLOBALS['TSFE']->content.= chr(10).'</noframes>';
817 }
818 $GLOBALS['TSFE']->content.=chr(10).'</html>';
819 }
820
821
822
823
824
825
826
827
828
829
830
831
832
833 /*************************
834 *
835 * Helper functions
836 * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
837 *
838 *************************/
839
840 /**
841 * Writes string to a temporary file named after the md5-hash of the string
842 *
843 * @param string CSS styles / JavaScript to write to file.
844 * @param string Extension: "css" or "js"
845 * @return string <script> or <link> tag for the file.
846 */
847 function inline2TempFile($str,$ext) {
848
849 // Create filename / tags:
850 $script = '';
851 switch($ext) {
852 case 'js':
853 $script = 'typo3temp/javascript_'.substr(md5($str),0,10).'.js';
854 $output = '
855 <script type="text/javascript" src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'"></script>';
856 break;
857 case 'css':
858 $script = 'typo3temp/stylesheet_'.substr(md5($str),0,10).'.css';
859 $output = '
860 <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'" />';
861 break;
862 }
863
864 // Write file:
865 if ($script) {
866 if (!@is_file(PATH_site.$script)) {
867 t3lib_div::writeFile(PATH_site.$script,$str);
868 }
869 }
870
871 return $output;
872 }
873 }
874
875 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']) {
876 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']);
877 }
878
879
880
881 // ********************************************************
882 // Includes the search-class if $sword and $scols are set.
883 // ********************************************************
884 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
885 require_once(PATH_tslib.'class.tslib_search.php');
886 }
887
888 // ************
889 // LoadDBGroup
890 // ************
891 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
892
893 /**
894 * Class for fetching record relations for the frontend.
895 *
896 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
897 * @package TYPO3
898 * @subpackage tslib
899 * @see tslib_cObj::RECORDS()
900 */
901 class FE_loadDBGroup extends t3lib_loadDBGroup {
902 var $fromTC = 0; // Means the not only uid and label-field is returned, but everything
903 }
904
905 // **********************************
906 // includes stuff for graphical work
907 // **********************************
908 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
909 require_once(PATH_tslib.'class.tslib_gifbuilder.php');
910
911 // *************************
912 // includes menu-management
913 // *************************
914 require_once(PATH_tslib.'class.tslib_menu.php');
915
916 // *************************
917 // Global content object...
918 // *************************
919 require_once(PATH_tslib.'class.tslib_content.php');
920
921 ?>