This commit was manufactured by cvs2svn to create tag
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_pagegen.php
index 858c0aa..6740180 100755 (executable)
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
+*
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
-*  This script is part of the TYPO3 project. The TYPO3 project is 
+*  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
-* 
+*
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
+*  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
-* 
+*
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
+/**
  * Libraries for pagegen.php
  * The script "pagegen.php" is included by "index_ts.php" when a page is not cached but needs to be rendered.
  *
- * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
+ * $Id$
+ * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
  * XHTML compliant
  *
- * @author     Kasper Skårhøj <kasper@typo3.com>
- * @package TYPO3
- * @subpackage tslib
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   87: class TSpagegen 
- *   94:     function pagegenInit()    
- *  133:     function UnCryptMailto(s) 
- *  144:     function linkTo_UnCryptMailto(s)  
- *  217:     function getIncFiles()    
- *  250:     function JSeventFunctions()       
- *  284:     function renderContent()  
- *  311:     function renderContentWithHeader($pageContent)    
- *  534:     function blurLink(theObject)      
+ *   85: class TSpagegen
+ *   92:     function pagegenInit()
+ *  216:     function getIncFiles()
+ *  249:     function JSeventFunctions()
+ *  283:     function renderContent()
+ *  310:     function renderContentWithHeader($pageContent)
  *
  *
- *  603: class FE_loadDBGroup extends t3lib_loadDBGroup        
+ *  674: class FE_loadDBGroup extends t3lib_loadDBGroup
  *
- * TOTAL FUNCTIONS: 8
+ * TOTAL FUNCTIONS: 5
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
+
 
 
 
 
 /**
  * Class for starting TypoScript page generation
- * 
+ *
  * The class is not instantiated as an objects but called directly with the "::" operator.
  * eg: TSpagegen::pagegenInit()
- * 
- * @author     Kasper Skårhøj <kasper@typo3.com>
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tslib
  */
 class TSpagegen {
 
        /**
         * Setting some vars in TSFE, primarily based on TypoScript config settings.
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function pagegenInit()  {
                if ($GLOBALS['TSFE']->page['content_from_pid']>0)       {
@@ -117,7 +115,7 @@ class TSpagegen {
                                $GLOBALS['TSFE']->pEncAllowedParamNames[$temp_p]=1;
                        }
                }
-               
+
 
                        // Global vars...
                $GLOBALS['TSFE']->indexedDocTitle = $GLOBALS['TSFE']->page['title'];
@@ -130,50 +128,50 @@ class TSpagegen {
                if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
                        $GLOBALS['TSFE']->additionalJavaScript['UnCryptMailto()']='
   // JS function for uncrypting spam-protected emails:
-function UnCryptMailto(s) {
+function UnCryptMailto(s) {    //
        var n=0;
        var r="";
-       for(var i=0; i < s.length; i++) { 
-               n=s.charCodeAt(i); 
+       for(var i=0; i < s.length; i++) {
+               n=s.charCodeAt(i);
                if (n>=8364) {n = 128;}
-               r += String.fromCharCode(n-('.$GLOBALS['TSFE']->spamProtectEmailAddresses.')); 
+               r += String.fromCharCode(n-('.$GLOBALS['TSFE']->spamProtectEmailAddresses.'));
        }
        return r;
 }
   // JS function for uncrypting spam-protected emails:
-function linkTo_UnCryptMailto(s)       {
+function linkTo_UnCryptMailto(s)       {       //
        location.href=UnCryptMailto(s);
 }
                ';
                }
 
-               
+
                $GLOBALS['TSFE']->absRefPrefix = trim(''.$GLOBALS['TSFE']->config['config']['absRefPrefix']);
-               if ((!strcmp($GLOBALS['TSFE']->config['config']['simulateStaticDocuments'],'PATH_INFO') || $GLOBALS['TSFE']->absRefPrefix_force) 
+               if ((!strcmp($GLOBALS['TSFE']->config['config']['simulateStaticDocuments'],'PATH_INFO') || $GLOBALS['TSFE']->absRefPrefix_force)
                                && !$GLOBALS['TSFE']->absRefPrefix)     {
-                       $GLOBALS['TSFE']->absRefPrefix=t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/'; 
+                       $GLOBALS['TSFE']->absRefPrefix=t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
                }               // Force absRefPrefix to this value is PATH_INFO is used.
-               
+
                if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) {
                        $tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'_top',$GLOBALS['TSFE']->no_cache,'');
                        $GLOBALS['TSFE']->JSCode = 'if(!parent.'.trim($GLOBALS['TSFE']->sPre).' && !parent.view_frame) top.document.location="'.$tdlLD['totalURL'].'"';
-               }               
-               $GLOBALS['TSFE']->compensateFieldWidth = ''.$GLOBALS['TSFE']->config['config']['compensateFieldWidth'];  
-               $GLOBALS['TSFE']->lockFilePath = ''.$GLOBALS['TSFE']->config['config']['lockFilePath'];  
+               }
+               $GLOBALS['TSFE']->compensateFieldWidth = ''.$GLOBALS['TSFE']->config['config']['compensateFieldWidth'];
+               $GLOBALS['TSFE']->lockFilePath = ''.$GLOBALS['TSFE']->config['config']['lockFilePath'];
                $GLOBALS['TSFE']->lockFilePath = $GLOBALS['TSFE']->lockFilePath ? $GLOBALS['TSFE']->lockFilePath : 'fileadmin/';
                $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'];
                $GLOBALS['TSFE']->TYPO3_CONF_VARS['GFX']['im_noScaleUp'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
-               
+
                $GLOBALS['TSFE']->ATagParams = trim($GLOBALS['TSFE']->config['config']['ATagParams']) ? ' '.trim($GLOBALS['TSFE']->config['config']['ATagParams']) : '';
                if ($GLOBALS['TSFE']->config['config']['setJS_mouseOver'])      $GLOBALS['TSFE']->setJS('mouseOver');
                if ($GLOBALS['TSFE']->config['config']['setJS_openPic'])        $GLOBALS['TSFE']->setJS('openPic');
-               
+
                $GLOBALS['TSFE']->sWordRegEx='';
-               $GLOBALS['TSFE']->sWordList = t3lib_div::GPvar('sword_list');
+               $GLOBALS['TSFE']->sWordList = t3lib_div::_GP('sword_list');
                if (is_array($GLOBALS['TSFE']->sWordList))      {
                        $standAlone = trim(''.$GLOBALS['TSFE']->config['config']['sword_standAlone']);
                        $noMixedCase = trim(''.$GLOBALS['TSFE']->config['config']['sword_noMixedCase']);
-               
+
                        $space = ($standAlone) ? '[[:space:]]' : '';
                        reset($GLOBALS['TSFE']->sWordList);
                        while (list($key,$val) = each($GLOBALS['TSFE']->sWordList))     {
@@ -187,20 +185,21 @@ function linkTo_UnCryptMailto(s)  {
                        }
                        $GLOBALS['TSFE']->sWordRegEx = ereg_replace('\|$','',$GLOBALS['TSFE']->sWordRegEx);
                }
-               
+
                        // linkVars
                $GLOBALS['TSFE']->linkVars = ''.$GLOBALS['TSFE']->config['config']['linkVars'];
                if ($GLOBALS['TSFE']->linkVars) {
                        $linkVarArr = explode(',',$GLOBALS['TSFE']->linkVars);
-                       reset($linkVarArr);
                        $GLOBALS['TSFE']->linkVars='';
+                       reset($linkVarArr);
                        while(list(,$val)=each($linkVarArr))    {
                                $val=trim($val);
-                               if ($val && isset($GLOBALS['HTTP_GET_VARS'][$val]))     {
-                                       if (!is_array($GLOBALS['HTTP_GET_VARS'][$val])) {
-                                               $GLOBALS['TSFE']->linkVars.='&'.$val.'='.rawurlencode($GLOBALS['HTTP_GET_VARS'][$val]);
+                               $GET = t3lib_div::_GET();
+                               if ($val && isset($GET[$val]))  {
+                                       if (!is_array($GET[$val]))      {
+                                               $GLOBALS['TSFE']->linkVars.='&'.$val.'='.rawurlencode($GET[$val]);
                                        } else {
-                                               $GLOBALS['TSFE']->linkVars.=t3lib_div::implodeArrayForUrl($val,$GLOBALS['HTTP_GET_VARS'][$val]);
+                                               $GLOBALS['TSFE']->linkVars.=t3lib_div::implodeArrayForUrl($val,$GET[$val]);
                                        }
                                }
                        }
@@ -211,7 +210,7 @@ function linkTo_UnCryptMailto(s)    {
 
        /**
         * Returns an array with files to include. These files are the ones set up in TypoScript config.
-        * 
+        *
         * @return      array           Files to include. Paths are relative to PATH_site.
         */
        function getIncFiles()  {
@@ -224,7 +223,7 @@ function linkTo_UnCryptMailto(s)    {
                                $incFilesArray[] = $incFile;
                        }
                }
-               
+
                if (is_array($GLOBALS['TSFE']->pSetup['includeLibs.'])) {$incLibs=$GLOBALS['TSFE']->pSetup['includeLibs.'];} else {$incLibs=array();}
                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)
                if (count($incLibs))    {
@@ -241,10 +240,10 @@ function linkTo_UnCryptMailto(s)  {
                }
                return $incFilesArray;
        }
