6d6947d7b3b0af67b1cf36f9933da416ea927d92
[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 * 229: function getIncFiles()
45 * 262: function JSeventFunctions()
46 * 296: function renderContent()
47 * 323: function renderContentWithHeader($pageContent)
48 *
49 * SECTION: Helper functions
50 * 760: function inline2TempFile($str,$ext)
51 *
52 *
53 * 814: 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 = $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 $GLOBALS['TSFE']->baseUrl = (intval($GLOBALS['TSFE']->config['config']['baseURL']) ? t3lib_div::getIndpEnv('TYPO3_SITE_URL') : $GLOBALS['TSFE']->config['config']['baseURL']);
130 $GLOBALS['TSFE']->anchorPrefix = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
131 }
132
133 // Internal and External target defaults
134 $GLOBALS['TSFE']->intTarget = ''.$GLOBALS['TSFE']->config['config']['intTarget'];
135 $GLOBALS['TSFE']->extTarget = ''.$GLOBALS['TSFE']->config['config']['extTarget'];
136 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'] === 'ascii') {
137 $GLOBALS['TSFE']->spamProtectEmailAddresses = 'ascii';
138 } else {
139 $GLOBALS['TSFE']->spamProtectEmailAddresses = t3lib_div::intInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'],-5,1,0);
140 if ($GLOBALS['TSFE']->spamProtectEmailAddresses) {
141 $GLOBALS['TSFE']->additionalJavaScript['UnCryptMailto()']='
142 // JS function for uncrypting spam-protected emails:
143 function UnCryptMailto(s) { //
144 var n=0;
145 var r="";
146 for(var i=0; i < s.length; i++) {
147 n=s.charCodeAt(i);
148 if (n>=8364) {n = 128;}
149 r += String.fromCharCode(n-('.$GLOBALS['TSFE']->spamProtectEmailAddresses.'));
150 }
151 return r;
152 }
153 // JS function for uncrypting spam-protected emails:
154 function linkTo_UnCryptMailto(s) { //
155 location.href=UnCryptMailto(s);
156 }
157 ';
158 }
159 }
160
161
162 $GLOBALS['TSFE']->absRefPrefix = trim(''.$GLOBALS['TSFE']->config['config']['absRefPrefix']);
163 if ((!strcmp($GLOBALS['TSFE']->config['config']['simulateStaticDocuments'],'PATH_INFO') || $GLOBALS['TSFE']->absRefPrefix_force)
164 && !$GLOBALS['TSFE']->absRefPrefix) {
165 $GLOBALS['TSFE']->absRefPrefix=t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
166 } // Force absRefPrefix to this value is PATH_INFO is used.
167
168 if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) {
169 $tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'_top',$GLOBALS['TSFE']->no_cache,'');
170 $GLOBALS['TSFE']->JSCode = 'if(!parent.'.trim($GLOBALS['TSFE']->sPre).' && !parent.view_frame) top.document.location="'.$GLOBALS['TSFE']->baseUrlWrap($tdlLD['totalURL']).'"';
171 }
172 $GLOBALS['TSFE']->compensateFieldWidth = ''.$GLOBALS['TSFE']->config['config']['compensateFieldWidth'];
173 $GLOBALS['TSFE']->lockFilePath = ''.$GLOBALS['TSFE']->config['config']['lockFilePath'];
174 $GLOBALS['TSFE']->lockFilePath = $GLOBALS['TSFE']->lockFilePath ? $GLOBALS['TSFE']->lockFilePath : 'fileadmin/';
175 $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'];
176 $GLOBALS['TSFE']->TYPO3_CONF_VARS['GFX']['im_noScaleUp'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
177
178 $GLOBALS['TSFE']->ATagParams = trim($GLOBALS['TSFE']->config['config']['ATagParams']) ? ' '.trim($GLOBALS['TSFE']->config['config']['ATagParams']) : '';
179 if ($GLOBALS['TSFE']->config['config']['setJS_mouseOver']) $GLOBALS['TSFE']->setJS('mouseOver');
180 if ($GLOBALS['TSFE']->config['config']['setJS_openPic']) $GLOBALS['TSFE']->setJS('openPic');
181
182 $GLOBALS['TSFE']->sWordRegEx='';
183 $GLOBALS['TSFE']->sWordList = t3lib_div::_GP('sword_list');
184 if (is_array($GLOBALS['TSFE']->sWordList)) {
185 $standAlone = trim(''.$GLOBALS['TSFE']->config['config']['sword_standAlone']);
186 $noMixedCase = trim(''.$GLOBALS['TSFE']->config['config']['sword_noMixedCase']);
187
188 $space = ($standAlone) ? '[[:space:]]' : '';
189 reset($GLOBALS['TSFE']->sWordList);
190 while (list($key,$val) = each($GLOBALS['TSFE']->sWordList)) {
191 if (trim($val)) {
192 if (!$noMixedCase) {
193 $GLOBALS['TSFE']->sWordRegEx.= $space.sql_regcase(quotemeta($val)).$space.'|';
194 } else {
195 $GLOBALS['TSFE']->sWordRegEx.= $space.quotemeta($val).$space.'|';
196 }
197 }
198 }
199 $GLOBALS['TSFE']->sWordRegEx = ereg_replace('\|$','',$GLOBALS['TSFE']->sWordRegEx);
200 }
201
202 // linkVars
203 $GLOBALS['TSFE']->linkVars = ''.$GLOBALS['TSFE']->config['config']['linkVars'];
204 if ($GLOBALS['TSFE']->linkVars) {
205 $linkVarArr = explode(',',$GLOBALS['TSFE']->linkVars);
206 $GLOBALS['TSFE']->linkVars='';
207 reset($linkVarArr);
208 while(list(,$val)=each($linkVarArr)) {
209 $val=trim($val);
210 $GET = t3lib_div::_GET();
211 if ($val && isset($GET[$val])) {
212 if (!is_array($GET[$val])) {
213 $GLOBALS['TSFE']->linkVars.='&'.$val.'='.rawurlencode($GET[$val]);
214 } else {
215 $GLOBALS['TSFE']->linkVars.=t3lib_div::implodeArrayForUrl($val,$GET[$val]);
216 }
217 }
218 }
219 } else {
220 $GLOBALS['TSFE']->linkVars='';
221 }
222 }
223
224 /**
225 * Returns an array with files to include. These files are the ones set up in TypoScript config.
226 *
227 * @return array Files to include. Paths are relative to PATH_site.
228 */
229 function getIncFiles() {
230 $incFilesArray = array();
231 // Get files from config.includeLibrary
232 $includeLibrary = trim(''.$GLOBALS['TSFE']->config['config']['includeLibrary']);
233 if ($includeLibrary) {
234 $incFile=$GLOBALS['TSFE']->tmpl->getFileName($includeLibrary);
235 if ($incFile) {
236 $incFilesArray[] = $incFile;
237 }
238 }
239
240 if (is_array($GLOBALS['TSFE']->pSetup['includeLibs.'])) {$incLibs=$GLOBALS['TSFE']->pSetup['includeLibs.'];} else {$incLibs=array();}
241 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)
242 if (count($incLibs)) {
243 reset($incLibs);
244 while(list(,$theLib)=each($incLibs)) {
245 if (!is_array($theLib) && $incFile=$GLOBALS['TSFE']->tmpl->getFileName($theLib)) {
246 $incFilesArray[] = $incFile;
247 }
248 }
249 }
250 // Include HTML mail library?
251 if ($GLOBALS['TSFE']->config['config']['incT3Lib_htmlmail']) {
252 $incFilesArray[] = 't3lib/class.t3lib_htmlmail.php';
253 }
254 return $incFilesArray;
255 }
256
257 /**
258 * Processing JavaScript handlers
259 *
260 * @return array Array with a) a JavaScript section with event handlers and variables set and b) an array with attributes for the body tag.
261 */
262 function JSeventFunctions() {
263 $functions=array();
264 $setEvents=array();
265 $setBody=array();
266
267 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'])) {
268 $functions[]=' function T3_onmousemoveWrapper(e) { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']).' }';
269 $setEvents[]=' document.onmousemove=T3_onmousemoveWrapper;';
270 }
271 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onmouseup']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'])) {
272 $functions[]=' function T3_onmouseupWrapper(e) { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onmouseup']).' }';
273 $setEvents[]=' document.onmouseup=T3_onmouseupWrapper;';
274 }
275 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onload']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onload'])) {
276 $functions[]=' function T3_onloadWrapper() { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onload']).' }';
277 $setEvents[]=' document.onload=T3_onloadWrapper;';
278 $setBody[]='onload="T3_onloadWrapper();"';
279 }
280
281 return Array(count($functions)?'
282 <script type="text/javascript">
283 /*<![CDATA[*/
284 '.implode(chr(10),$functions).'
285 '.implode(chr(10),$setEvents).'
286 /*]]>*/
287 </script>
288 ':'',$setBody);
289 }
290
291 /**
292 * Rendering the page content
293 *
294 * @return void
295 */
296 function renderContent() {
297 // PAGE CONTENT
298 $GLOBALS['TT']->incStackPointer();
299 $GLOBALS['TT']->push($GLOBALS['TSFE']->sPre, 'PAGE');
300 $pageContent = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup);
301
302 if ($GLOBALS['TSFE']->pSetup['wrap']) {$pageContent = $GLOBALS['TSFE']->cObj->wrap($pageContent, $GLOBALS['TSFE']->pSetup['wrap']);}
303 if ($GLOBALS['TSFE']->pSetup['stdWrap.']) {$pageContent = $GLOBALS['TSFE']->cObj->stdWrap($pageContent, $GLOBALS['TSFE']->pSetup['stdWrap.']);}
304
305 // PAGE HEADER (after content - maybe JS is inserted!
306
307 // if 'disableAllHeaderCode' is set, all the header-code is discarded!
308 if ($GLOBALS['TSFE']->config['config']['disableAllHeaderCode']) {
309 $GLOBALS['TSFE']->content = $pageContent;
310 } else {
311 TSpagegen::renderContentWithHeader($pageContent);
312 }
313 $GLOBALS['TT']->pull($GLOBALS['TT']->LR?$GLOBALS['TSFE']->content:'');
314 $GLOBALS['TT']->decStackPointer();
315 }
316
317 /**
318 * Rendering normal HTML-page with header by wrapping the generated content ($pageContent) in body-tags and setting the header accordingly.
319 *
320 * @param string The page content which TypoScript objects has generated
321 * @return void
322 */
323 function renderContentWithHeader($pageContent) {
324 $customContent = $GLOBALS['TSFE']->config['config']['headerComment'];
325 if (trim($customContent)) {
326 $customContent = chr(10).$customContent;
327 } else $customContent='';
328
329 // Setting charset:
330 $theCharset = $GLOBALS['TSFE']->metaCharset;
331
332 // Reset the content variables:
333 $GLOBALS['TSFE']->content='';
334 $htmlTagAttributes = array();
335 $htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ? $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] : 'en';
336
337 // Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
338 if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
339 $htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
340 }
341
342 // Setting document type:
343 $docTypeParts = array();
344 $XMLprologue = $GLOBALS['TSFE']->config['config']['xmlprologue'] != 'none';
345 if ($GLOBALS['TSFE']->config['config']['doctype']) {
346
347 // Setting doctypes:
348 switch((string)$GLOBALS['TSFE']->config['config']['doctype']) {
349 case 'xhtml_trans':
350 if ($XMLprologue) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
351 $docTypeParts[]='<!DOCTYPE html
352 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
353 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
354 break;
355 case 'xhtml_strict':
356 if ($XMLprologue) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
357 $docTypeParts[]='<!DOCTYPE html
358 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
359 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
360 break;
361 case 'xhtml_frames':
362 if ($XMLprologue) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
363 $docTypeParts[]='<!DOCTYPE html
364 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
365 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
366 break;
367 case 'xhtml_11':
368 if ($XMLprologue) $docTypeParts[]='<?xml version="1.1" encoding="'.$theCharset.'"?>';
369 $docTypeParts[]='<!DOCTYPE html
370 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
371 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
372 break;
373 case 'xhtml_2':
374 if ($XMLprologue) $docTypeParts[]='<?xml version="2.0" encoding="'.$theCharset.'"?>';
375 $docTypeParts[]='<!DOCTYPE html
376 PUBLIC "-//W3C//DTD XHTML 2.0//EN"
377 "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
378 break;
379 case 'none':
380 break;
381 default:
382 $docTypeParts[] = $GLOBALS['TSFE']->config['config']['doctype'];
383 break;
384 }
385 // Setting <html> tag attributes:
386 switch((string)$GLOBALS['TSFE']->config['config']['doctype']) {
387 case 'xhtml_trans':
388 case 'xhtml_strict':
389 case 'xhtml_frames':
390 $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
391 $htmlTagAttributes['xml:lang'] = $htmlLang;
392 $htmlTagAttributes['lang'] = $htmlLang;
393 break;
394 case 'xhtml_11':
395 case 'xhtml_2':
396 $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
397 $htmlTagAttributes['xml:lang'] = $htmlLang;
398 break;
399 }
400 } else {
401 $docTypeParts[]='<!DOCTYPE html
402 PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
403 }
404
405 // Swap XML and doctype order around (for MSIE / Opera standards compliance)
406 if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
407 $docTypeParts = array_reverse($docTypeParts);
408 }
409
410 // Adding doctype parts:
411 $GLOBALS['TSFE']->content.= count($docTypeParts) ? implode(chr(10),$docTypeParts).chr(10) : '';
412
413 // Begin header section:
414 if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'],'none')) {
415 $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : t3lib_div::implodeAttributes($htmlTagAttributes);
416 } else {
417 $_attr = '';
418 }
419 $GLOBALS['TSFE']->content.='<html'.($_attr ? ' '.$_attr : '').'>';
420
421 // Head tag:
422 $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : '<head>';
423 $GLOBALS['TSFE']->content.= chr(10).$headTag;
424
425 // Setting charset meta tag:
426 $GLOBALS['TSFE']->content.='
427 <meta http-equiv="Content-Type" content="text/html; charset='.$theCharset.'" />';
428
429 $GLOBALS['TSFE']->content.='
430
431 <!-- '.($customContent?$customContent.chr(10):'').'
432 This website is powered by TYPO3 - inspiring people to share!
433 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
434 TYPO3 is copyright 1998-2005 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
435 Information and contribution at http://typo3.com/ and http://typo3.org/
436 -->
437 ';
438
439
440 if ($GLOBALS['TSFE']->baseUrl) {
441 $GLOBALS['TSFE']->content.='
442 <base href="'.htmlspecialchars($GLOBALS['TSFE']->baseUrl).'" />';
443 }
444
445 if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
446 $ss=$path.$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
447 $GLOBALS['TSFE']->content.='
448 <link rel="SHORTCUT ICON" href="'.htmlspecialchars($ss).'" />';
449 }
450
451 /** CSS STYLESHEET handling: */
452 if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
453 $temp_styleLines=array();
454 reset($GLOBALS['TSFE']->tmpl->setup['plugin.']);
455 while(list($k2,$iCSScode)=each($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
456 if (is_array($iCSScode) && $iCSScode['_CSS_DEFAULT_STYLE']) {
457 $temp_styleLines[]='/* default styles for extension "'.substr($k2,0,-1).'" */'.chr(10).$iCSScode['_CSS_DEFAULT_STYLE'];
458 }
459 }
460 if (count($temp_styleLines)) {
461 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
462 $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile(implode(chr(10),$temp_styleLines),'css');
463 } else {
464 $GLOBALS['TSFE']->content.='
465 <style type="text/css">
466 /*<![CDATA[*/
467 <!--
468 '.implode(chr(10),$temp_styleLines).'
469 -->
470 /*]]>*/
471 </style>';
472 }
473 }
474 }
475
476 if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
477 $ss=$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
478 if ($ss) {
479 $GLOBALS['TSFE']->content.='
480 <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($ss).'" />';
481 }
482 }
483 if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
484 reset($GLOBALS['TSFE']->pSetup['includeCSS.']);
485 while(list($k2,$iCSSfile)=each($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
486 if (!is_array($iCSSfile)) {
487 $ss = $GLOBALS['TSFE']->tmpl->getFileName($iCSSfile);
488 if ($ss) {
489 if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['import']) {
490 if (substr($ss,0,1)!='/') { // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
491 $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/'.$ss;
492 }
493 $GLOBALS['TSFE']->content.='
494 <style type="text/css">
495 <!--
496 @import url("'.htmlspecialchars($ss).'") '.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['media']).';
497 -->
498 </style>
499 ';
500 } else {
501 $GLOBALS['TSFE']->content.='
502 <link rel="'.($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['alternate'] ? 'alternate stylesheet' : 'stylesheet').'" type="text/css" href="'.htmlspecialchars($ss).'"'.
503 ($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['title'] ? ' title="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['title']).'"' : '').
504 ($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['media'] ? ' media="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['media']).'"' : '').
505 ' />';
506 }
507 }
508 }
509 }
510 }
511
512 // Stylesheets
513 $style='';
514 $style.=trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']).chr(10);
515
516 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
517 $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
518 $RTEclasses = $pageTSConfig['RTE.']['classes.'];
519 if (is_array($RTEclasses)) {
520 reset($RTEclasses);
521 while(list($RTEclassName,$RTEvalueArray)=each($RTEclasses)) {
522 if ($RTEvalueArray['value']) {
523 $style.='
524 .'.substr($RTEclassName,0,-1).' {'.$RTEvalueArray['value'].'}';
525 }
526 }
527 }
528
529 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
530 $mSOa_tList = t3lib_div::trimExplode(',',strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']),1);
531 reset($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.']);
532 while(list($mSOa_key,$mSOa_value)=each($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
533 if (!is_array($mSOa_value) && (in_array('*',$mSOa_tList)||in_array($mSOa_key,$mSOa_tList))) {
534 $style.='
535 '.$mSOa_key.' {'.$mSOa_value.'}';
536 }
537 }
538 }
539 }
540
541 // Setting body tag margins in CSS:
542 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
543 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
544 $style.='
545 BODY {margin: '.$margins.'px '.$margins.'px '.$margins.'px '.$margins.'px;}';
546 }
547
548 if ($GLOBALS['TSFE']->pSetup['noLinkUnderline']) {
549 $style.='
550 A:link {text-decoration: none}
551 A:visited {text-decoration: none}
552 A:active {text-decoration: none}';
553 }
554 if (trim($GLOBALS['TSFE']->pSetup['hover'])) {
555 $style.='
556 A:hover {color: '.trim($GLOBALS['TSFE']->pSetup['hover']).';}';
557 }
558 if (trim($GLOBALS['TSFE']->pSetup['hoverStyle'])) {
559 $style.='
560 A:hover {'.trim($GLOBALS['TSFE']->pSetup['hoverStyle']).'}';
561 }
562 if ($GLOBALS['TSFE']->pSetup['smallFormFields']) {
563 $style.='
564 SELECT { font-family: Verdana, Arial, Helvetica; font-size: 10px }
565 TEXTAREA { font-family: Verdana, Arial, Helvetica; font-size: 10px}
566 INPUT { font-family: Verdana, Arial, Helvetica; font-size: 10px }';
567 }
568 if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
569 $style.='
570
571 /* Default styles for the Admin Panel */
572 TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
573 TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
574 TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
575 TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
576 TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
577 TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
578 TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
579 TABLE.typo3-editPanel TD { border: 0px; }
580 ';
581 }
582
583 if (trim($style)) {
584 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
585 $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($style, 'css');
586 } else {
587 $GLOBALS['TSFE']->content.='
588 <style type="text/css">
589 /*<![CDATA[*/
590 <!--'.$style.'
591 -->
592 /*]]>*/
593 </style>';
594 }
595 }
596
597
598
599
600
601 // Headerdata
602 if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
603 $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'],'headerData.');
604 }
605
606 // <title></title> :
607 $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle(
608 $GLOBALS['TSFE']->altPageTitle?$GLOBALS['TSFE']->altPageTitle:$GLOBALS['TSFE']->page['title'],
609 $GLOBALS['TSFE']->config['config']['noPageTitle'],
610 $GLOBALS['TSFE']->config['config']['pageTitleFirst']
611 );
612 if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
613 $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array(), $titleTagContent);
614 }
615
616 if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle'])!==2) {
617 $GLOBALS['TSFE']->content.='
618 <title>'.htmlspecialchars($titleTagContent).'</title>';
619 }
620 $GLOBALS['TSFE']->content.='
621 <meta name="generator" content="TYPO3 '.TYPO3_branch.' CMS" />';
622
623 $conf=$GLOBALS['TSFE']->pSetup['meta.'];
624 if (is_array($conf)) {
625 reset($conf);
626 while(list($theKey,$theValue)=each($conf)) {
627 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
628 if (strstr($theKey,'.')) {
629 $theKey = substr($theKey,0,-1);
630 }
631 $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey],$conf[$theKey.'.']);
632 $key = $theKey;
633 if (trim($val)) {
634 $a='name';
635 if (strtolower($key)=='refresh') {$a='http-equiv';}
636 $GLOBALS['TSFE']->content.= '
637 <meta '.$a.'="'.$key.'" content="'.htmlspecialchars(trim($val)).'" />';
638 }
639 }
640 }
641 }
642
643 unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
644 unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
645
646 if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
647 // Storing the JSCode and JSImgCode vars...
648 $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
649 $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
650 $GLOBALS['TSFE']->config['INTincScript_ext']['divKey']= $GLOBALS['TSFE']->uniqueHash();
651 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
652 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
653 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
654
655 $GLOBALS['TSFE']->additionalHeaderData=array('<!--HD_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->'); // Clearing the array
656 $GLOBALS['TSFE']->divSection.='<!--TDS_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->';
657 } else {
658 $GLOBALS['TSFE']->INTincScript_loadJSCode();
659 }
660 $JSef = TSpagegen::JSeventFunctions();
661
662 // Adding default Java Script:
663 $_scriptCode = '
664 browserName = navigator.appName;
665 browserVer = parseInt(navigator.appVersion);
666 var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
667 if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
668 // Blurring links:
669 function blurLink(theObject) { //
670 if (msie4) {theObject.blur();}
671 }
672 ';
673 if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
674 // NOTICE: The following code must be kept synchronized with "tslib/default.js"!!!
675 $GLOBALS['TSFE']->content.='
676 <script type="text/javascript">
677 /*<![CDATA[*/
678 <!--'.$_scriptCode.'
679 // -->
680 /*]]>*/
681 </script>';
682 } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS']==='external') {
683 $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($_scriptCode, 'js');
684 }
685
686 $GLOBALS['TSFE']->content.=chr(10).implode($GLOBALS['TSFE']->additionalHeaderData,chr(10)).'
687 '.$JSef[0].'
688 </head>';
689 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
690 $fs = t3lib_div::makeInstance('tslib_frameset');
691 $GLOBALS['TSFE']->content.=$fs->make($GLOBALS['TSFE']->pSetup['frameSet.']);
692 $GLOBALS['TSFE']->content.= chr(10).'<noframes>'.chr(10);
693 }
694
695 // Bodytag:
696 $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'],$GLOBALS['TSFE']->pSetup['bodyTagCObject.'],'bodyTagCObject') : '';
697 if (!$defBT) $defBT = $GLOBALS['TSFE']->defaultBodyTag;
698 $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
699 if ($bgImg=$GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'],$GLOBALS['TSFE']->pSetup['bgImg.'])) {
700 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' background="'.$GLOBALS["TSFE"]->absRefPrefix.$bgImg[3].'">';
701 }
702
703 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
704 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
705 if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
706 // Setting margins in CSS, see above
707 } else {
708 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' leftmargin="'.$margins.'" topmargin="'.$margins.'" marginwidth="'.$margins.'" marginheight="'.$margins.'">';
709 }
710 }
711
712 if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
713 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']).'>';
714 }
715
716 if (count($JSef[1])) { // Event functions:
717 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim(implode(' ',$JSef[1])).'>';
718 }
719 $GLOBALS['TSFE']->content.= chr(10).$bodyTag;
720
721
722 // Div-sections
723 if ($GLOBALS['TSFE']->divSection) {
724 $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->divSection;
725 }
726
727 // Page content
728 $GLOBALS['TSFE']->content.=chr(10).$pageContent;
729
730 // Ending page
731 $GLOBALS['TSFE']->content.= chr(10).'</body>';
732 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
733 $GLOBALS['TSFE']->content.= chr(10).'</noframes>';
734 }
735 $GLOBALS['TSFE']->content.=chr(10).'</html>';
736 }
737
738
739
740
741
742
743
744
745
746
747
748
749
750 /*************************
751 *
752 * Helper functions
753 * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
754 *
755 *************************/
756
757 /**
758 * Writes string to a temporary file named after the md5-hash of the string
759 *
760 * @param string CSS styles / JavaScript to write to file.
761 * @param string Extension: "css" or "js"
762 * @return string <script> or <link> tag for the file.
763 */
764 function inline2TempFile($str,$ext) {
765
766 // Create filename / tags:
767 $script = '';
768 switch($ext) {
769 case 'js':
770 $script = 'typo3temp/javascript_'.substr(md5($str),0,10).'.js';
771 $output = '
772 <script type="text/javascript" src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'"></script>';
773 break;
774 case 'css':
775 $script = 'typo3temp/stylesheet_'.substr(md5($str),0,10).'.css';
776 $output = '
777 <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'" />';
778 break;
779 }
780
781 // Write file:
782 if ($script) {
783 if (!@is_file(PATH_site.$script)) {
784 t3lib_div::writeFile(PATH_site.$script,$str);
785 }
786 }
787
788 return $output;
789 }
790 }
791
792 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']) {
793 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']);
794 }
795
796
797
798 // ********************************************************
799 // Includes the search-class if $sword and $scols are set.
800 // ********************************************************
801 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
802 require_once(PATH_tslib.'class.tslib_search.php');
803 }
804
805 // ************
806 // LoadDBGroup
807 // ************
808 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
809
810 /**
811 * Class for fetching record relations for the frontend.
812 *
813 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
814 * @package TYPO3
815 * @subpackage tslib
816 * @see tslib_cObj::RECORDS()
817 */
818 class FE_loadDBGroup extends t3lib_loadDBGroup {
819 var $fromTC = 0; // Means the not only uid and label-field is returned, but everything
820 }
821
822 // **********************************
823 // includes stuff for graphical work
824 // **********************************
825 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
826 require_once(PATH_tslib.'class.tslib_gifbuilder.php');
827
828 // *************************
829 // includes menu-management
830 // *************************
831 require_once(PATH_tslib.'class.tslib_menu.php');
832
833 // *************************
834 // Global content object...
835 // *************************
836 require_once(PATH_tslib.'class.tslib_content.php');
837
838 ?>