TYPO3 API  SVNRelease
class.tslib_pagegen.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Libraries for pagegen.php
00029  * The script "pagegen.php" is included by "index_ts.php" when a page is not cached but needs to be rendered.
00030  *
00031  * $Id: class.tslib_pagegen.php 10317 2011-01-26 00:56:49Z baschny $
00032  * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
00033  * XHTML compliant
00034  *
00035  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00036  */
00037 /**
00038  * [CLASS/FUNCTION INDEX of SCRIPT]
00039  *
00040  *
00041  *
00042  *   88: class TSpagegen
00043  *   95:     function pagegenInit()
00044  *  271:     function getIncFiles()
00045  *  304:     function JSeventFunctions()
00046  *  338:     function renderContent()
00047  *  365:     function renderContentWithHeader($pageContent)
00048  *
00049  *              SECTION: Helper functions
00050  *  827:     function inline2TempFile($str,$ext)
00051  *
00052  *
00053  *  881: class FE_loadDBGroup extends t3lib_loadDBGroup
00054  *
00055  * TOTAL FUNCTIONS: 6
00056  * (This index is automatically created/updated by the extension "extdeveval")
00057  *
00058  */
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 /**
00079  * Class for starting TypoScript page generation
00080  *
00081  * The class is not instantiated as an objects but called directly with the "::" operator.
00082  * eg: TSpagegen::pagegenInit()
00083  *
00084  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00085  * @package TYPO3
00086  * @subpackage tslib
00087  */
00088 class TSpagegen {
00089 
00090     /**
00091      * Setting some vars in TSFE, primarily based on TypoScript config settings.
00092      *
00093      * @return  void
00094      */
00095     public static function pagegenInit() {
00096         if ($GLOBALS['TSFE']->page['content_from_pid']>0)   {
00097             $temp_copy_TSFE = clone($GLOBALS['TSFE']);  // make REAL copy of TSFE object - not reference!
00098             $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!
00099             $temp_copy_TSFE->getPageAndRootlineWithDomain($GLOBALS['TSFE']->config['config']['content_from_pid_allowOutsideDomain']?0:$GLOBALS['TSFE']->domainStartPage);
00100             $GLOBALS['TSFE']->contentPid = intval($temp_copy_TSFE->id);
00101             unset($temp_copy_TSFE);
00102         }
00103         if ($GLOBALS['TSFE']->config['config']['MP_defaults'])  {
00104             $temp_parts = t3lib_div::trimExplode('|',$GLOBALS['TSFE']->config['config']['MP_defaults'],1);
00105             foreach ($temp_parts as $temp_p) {
00106                 list($temp_idP,$temp_MPp) = explode(':',$temp_p,2);
00107                 $temp_ids=t3lib_div::intExplode(',',$temp_idP);
00108                 foreach ($temp_ids as $temp_id) {
00109                     $GLOBALS['TSFE']->MP_defaults[$temp_id]=$temp_MPp;
00110                 }
00111             }
00112         }
00113 
00114             // Global vars...
00115         $GLOBALS['TSFE']->indexedDocTitle = $GLOBALS['TSFE']->page['title'];
00116         $GLOBALS['TSFE']->debug = ''.$GLOBALS['TSFE']->config['config']['debug'];
00117 
00118             // Base url:
00119         if ($GLOBALS['TSFE']->config['config']['baseURL'])  {
00120             if ($GLOBALS['TSFE']->config['config']['baseURL']==='1')    {
00121                     // Deprecated property, going to be dropped in TYPO3 4.7.
00122                 $error = 'Unsupported TypoScript property was found in this template: "config.baseURL="1"
00123 
00124 This setting has been deprecated in TYPO 3.8.1 due to security concerns.
00125 You need to change this value to the URL of your website root, otherwise TYPO3 will not work!
00126 
00127 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.';
00128                 throw new RuntimeException(nl2br($error));
00129             } else {
00130                 $GLOBALS['TSFE']->baseUrl = $GLOBALS['TSFE']->config['config']['baseURL'];
00131             }
00132             $GLOBALS['TSFE']->anchorPrefix = substr(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'),strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));
00133         }
00134 
00135             // Internal and External target defaults
00136         $GLOBALS['TSFE']->intTarget = ''.$GLOBALS['TSFE']->config['config']['intTarget'];
00137         $GLOBALS['TSFE']->extTarget = ''.$GLOBALS['TSFE']->config['config']['extTarget'];
00138         $GLOBALS['TSFE']->fileTarget = ''.$GLOBALS['TSFE']->config['config']['fileTarget'];
00139         if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'] === 'ascii') {
00140             $GLOBALS['TSFE']->spamProtectEmailAddresses = 'ascii';
00141         } else {
00142             $GLOBALS['TSFE']->spamProtectEmailAddresses = t3lib_div::intInRange($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses'],-10,10,0);
00143         }
00144 
00145         $GLOBALS['TSFE']->absRefPrefix = ($GLOBALS['TSFE']->config['config']['absRefPrefix'] ? trim($GLOBALS['TSFE']->config['config']['absRefPrefix']) : '');
00146 
00147         if ($GLOBALS['TSFE']->type && $GLOBALS['TSFE']->config['config']['frameReloadIfNotInFrameset']) {
00148             $tdlLD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'_top',$GLOBALS['TSFE']->no_cache,'');
00149             $GLOBALS['TSFE']->JSCode = 'if(!parent.'.trim($GLOBALS['TSFE']->sPre).' && !parent.view_frame) top.location.href="'.$GLOBALS['TSFE']->baseUrlWrap($tdlLD['totalURL']).'"';
00150         }
00151         $GLOBALS['TSFE']->compensateFieldWidth = ''.$GLOBALS['TSFE']->config['config']['compensateFieldWidth'];
00152         $GLOBALS['TSFE']->lockFilePath = ''.$GLOBALS['TSFE']->config['config']['lockFilePath'];
00153         $GLOBALS['TSFE']->lockFilePath = $GLOBALS['TSFE']->lockFilePath ? $GLOBALS['TSFE']->lockFilePath : $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
00154         $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'];
00155         $GLOBALS['TSFE']->TYPO3_CONF_VARS['GFX']['im_noScaleUp'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_noScaleUp'];
00156 
00157         $GLOBALS['TSFE']->ATagParams = trim($GLOBALS['TSFE']->config['config']['ATagParams']) ? ' '.trim($GLOBALS['TSFE']->config['config']['ATagParams']) : '';
00158         if ($GLOBALS['TSFE']->config['config']['setJS_mouseOver'])  $GLOBALS['TSFE']->setJS('mouseOver');
00159         if ($GLOBALS['TSFE']->config['config']['setJS_openPic'])    $GLOBALS['TSFE']->setJS('openPic');
00160 
00161         $GLOBALS['TSFE']->sWordRegEx='';
00162         $GLOBALS['TSFE']->sWordList = t3lib_div::_GP('sword_list');
00163         if (is_array($GLOBALS['TSFE']->sWordList))  {
00164             $space = (!empty($GLOBALS['TSFE']->config['config']['sword_standAlone'])) ? '[[:space:]]' : '';
00165 
00166             foreach ($GLOBALS['TSFE']->sWordList as $val) {
00167                 if (strlen(trim($val)) > 0) {
00168                         $GLOBALS['TSFE']->sWordRegEx.= $space.quotemeta($val).$space.'|';
00169                 }
00170             }
00171             $GLOBALS['TSFE']->sWordRegEx = preg_replace('/\|$/','',$GLOBALS['TSFE']->sWordRegEx);
00172         }
00173 
00174             // linkVars
00175         $linkVars = (string)$GLOBALS['TSFE']->config['config']['linkVars'];
00176         if ($linkVars)  {
00177             $linkVarArr = explode(',',$linkVars);
00178 
00179             $GLOBALS['TSFE']->linkVars='';
00180             $GET = t3lib_div::_GET();
00181 
00182             foreach ($linkVarArr as $val)   {
00183                 $val = trim($val);
00184 
00185                 if (preg_match('/^(.*)\((.+)\)$/',$val,$match)) {
00186                     $val = trim($match[1]);
00187                     $test = trim($match[2]);
00188                 } else unset($test);
00189 
00190                 if ($val && isset($GET[$val]))  {
00191                     if (!is_array($GET[$val]))  {
00192                         $tmpVal = rawurlencode($GET[$val]);
00193 
00194                         if ($test && !TSpagegen::isAllowedLinkVarValue($tmpVal,$test))  {
00195                             continue;   // Error: This value was not allowed for this key
00196                         }
00197 
00198                         $value = '&'.$val.'='.$tmpVal;
00199                     } else {
00200                         if ($test && strcmp('array',$test)) {
00201                             continue;   // Error: This key must not be an array!
00202                         }
00203                         $value = t3lib_div::implodeArrayForUrl($val,$GET[$val]);
00204                     }
00205                 } else continue;
00206 
00207                 $GLOBALS['TSFE']->linkVars.= $value;
00208             }
00209             unset($GET);
00210         } else {
00211             $GLOBALS['TSFE']->linkVars='';
00212         }
00213 
00214         if($GLOBALS['TSFE']->config['config']['doctype'] == 'html_5') {
00215             $GLOBALS['TSFE']->logDeprecatedTyposcript('config.doctype = html_5', 'It will be removed in TYPO3 4.7. Use html5 instead.');
00216             $GLOBALS['TSFE']->config['config']['doctype'] = 'html5';
00217         }
00218         
00219             // Setting XHTML-doctype from doctype
00220         if (!$GLOBALS['TSFE']->config['config']['xhtmlDoctype'])    {
00221             $GLOBALS['TSFE']->config['config']['xhtmlDoctype'] = $GLOBALS['TSFE']->config['config']['doctype'];
00222         }
00223 
00224         if ($GLOBALS['TSFE']->config['config']['xhtmlDoctype']) {
00225             $GLOBALS['TSFE']->xhtmlDoctype = $GLOBALS['TSFE']->config['config']['xhtmlDoctype'];
00226 
00227                 // Checking XHTML-docytpe
00228             switch((string)$GLOBALS['TSFE']->config['config']['xhtmlDoctype'])  {
00229                 case 'xhtml_trans':
00230                 case 'xhtml_strict':
00231                 case 'xhtml_frames':
00232                     $GLOBALS['TSFE']->xhtmlVersion = 100;
00233                 break;
00234                 case 'xhtml_basic':
00235                     $GLOBALS['TSFE']->xhtmlVersion = 105;
00236                 break;
00237                 case 'xhtml_11':
00238                 case 'xhtml+rdfa_10':
00239                     $GLOBALS['TSFE']->xhtmlVersion = 110;
00240                 break;
00241                 case 'xhtml_2':
00242                     $GLOBALS['TSFE']->xhtmlVersion = 200;
00243                 break;
00244                 default:
00245                     $GLOBALS['TSFE']->getPageRenderer()->setRenderXhtml(FALSE);
00246                     $GLOBALS['TSFE']->xhtmlDoctype = '';
00247                     $GLOBALS['TSFE']->xhtmlVersion = 0;
00248             }
00249         } else {
00250             $GLOBALS['TSFE']->getPageRenderer()->setRenderXhtml(FALSE);
00251         }
00252     }
00253 
00254     /**
00255      * Returns an array with files to include. These files are the ones set up in TypoScript config.
00256      *
00257      * @return  array       Files to include. Paths are relative to PATH_site.
00258      */
00259     public static function getIncFiles() {
00260         $incFilesArray = array();
00261             // Get files from config.includeLibrary
00262         $includeLibrary = trim(''.$GLOBALS['TSFE']->config['config']['includeLibrary']);
00263         if ($includeLibrary)    {
00264             $incFile=$GLOBALS['TSFE']->tmpl->getFileName($includeLibrary);
00265             if ($incFile)   {
00266                 $incFilesArray[] = $incFile;
00267             }
00268         }
00269 
00270         if (is_array($GLOBALS['TSFE']->pSetup['includeLibs.'])) {$incLibs=$GLOBALS['TSFE']->pSetup['includeLibs.'];} else {$incLibs=array();}
00271         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)
00272         if (count($incLibs))    {
00273             foreach ($incLibs as $theLib) {
00274                 if (!is_array($theLib) && $incFile=$GLOBALS['TSFE']->tmpl->getFileName($theLib))    {
00275                     $incFilesArray[] = $incFile;
00276                 }
00277             }
00278         }
00279             // Include HTML mail library?
00280         if ($GLOBALS['TSFE']->config['config']['incT3Lib_htmlmail'])    {
00281             $GLOBALS['TSFE']->logDeprecatedTyposcript('config.incT3Lib_htmlmail');
00282             $incFilesArray[] = 't3lib/class.t3lib_htmlmail.php';
00283         }
00284         return $incFilesArray;
00285     }
00286 
00287     /**
00288      * Processing JavaScript handlers
00289      *
00290      * @return  array       Array with a) a JavaScript section with event handlers and variables set and b) an array with attributes for the body tag.
00291      */
00292     public static function JSeventFunctions()   {
00293         $functions = array();
00294         $setEvents = array();
00295         $setBody = array();
00296 
00297         foreach ($GLOBALS['TSFE']->JSeventFuncCalls as $event => $handlers) {
00298             if (count($handlers))   {
00299                 $functions[] = '    function T3_'.$event.'Wrapper(e)    {   '.implode('   ',$handlers).'    }';
00300                 $setEvents[] = '    document.'.$event.'=T3_'.$event.'Wrapper;';
00301                 if ($event == 'onload') {
00302                     $setBody[]='onload="T3_onloadWrapper();"';  // dubiuos double setting breaks on some browser - do we need it?
00303                 }
00304             }
00305         }
00306 
00307         return array(count($functions)? implode(LF, $functions) . LF . implode(LF, $setEvents) : '', $setBody);
00308     }
00309 
00310     /**
00311      * Rendering the page content
00312      *
00313      * @return  void
00314      */
00315     public static function renderContent() {
00316             // PAGE CONTENT
00317         $GLOBALS['TT']->incStackPointer();
00318         $GLOBALS['TT']->push($GLOBALS['TSFE']->sPre, 'PAGE');
00319             $pageContent = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup);
00320 
00321             if ($GLOBALS['TSFE']->pSetup['wrap'])   {$pageContent = $GLOBALS['TSFE']->cObj->wrap($pageContent, $GLOBALS['TSFE']->pSetup['wrap']);}
00322             if ($GLOBALS['TSFE']->pSetup['stdWrap.'])   {$pageContent = $GLOBALS['TSFE']->cObj->stdWrap($pageContent, $GLOBALS['TSFE']->pSetup['stdWrap.']);}
00323 
00324             // PAGE HEADER (after content - maybe JS is inserted!
00325 
00326             // if 'disableAllHeaderCode' is set, all the header-code is discarded!
00327         if ($GLOBALS['TSFE']->config['config']['disableAllHeaderCode']) {
00328             $GLOBALS['TSFE']->content = $pageContent;
00329         } else {
00330             TSpagegen::renderContentWithHeader($pageContent);
00331         }
00332         $GLOBALS['TT']->pull($GLOBALS['TT']->LR?$GLOBALS['TSFE']->content:'');
00333         $GLOBALS['TT']->decStackPointer();
00334     }
00335 
00336     /**
00337      * Rendering normal HTML-page with header by wrapping the generated content ($pageContent) in body-tags and setting the header accordingly.
00338      *
00339      * @param   string      The page content which TypoScript objects has generated
00340      * @return  void
00341      */
00342     public static function renderContentWithHeader($pageContent) {
00343             // get instance of t3lib_PageRenderer
00344         /** @var $pageRenderer t3lib_PageRenderer */
00345         $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
00346 
00347         $pageRenderer->backPath = TYPO3_mainDir;
00348 
00349         if ($GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter']) {
00350             $pageRenderer->enableMoveJsFromHeaderToFooter();
00351         }
00352 
00353         if ($GLOBALS['TSFE']->config['config']['pageRendererTemplateFile']) {
00354             $file = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->config['config']['pageRendererTemplateFile']);
00355             if ($file) {
00356                 $pageRenderer->setTemplateFile($file);
00357             }
00358         }
00359 
00360         $headerComment = $GLOBALS['TSFE']->config['config']['headerComment'];
00361         if (trim($headerComment)) {
00362             $pageRenderer->addInlineComment(TAB . str_replace(LF, LF . TAB, trim($headerComment)) . LF);
00363         }
00364 
00365             // Setting charset:
00366         $theCharset = $GLOBALS['TSFE']->metaCharset;
00367 
00368             // Reset the content variables:
00369         $GLOBALS['TSFE']->content = '';
00370         $htmlTagAttributes = array ();
00371         $htmlLang = $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] ? $GLOBALS['TSFE']->config['config']['htmlTag_langKey'] : 'en';
00372 
00373             // Set content direction: (More info: http://www.tau.ac.il/~danon/Hebrew/HTML_and_Hebrew.html)
00374         if ($GLOBALS['TSFE']->config['config']['htmlTag_dir']) {
00375             $htmlTagAttributes['dir'] = htmlspecialchars($GLOBALS['TSFE']->config['config']['htmlTag_dir']);
00376         }
00377 
00378             // Setting document type:
00379         $docTypeParts = array ();
00380         // Part 1: XML prologue
00381         switch ((string) $GLOBALS['TSFE']->config['config']['xmlprologue']) {
00382             case 'none' :
00383                 break;
00384             case 'xml_10' :
00385                 $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
00386                 break;
00387             case 'xml_11' :
00388                 $docTypeParts[] = '<?xml version="1.1" encoding="' . $theCharset . '"?>';
00389                 break;
00390             case '' :
00391                 if ($GLOBALS['TSFE']->xhtmlVersion)
00392                     $docTypeParts[] = '<?xml version="1.0" encoding="' . $theCharset . '"?>';
00393                 break;
00394             default :
00395                 $docTypeParts[] = $GLOBALS['TSFE']->config['config']['xmlprologue'];
00396         }
00397         // Part 2: DTD
00398         $doctype = $GLOBALS['TSFE']->config['config']['doctype'];
00399         if ($doctype) {
00400             switch ($doctype) {
00401                 case 'xhtml_trans' :
00402                     $docTypeParts[] = '<!DOCTYPE html
00403      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
00404      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
00405                     break;
00406                 case 'xhtml_strict' :
00407                     $docTypeParts[] = '<!DOCTYPE html
00408      PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
00409      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
00410                     break;
00411                 case 'xhtml_frames' :
00412                     $docTypeParts[] = '<!DOCTYPE html
00413      PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
00414      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
00415                     break;
00416                 case 'xhtml_basic' :
00417                     $docTypeParts[] = '<!DOCTYPE html
00418     PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
00419     "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">';
00420                     break;
00421                 case 'xhtml_11' :
00422                     $docTypeParts[] = '<!DOCTYPE html
00423      PUBLIC "-//W3C//DTD XHTML 1.1//EN"
00424      "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
00425                     break;
00426                 case 'xhtml_2' :
00427                     $docTypeParts[] = '<!DOCTYPE html
00428     PUBLIC "-//W3C//DTD XHTML 2.0//EN"
00429     "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
00430                     break;
00431                 case 'xhtml+rdfa_10' :
00432                     $docTypeParts[] = '<!DOCTYPE html
00433     PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
00434     "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">';
00435                     break;
00436                 case 'html5' :
00437                     $docTypeParts[] = '<!DOCTYPE html>';
00438                     break;
00439                 case 'none' :
00440                     break;
00441                 default :
00442                     $docTypeParts[] = $doctype;
00443             }
00444         } else {
00445             $docTypeParts[] = '<!DOCTYPE html
00446     PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
00447         }
00448 
00449         if ($GLOBALS['TSFE']->xhtmlVersion) {
00450             $htmlTagAttributes['xml:lang'] = $htmlLang;
00451         }
00452         if ($GLOBALS['TSFE']->xhtmlVersion < 110 || $doctype === 'html5') {
00453             $htmlTagAttributes['lang'] = $htmlLang;
00454         }
00455         if ($GLOBALS['TSFE']->xhtmlVersion || $doctype === 'html5') {
00456             $htmlTagAttributes['xmlns'] = 'http://www.w3.org/1999/xhtml'; // We add this to HTML5 to achieve a slightly better backwards compatibility
00457             if (is_array($GLOBALS['TSFE']->config['config']['namespaces.'])) {
00458                 foreach ($GLOBALS['TSFE']->config['config']['namespaces.'] as $prefix => $uri) {
00459                     $htmlTagAttributes['xmlns:' . htmlspecialchars($prefix)] = $uri; // $uri gets htmlspecialchared later
00460                 }
00461             }
00462         }
00463 
00464             // Swap XML and doctype order around (for MSIE / Opera standards compliance)
00465         if ($GLOBALS['TSFE']->config['config']['doctypeSwitch']) {
00466             $docTypeParts = array_reverse($docTypeParts);
00467         }
00468 
00469             // Adding doctype parts:
00470         if (count($docTypeParts)) {
00471             $pageRenderer->setXmlPrologAndDocType(implode(LF, $docTypeParts));
00472         }
00473 
00474             // Begin header section:
00475         if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'], 'none')) {
00476             $_attr = $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] ? $GLOBALS['TSFE']->config['config']['htmlTag_setParams'] : t3lib_div::implodeAttributes($htmlTagAttributes);
00477         } else {
00478             $_attr = '';
00479         }
00480         $pageRenderer->setHtmlTag('<html' . ($_attr ? ' ' . $_attr : '') . '>');
00481 
00482             // Head tag:
00483         $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : '<head>';
00484         $pageRenderer->setHeadTag($headTag);
00485 
00486             // Setting charset meta tag:
00487         $pageRenderer->setCharSet($theCharset);
00488 
00489         $pageRenderer->addInlineComment('   This website is powered by TYPO3 - inspiring people to share!
00490     TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
00491     TYPO3 is copyright ' . TYPO3_copyright_year . ' of Kasper Skaarhoj. Extensions are copyright of their respective owners.
00492     Information and contribution at ' . TYPO3_URL_GENERAL . ' and ' . TYPO3_URL_ORG . '
00493 ');
00494 
00495         if ($GLOBALS['TSFE']->baseUrl) {
00496             $pageRenderer->setBaseUrl($GLOBALS['TSFE']->baseUrl);
00497         }
00498 
00499         if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) {
00500             $favIcon = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['shortcutIcon']);
00501             $iconMimeType = '';
00502             if (function_exists('finfo_open')) {
00503                 if (($finfo = @finfo_open(FILEINFO_MIME))) {
00504                     $iconMimeType = ' type="' . finfo_file($finfo, PATH_site . $favIcon) . '"';
00505                     finfo_close($finfo);
00506                     $pageRenderer->setIconMimeType($iconMimeType);
00507                 }
00508             }
00509             $pageRenderer->setFavIcon(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $favIcon);
00510 
00511         }
00512 
00513             // Including CSS files
00514         if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) {
00515             $temp_styleLines = array ();
00516             foreach ($GLOBALS['TSFE']->tmpl->setup['plugin.'] as $key => $iCSScode) {
00517                 if (is_array($iCSScode) && $iCSScode['_CSS_DEFAULT_STYLE']) {
00518                     $temp_styleLines[] = '/* default styles for extension "' . substr($key, 0, - 1) . '" */' . LF . $iCSScode['_CSS_DEFAULT_STYLE'];
00519                 }
00520             }
00521             if (count($temp_styleLines)) {
00522                 if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
00523                     $pageRenderer->addCssFile(TSpagegen::inline2TempFile(implode(LF, $temp_styleLines), 'css'));
00524                 } else {
00525                     $pageRenderer->addCssInlineBlock('TSFEinlineStyle', implode(LF, $temp_styleLines));
00526                 }
00527             }
00528         }
00529 
00530         if ($GLOBALS['TSFE']->pSetup['stylesheet']) {
00531             $ss = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']);
00532             if ($ss) {
00533                 $pageRenderer->addCssFile($ss);
00534             }
00535         }
00536 
00537         /**********************************************************************/
00538         /* includeCSS
00539         /* config.includeCSS {
00540         /*
00541         /* }
00542         /**********************************************************************/
00543 
00544         if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) {
00545             foreach ($GLOBALS['TSFE']->pSetup['includeCSS.'] as $key => $CSSfile) {
00546                 if (!is_array($CSSfile)) {
00547                     $ss = $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['external'] ? $CSSfile : $GLOBALS['TSFE']->tmpl->getFileName($CSSfile);
00548                     if ($ss) {
00549                         if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['import']) {
00550                             if (! $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['external'] && substr($ss, 0, 1) != '/') { // To fix MSIE 6 that cannot handle these as relative paths (according to Ben v Ende)
00551                                 $ss = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . $ss;
00552                             }
00553                             $pageRenderer->addCssInlineBlock(
00554                                 'import_' . $key,
00555                                 '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media']) . ';',
00556                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['compress'] ? TRUE : FALSE,
00557                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
00558                                 ''
00559                             );
00560                         } else {
00561                             $pageRenderer->addCssFile(
00562                                 $ss,
00563                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['alternate'] ? 'alternate stylesheet' : 'stylesheet',
00564                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media'] : 'all',
00565                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] : '',
00566                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['compress'] ? TRUE : FALSE,
00567                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
00568                                 $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['allWrap']);
00569 
00570                         }
00571                     }
00572                 }
00573             }
00574         }
00575 
00576             // Stylesheets
00577         $style = '';
00578         if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) {
00579             $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
00580             $RTEclasses = $pageTSConfig['RTE.']['classes.'];
00581             if (is_array($RTEclasses)) {
00582                 foreach ($RTEclasses as $RTEclassName => $RTEvalueArray) {
00583                     if ($RTEvalueArray['value']) {
00584                         $style .= '
00585 .' . substr($RTEclassName, 0, - 1) . ' {' . $RTEvalueArray['value'] . '}';
00586                     }
00587                 }
00588             }
00589 
00590             if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs'] && is_array($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'])) {
00591                 $mSOa_tList = t3lib_div::trimExplode(',', strtoupper($GLOBALS['TSFE']->pSetup['insertClassesFromRTE.']['add_mainStyleOverrideDefs']), 1);
00592                 foreach ($pageTSConfig['RTE.']['default.']['mainStyleOverride_add.'] as $mSOa_key => $mSOa_value) {
00593                     if (! is_array($mSOa_value) && (in_array('*', $mSOa_tList) || in_array($mSOa_key, $mSOa_tList))) {
00594                         $style .= '
00595 ' . $mSOa_key . ' {' . $mSOa_value . '}';
00596                     }
00597                 }
00598             }
00599         }
00600 
00601             // Setting body tag margins in CSS:
00602         if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins']) && $GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
00603             $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
00604             $style .= '
00605     BODY {margin: ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px ' . $margins . 'px;}';
00606         }
00607 
00608         if ($GLOBALS['TSFE']->pSetup['noLinkUnderline']) {
00609             $GLOBALS['TSFE']->logDeprecatedTyposcript('config.noLinkUnderline');
00610             $style .= '
00611     A:link {text-decoration: none}
00612     A:visited {text-decoration: none}
00613     A:active {text-decoration: none}';
00614         }
00615         if (trim($GLOBALS['TSFE']->pSetup['hover'])) {
00616             $GLOBALS['TSFE']->logDeprecatedTyposcript('config.hover');
00617             $style .= '
00618     A:hover {color: ' . trim($GLOBALS['TSFE']->pSetup['hover']) . ';}';
00619         }
00620         if (trim($GLOBALS['TSFE']->pSetup['hoverStyle'])) {
00621             $GLOBALS['TSFE']->logDeprecatedTyposcript('config.hoverStyle');
00622             $style .= '
00623     A:hover {' . trim($GLOBALS['TSFE']->pSetup['hoverStyle']) . '}';
00624         }
00625         if ($GLOBALS['TSFE']->pSetup['smallFormFields']) {
00626             $GLOBALS['TSFE']->logDeprecatedTyposcript('config.smallFormFields');
00627             $style .= '
00628     SELECT {  font-family: Verdana, Arial, Helvetica; font-size: 10px }
00629     TEXTAREA  {  font-family: Verdana, Arial, Helvetica; font-size: 10px}
00630     INPUT   {  font-family: Verdana, Arial, Helvetica; font-size: 10px }';
00631         }
00632         if ($GLOBALS['TSFE']->pSetup['adminPanelStyles']) {
00633             $style .= '
00634 
00635     /* Default styles for the Admin Panel */
00636     TABLE.typo3-adminPanel { border: 1px solid black; background-color: #F6F2E6; }
00637     TABLE.typo3-adminPanel TR.typo3-adminPanel-hRow TD { background-color: #9BA1A8; }
00638     TABLE.typo3-adminPanel TR.typo3-adminPanel-itemHRow TD { background-color: #ABBBB4; }
00639     TABLE.typo3-adminPanel TABLE, TABLE.typo3-adminPanel TD { border: 0px; }
00640     TABLE.typo3-adminPanel TD FONT { font-family: verdana; font-size: 10px; color: black; }
00641     TABLE.typo3-adminPanel TD A FONT { font-family: verdana; font-size: 10px; color: black; }
00642     TABLE.typo3-editPanel { border: 1px solid black; background-color: #F6F2E6; }
00643     TABLE.typo3-editPanel TD { border: 0px; }
00644             ';
00645         }
00646             // CSS_inlineStyle from TS
00647         $style .= trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']);
00648         $style .= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['cssInline.'], 'cssInline.');
00649 
00650         if (trim($style)) {
00651             if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) {
00652                 $pageRenderer->addCssFile(TSpagegen::inline2TempFile($style, 'css'));
00653             } else {
00654                 $pageRenderer->addCssInlineBlock('additionalTSFEInlineStyle', $style);
00655             }
00656         }
00657 
00658             // Javascript Libraries
00659         if (is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.'])) {
00660             if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG']) {
00661                 $pageRenderer->loadSvg();
00662                 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['debug']) {
00663                     $pageRenderer->enableSvgDebug();
00664                 }
00665                 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['SVG.']['forceFlash']) {
00666                     $pageRenderer->svgForceFlash();
00667                 }
00668             }
00669 
00670             if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Prototype']) {
00671                 $pageRenderer->loadPrototype();
00672             }
00673             if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous']) {
00674                 $modules = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] : '';
00675                 $pageRenderer->loadScriptaculous($modules);
00676             }
00677             if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore']) {
00678                 $pageRenderer->loadExtCore();
00679                 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore.']['debug']) {
00680                     $pageRenderer->enableExtCoreDebug();
00681                 }
00682             }
00683             if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs']) {
00684                 $css = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['css'] ? TRUE : FALSE;
00685                 $theme = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['theme'] ? TRUE : FALSE;
00686                 $adapter = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] : '';
00687                 $pageRenderer->loadExtJs($css, $theme, $adapter);
00688                 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['debug']) {
00689                     $pageRenderer->enableExtJsDebug();
00690                 }
00691                 if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['quickTips']) {
00692                     $pageRenderer->enableExtJSQuickTips();
00693                 }
00694             }
00695         }
00696 
00697             // JavaScript library files
00698         if (is_array($GLOBALS['TSFE']->pSetup['includeJSlibs.'])) {
00699             foreach ($GLOBALS['TSFE']->pSetup['includeJSlibs.'] as $key => $JSfile) {
00700                 if (!is_array($JSfile)) {
00701                     $ss = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
00702                     if ($ss) {
00703                         $type = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['type'];
00704                         if (! $type) {
00705                             $type = 'text/javascript';
00706                         }
00707                         $pageRenderer->addJsLibrary(
00708                             $key,
00709                             $ss,
00710                             $type,
00711                             $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
00712                             $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
00713                             $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['allWrap']
00714                         );
00715                     }
00716                 }
00717             }
00718         }
00719 
00720         if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'])) {
00721             foreach ($GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'] as $key => $JSfile) {
00722                 if (!is_array($JSfile)) {
00723                     $ss = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
00724                     if ($ss) {
00725                         $type = $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['type'];
00726                         if (! $type) {
00727                             $type = 'text/javascript';
00728                         }
00729                         $pageRenderer->addJsFooterLibrary(
00730                             $key,
00731                             $ss,
00732                             $type,
00733                             $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
00734                             $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
00735                             $GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['allWrap']
00736                         );
00737                     }
00738                 }
00739             }
00740         }
00741 
00742             // JavaScript files
00743         if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) {
00744             foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key => $JSfile) {
00745                 if (!is_array($JSfile)) {
00746                     $ss = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
00747                     if ($ss) {
00748                         $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['type'];
00749                         if (! $type) {
00750                             $type = 'text/javascript';
00751                         }
00752                         $pageRenderer->addJsFile(
00753                             $ss,
00754                             $type,
00755                             $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['compress'] ? TRUE : FALSE,
00756                             $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
00757                             $GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap']
00758                         );
00759                     }
00760                 }
00761             }
00762         }
00763 
00764         if (is_array($GLOBALS['TSFE']->pSetup['includeJSFooter.'])) {
00765             foreach ($GLOBALS['TSFE']->pSetup['includeJSFooter.'] as $key => $JSfile) {
00766                 if (!is_array($JSfile)) {
00767                     $ss = $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['external'] ? $JSfile : $GLOBALS['TSFE']->tmpl->getFileName($JSfile);
00768                     if ($ss) {
00769                         $type = $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['type'];
00770                         if (! $type) {
00771                             $type = 'text/javascript';
00772                         }
00773                         $pageRenderer->addJsFooterFile(
00774                             $ss,
00775                             $type,
00776                             $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['compress'] ? TRUE : FALSE,
00777                             $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
00778                             $GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['allWrap']
00779                         );
00780                     }
00781                 }
00782             }
00783         }
00784 
00785             // Headerdata
00786         if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) {
00787             $pageRenderer->addHeaderData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'], 'headerData.'));
00788         }
00789 
00790             // Footerdata
00791         if (is_array($GLOBALS['TSFE']->pSetup['footerData.'])) {
00792             $pageRenderer->addFooterData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['footerData.'], 'footerData.'));
00793         }
00794 
00795             // Title
00796         $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle($GLOBALS['TSFE']->altPageTitle ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'], $GLOBALS['TSFE']->config['config']['noPageTitle'], $GLOBALS['TSFE']->config['config']['pageTitleFirst']);
00797         if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
00798             $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array (), $titleTagContent);
00799         }
00800 
00801         if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle']) !== 2) {
00802             $pageRenderer->setTitle($titleTagContent);
00803         }
00804 
00805             // add ending slash only to documents rendered as xhtml
00806         $endingSlash = $GLOBALS['TSFE']->xhtmlVersion ? ' /' : '';
00807 
00808         $pageRenderer->addMetaTag('<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS"' . $endingSlash . '>');
00809 
00810         $conf = $GLOBALS['TSFE']->pSetup['meta.'];
00811         if (is_array($conf)) {
00812             foreach ($conf as $theKey => $theValue) {
00813                 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
00814                     if (strstr($theKey, '.')) {
00815                         $theKey = substr($theKey, 0, - 1);
00816                     }
00817                     $val = $GLOBALS['TSFE']->cObj->stdWrap($conf[$theKey], $conf[$theKey . '.']);
00818                     $key = $theKey;
00819                     if (trim($val)) {
00820                         $a = 'name';
00821                         if (strtolower($key) == 'refresh') {
00822                             $a = 'http-equiv';
00823                         }
00824                         $pageRenderer->addMetaTag('<meta ' . $a . '="' . $key . '" content="' . htmlspecialchars(trim($val)) . '"' . $endingSlash . '>');
00825                     }
00826                 }
00827             }
00828         }
00829 
00830         unset($GLOBALS['TSFE']->additionalHeaderData['JSCode']);
00831         unset($GLOBALS['TSFE']->additionalHeaderData['JSImgCode']);
00832 
00833         if (is_array($GLOBALS['TSFE']->config['INTincScript'])) {
00834             // Storing the JSCode and JSImgCode vars...
00835             $GLOBALS['TSFE']->additionalHeaderData['JSCode'] = $GLOBALS['TSFE']->JSCode;
00836             $GLOBALS['TSFE']->additionalHeaderData['JSImgCode'] = $GLOBALS['TSFE']->JSImgCode;
00837             $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] = $GLOBALS['TSFE']->uniqueHash();
00838             $GLOBALS['TSFE']->config['INTincScript_ext']['additionalHeaderData'] = $GLOBALS['TSFE']->additionalHeaderData; // Storing the header-data array
00839             $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
00840             $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
00841 
00842 
00843             $GLOBALS['TSFE']->additionalHeaderData = array ('<!--HD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->'); // Clearing the array
00844             $GLOBALS['TSFE']->divSection .= '<!--TDS_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->';
00845         } else {
00846             $GLOBALS['TSFE']->INTincScript_loadJSCode();
00847         }
00848         $JSef = TSpagegen::JSeventFunctions();
00849 
00850             // Adding default Java Script:
00851         $scriptJsCode = '
00852         var browserName = navigator.appName;
00853         var browserVer = parseInt(navigator.appVersion);
00854         var version = "";
00855         var msie4 = (browserName == "Microsoft Internet Explorer" && browserVer >= 4);
00856         if ((browserName == "Netscape" && browserVer >= 3) || msie4 || browserName=="Konqueror" || browserName=="Opera") {version = "n3";} else {version = "n2";}
00857             // Blurring links:
00858         function blurLink(theObject)    {   //
00859             if (msie4)  {theObject.blur();}
00860         }
00861         ' . $JSef[0];
00862 
00863         if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') {
00864             $scriptJsCode .= '
00865             // decrypt helper function
00866         function decryptCharcode(n,start,end,offset)    {
00867             n = n + offset;
00868             if (offset > 0 && n > end)  {
00869                 n = start + (n - end - 1);
00870             } else if (offset < 0 && n < start) {
00871                 n = end - (start - n - 1);
00872             }
00873             return String.fromCharCode(n);
00874         }
00875             // decrypt string
00876         function decryptString(enc,offset)  {
00877             var dec = "";
00878             var len = enc.length;
00879             for(var i=0; i < len; i++)  {
00880                 var n = enc.charCodeAt(i);
00881                 if (n >= 0x2B && n <= 0x3A) {
00882                     dec += decryptCharcode(n,0x2B,0x3A,offset); // 0-9 . , - + / :
00883                 } else if (n >= 0x40 && n <= 0x5A)  {
00884                     dec += decryptCharcode(n,0x40,0x5A,offset); // A-Z @
00885                 } else if (n >= 0x61 && n <= 0x7A)  {
00886                     dec += decryptCharcode(n,0x61,0x7A,offset); // a-z
00887                 } else {
00888                     dec += enc.charAt(i);
00889                 }
00890             }
00891             return dec;
00892         }
00893             // decrypt spam-protected emails
00894         function linkTo_UnCryptMailto(s)    {
00895             location.href = decryptString(s,' . ($GLOBALS['TSFE']->spamProtectEmailAddresses * - 1) . ');
00896         }
00897         ';
00898         }
00899 
00900             //add inline JS
00901         $inlineJS = '';
00902 
00903             // defined in php
00904         if (is_array($GLOBALS['TSFE']->inlineJS)) {
00905             foreach ($GLOBALS['TSFE']->inlineJS as $key => $val) {
00906                 if (! is_array($val)) {
00907                     $inlineJS .= LF . $val . LF;
00908                 }
00909             }
00910         }
00911 
00912             // defined in TS with page.inlineJS
00913             // Javascript inline code
00914         $inline = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsInline.'], 'jsInline.');
00915         if ($inline) {
00916             $inlineJS .= LF . $inline . LF;
00917         }
00918 
00919             // Javascript inline code for Footer
00920         $inlineFooterJs = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsFooterInline.'], 'jsFooterInline.');
00921 
00922             // Should minify?
00923         if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
00924             $pageRenderer->enableCompressJavascript();
00925             $minifyErrorScript = $minifyErrorInline = '';
00926             $scriptJsCode = t3lib_div::minifyJavaScript($scriptJsCode, $minifyErrorScript);
00927             if ($minifyErrorScript) {
00928                 $GLOBALS['TT']->setTSlogMessage($minifyErrorScript, 3);
00929             }
00930             if ($inlineJS) {
00931                 $inlineJS = t3lib_div::minifyJavaScript($inlineJS, $minifyErrorInline);
00932                 if ($minifyErrorInline) {
00933                     $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
00934                 }
00935             }
00936             if ($inlineFooterJs) {
00937                 $inlineFooterJs = t3lib_div::minifyJavaScript($inlineFooterJs, $minifyErrorInline);
00938                 if ($minifyErrorInline) {
00939                     $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3);
00940                 }
00941             }
00942 
00943         }
00944 
00945         if (! $GLOBALS['TSFE']->config['config']['removeDefaultJS']) {
00946                 // inlude default and inlineJS
00947             if ($scriptJsCode) {
00948                 $pageRenderer->addJsInlineCode('_scriptCode', $scriptJsCode, $GLOBALS['TSFE']->config['config']['minifyJS']);
00949             }
00950             if ($inlineJS) {
00951                 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
00952             }
00953             if ($inlineFooterJs) {
00954                 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
00955             }
00956         } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS'] === 'external') {
00957             /*
00958              This keeps inlineJS from *_INT Objects from being moved to external files.
00959              At this point in frontend rendering *_INT Objects only have placeholders instead
00960              of actual content so moving these placeholders to external files would
00961                 a) break the JS file (syntax errors due to the placeholders)
00962                 b) the needed JS would never get included to the page
00963              Therefore inlineJS from *_INT Objects must not be moved to external files but
00964              kept internal.
00965             */
00966             $inlineJSint = '';
00967             self::stripIntObjectPlaceholder($inlineJS, $inlineJSint);
00968             if ($inlineJSint) {
00969                 $pageRenderer->addJsInlineCode('TS_inlineJSint', $inlineJSint, $GLOBALS['TSFE']->config['config']['minifyJS']);
00970             }
00971             $pageRenderer->addJsFile(TSpagegen::inline2TempFile($scriptJsCode . $inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
00972 
00973             if ($inlineFooterJs) {
00974                 $inlineFooterJSint = '';
00975                 self::stripIntObjectPlaceholder($inlineFooterJs, $inlineFooterJSint);
00976                 if ($inlineFooterJSint) {
00977                     $pageRenderer->addJsFooterInlineCode('TS_inlineFooterJSint', $inlineFooterJSint, $GLOBALS['TSFE']->config['config']['minifyJS']);
00978                 }
00979                 $pageRenderer->addJsFooterFile(TSpagegen::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']);
00980             }
00981         } else {
00982                 // include only inlineJS
00983             if ($inlineJS) {
00984                 $pageRenderer->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']);
00985             }
00986             if ($inlineFooterJs) {
00987                 $pageRenderer->addJsFooterInlineCode('TS_inlineFooter', $inlineFooterJs, $GLOBALS['TSFE']->config['config']['minifyJS']);
00988             }
00989         }
00990 
00991             // ExtJS specific code
00992         if (is_array($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.'])) {
00993             $pageRenderer->addInlineLanguageLabelArray($GLOBALS['TSFE']->pSetup['inlineLanguageLabel.']);
00994         }
00995 
00996         if (is_array($GLOBALS['TSFE']->pSetup['inlineSettings.'])) {
00997             $pageRenderer->addInlineSettingArray('TS', $GLOBALS['TSFE']->pSetup['inlineSettings.']);
00998         }
00999 
01000         if (is_array($GLOBALS['TSFE']->pSetup['extOnReady.'])) {
01001             $pageRenderer->addExtOnReadyCode($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['extOnReady.'], 'extOnReady.'));
01002         }
01003 
01004             // compression and concatenate settings
01005         if ($GLOBALS['TSFE']->config['config']['minifyCSS']) {
01006             $pageRenderer->enableCompressCss();
01007         }
01008         if ($GLOBALS['TSFE']->config['config']['minifyJS']) {
01009             $pageRenderer->enableCompressJavascript();
01010         }
01011         if ($GLOBALS['TSFE']->config['config']['concatenateJsAndCss']) {
01012             $pageRenderer->enableConcatenateFiles();
01013         }
01014 
01015             // add header data block
01016         if ($GLOBALS['TSFE']->additionalHeaderData) {
01017             $pageRenderer->addHeaderData(implode(LF, $GLOBALS['TSFE']->additionalHeaderData));
01018         }
01019 
01020             // add footer data block
01021         if ($GLOBALS['TSFE']->additionalFooterData) {
01022             $pageRenderer->addFooterData(implode(LF, $GLOBALS['TSFE']->additionalFooterData));
01023         }
01024 
01025         // Header complete, now add content
01026 
01027 
01028         if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
01029             $fs = t3lib_div::makeInstance('tslib_frameset');
01030             $pageRenderer->addBodyContent($fs->make($GLOBALS['TSFE']->pSetup['frameSet.']));
01031             $pageRenderer->addBodyContent(LF . '<noframes>' . LF);
01032         }
01033 
01034             // Bodytag:
01035         $defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
01036         if (! $defBT)
01037             $defBT = $GLOBALS['TSFE']->defaultBodyTag;
01038         $bodyTag = $GLOBALS['TSFE']->pSetup['bodyTag'] ? $GLOBALS['TSFE']->pSetup['bodyTag'] : $defBT;
01039         if ($bgImg = $GLOBALS['TSFE']->cObj->getImgResource($GLOBALS['TSFE']->pSetup['bgImg'], $GLOBALS['TSFE']->pSetup['bgImg.'])) {
01040             $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS["TSFE"]->absRefPrefix . $bgImg[3] . '">';
01041         }
01042 
01043         if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
01044             $margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
01045             if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
01046                 // Setting margins in CSS, see above
01047             } else {
01048                 $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
01049             }
01050         }
01051 
01052         if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
01053             $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
01054         }
01055 
01056         if (count($JSef[1])) { // Event functions:
01057             $bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
01058         }
01059         $pageRenderer->addBodyContent(LF . $bodyTag);
01060 
01061             // Div-sections
01062         if ($GLOBALS['TSFE']->divSection) {
01063             $pageRenderer->addBodyContent(LF . $GLOBALS['TSFE']->divSection);
01064         }
01065 
01066             // Page content
01067         $pageRenderer->addBodyContent(LF . $pageContent);
01068 
01069             // Render complete page
01070         $GLOBALS['TSFE']->content = $pageRenderer->render();
01071 
01072             // Ending page
01073         if ($GLOBALS['TSFE']->pSetup['frameSet.']) {
01074             $GLOBALS['TSFE']->content .= LF . '</noframes>';
01075         }
01076 
01077     }
01078 
01079 
01080 
01081 
01082 
01083 
01084 
01085 
01086 
01087 
01088 
01089 
01090 
01091     /*************************
01092      *
01093      * Helper functions
01094      * Remember: Calls internally must still be done on the non-instantiated class: TSpagegen::inline2TempFile()
01095      *
01096      *************************/
01097 
01098     /**
01099      * Searches for placeholder created from *_INT cObjects, removes them from
01100      * $searchString and merges them to $intObjects
01101      *
01102      * @param   string      $searchString: the String which should be cleaned from int-object markers
01103      * @param   string      $intObjects: the String the found int-placeholders are moved to (for further processing)
01104      */
01105     protected static function stripIntObjectPlaceholder(&$searchString, &$intObjects) {
01106         $tempArray = array();
01107         preg_match_all('/<\!--INT_SCRIPT.[a-z0-9]*-->/', $searchString, $tempArray);
01108         $searchString = preg_replace('/<\!--INT_SCRIPT.[a-z0-9]*-->/', '', $searchString);
01109         $intObjects = implode('', $tempArray[0]);
01110     }
01111 
01112     /**
01113      * Writes string to a temporary file named after the md5-hash of the string
01114      *
01115      * @param   string      CSS styles / JavaScript to write to file.
01116      * @param   string      Extension: "css" or "js"
01117      * @return  string      <script> or <link> tag for the file.
01118      */
01119     public static function inline2TempFile($str, $ext) {
01120 
01121             // Create filename / tags:
01122         $script = '';
01123         switch ($ext) {
01124             case 'js' :
01125                 $script = 'typo3temp/javascript_' . substr(md5($str), 0, 10) . '.js';
01126                 $output = $GLOBALS['TSFE']->absRefPrefix . $script;
01127             break;
01128             case 'css' :
01129                 $script = 'typo3temp/stylesheet_' . substr(md5($str), 0, 10) . '.css';
01130                 $output = $GLOBALS['TSFE']->absRefPrefix . $script;
01131             break;
01132         }
01133 
01134             // Write file:
01135         if ($script) {
01136             if (! @is_file(PATH_site . $script)) {
01137                 t3lib_div::writeFile(PATH_site . $script, $str);
01138             }
01139         }
01140 
01141         return $output;
01142     }
01143 
01144     /**
01145      * 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.
01146      *
01147      * @param   string      The string in which to find $needle
01148      * @param   string      The string to find in $haystack
01149      * @return  boolean     Returns true if $needle matches or is found in $haystack
01150      */
01151     public static function isAllowedLinkVarValue($haystack,$needle) {
01152         $OK = false;
01153 
01154         if ($needle=='int' || $needle=='integer')   {   // Integer
01155 
01156             if (t3lib_div::testInt($haystack))  {
01157                 $OK = true;
01158             }
01159 
01160         } elseif (preg_match('/^\/.+\/[imsxeADSUXu]*$/', $needle))  {   // Regular expression, only "//" is allowed as delimiter
01161 
01162             if (@preg_match($needle, $haystack))    {
01163                 $OK = true;
01164             }
01165 
01166         } elseif (strstr($needle,'-'))  {   // Range
01167 
01168             if (t3lib_div::testInt($haystack))  {
01169                 $range = explode('-',$needle);
01170                 if ($range[0] <= $haystack && $range[1] >= $haystack)   {
01171                     $OK = true;
01172                 }
01173             }
01174 
01175         } elseif (strstr($needle,'|'))  {   // List
01176 
01177             $haystack = str_replace(' ','',$haystack);  // Trim the input
01178             if (strstr('|'.$needle.'|', '|'.$haystack.'|')) {
01179                 $OK = true;
01180             }
01181 
01182         } elseif (!strcmp($needle,$haystack))   {   // String comparison
01183             $OK = true;
01184         }
01185 
01186         return $OK;
01187     }
01188 }
01189 
01190 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php'])) {
01191     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_pagegen.php']);
01192 }
01193 
01194 
01195 
01196 /**
01197  * Class for fetching record relations for the frontend.
01198  *
01199  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
01200  * @package TYPO3
01201  * @subpackage tslib
01202  * @see tslib_cObj::RECORDS()
01203  */
01204 class FE_loadDBGroup extends t3lib_loadDBGroup {
01205     var $fromTC = 0;    // Means that everything is returned instead of only uid and label-field
01206 }
01207 
01208 ?>