Added feature #4476: Allow limitation of config.linkVars
[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 $linkVars = (string)$GLOBALS['TSFE']->config['config']['linkVars'];
198 if ($linkVars) {
199 $linkVarArr = explode(',',$linkVars);
200
201 $GLOBALS['TSFE']->linkVars='';
202 $GET = t3lib_div::_GET();
203
204 foreach ($linkVarArr as $val) {
205 $val = trim($val);
206
207 if (preg_match('/^(.*)\((.+)\)$/',$val,$match)) {
208 $val = trim($match[1]);
209 $test = trim($match[2]);
210 } else unset($test);
211
212 if ($val && isset($GET[$val])) {
213 if (!is_array($GET[$val])) {
214 $tmpVal = rawurlencode($GET[$val]);
215
216 if ($test && !TSpagegen::isAllowedLinkVarValue($tmpVal,$test)) {
217 continue; // Error: This value was not allowed for this key
218 }
219
220 $value = '&'.$val.'='.$tmpVal;
221 } else {
222 if ($test && strcmp('array',$test)) {
223 continue; // Error: This key must not be an array!
224 }
225 $value = t3lib_div::implodeArrayForUrl($val,$GET[$val]);
226 }
227 } else continue;
228
229 $GLOBALS['TSFE']->linkVars.= $value;
230 }
231 unset($GET);
232 } else {
233 $GLOBALS['TSFE']->linkVars='';
234 }
235
236 // Setting XHTML-doctype from doctype
237 if (!$GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
238 $GLOBALS['TSFE']->config['config']['xhtmlDoctype'] = $GLOBALS['TSFE']->config['config']['doctype'];
239 }
240
241 if ($GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
242 $GLOBALS['TSFE']->xhtmlDoctype = $GLOBALS['TSFE']->config['config']['xhtmlDoctype'];
243
244 // Checking XHTML-docytpe
245 switch((string)$GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
246 case 'xhtml_trans':
247 case 'xhtml_strict':
248 case 'xhtml_frames':
249 $GLOBALS['TSFE']->xhtmlVersion = 100;
250 break;
251 case 'xhtml_basic':
252 $GLOBALS['TSFE']->xhtmlVersion = 105;
253 break;
254 case 'xhtml_11':
255 $GLOBALS['TSFE']->xhtmlVersion = 110;
256 break;
257 case 'xhtml_2':
258 $GLOBALS['TSFE']->xhtmlVersion = 200;
259 break;
260 default:
261 $GLOBALS['TSFE']->xhtmlDoctype = '';
262 $GLOBALS['TSFE']->xhtmlVersion = 0;
263 }
264 }
265 }
266
267 /**
268 * Returns an array with files to include. These files are the ones set up in TypoScript config.
269 *
270 * @return array Files to include. Paths are relative to PATH_site.
271 */
272 function getIncFiles() {
273 $incFilesArray = array();
274 // Get files from config.includeLibrary
275 $includeLibrary = trim(''.$GLOBALS['TSFE']->config['config']['includeLibrary']);
276 if ($includeLibrary) {
277 $incFile=$GLOBALS['TSFE']->tmpl->getFileName($includeLibrary);
278 if ($incFile) {
279 $incFilesArray[] = $incFile;
280 }
281 }
282
283 if (is_array($GLOBALS['TSFE']->pSetup['includeLibs.'])) {$incLibs=$GLOBALS['TSFE']->pSetup['includeLibs.'];} else {$incLibs=array();}
284 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)
285 if (count($incLibs)) {
286 reset($incLibs);
287 while(list(,$theLib)=each($incLibs)) {
288 if (!is_array($theLib) && $incFile=$GLOBALS['TSFE']->tmpl->getFileName($theLib)) {
289 $incFilesArray[] = $incFile;
290 }
291 }
292 }
293 // Include HTML mail library?
294 if ($GLOBALS['TSFE']->config['config']['incT3Lib_htmlmail']) {
295 $incFilesArray[] = 't3lib/class.t3lib_htmlmail.php';
296 }
297 return $incFilesArray;
298 }
299
300 /**
301 * Processing JavaScript handlers
302 *
303 * @return array Array with a) a JavaScript section with event handlers and variables set and b) an array with attributes for the body tag.
304 */
305 function JSeventFunctions() {
306 $functions=array();
307 $setEvents=array();
308 $setBody=array();
309
310 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onmousemove'])) {
311 $functions[]=' function T3_onmousemoveWrapper(e) { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']).' }';
312 $setEvents[]=' document.onmousemove=T3_onmousemoveWrapper;';
313 }
314 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onmouseup']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onmouseup'])) {
315 $functions[]=' function T3_onmouseupWrapper(e) { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onmouseup']).' }';
316 $setEvents[]=' document.onmouseup=T3_onmouseupWrapper;';
317 }
318 if (is_array($GLOBALS['TSFE']->JSeventFuncCalls['onload']) && count($GLOBALS['TSFE']->JSeventFuncCalls['onload'])) {
319 $functions[]=' function T3_onloadWrapper() { '.implode(' ',$GLOBALS['TSFE']->JSeventFuncCalls['onload']).' }';
320 $setEvents[]=' document.onload=T3_onloadWrapper;';
321 $setBody[]='onload="T3_onloadWrapper();"';
322 }
323
324 return Array(count($functions)?'
325 <script type="text/javascript">
326 /*<![CDATA[*/
327 '.implode(chr(10),$functions).'
328 '.implode(chr(10),$setEvents).'
329 /*]]>*/
330 </script>
331 ':'',$setBody);
332 }
333
334 /**
335 * Rendering the page content
336 *
337 * @return void
338 */
339 function renderContent() {
340 // PAGE CONTENT
341 $GLOBALS['TT']->incStackPointer();
342 $GLOBALS['TT']->push($GLOBALS['TSFE']->sPre, 'PAGE');
343 $pageContent = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup);
344
345 if ($GLOBALS['TSFE']->pSetup['wrap']) {$pageContent = $GLOBALS['TSFE']->cObj->wrap($pageContent, $GLOBALS['TSFE']->pSetup['wrap']);}
346 if ($GLOBALS['TSFE']->pSetup['stdWrap.']) {$pageContent = $GLOBALS['TSFE']->cObj->stdWrap($pageContent, $GLOBALS['TSFE']->pSetup['stdWrap.']);}
347
348 // PAGE HEADER (after content - maybe JS is inserted!
349
350 // if 'disableAllHeaderCode' is set, all the header-code is discarded!
351 if ($GLOBALS['TSFE']->config['config']['disableAllHeaderCode']) {
352 $GLOBALS['TSFE']->content = $pageContent;
353 } else {
354 TSpagegen::renderContentWithHeader($pageContent);
355 }
356 $GLOBALS['TT']->pull($GLOBALS['TT']->LR?$GLOBALS['TSFE']->content:'');
357 $GLOBALS['TT']->decStackPointer();
358 }
359
360 /**
361 * Rendering normal HTML-page with header by wrapping the generated content ($pageContent) in body-tags and setting the header accordingly.
362 *
363 * @param string The page content which TypoScript objects has generated
364 * @return void
365 */
366 function renderContentWithHeader($pageContent) {
367 $customContent = $GLOBALS['TSFE']->config['config']['headerComment'];
368 if (trim($customContent)) {
369 $customContent = chr(10).$customContent;
370 } else $customContent='';
371
372 // Setting charset:
373 $theCharset = $GLOBALS['TSFE']->metaCharset;
374
375 // Reset the content variables:
376 $GLOBALS['TSFE']->content='';
377 $htmlTagAttributes = array();
378 $htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ? $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] : 'en';
379
380 // Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
381 if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
382 $htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
383 }
384
385 // Setting document type:
386 $docTypeParts = array();
387 // Part 1: XML prologue
388 switch((string)$GLOBALS['TSFE']->config['config']['xmlprologue']) {
389 case 'none':
390 break;
391 case 'xml_10':
392 $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
393 break;
394 case 'xml_11':
395 $docTypeParts[]='<?xml version="1.1" encoding="'.$theCharset.'"?>';
396 break;
397 case '':
398 if ($GLOBALS['TSFE']->xhtmlVersion) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
399 break;
400 default:
401 $docTypeParts[]=$GLOBALS['TSFE']->config['config']['xmlprologue'];
402 }
403 // Part 2: DTD
404 if ($GLOBALS['TSFE']->config['config']['doctype']) {
405 switch((string)$GLOBALS['TSFE']->config['config']['doctype']) {
406 case 'xhtml_trans':
407 $docTypeParts[]='<!DOCTYPE html
408 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
409 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
410 break;
411 case 'xhtml_strict':
412 $docTypeParts[]='<!DOCTYPE html
413 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
414 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
415 break;
416 case 'xhtml_frames':
417 $docTypeParts[]='<!DOCTYPE html
418 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
419 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
420 break;
421 case 'xhtml_basic':
422 $docTypeParts[]='<!DOCTYPE html
423 PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
424 "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
425 break;
426 case 'xhtml_11':
427 $docTypeParts[]='<!DOCTYPE html
428 PUBLIC "-//W3C//DTD XHTML 1.1//EN"
429 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
430 break;
431 case 'xhtml_2':
432 $docTypeParts[]='<!DOCTYPE html
433 PUBLIC "-//W3C//DTD XHTML 2.0//EN"
434 "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
435 break;
436 case 'none':
437 break;
438 default:
439 $docTypeParts[] = $GLOBALS['TSFE']->config['config']['doctype'];
440 }
441 } else {
442 $docTypeParts[]='<!DOCTYPE html
443 PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
444 }
445
446 if ($GLOBALS['TSFE']->xhtmlVersion) {
447
448 // Setting <html> tag attributes:
449 $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
450 $htmlTagAttributes['xml:lang'] = $htmlLang;
451 if ($GLOBALS['TSFE']->xhtmlVersion < 110) {
452 $htmlTagAttributes['lang'] = $htmlLang;
453 }
454 }
455
456 // Swap XML and doctype order around (for MSIE / Opera standards compliance)
457 if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
458 $docTypeParts = array_reverse($docTypeParts);
459 }
460
461 // Adding doctype parts:
462 $GLOBALS['TSFE']->content.= count($docTypeParts) ? implode(chr(10),$docTypeParts).chr(10) : '';
463
464 // Begin header section:
465 if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'],'none')) {
466 $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : t3lib_div::implodeAttributes($htmlTagAttributes);
467 } else {
468 $_attr = '';
469 }
470 $GLOBALS['TSFE']->content.='<html'.($_attr ? ' '.$_attr : '').'>';
471
472 // Head tag:
473 $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : '<head>';
474 $GLOBALS['TSFE']->content.= chr(10).$headTag;
475
476 // Setting charset meta tag:
477 $GLOBALS['TSFE']->content.='
478 <meta http-equiv="Content-Type" content="text/html; charset='.$theCharset.'" />';
479
480 $GLOBALS['TSFE']->content.='
481
482 <!-- '.($customContent?$customContent.chr(10):'').'
483 This website is powered by TYPO3 - inspiring people to share!
484 TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
485 TYPO3 is copyright 1998-2006 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
486 Information and contribution at http://typo3.com/ and http://typo3.org/
487 -->
488 ';
489
490
491 if ($GLOBALS['TSFE']->baseUrl) {
492 $GLOBALS['TSFE']->content.='
493 <base href="'.htmlspecialchars($GLOBALS['TSFE']->baseUrl).'" />';
494 }
495
496 if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
497 $ss=$path.$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
498 $GLOBALS['TSFE']->content.='
499 <link rel="SHORTCUT ICON" href="'.htmlspecialchars($ss).'" />';
500 }
501
502 // Including CSS files
503 if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
504 $temp_styleLines=array();
505 foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key=>$iCSScode) {
506 if (is_array($iCSScode) && $iCSScode['_CSS_DEFAULT_STYLE']) {
507 $temp_styleLines[]='/* default styles for extension "'.substr($key,0,-1).'" */'.chr(10).$iCSScode['_CSS_DEFAULT_STYLE'];
508 }
509 }
510 if (count($temp_styleLines)) {
511 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
512 $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile(implode(chr(10),$temp_styleLines),'css');
513 } else {
514 $GLOBALS['TSFE']->content.='
515 <style type="text/css">
516 /*<![CDATA[*/
517 <!--
518 '.implode(chr(10),$temp_styleLines).'
519 -->
520 /*]]>*/
521 </style>';
522 }
523 }
524 }
525
526 if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
527 $ss=$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
528 if ($ss) {
529 $GLOBALS['TSFE']->content.='
530 <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($ss).'" />';
531 }
532 }
533 if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
534 foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key=>$iCSSfile) {
535 if (!is_array($iCSSfile)) {
536 $ss=$GLOBALS['TSFE']->tmpl->getFileName($iCSSfile);
537 if ($ss) {
538 if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['import']) {
539 if (substr($ss,0,1)!='/') { // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
540 $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/'.$ss;
541 }
542 $GLOBALS['TSFE']->content.='
543 <style type="text/css">
544 <!--
545 @import url("'.htmlspecialchars($ss).'") '.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media']).';
546 -->
547 </style>
548 ';
549 } else {
550 $GLOBALS['TSFE']->content.='
551 <link rel="'.($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['alternate'] ? 'alternate stylesheet' : 'stylesheet').'" type="text/css" href="'.htmlspecialchars($ss).'"'.
552 ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title'] ? ' title="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title']).'"' : '').
553 ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media'] ? ' media="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media']).'"' : '').
554 ' />';
555 }
556 }
557 }
558 }
559 }
560
561 // Stylesheets
562 $style='';
563 $style.=trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']).chr(10);
564
565 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
566 $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
567 $RTEclasses = $pageTSConfig['RTE.']['classes.'];
568 if (is_array($RTEclasses)) {
569 foreach ($RTEclasses as $RTEclassName=>$RTEvalueArray) {
570 if ($RTEvalueArray['value']) {
571 $style.='
572 .'.substr($RTEclassName,0,-1).' {'.$RTEvalueArray['value'].'}';
573 }
574 }
575 }
576
577 if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
578 $mSOa_tList = t3lib_div::trimExplode(',',strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']),1);
579 foreach ($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'] as $mSOa_key=>$mSOa_value) {
580 if (!is_array($mSOa_value) && (in_array('*',$mSOa_tList)||in_array($mSOa_key,$mSOa_tList))) {
581 $style.='
582 '.$mSOa_key.' {'.$mSOa_value.'}';
583 }
584 }
585 }
586 }
587
588 // Setting body tag margins in CSS:
589 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
590 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
591 $style.='
592 BODY {margin: '.$margins.'px '.$margins.'px '.$margins.'px '.$margins.'px;}';
593 }
594
595 if ($GLOBALS['TSFE']->pSetup['noLinkUnderline']) {
596 $style.='
597 A:link {text-decoration: none}
598 A:visited {text-decoration: none}
599 A:active {text-decoration: none}';
600 }
601 if (trim($GLOBALS['TSFE']->pSetup['hover'])) {
602 $style.='
603 A:hover {color: '.trim($GLOBALS['TSFE']->pSetup['hover']).';}';
604 }
605 if (trim($GLOBALS['TSFE']->pSetup['hoverStyle'])) {
606 $style.='
607 A:hover {'.trim($GLOBALS['TSFE']->pSetup['hoverStyle']).'}';
608 }
609 if ($GLOBALS['TSFE']->pSetup['smallFormFields']) {
610 $style.='
611 SELECT { font-family: Verdana, Arial, Helvetica; font-size: 10px }
612 TEXTAREA { font-family: Verdana, Arial, Helvetica; font-size: 10px}
613 INPUT { font-family: Verdana, Arial, Helvetica; font-size: 10px }';
614 }
615 if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
616 $style.='
617
618 /* Default styles for the Admin Panel */
619 TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
620 TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
621 TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
622 TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
623 TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
624 TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
625 TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
626 TABLE.typo3-editPanel TD { border: 0px; }
627 ';
628 }
629
630 if (trim($style)) {
631 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
632 $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($style, 'css');
633 } else {
634 $GLOBALS['TSFE']->content.='
635 <style type="text/css">
636 /*<![CDATA[*/
637 <!--'.$style.'
638 -->
639 /*]]>*/
640 </style>';
641 }
642 }
643
644 // JavaScript files
645 if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
646 foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key=>$JSfile) {
647 if (!is_array($JSfile)) {
648 $ss = $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
649 if ($ss) {
650 $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['type'];
651 if (!$type) $type = 'text/javascript';
652
653 $GLOBALS['TSFE']->content.='
654 <script src="'.htmlspecialchars($ss).'" type="'.htmlspecialchars($type).'"></script>';
655 }
656 }
657 }
658 }
659
660
661
662
663
664 // Headerdata
665 if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
666 $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'],'headerData.');
667 }
668
669 // Title
670 $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle(
671 $GLOBALS['TSFE']->altPageTitle?$GLOBALS['TSFE']->altPageTitle:$GLOBALS['TSFE']->page['title'],
672 $GLOBALS['TSFE']->config['config']['noPageTitle'],
673 $GLOBALS['TSFE']->config['config']['pageTitleFirst']
674 );
675 if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
676 $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array(), $titleTagContent);
677 }
678
679 if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle'])!==2) {
680 $GLOBALS['TSFE']->content.='
681 <title>'.htmlspecialchars($titleTagContent).'</title>';
682 }
683 $GLOBALS['TSFE']->content.='
684 <meta name="generator" content="TYPO3 '.TYPO3_branch.' CMS" />';
685
686 $conf=$GLOBALS['TSFE']->pSetup['meta.'];
687 if (is_array($conf)) {
688 reset($conf);
689 while(list($theKey,$theValue)=each($conf)) {
690 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
691 if (strstr($theKey,'.')) {
692 $theKey = substr($theKey,0,-1);
693 }
694 $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey],$conf[$theKey.'.']);
695 $key = $theKey;
696 if (trim($val)) {
697 $a='name';
698 if (strtolower($key)=='refresh') {$a='http-equiv';}
699 $GLOBALS['TSFE']->content.= '
700 <meta '.$a.'="'.$key.'" content="'.htmlspecialchars(trim($val)).'" />';
701 }
702 }
703 }
704 }
705
706 unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
707 unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
708
709 if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
710 // Storing the JSCode and JSImgCode vars...
711 $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
712 $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
713 $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
714 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
715 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
716 $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
717
718 $GLOBALS['TSFE']->additionalHeaderData = array('<!--HD_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->'); // Clearing the array
719 $GLOBALS['TSFE']->divSection.= '<!--TDS_'.$GLOBALS['TSFE']->config['INTincScript_ext']['divKey'].'-->';
720 } else {
721 $GLOBALS['TSFE']->INTincScript_loadJSCode();
722 }
723 $JSef = TSpagegen::JSeventFunctions();
724
725 // Adding default Java Script:
726 $_scriptCode = '
727 var browserName = navigator.appName;
728 var browserVer = parseInt(navigator.appVersion);
729 var version = "";
730 var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
731 if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
732 // Blurring links:
733 function blurLink(theObject) { //
734 if (msie4) {theObject.blur();}
735 }
736 ';
737
738 if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
739 $_scriptCode.= '
740 // decrypt helper function
741 function decryptCharcode(n,start,end,offset) {
742 n = n + offset;
743 if (offset > 0 && n > end) {
744 n = start + (n - end - 1);
745 } else if (offset < 0 && n < start) {
746 n = end - (start - n - 1);
747 }
748 return String.fromCharCode(n);
749 }
750 // decrypt string
751 function decryptString(enc,offset) {
752 var dec = "";
753 var len = enc.length;
754 for(var i=0; i < len; i++) {
755 var n = enc.charCodeAt(i);
756 if (n >= 0x2B && n <= 0x3A) {
757 dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
758 } else if (n >= 0x40 && n <= 0x5A) {
759 dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
760 } else if (n >= 0x61 && n <= 0x7A) {
761 dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
762 } else {
763 dec += enc.charAt(i);
764 }
765 }
766 return dec;
767 }
768 // decrypt spam-protected emails
769 function linkTo_UnCryptMailto(s) {
770 location.href = decryptString(s,'.($GLOBALS['TSFE']->spamProtectEmailAddresses*-1).');
771 }
772 ';
773 }
774
775 if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
776 // NOTICE: The following code must be kept synchronized with "tslib/default.js"!!!
777 $GLOBALS['TSFE']->content.='
778 <script type="text/javascript">
779 /*<![CDATA[*/
780 <!--'.$_scriptCode.'
781 // -->
782 /*]]>*/
783 </script>';
784 } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS']==='external') {
785 $GLOBALS['TSFE']->content.= TSpagegen::inline2TempFile($_scriptCode, 'js');
786 }
787
788 $GLOBALS['TSFE']->content.= chr(10).implode($GLOBALS['TSFE']->additionalHeaderData,chr(10)).'
789 '.$JSef[0].'
790 </head>';
791 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
792 $fs = t3lib_div::makeInstance('tslib_frameset');
793 $GLOBALS['TSFE']->content.= $fs->make($GLOBALS['TSFE']->pSetup['frameSet.']);
794 $GLOBALS['TSFE']->content.= chr(10).'<noframes>'.chr(10);
795 }
796
797 // Bodytag:
798 $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'],$GLOBALS['TSFE']->pSetup['bodyTagCObject.'],'bodyTagCObject') : '';
799 if (!$defBT) $defBT = $GLOBALS['TSFE']->defaultBodyTag;
800 $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
801 if ($bgImg=$GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'],$GLOBALS['TSFE']->pSetup['bgImg.'])) {
802 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' background="'.$GLOBALS["TSFE"]->absRefPrefix.$bgImg[3].'">';
803 }
804
805 if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
806 $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
807 if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
808 // Setting margins in CSS, see above
809 } else {
810 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' leftmargin="'.$margins.'" topmargin="'.$margins.'" marginwidth="'.$margins.'" marginheight="'.$margins.'">';
811 }
812 }
813
814 if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
815 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']).'>';
816 }
817
818 if (count($JSef[1])) { // Event functions:
819 $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim(implode(' ',$JSef[1])).'>';
820 }
821 $GLOBALS['TSFE']->content.= chr(10).$bodyTag;
822
823
824 // Div-sections
825 if ($GLOBALS['TSFE']->divSection) {
826 $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->divSection;
827 }
828
829 // Page content
830 $GLOBALS['TSFE']->content.= chr(10).$pageContent;
831
832 // Ending page
833 $GLOBALS['TSFE']->content.= chr(10).'</body>';
834 if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
835 $GLOBALS['TSFE']->content.= chr(10).'</noframes>';
836 }
837 $GLOBALS['TSFE']->content.=chr(10).'</html>';
838 }
839
840
841
842
843
844
845
846
847
848
849
850
851
852 /*************************
853 *
854 * Helper functions
855 * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
856 *
857 *************************/
858
859 /**
860 * Writes string to a temporary file named after the md5-hash of the string
861 *
862 * @param string CSS styles / JavaScript to write to file.
863 * @param string Extension: "css" or "js"
864 * @return string <script> or <link> tag for the file.
865 */
866 function inline2TempFile($str,$ext) {
867
868 // Create filename / tags:
869 $script = '';
870 switch($ext) {
871 case 'js':
872 $script = 'typo3temp/javascript_'.substr(md5($str),0,10).'.js';
873 $output = '
874 <script type="text/javascript" src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'"></script>';
875 break;
876 case 'css':
877 $script = 'typo3temp/stylesheet_'.substr(md5($str),0,10).'.css';
878 $output = '
879 <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'" />';
880 break;
881 }
882
883 // Write file:
884 if ($script) {
885 if (!@is_file(PATH_site.$script)) {
886 t3lib_div::writeFile(PATH_site.$script,$str);
887 }
888 }
889
890 return $output;
891 }
892
893 /**
894 * Checks if the value defined in "config.linkVars" contains an allowed value. Otherwise, return false which means the value will not be added to any links.
895 *
896 * @param string The string in which to find $needle
897 * @param string The string to find in $haystack
898 * @return boolean Returns true if $needle matches or is found in $haystack
899 */
900 function isAllowedLinkVarValue($haystack,$needle) {
901 $OK = false;
902
903 if ($needle=='int' || $needle=='integer') { // Integer
904
905 if (t3lib_div::testInt($haystack)) {
906 $OK = true;
907 }
908
909 } elseif (preg_match('/^\/.+\/[imsxeADSUXu]*$/', $needle)) { // Regular expression, only "//" is allowed as delimiter
910
911 if (@preg_match($needle, $haystack)) {
912 $OK = true;
913 }
914
915 } elseif (strstr($needle,'-')) { // Range
916
917 if (t3lib_div::testInt($haystack)) {
918 $range = explode('-',$needle);
919 if ($range[0] <= $haystack && $range[1] >= $haystack) {
920 $OK = true;
921 }
922 }
923
924 } elseif (strstr($needle,'|')) { // List
925
926 $haystack = str_replace(' ','',$haystack); // Trim the input
927 if (strstr('|'.$needle.'|', '|'.$haystack.'|')) {
928 $OK = true;
929 }
930
931 } elseif (!strcmp($needle,$haystack)) { // String comparison
932 $OK = true;
933 }
934
935 return $OK;
936 }
937 }
938
939 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']) {
940 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']);
941 }
942
943
944
945 // ********************************************************
946 // Includes the search-class if $sword and $scols are set.
947 // ********************************************************
948 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
949 require_once(PATH_tslib.'class.tslib_search.php');
950 }
951
952 // ************
953 // LoadDBGroup
954 // ************
955 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
956
957 /**
958 * Class for fetching record relations for the frontend.
959 *
960 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
961 * @package TYPO3
962 * @subpackage tslib
963 * @see tslib_cObj::RECORDS()
964 */
965 class FE_loadDBGroup extends t3lib_loadDBGroup {
966 var $fromTC = 0; // Means the not only uid and label-field is returned, but everything
967 }
968
969 // **********************************
970 // includes stuff for graphical work
971 // **********************************
972 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
973 require_once(PATH_tslib.'class.tslib_gifbuilder.php');
974
975 // *************************
976 // includes menu-management
977 // *************************
978 require_once(PATH_tslib.'class.tslib_menu.php');
979
980 // *************************
981 // Global content object...
982 // *************************
983 require_once(PATH_tslib.'class.tslib_content.php');
984
985 ?>