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