Fixed bug #11503: HTML5 doctype implementation
authorSteffen Kamper <info@sk-typo3.de>
Fri, 28 May 2010 23:24:22 +0000 (23:24 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Fri, 28 May 2010 23:24:22 +0000 (23:24 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7737 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_pagegen.php
typo3/template.php

index 40bee12..03b1418 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-05-28  Steffen Kamper  <info@sk-typo3.de>
 
+       * Fixed bug #11503: HTML5 doctype implementation
        * Follow-up to feature #14506: Fixes for alt_db_navframe (page tree filter) (Thanks to Steffen Gebert)
        * Follow-up to feature #14490: forgotten css file
        * Follow-up to feature #14490: A new skin for the TYPO3 Backend (Thanks to Steffen Gebert and Lars Zimmermann)
index a120227..3dbc83f 100644 (file)
@@ -428,6 +428,9 @@ See <a href="http://wiki.typo3.org/index.php/TYPO3_3.8.1" target="_blank">wiki.t
        PUBLIC "-//W3C//DTD XHTML 2.0//EN"
        "http://www.w3.org/TR/xhtml2/DTD/xhtml2.dtd">';
                                        break;
+                               case 'html_5' :
+                                       $docTypeParts[] = '<!DOCTYPE html>';
+                                       break;
                                case 'none' :
                                        break;
                                default :
index edda1b4..dd41001 100644 (file)
@@ -195,6 +195,12 @@ class template {
        var $backGroundImage = '';              // Background image of page (relative to PATH_typo3)
        var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array
 
+       /**
+        * Whether to use the X-UA-Compatible meta tag
+        * @var boolean 
+        */
+       protected $useCompatibilityTag = TRUE;
+
                // Skinning
                // stylesheets from core
        protected $stylesheetsCore = array(
@@ -630,6 +636,16 @@ class template {
                }
        }
 
+       /**
+        * Defines whether to use the X-UA-Compatible meta tag.
+        *
+        * @param boolean $useCompatibilityTag Whether to use the tag
+        * @return void
+        */
+       public function useCompatibilityTag($useCompatibilityTag = TRUE) {
+               $this->useCompatibilityTag = (bool) $useCompatibilityTag;
+       }
+
 
 
 
@@ -687,7 +703,7 @@ class template {
                header ('Content-Type:text/html;charset='.$this->charset);
 
                        // Standard HTML tag
-               $this->pageRenderer->setHtmlTag('<html xmlns="http://www.w3.org/1999/xhtml">');
+               $htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
 
                switch($this->docType)  {
                        case 'html_3':
@@ -703,10 +719,16 @@ class template {
                                break;
                        case 'xhtml_frames':
                                $headerStart = '<!DOCTYPE html
-     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
+       PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
                                break;
-                       // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE.
+                       case 'html_5':
+                               $headerStart = '<!DOCTYPE html>' . LF;
+                               $htmlTag = '<html>';
+                               // disable rendering of XHTML tags
+                               $this->getPageRenderer()->setRenderXhtml(FALSE);
+                               break;
+                               // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE.
                        case 'xhtml_trans':
                        default:
                                $headerStart = '<!DOCTYPE html
@@ -714,6 +736,8 @@ class template {
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
                }
 
+               $this->pageRenderer->setHtmlTag($htmlTag);
+
                // This loads the tabulator-in-textarea feature. It automatically modifies
                // every textarea which is found.
                if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea']) {
@@ -730,7 +754,7 @@ class template {
                $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
 
                        // Add the XML prologue for XHTML doctypes
-               if ($this->docType !== 'html_3') {
+               if ($this->docType !== 'html_3' && $this->docType !== 'html_5') {
                                // Put the XML prologue before or after the doctype declaration according to browser
                        if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
                                $headerStart = $headerStart . LF . $xmlPrologue;
@@ -748,7 +772,9 @@ class template {
                $this->pageRenderer->setHeadTag('<head>' . LF. '<!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->');
                $this->pageRenderer->setCharSet($this->charset);
                $this->pageRenderer->addMetaTag($this->generator());
-               $this->pageRenderer->addMetaTag($this->xUaCompatible());
+               if ($this->useCompatibilityTag) {
+                       $this->pageRenderer->addMetaTag($this->xUaCompatible());
+               }
                $this->pageRenderer->setTitle($title);
 
                // add docstyles
@@ -813,7 +839,7 @@ $str.=$this->docBodyTagBegin().
                        header('Content-Encoding: None');
                }
 
-               if ($this->docType!='xhtml_frames') {
+               if ($this->docType !== 'xhtml_frames') {
 
                        $str .= ($this->divClass?'
 
@@ -1169,12 +1195,11 @@ $str.=$this->docBodyTagBegin().
        /**
         * Returns X-UA-Compatible meta tag
         *
+        * @param       string          $content Content of the compatible tag (default: IE-8)
         * @return      string          <meta http-equiv="X-UA-Compatible" content="???" />
         */
-       function xUaCompatible() {
-                       // the most recent version if Internet Explorer, in which the Backend works
-               $str = "IE=8";
-               return '<meta http-equiv="X-UA-Compatible" content="' . $str . '" />';
+       public function xUaCompatible($content = 'IE=8') {
+               return '<meta http-equiv="X-UA-Compatible" content="' . $content . '" />';
        }