-       
+
        /**
         * Processing JavaScript handlers
-        * 
+        *
         * @return      array           Array with a) a JavaScript section with event handlers and variables set and b) an array with attributes for the body tag.
         */
        function JSeventFunctions()     {
@@ -278,8 +277,8 @@ function linkTo_UnCryptMailto(s)    {
 
        /**
         * Rendering the page content
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function renderContent()        {
                // PAGE CONTENT
@@ -289,24 +288,24 @@ function linkTo_UnCryptMailto(s)  {
 
                        if ($GLOBALS['TSFE']->pSetup['wrap'])   {$pageContent = $GLOBALS['TSFE']->cObj->wrap($pageContent, $GLOBALS['TSFE']->pSetup['wrap']);}
                        if ($GLOBALS['TSFE']->pSetup['stdWrap.'])       {$pageContent = $GLOBALS['TSFE']->cObj->stdWrap($pageContent, $GLOBALS['TSFE']->pSetup['stdWrap.']);}
-               
+
                        // PAGE HEADER (after content - maybe JS is inserted!
-               
+
                        // if 'disableAllHeaderCode' is set, all the header-code is discarded!
                if ($GLOBALS['TSFE']->config['config']['disableAllHeaderCode']) {
-                       $GLOBALS['TSFE']->content=$pageContent;
-               } else {                        
+                       $GLOBALS['TSFE']->content = $pageContent;
+               } else {
                        TSpagegen::renderContentWithHeader($pageContent);
                }
                $GLOBALS['TT']->pull($GLOBALS['TT']->LR?$GLOBALS['TSFE']->content:'');
                $GLOBALS['TT']->decStackPointer();
        }
-       
+
        /**
         * Rendering normal HTML-page with header by wrapping the generated content ($pageContent) in body-tags and setting the header accordingly.
-        * 
+        *
         * @param       string          The page content which TypoScript objects has generated
-        * @return      void            
+        * @return      void
         */
        function renderContentWithHeader($pageContent)  {
                $customContent = $GLOBALS['TSFE']->config['config']['headerComment'];
@@ -314,47 +313,118 @@ function linkTo_UnCryptMailto(s) {
                        $customContent = chr(10).$customContent;
                } else $customContent='';
 
-                       // Setting charset:             
-               $theCharset = ($GLOBALS['TSFE']->config['config']['metaCharset'] ? $GLOBALS['TSFE']->config['config']['metaCharset'] : 'iso-8859-1');
-               
+                       // Setting charset:
+               $theCharset = ($GLOBALS['TSFE']->config['config']['metaCharset'] ? $GLOBALS['TSFE']->config['config']['metaCharset'] : $GLOBALS['TSFE']->defaultCharSet);
+
                        // Reset the content variables:
                $GLOBALS['TSFE']->content='';
+               $htmlTagAttributes = array();
+               $htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ? $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] : 'en';
+
+                       // Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
+               if ($GLOBALS['TSFE']->config['config']['htmlTag_dir'])  {
+                       $htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
+               }
 
                        // Setting document type:
-               switch((string)$GLOBALS['TSFE']->config['config']['doctype'])   {
-                       case 'xhtml_trans':
-                               $GLOBALS['TSFE']->content.='<?xml version="1.0" encoding="'.$theCharset.'"?>
-<!DOCTYPE html 
+               $docTypeParts = array();
+               $XMLprologue = $GLOBALS['TSFE']->config['config']['xmlprologue'] != 'none';
+               if ($GLOBALS['TSFE']->config['config']['doctype'])      {
+
+                               // Setting doctypes:
+                       switch((string)$GLOBALS['TSFE']->config['config']['doctype'])   {
+                               case 'xhtml_trans':
+                                       if ($XMLprologue) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
+                                       $docTypeParts[]='<!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
-                       break;
-                       default:
-                               $GLOBALS['TSFE']->content.='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
-                       break;
+                               break;
+                               case 'xhtml_strict':
+                                       if ($XMLprologue) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
+                                       $docTypeParts[]='<!DOCTYPE html
+     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
+                               break;
+                               case 'xhtml_frames':
+                                       if ($XMLprologue) $docTypeParts[]='<?xml version="1.0" encoding="'.$theCharset.'"?>';
+                                       $docTypeParts[]='<!DOCTYPE html
+     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
+                               break;
+                               case 'xhtml_11':
+                                       if ($XMLprologue) $docTypeParts[]='<?xml version="1.1" encoding="'.$theCharset.'"?>';
+                                       $docTypeParts[]='<!DOCTYPE html
+     PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
+                               break;
+                               case 'xhtml_2':
+                                       if ($XMLprologue) $docTypeParts[]='<?xml version="2.0" encoding="'.$theCharset.'"?>';
+                                       $docTypeParts[]='<!DOCTYPE html
+       PUBLIC "-//W3C//DTD XHTML 2.0//EN"
+       "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
+                               break;
+                               case 'none':
+                               break;
+                               default:
+                                       $docTypeParts[] = $GLOBALS['TSFE']->config['config']['doctype'];
+                               break;
+                       }
+                               // Setting <html> tag attributes:
+                       switch((string)$GLOBALS['TSFE']->config['config']['doctype'])   {
+                               case 'xhtml_trans':
+                               case 'xhtml_strict':
+                               case 'xhtml_frames':
+                                       $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
+                                       $htmlTagAttributes['xml:lang'] = $htmlLang;
+                                       $htmlTagAttributes['lang'] = $htmlLang;
+                               break;
+                               case 'xhtml_11':
+                               case 'xhtml_2':
+                                       $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml';
+                                       $htmlTagAttributes['xml:lang'] = $htmlLang;
+                               break;
+                       }
+               } else {
+                       $docTypeParts[]='<!DOCTYPE html
+       PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
                }
-               
-               $GLOBALS['TSFE']->content.='
-<html>
+
+                       // Swap XML and doctype order around (for MSIE / Opera standards compliance)
+               if ($GLOBALS['TSFE']->config['config']['doctypeSwitch'])        {
+                       $docTypeParts = array_reverse($docTypeParts);
+               }
+
+                       // Adding doctype parts:
+               $GLOBALS['TSFE']->content.= count($docTypeParts) ? implode(chr(10),$docTypeParts).chr(10) : '';
+
+                       // Begin header section:
+               if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'],'none'))     {
+                       $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : t3lib_div::implodeParams($htmlTagAttributes);
+               } else {
+                       $_attr = '';
+               }
+               $GLOBALS['TSFE']->content.='<html'.($_attr ? ' '.$_attr : '').'>
 <head>
 <!-- '.($customContent?$customContent.chr(10):'').'
        This website is brought to you by TYPO3 - get.content.right
-       TYPO3 is a free open source Content Management Framework
-       created by Kasper Skaarhoej and licensed under GNU/GPL.
+       TYPO3 is a free open source Content Management Framework created by Kasper Skaarhoj and licensed under GNU/GPL.
+       TYPO3 is copyright 1998-2004 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
        Information and contribution at http://www.typo3.com
 -->
 ';
-               
-               
+
+
+               if ($GLOBALS['TSFE']->config['config']['baseURL']) {
+                       $ss = intval($GLOBALS['TSFE']->config['config']['baseURL']) ? t3lib_div::getIndpEnv('TYPO3_SITE_URL') : $GLOBALS['TSFE']->config['config']['baseURL'];
+                       $GLOBALS['TSFE']->content.='
+       <base href="'.htmlspecialchars($ss).'" />';
+               }
+
                if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
                        $ss=$path.$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
                        $GLOBALS['TSFE']->content.='
-<link rel="SHORTCUT ICON" href="'.$ss.'" />';
+       <link rel="SHORTCUT ICON" href="'.htmlspecialchars($ss).'" />';
                }
-               
-               
-
-
-
 
                /** CSS STYLESHEET handling: */
                if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
@@ -366,14 +436,18 @@ function linkTo_UnCryptMailto(s)  {
                                }
                        }
                        if (count($temp_styleLines))    {
-                               $GLOBALS['TSFE']->content.='
-<style type="text/css">
-       /*<![CDATA[*/
-<!--
-'.implode(chr(10),$temp_styleLines).'
--->
-       /*]]>*/
-</style>';
+                               if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
+                                       $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile(implode(chr(10),$temp_styleLines),'css');
+                               } else {
+                                       $GLOBALS['TSFE']->content.='
+       <style type="text/css">
+               /*<![CDATA[*/
+       <!--
+       '.implode(chr(10),$temp_styleLines).'
+       -->
+               /*]]>*/
+       </style>';
+                               }
                        }
                }
 
