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