From ee34eb469bf16aedec0f78b130e6ecf4a57dd9cb Mon Sep 17 00:00:00 2001
From: Michael Kunze <michael.kunze@netresearch.de>
Date: Mon, 17 Sep 2012 09:23:54 +0200
Subject: [FEATURE] TS config to not generate body tag automatically

When using TemplaVoila for page generation, you sometimes need to be able to set classes directly on the body tag from within TemplaVoila. Thus TV needs to generate the page's <body> tag.

Unfortunately, TYPO3 itself generates the <body> tag, too - so we have 2 body tags in the HTML document. To solve this problem, TYPO3 needs a way to not generate a <body> tag.

The attached patch introduces the "config.disableBodyTag" TypoScript option. When it is set, TYPO3's page generator does not generate a <body> tag at all.

---
 sysext/cms/tslib/class.tslib_pagegen.php |   42 ++++++++++++++++-------------
 1 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/sysext/cms/tslib/class.tslib_pagegen.php b/sysext/cms/tslib/class.tslib_pagegen.php
index 31badc9..29277e3 100644
--- a/sysext/cms/tslib/class.tslib_pagegen.php
+++ b/sysext/cms/tslib/class.tslib_pagegen.php
@@ -1004,29 +1004,33 @@ See <a href="http://wiki.typo3.org/index.php/TYPO3_3.8.1" target="_blank">wiki.t
 		}
 
 			// Bodytag:
-		$defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
-		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 = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS["TSFE"]->absRefPrefix . $bgImg[3] . '">';
-		}
+		if ($GLOBALS['TSFE']->config['config']['disableBodyTag'])    {
+			$bodyTag = '';
+		} else {
+			$defBT = $GLOBALS['TSFE']->pSetup['bodyTagCObject'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($GLOBALS['TSFE']->pSetup['bodyTagCObject'], $GLOBALS['TSFE']->pSetup['bodyTagCObject.'], 'bodyTagCObject') : '';
+			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 = preg_replace('/>$/', '', trim($bodyTag)) . ' background="' . $GLOBALS["TSFE"]->absRefPrefix . $bgImg[3] . '">';
+			}
 
-		if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
-			$margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
-			if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
-				// Setting margins in CSS, see above
-			} else {
-				$bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
+			if (isset($GLOBALS['TSFE']->pSetup['bodyTagMargins'])) {
+				$margins = intval($GLOBALS['TSFE']->pSetup['bodyTagMargins']);
+				if ($GLOBALS['TSFE']->pSetup['bodyTagMargins.']['useCSS']) {
+					// Setting margins in CSS, see above
+				} else {
+					$bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' leftmargin="' . $margins . '" topmargin="' . $margins . '" marginwidth="' . $margins . '" marginheight="' . $margins . '">';
+				}
 			}
-		}
 
-		if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
-			$bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
-		}
+			if (trim($GLOBALS['TSFE']->pSetup['bodyTagAdd'])) {
+				$bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim($GLOBALS['TSFE']->pSetup['bodyTagAdd']) . '>';
+			}
 
-		if (count($JSef[1])) { // Event functions:
-			$bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
+			if (count($JSef[1])) { // Event functions:
+				$bodyTag = preg_replace('/>$/', '', trim($bodyTag)) . ' ' . trim(implode(' ', $JSef[1])) . '>';
+			}
 		}
 		$pageRenderer->addBodyContent(LF . $bodyTag);
 
-- 
1.7.6