@@ -381,17 +455,33 @@ function linkTo_UnCryptMailto(s)  {
                        $ss=$GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
                        if ($ss) {
                                $GLOBALS['TSFE']->content.='
-<link rel="stylesheet" href="'.$ss.'" />';
+       <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($ss).'" />';
                        }
                }
                if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
                        reset($GLOBALS['TSFE']->pSetup['includeCSS.']);
                        while(list($k2,$iCSSfile)=each($GLOBALS['TSFE']->pSetup['includeCSS.']))        {
                                if (!is_array($iCSSfile))       {
-                                       $ss=$GLOBALS['TSFE']->tmpl->getFileName($iCSSfile);
+                                       $ss = $GLOBALS['TSFE']->tmpl->getFileName($iCSSfile);
                                        if ($ss) {
-                                               $GLOBALS['TSFE']->content.='
-<link rel="stylesheet" href="'.$ss.'" />';
+                                               if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['import']) {
+                                                       if (substr($ss,0,1)!='/')       {       // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
+                                                               $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/'.$ss;
+                                                       }
+                                                       $GLOBALS['TSFE']->content.='
+       <style type="text/css">
+       <!--
+       @import url("'.htmlspecialchars($ss).'") '.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['media']).';
+       -->
+       </style>
+                                                       ';
+                                               } else {
+                                                       $GLOBALS['TSFE']->content.='
+       <link rel="'.($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['alternate'] ? 'alternate stylesheet' : 'stylesheet').'" type="text/css" href="'.htmlspecialchars($ss).'"'.
+                       ($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['title'] ? ' title="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['title']).'"' : '').
+                       ($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['media'] ? ' media="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$k2.'.']['media']).'"' : '').
+                       ' />';
+                                               }
                                        }
                                }
                        }
@@ -400,7 +490,7 @@ function linkTo_UnCryptMailto(s)    {
                // Stylesheets
                $style='';
                $style.=trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']).chr(10);
-               
+
                if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE'])   {
                        $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
                        $RTEclasses = $pageTSConfig['RTE.']['classes.'];
@@ -425,38 +515,63 @@ function linkTo_UnCryptMailto(s)  {
                                }
                        }
                }
