[BUGFIX] TSFE->additionalFooterData for USER_INT
authorOliver Hader <oliver@typo3.org>
Thu, 7 Jun 2012 09:13:24 +0000 (11:13 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 4 Jul 2012 08:05:25 +0000 (10:05 +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: I728dfd43d0c72138b18dc87b81c4d4be4491177b
Fixes: #29254
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/11860
Reviewed-on: http://review.typo3.org/12570
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
tests/typo3/sysext/cms/fixtures/renderedPage.html [new file with mode: 0644]
tests/typo3/sysext/cms/tslib/tslib_feTest.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_pagegen.php

diff --git a/tests/typo3/sysext/cms/fixtures/renderedPage.html b/tests/typo3/sysext/cms/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 e9c0a75..5936c2d 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;
@@ -59,6 +74,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 91f431e..94bb3b5 100644 (file)
                        JSImgCode : reserved
        */
        var $additionalHeaderData=array();      // 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[] = '...')
+       public $additionalFooterData = array(); // used to accumulate additional HTML-code for the footer-section of the template
        var $additionalJavaScript=array();      // used to accumulate additional JavaScript-code. Works like additionalHeaderData. Reserved keys at 'openPic' and 'mouseOver'
        var $additionalCSS=array();                     // used to accumulate additional Style code. Works like additionalHeaderData.
        var $JSeventFuncCalls = array(          // you can add JavaScript functions to each entry in these arrays. Please see how this is done in the GMENU_LAYERS script. The point is that many applications on a page can set handlers for onload, onmouseover and onmouseup
                'onmousemove' => array(),
                'onmouseup' => array(),
-               'onmousemove' => array(),
                'onkeydown' => array(),
                'onkeyup' => array(),
                'onkeypress' => array(),
        function INTincScript() {
                        // Deprecated stuff:
                $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->JSCode = $this->additionalHeaderData['JSCode'];
                $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 ff701d3..6478332 100644 (file)
@@ -837,11 +837,13 @@ See <a href="http://wiki.typo3.org/index.php/TYPO3_3.8.1" target="_blank">wiki.t
                        $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();