[BUGFIX] TSFE->additionalFooterData for USER_INT
authorOliver Hader <oliver@typo3.org>
Thu, 7 Jun 2012 09:13:24 +0000 (11:13 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Fri, 29 Jun 2012 18:34:28 +0000 (20:34 +0200)
TSFE->additionalFooterData was introduced with TYPO3 4.3, but
only for the purpose of t3lib_PageRenderer. The definition of
this property is e.g. missing at all in tslib_fe and besides
that, the handling for USER_INT/COA_INT objects is not there
at all.

Change-Id: I86372e332503d6907e5ff2d28c893bfd127bdcdc
Fixes: #29254
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/11859
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/cms/tests/fixtures/renderedPage.html [new file with mode: 0644]
typo3/sysext/cms/tests/tslib/class.tslib_feTest.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_pagegen.php

diff --git a/typo3/sysext/cms/tests/fixtures/renderedPage.html b/typo3/sysext/cms/tests/fixtures/renderedPage.html
new file mode 100644 (file)
index 0000000..cab1e65
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html
+       PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<!-- 
+       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-2012 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
+       Information and contribution at http://typo3.org/
+-->
+
+
+
+<title>powermail</title>
+<meta name="generator" content="TYPO3 6.0 CMS">
+
+<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_427bb03fe1.css?1334416344" media="all">
+
+
+
+<script src="typo3temp/javascript_175aa1ef20.js?1340313498" type="text/javascript"></script>
+
+
+<!--HD_679b52796e75d474ccbbed486b6837ab-->
+</head>
+<body>
+<!--TDS_679b52796e75d474ccbbed486b6837ab-->
+
+       <!--  CONTENT ELEMENT, uid:65/login [begin] -->
+               <div id="c65" class="csc-default csc-space-before- csc-space-after-"><!--INT_SCRIPT.13e1737dd0938292520612f3088602ba--></div>
+       <!--  CONTENT ELEMENT, uid:65/login [end] -->
+
+
+<!--FD_679b52796e75d474ccbbed486b6837ab-->
+</body>
+</html>
\ No newline at end of file
index 8281851..979c9c2 100644 (file)
  */
 class tslib_feTest extends tx_phpunit_testcase {
        /**
+        * Enable backup of global and system variables
+        *
+        * @var boolean
+        */
+       protected $backupGlobals = TRUE;
+
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
+
+       /**
         * @var tslib_fe
         */
        private $fixture;
@@ -69,6 +84,60 @@ class tslib_feTest extends tx_phpunit_testcase {
                unset($this->fixture);
        }
 
+       ////////////////////////////////
+       // Tests concerning rendering content
+       ////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function headerAndFooterMarkersAreReplacedDuringIntProcessing() {
+               $GLOBALS['TSFE'] = $this->setupTsfeMockForHeaderFooterReplacementCheck();
+
+               $GLOBALS['TSFE']->INTincScript();
+
+               $this->assertContains('headerData', $GLOBALS['TSFE']->content);
+               $this->assertContains('footerData', $GLOBALS['TSFE']->content);
+       }
+
+       /**
+        * This is the callback that mimics a USER_INT extension
+        */
+       public function INTincScript_processCallback() {
+               $GLOBALS['TSFE']->additionalHeaderData[] = 'headerData';
+               $GLOBALS['TSFE']->additionalFooterData[] = 'footerData';
+       }
+
+       /**
+        * Setup a tslib_fe object only for testing the header and footer
+        * replacement during USER_INT rendering
+        *
+        * @return PHPUnit_Framework_MockObject_MockObject
+        */
+       protected function setupTsfeMockForHeaderFooterReplacementCheck() {
+               $tsfe = $this->getMock('tslib_fe',
+                       array('INTincScript_process',
+                               'INTincScript_includeLibs',
+                               'INTincScript_loadJSCode',
+                               'setAbsRefPrefix'
+                       ),
+                       array(),
+                       '',
+                       FALSE
+               );
+               $tsfe->expects($this->once())
+                       ->method('INTincScript_process')
+                       ->will($this->returnCallback(array($this, 'INTincScript_processCallback')));
+
+               $tsfe->content = file_get_contents(__DIR__ . '/../fixtures/renderedPage.html');
+               $tsfe->config['INTincScript_ext']['divKey'] = '679b52796e75d474ccbbed486b6837ab';
+               $tsfe->config['INTincScript'] = array('INT_SCRIPT.679b52796e75d474ccbbed486b6837ab' => array());
+
+               $GLOBALS['TT'] = new t3lib_timeTrackNull();
+
+               return $tsfe;
+       }
+
 
        ////////////////////////////////
        // Tests concerning codeString
index 09d739c..2242567 100644 (file)
@@ -181,6 +181,8 @@ class tslib_fe {
        */
                // used to accumulate additional HTML-code for the header-section, <head>...</head>. Insert either associative keys (like additionalHeaderData['myStyleSheet'], see reserved keys above) or num-keys (like additionalHeaderData[] = '...')
        var $additionalHeaderData = array();
+               // used to accumulate additional HTML-code for the footer-section of the template
+       public $additionalFooterData = array();
                // used to accumulate additional JavaScript-code. Works like additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver'
        var $additionalJavaScript = array();
                // used to accumulate additional Style code. Works like additionalHeaderData.
@@ -189,7 +191,6 @@ class tslib_fe {
        var $JSeventFuncCalls = array(
                'onmousemove' => array(),
                'onmouseup' => array(),
-               'onmousemove' => array(),
                'onkeydown' => array(),
                'onkeyup' => array(),
                'onkeypress' => array(),
@@ -3091,6 +3092,7 @@ class tslib_fe {
                        // Deprecated stuff:
                        // @deprecated: annotation added TYPO3 4.6
                $this->additionalHeaderData = is_array($this->config['INTincScript_ext']['additionalHeaderData']) ? $this->config['INTincScript_ext']['additionalHeaderData'] : array();
+               $this->additionalFooterData = is_array($this->config['INTincScript_ext']['additionalFooterData']) ? $this->config['INTincScript_ext']['additionalFooterData'] : array();
                $this->additionalJavaScript = $this->config['INTincScript_ext']['additionalJavaScript'];
                $this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS'];
                $this->JSImgCode = $this->additionalHeaderData['JSImgCode'];
@@ -3108,6 +3110,7 @@ class tslib_fe {
                $GLOBALS['TT']->push('Substitute header section');
                $this->INTincScript_loadJSCode();
                $this->content = str_replace('<!--HD_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset(implode(LF, $this->additionalHeaderData), 'HD'), $this->content);
+               $this->content = str_replace('<!--FD_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset(implode(LF, $this->additionalFooterData), 'FD'), $this->content);
                $this->content = str_replace('<!--TDS_'.$this->config['INTincScript_ext']['divKey'].'-->', $this->convOutputCharset($this->divSection, 'TDS'), $this->content);
                $this->setAbsRefPrefix();
                $GLOBALS['TT']->pull();
index 30c60ab..4eaaedf 100644 (file)
@@ -796,11 +796,12 @@ class TSpagegen {
                        $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
+                       $GLOBALS['TSFE']->config['INTincScript_ext']['additionalFooterData'] = $GLOBALS['TSFE']->additionalFooterData; // Storing the footer-data array
                        $GLOBALS['TSFE']->config['INTincScript_ext']['additionalJavaScript'] = $GLOBALS['TSFE']->additionalJavaScript; // Storing the JS-data array
                        $GLOBALS['TSFE']->config['INTincScript_ext']['additionalCSS'] = $GLOBALS['TSFE']->additionalCSS; // Storing the Style-data array
 
-
                        $GLOBALS['TSFE']->additionalHeaderData = array ('<!--HD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->'); // Clearing the array
+                       $GLOBALS['TSFE']->additionalFooterData = array ('<!--FD_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->'); // Clearing the array
                        $GLOBALS['TSFE']->divSection .= '<!--TDS_' . $GLOBALS['TSFE']->config['INTincScript_ext']['divKey'] . '-->';
                } else {
                        $GLOBALS['TSFE']->INTincScript_loadJSCode();
@@ -1152,4 +1153,4 @@ class FE_loadDBGroup extends t3lib_loadDBGroup {
        var $fromTC = 0;
 }
 
-?>
\ No newline at end of file
+?>