-               
+
+                       // Setting body tag margins in CSS:
+               if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
+                       $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
+                       $style.='
+       BODY {margin: '.$margins.'px '.$margins.'px '.$margins.'px '.$margins.'px;}';
+               }
+
                if ($GLOBALS['TSFE']->pSetup['noLinkUnderline'])        {
                        $style.='
-A:link {text-decoration: none}
-A:visited {text-decoration: none}
-A:active {text-decoration: none}';
+       A:link {text-decoration: none}
+       A:visited {text-decoration: none}
+       A:active {text-decoration: none}';
                }
                if (trim($GLOBALS['TSFE']->pSetup['hover']))    {
                        $style.='
-A:hover {color: '.trim($GLOBALS['TSFE']->pSetup['hover']).';}';
+       A:hover {color: '.trim($GLOBALS['TSFE']->pSetup['hover']).';}';
                }
                if (trim($GLOBALS['TSFE']->pSetup['hoverStyle']))       {
                        $style.='
-A:hover {'.trim($GLOBALS['TSFE']->pSetup['hoverStyle']).'}';
+       A:hover {'.trim($GLOBALS['TSFE']->pSetup['hoverStyle']).'}';
                }
                if ($GLOBALS['TSFE']->pSetup['smallFormFields'])        {
                        $style.='
-SELECT {  font-family: Verdana, Arial, Helvetica; font-size: 10px }
-TEXTAREA  {  font-family: Verdana, Arial, Helvetica; font-size: 10px} 
-INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
+       SELECT {  font-family: Verdana, Arial, Helvetica; font-size: 10px }
+       TEXTAREA  {  font-family: Verdana, Arial, Helvetica; font-size: 10px}
+       INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
+               }
+               if ($GLOBALS['TSFE']->pSetup['adminPanelStyles'])       {
+                       $style.='
+
+       /* Default styles for the Admin Panel */
+       TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
+       TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
+       TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
+       TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
+       TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
+       TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
+       TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
+       TABLE.typo3-editPanel TD { border: 0px; }
+                       ';
                }
