Index: typo3/sysext/cms/tslib/class.tslib_fe.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_fe.php (revision 5734) +++ typo3/sysext/cms/tslib/class.tslib_fe.php (working copy) @@ -405,6 +405,8 @@ protected $pageCache; protected $pageCacheTags = array(); + // class for render the header / footer + var $pageIncludes; /** * Class constructor @@ -448,6 +450,7 @@ $this->csConvObj = t3lib_div::makeInstance('t3lib_cs'); + // Call post processing function for constructor: if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'])) { $_params = array('pObj' => &$this); @@ -2041,7 +2044,17 @@ $this->config['FEData'] = $this->tmpl->setup['FEData']; $this->config['FEData.'] = $this->tmpl->setup['FEData.']; + + // class for render Header and Footer parts + $template = ''; + if ($this->pSetup['pageHeaderFooterTemplateFile']) { + $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']); + if ($file) { + $template = $file; } + } + $this->pageIncludes = t3lib_div::makeInstance('t3lib_pageIncludes', $template, 'typo3/'); + } $GLOBALS['TT']->pull(); } else { if ($this->checkPageUnavailableHandler()) { Index: typo3/sysext/cms/tslib/class.tslib_pagegen.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_pagegen.php (revision 5734) +++ typo3/sysext/cms/tslib/class.tslib_pagegen.php (working copy) @@ -93,6 +93,8 @@ * @return void */ public static function pagegenInit() { + + if ($GLOBALS['TSFE']->page['content_from_pid']>0) { $temp_copy_TSFE = clone($GLOBALS['TSFE']); // make REAL copy of TSFE object - not reference! $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! @@ -342,10 +344,15 @@ * @return void */ public static function renderContentWithHeader($pageContent) { + + if ($GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter']) { + $GLOBALS['TSFE']->pageIncludes->moveJsFromHeaderToFooter = TRUE; + } + $customContent = $GLOBALS['TSFE']->config['config']['headerComment']; if (trim($customContent)) { - $customContent = chr(10).$customContent; - } else $customContent=''; + $GLOBALS['TSFE']->pageIncludes->addInlineComment($customContent); + } // Setting charset: $theCharset = $GLOBALS['TSFE']->metaCharset; @@ -437,7 +444,9 @@ } // Adding doctype parts: - $GLOBALS['TSFE']->content.= count($docTypeParts) ? implode(chr(10),$docTypeParts).chr(10) : ''; + if (count($docTypeParts)) { + $GLOBALS['TSFE']->pageIncludes->setXmlPrologAndDocType(implode(chr(10),$docTypeParts)); + } // Begin header section: if (strcmp($GLOBALS['TSFE']->config['config']['htmlTag_setParams'],'none')) { @@ -445,30 +454,24 @@ } else { $_attr = ''; } - $GLOBALS['TSFE']->content.=''; + $GLOBALS['TSFE']->pageIncludes->setHtmlTag(''); + // Head tag: $headTag = $GLOBALS['TSFE']->pSetup['headTag'] ? $GLOBALS['TSFE']->pSetup['headTag'] : ''; - $GLOBALS['TSFE']->content.= chr(10).$headTag; + $GLOBALS['TSFE']->pageIncludes->setHeadTag($headTag); // Setting charset meta tag: - $GLOBALS['TSFE']->content.=' - '; - - $GLOBALS['TSFE']->content.=' - - -'; - - + $GLOBALS['TSFE']->pageIncludes->setMetaCharsetTag($theCharset); + + $GLOBALS['TSFE']->pageIncludes->addInlineComment('This website is powered by TYPO3 - inspiring people to share! +TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL. +TYPO3 is copyright 1998-2009 of Kasper Skaarhoj. Extensions are copyright of their respective owners. +Information and contribution at http://typo3.com/ and http://typo3.org/'); + + if ($GLOBALS['TSFE']->baseUrl) { - $GLOBALS['TSFE']->content.=' - '; + $GLOBALS['TSFE']->pageIncludes->setBaseUrlTag($GLOBALS['TSFE']->baseUrl); } if ($GLOBALS['TSFE']->pSetup['shortcutIcon']) { @@ -480,12 +483,11 @@ finfo_close($finfo); } } + $GLOBALS['TSFE']->pageIncludes->setShortcutTag($favIcon, $iconMimeType); + } - $GLOBALS['TSFE']->content.= ' - - '; - } - + + // Including CSS files if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'])) { $temp_styleLines=array(); @@ -496,16 +498,9 @@ } if (count($temp_styleLines)) { if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) { - $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile(implode(chr(10),$temp_styleLines),'css'); + $GLOBALS['TSFE']->pageIncludes->addCssFile(TSpagegen::inline2TempFile(implode(chr(10), $temp_styleLines), 'css')); } else { - $GLOBALS['TSFE']->content.=' - '; + $GLOBALS['TSFE']->pageIncludes->addCssInlineBlock('inlineStyle2TempFile', implode(chr(10),$temp_styleLines)); } } } @@ -513,8 +508,7 @@ if ($GLOBALS['TSFE']->pSetup['stylesheet']) { $ss = $GLOBALS['TSFE']->tmpl->getFileName($GLOBALS['TSFE']->pSetup['stylesheet']); if ($ss) { - $GLOBALS['TSFE']->content.=' - '; + $GLOBALS['TSFE']->pageIncludes->addCssFile($ss); } } if (is_array($GLOBALS['TSFE']->pSetup['includeCSS.'])) { @@ -522,23 +516,22 @@ if (!is_array($iCSSfile)) { $ss=$GLOBALS['TSFE']->tmpl->getFileName($iCSSfile); if ($ss) { - if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['import']) { + if ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['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.=' - - '; + $GLOBALS['TSFE']->pageIncludes->addCssInlineBlock('import_' . $key, + '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['media']) . ';', + $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['compressed'] ? TRUE : FALSE, + $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['forceOnTop'] ? TRUE : FALSE); } else { - $GLOBALS['TSFE']->content.=' - pSetup['includeCSS.'][$key.'.']['title'] ? ' title="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title']).'"' : ''). - ($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media'] ? ' media="'.htmlspecialchars($GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media']).'"' : ''). - ' />'; + $GLOBALS['TSFE']->pageIncludes->addCssFile(htmlspecialchars($ss), + $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['alternate'] ? 'alternate stylesheet' : 'stylesheet', + $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['media'] : 'screen', + $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['title'] : '', + $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['compressed'] ? TRUE : FALSE, + $GLOBALS['TSFE']->pSetup['includeCSS.'][$key.'.']['forceOnTop'] ? TRUE : FALSE); + } } } @@ -547,8 +540,6 @@ // Stylesheets $style=''; - $style.=trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']).chr(10); - if ($GLOBALS['TSFE']->pSetup['insertClassesFromRTE']) { $pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig(); $RTEclasses = $pageTSConfig['RTE.']['classes.']; @@ -617,46 +608,108 @@ TABLE.typo3-editPanel TD { border: 0px; } '; } - + // CSS_inlineStyle from TS + $style .= trim($GLOBALS['TSFE']->pSetup['CSS_inlineStyle']); + $style .= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['cssInline.'], 'cssInline.'); + if (trim($style)) { if ($GLOBALS['TSFE']->config['config']['inlineStyle2TempFile']) { - $GLOBALS['TSFE']->content.=TSpagegen::inline2TempFile($style, 'css'); + $GLOBALS['TSFE']->pageIncludes->addCssFile(TSpagegen::inline2TempFile($style, 'css')); } else { - $GLOBALS['TSFE']->content.=' - '; + $GLOBALS['TSFE']->pageIncludes->addCssInlineBlock('additionalInlineStyle2TempFile', $style); } } + + + // Javascript Libraries + if (is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.'])) { + if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Prototype']) { + $GLOBALS['TSFE']->pageIncludes->loadPrototype(); + } + if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous']) { + $modules = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['Scriptaculous.']['modules'] : ''; + $GLOBALS['TSFE']->pageIncludes->loadScriptaculous($modules); + } + if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore']) { + $GLOBALS['TSFE']->pageIncludes->loadExtCore(); + if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtCore.']['debug']) { + $GLOBALS['TSFE']->pageIncludes->enableExtCoreDebug(); + } + } + if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs']) { + $css = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['css'] ? TRUE : FALSE; + $theme = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['theme'] ? TRUE : FALSE; + $adapter = $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] ? $GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['adapter'] : ''; + $GLOBALS['TSFE']->pageIncludes->loadExtJs($css, $theme, $adapter); + if ($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.']['debug']) { + $GLOBALS['TSFE']->pageIncludes->enableExtJsDebug(); + } + } + } + + // JavaScript library files + if (is_array($GLOBALS['TSFE']->pSetup['includeJSlibs.'])) { + foreach ($GLOBALS['TSFE']->pSetup['includeJSlibs.'] as $key => $JSfile) { + $ss = $GLOBALS['TSFE']->tmpl->getFileName($JSfile); + if ($ss) { + $type = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key.'.']['type']; + if (!$type) { + $type = 'text/javascript'; + } + $section = $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key.'.']['footer'] ? t3lib_pageIncludes::PART_FOOTER : t3lib_pageIncludes::PART_HEADER; + $GLOBALS['TSFE']->pageIncludes->addJsLibrary( + htmlspecialchars($key), + htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss), + $type, + $section, + $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key.'.']['compressed'] ? TRUE : FALSE, + $GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key.'.']['forceOnTop'] ? TRUE : FALSE + ); + } + + } + } + // JavaScript files - if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) { - foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key=>$JSfile) { + if (is_array($GLOBALS['TSFE']->pSetup['includeJS.'])) { + foreach ($GLOBALS['TSFE']->pSetup['includeJS.'] as $key => $JSfile) { if (!is_array($JSfile)) { $ss = $GLOBALS['TSFE']->tmpl->getFileName($JSfile); - if ($ss) { + if ($ss) { $type = $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['type']; - if (!$type) $type = 'text/javascript'; - - $GLOBALS['TSFE']->content.=' - '; + if (!$type) { + $type = 'text/javascript'; + } + if (!$GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['footer']) { + $GLOBALS['TSFE']->pageIncludes->addJsFile( + htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss), + htmlspecialchars($type), + $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['compressed'] ? TRUE : FALSE, + $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['forceOnTop'] ? TRUE : FALSE + ); + } else { + $GLOBALS['TSFE']->pageIncludes->addJsFooterFile( + htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . $ss), + htmlspecialchars($type), + $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['compressed'] ? TRUE : FALSE, + $GLOBALS['TSFE']->pSetup['includeJS.'][$key.'.']['forceOnTop'] ? TRUE : FALSE + ); + } } } } } + + + - - - - // Headerdata if (is_array($GLOBALS['TSFE']->pSetup['headerData.'])) { - $GLOBALS['TSFE']->content.= chr(10).$GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'],'headerData.'); + $GLOBALS['TSFE']->pageIncludes->addHeaderData($GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['headerData.'], 'headerData.')); } + // Title $titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle( $GLOBALS['TSFE']->altPageTitle?$GLOBALS['TSFE']->altPageTitle:$GLOBALS['TSFE']->page['title'], @@ -668,11 +721,10 @@ } if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle'])!==2) { - $GLOBALS['TSFE']->content.=' - '.htmlspecialchars($titleTagContent).''; + $GLOBALS['TSFE']->pageIncludes->setTitle($titleTagContent); } - $GLOBALS['TSFE']->content.=' - '; + + $GLOBALS['TSFE']->pageIncludes->addMetaData(''); $conf=$GLOBALS['TSFE']->pSetup['meta.']; if (is_array($conf)) { @@ -687,8 +739,7 @@ if (trim($val)) { $a='name'; if (strtolower($key)=='refresh') {$a='http-equiv';} - $GLOBALS['TSFE']->content.= ' - '; + $GLOBALS['TSFE']->pageIncludes->addMetaData(''); } } } @@ -697,6 +748,7 @@ 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; @@ -714,7 +766,7 @@ $JSef = TSpagegen::JSeventFunctions(); // Adding default Java Script: - $_scriptCode = ' + $scriptJsCode = ' var browserName = navigator.appName; var browserVer = parseInt(navigator.appVersion); var version = ""; @@ -727,7 +779,7 @@ ' . $JSef[0]; if ($GLOBALS['TSFE']->spamProtectEmailAddresses && $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii') { - $_scriptCode.= ' + $scriptJsCode.= ' // decrypt helper function function decryptCharcode(n,start,end,offset) { n = n + offset; @@ -764,59 +816,101 @@ } //add inline JS - $_inlineJS = ''; - // defined in TS with page.inlineJS - if (is_array($GLOBALS['TSFE']->pSetup['inlineJS.'])) { - $GLOBALS['TSFE']->inlineJS[]= $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['inlineJS.'],'inlineJS.'); - } + $inlineJS = ''; + + // defined in php if(is_array($GLOBALS['TSFE']->inlineJS)) { foreach($GLOBALS['TSFE']->inlineJS as $key=>$val) { if(!is_array($val)) { - $_inlineJS .= chr(10).$val.chr(10); + $inlineJS .= chr(10).$val.chr(10); } } } + // defined in TS with page.inlineJS + // Javascript inline code + $inline = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsInline.'], 'jsInline.'); + if ($inline) { + $inlineJS .= chr(10) . $inline . chr(10); + } + + // Javascript inline code for Footer + $inlineFooterJs = $GLOBALS['TSFE']->cObj->cObjGet($GLOBALS['TSFE']->pSetup['jsFooterInline.'], 'jsFooterInline.'); + + // Should minify? if ($GLOBALS['TSFE']->config['config']['minifyJS']) { + $GLOBALS['TSFE']->pageIncludes->compressJavascript = TRUE; $minifyErrorScript = $minifyErrorInline = ''; - $_scriptCode = t3lib_div::minifyJavaScript($_scriptCode,$minifyErrorScript); + $scriptJsCode = t3lib_div::minifyJavaScript($scriptJsCode, $minifyErrorScript); if ($minifyErrorScript) { $GLOBALS['TT']->setTSlogMessage($minifyErrorScript, 3); } - if ($_inlineJS) { - $_inlineJS = t3lib_div::minifyJavaScript($_inlineJS,$minifyErrorInline); + if ($inlineJS) { + $inlineJS = t3lib_div::minifyJavaScript($inlineJS, $minifyErrorInline); if ($minifyErrorInline) { $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3); } } + if ($inlineFooterJs) { + $inlineFooterJs = t3lib_div::minifyJavaScript($inlineFooterJs, $minifyErrorInline); + if ($minifyErrorInline) { + $GLOBALS['TT']->setTSlogMessage($minifyErrorInline, 3); + } + } + } + if (!$GLOBALS['TSFE']->config['config']['removeDefaultJS']) { // inlude default and inlineJS - $GLOBALS['TSFE']->content.=' - '; + if ($scriptJsCode) { + $GLOBALS['TSFE']->pageIncludes->addJsInlineCode('_scriptCode', $scriptJsCode, $GLOBALS['TSFE']->config['config']['minifyJS']); + } + if ($inlineJS) { + $GLOBALS['TSFE']->pageIncludes->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']); + } + if ($inlineFooterJs) { + $GLOBALS['TSFE']->pageIncludes->addJsFooterInlineCode('TS_inlineFooter', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']); + } } elseif ($GLOBALS['TSFE']->config['config']['removeDefaultJS']==='external') { // put default and inlineJS in external file - $GLOBALS['TSFE']->content.= TSpagegen::inline2TempFile($_scriptCode.$_inlineJS, 'js'); - } elseif ($_inlineJS) { + $GLOBALS['TSFE']->pageIncludes->addJsFile(TSpagegen::inline2TempFile($scriptJsCode .$inlineJS, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']); + if ($inlineFooterJs) { + $GLOBALS['TSFE']->pageIncludes->addJsFooterFile(TSpagegen::inline2TempFile($inlineFooterJs, 'js'), 'text/javascript', $GLOBALS['TSFE']->config['config']['minifyJS']); + } + } else { // include only inlineJS - $GLOBALS['TSFE']->content.=' - '; + if ($inlineJS) { + $GLOBALS['TSFE']->pageIncludes->addJsInlineCode('TS_inlineJS', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']); + } + if ($inlineFooterJs) { + $GLOBALS['TSFE']->pageIncludes->addJsFooterInlineCode('TS_inlineFooter', $inlineJS, $GLOBALS['TSFE']->config['config']['minifyJS']); + } } - $GLOBALS['TSFE']->content.= chr(10).implode($GLOBALS['TSFE']->additionalHeaderData,chr(10)).' + + + if ($GLOBALS['TSFE']->config['config']['minifyCSS']) { + $GLOBALS['TSFE']->pageIncludes->compressCss = true; + } + if ($GLOBALS['TSFE']->config['config']['concatenateJSandCSS']) { + $GLOBALS['TSFE']->pageIncludes->concatenateFiles = true; + } + + // add header data block + $GLOBALS['TSFE']->pageIncludes->addHeaderData(implode(chr(10), $GLOBALS['TSFE']->additionalHeaderData)); + + + + // Header complete, render it + $GLOBALS['TSFE']->content = $GLOBALS['TSFE']->pageIncludes->render(); + + + + + $GLOBALS['TSFE']->content.= ' '; if ($GLOBALS['TSFE']->pSetup['frameSet.']) { $fs = t3lib_div::makeInstance('tslib_frameset'); @@ -859,6 +953,9 @@ // Page content $GLOBALS['TSFE']->content.= chr(10).$pageContent; + // Footer Javascript + $GLOBALS['TSFE']->content .= $GLOBALS['TSFE']->pageIncludes->render(1); + // Ending page $GLOBALS['TSFE']->content.= chr(10).''; if ($GLOBALS['TSFE']->pSetup['frameSet.']) { @@ -900,13 +997,11 @@ switch($ext) { case 'js': $script = 'typo3temp/javascript_'.substr(md5($str),0,10).'.js'; - $output = ' - '; + $output = $GLOBALS['TSFE']->absRefPrefix.$script; break; case 'css': $script = 'typo3temp/stylesheet_'.substr(md5($str),0,10).'.css'; - $output = ' - '; + $output = $GLOBALS['TSFE']->absRefPrefix.$script; break; }