-               
+
                if (trim($style))       {
-               $GLOBALS['TSFE']->content.='
-<style type="text/css">
-       /*<![CDATA[*/
-<!--'.$style.'
--->
-       /*]]>*/
-</style>';
+                       if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
+                               $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($style, 'css');
+                       } else {
+                               $GLOBALS['TSFE']->content.='
+       <style type="text/css">
+               /*<![CDATA[*/
+       <!--'.$style.'
+       -->
+               /*]]>*/
+       </style>';
+                       }
                }
-       
+
 
 
 
@@ -475,14 +590,14 @@ INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
                if ($GLOBALS['TSFE']->config['config']['titleTagFunction'])     {
                        $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array(), $titleTagContent);
                }
-               
+
                $GLOBALS['TSFE']->content.='
-<title>'.htmlspecialchars($titleTagContent).'</title>';
+       <title>'.htmlspecialchars($titleTagContent).'</title>';
                $GLOBALS['TSFE']->content.='
-<meta http-equiv="Content-Type" content="text/html; charset='.$theCharset.'" />';
+       <meta http-equiv="Content-Type" content="text/html; charset='.$theCharset.'" />';
                $GLOBALS['TSFE']->content.='
-<meta name="generator" content="TYPO3 3.6 CMS" />';
-               
+       <meta name="generator" content="TYPO3 3.6 CMS" />';
+
                $conf=$GLOBALS['TSFE']->pSetup['meta.'];
                if (is_array($conf))    {
                        reset($conf);
@@ -497,18 +612,18 @@ INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
                                                $a='name';
                                                if (strtolower($key)=='refresh')        {$a='http-equiv';}
                                                $GLOBALS['TSFE']->content.= '
-<meta '.$a.'="'.$key.'" content="'.htmlspecialchars(trim($val)).'" />';
+       <meta '.$a.'="'.$key.'" content="'.htmlspecialchars(trim($val)).'" />';
                                        }
                                }
                        }
                }
-       
+
                unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
                unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
-       
+
                if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
                                // Storing the JSCode and JSImgCode vars...
-                       $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;    
+                       $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
                        $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
                        $GLOBALS['TSFE']->config['INTincScript_ext']['divKey']= $GLOBALS['TSFE']->uniqueHash();
                        $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData']    = $GLOBALS['TSFE']->additionalHeaderData;       // Storing the header-data array
@@ -522,22 +637,31 @@ INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
                }
                $JSef = TSpagegen::JSeventFunctions();
 
-               $GLOBALS['TSFE']->content.='
-<script type="text/javascript">
-       /*<![CDATA[*/
-<!--
-       browserName = navigator.appName;
-       browserVer = parseInt(navigator.appVersion);
-       var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
-       if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror") {version = "n3";} else {version = "n2";}
-               // Blurring links:
-       function blurLink(theObject)    {
-               if (msie4)      {theObject.blur();}
-       }
-// -->
-       /*]]>*/
-</script>
-'.implode($GLOBALS['TSFE']->additionalHeaderData,chr(10)).'
+                       // Adding default Java Script:
+               $_scriptCode = '
+               browserName = navigator.appName;
+               browserVer = parseInt(navigator.appVersion);
+               var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
+               if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror") {version = "n3";} else {version = "n2";}
+                       // Blurring links:
+               function blurLink(theObject)    {       //
+                       if (msie4)      {theObject.blur();}
+               }
+               ';
+               if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
+                               // NOTICE: The following code must be kept synchronized with "tslib/default.js"!!!
+                       $GLOBALS['TSFE']->content.='
+       <script type="text/javascript">
+               /*<![CDATA[*/
+       <!--'.$_scriptCode.'
+       // -->
+               /*]]>*/
+       </script>';
+               } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS']==='external')   {
+                       $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($_scriptCode, 'js');
+               }
+
+               $GLOBALS['TSFE']->content.=chr(10).implode($GLOBALS['TSFE']->additionalHeaderData,chr(10)).'
 '.$JSef[0].'
 </head>';
                if ($GLOBALS['TSFE']->pSetup['frameSet.'])      {
@@ -545,35 +669,42 @@ INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
                        $GLOBALS['TSFE']->content.=$fs->make($GLOBALS['TSFE']->pSetup['frameSet.']);
                        $GLOBALS['TSFE']->content.= chr(10).'<noframes>'.chr(10);
                }
-               
-               // Bodytag:
+
+                       // Bodytag:
                $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'],$GLOBALS['TSFE']->pSetup['bodyTagCObject.'],'bodyTagCObject') : '';
-               if (!$defBT)    $defBT = '<body bgcolor="#FFFFFF">';
+               if (!$defBT)    $defBT = $GLOBALS['TSFE']->defaultBodyTag;
                $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
                if ($bgImg=$GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'],$GLOBALS['TSFE']->pSetup['bgImg.']))        {
                        $bodyTag = ereg_replace('>$','',trim($bodyTag)).' background="'.$GLOBALS["TSFE"]->absRefPrefix.$bgImg[3].'">';
                }
+
                if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']))  {
-                       $margins = $GLOBALS['TSFE']->pSetup['bodyTagMargins'];
-                       $bodyTag = ereg_replace('>$','',trim($bodyTag)).' leftmargin="'.$margins.'" topmargin="'.$margins.'" marginwidth="'.$margins.'" marginheight="'.$margins.'">';
+                       $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
+                       if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS'])      {
+                               // Setting margins in CSS, see above
+                       } else {
+                               $bodyTag = ereg_replace('>$','',trim($bodyTag)).' leftmargin="'.$margins.'" topmargin="'.$margins.'" marginwidth="'.$margins.'" marginheight="'.$margins.'">';
+                       }
                }
+
                if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']))       {
                        $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']).'>';
                }
+
                if (count($JSef[1]))    {       // Event functions:
                        $bodyTag = ereg_replace('>$','',trim($bodyTag)).' '.trim(implode(' ',$JSef[1])).'>';
                }
-               
-
-               // Div-sections                 
                $GLOBALS['TSFE']->content.= chr(10).$bodyTag;
+
+
+               // Div-sections
                if ($GLOBALS['TSFE']->divSection)       {
                        $GLOBALS['TSFE']->content.=     chr(10).$GLOBALS['TSFE']->divSection;
                }
-               
+
                // Page content
                $GLOBALS['TSFE']->content.=chr(10).$pageContent;
-               
+
                // Ending page
                $GLOBALS['TSFE']->content.= chr(10).'</body>';
                if ($GLOBALS['TSFE']->pSetup['frameSet.'])      {
@@ -581,6 +712,59 @@ INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
                }
                $GLOBALS['TSFE']->content.=chr(10).'</html>';
        }
+
+
+
+
+
+
+
+
+
+
+
+
+
+       /*************************
+        *
+        * Helper functions
+        * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
+        *
+        *************************/
+
+       /**
+        * Writes string to a temporary file named after the md5-hash of the string
+        *
+        * @param       string          CSS styles / JavaScript to write to file.
+        * @param       string          Extension: "css" or "js"
+        * @return      string          <script> or <link> tag for the file.
+        */
+       function inline2TempFile($str,$ext)     {
+
+                       // Create filename / tags:
+               $script = '';
+               switch($ext)    {
+                       case 'js':
+                               $script = 'typo3temp/javascript_'.substr(md5($str),0,10).'.js';
+                               $output = '
+       <script type="text/javascript" src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'"></script>';
+                       break;
+                       case 'css':
+                               $script = 'typo3temp/stylesheet_'.substr(md5($str),0,10).'.css';
+                               $output = '
+       <link rel="stylesheet" type="text/css" href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$script).'" />';
+                       break;
+               }
+
+                       // Write file:
+               if ($script)    {
+                       if (!@is_file(PATH_site.$script))       {
+                               t3lib_div::writeFile(PATH_site.$script,$str);
+                       }
+               }
+
+               return $output;
+       }
 }
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php'])  {
@@ -592,7 +776,7 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class
 // ********************************************************
 // Includes the search-class if $sword and $scols are set.
 // ********************************************************
-if (t3lib_div::GPvar('sword') && t3lib_div::GPvar('scols'))    {
+if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols'))        {
        require_once(PATH_tslib.'class.tslib_search.php');
 }
 
@@ -600,6 +784,15 @@ if (t3lib_div::GPvar('sword') && t3lib_div::GPvar('scols'))        {
 // LoadDBGroup
 // ************
 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
+
+/**
+ * Class for fetching record relations for the frontend.
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @package TYPO3
+ * @subpackage tslib
+ * @see tslib_cObj::RECORDS()
+ */
 class FE_loadDBGroup extends t3lib_loadDBGroup {
        var $fromTC = 0;                // Means the not only uid and label-field is returned, but everything
 }
@@ -620,4 +813,4 @@ require_once(PATH_tslib.'class.tslib_menu.php');
 // *************************
 require_once(PATH_tslib.'class.tslib_content.php');
 
-?>
\ No newline at end of file
+?>