Fixed bug #8305: SQL debug output is not shown in the Backend (thanks to Stefan Galinski)
authorSteffen Kamper <info@sk-typo3.de>
Sat, 1 May 2010 15:05:05 +0000 (15:05 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Sat, 1 May 2010 15:05:05 +0000 (15:05 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7486 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php
typo3/backend.php
typo3/js/extjs/backendsizemanager.js
typo3/js/extjs/viewport.js
typo3/js/extjs/viewportConfiguration.js
typo3/sysext/lang/locallang_core.xml
typo3/template.php

index a327cc0..3b98686 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-05-01  Steffen Kamper  <info@sk-typo3.de>
+
+       * Fixed bug #8305: SQL debug output is not shown in the Backend (thanks to Stefan Galinski)
+
 2010-05-01  Susanne Moog  <typo3@susanne-moog.de>
 
        * Fixed bug #236: Rendered pages do not validate if no doctype is set. (thanks to Christian Buelter)
index 635367b..b664a82 100644 (file)
@@ -3419,8 +3419,8 @@ final class t3lib_div {
         * changed, and by that re-cached by the browser. If the file does not
         * exist physically the original file passed to the function is
         * returned without the timestamp.
-        * 
-        * Behaviour is influenced by the setting 
+        *
+        * Behaviour is influenced by the setting
         * TYPO3_CONF_VARS[TYPO3_MODE][versionNumberInFilename]
         * = true (BE) / "embed" (FE) : modify filename
         * = false (BE) / "querystring" (FE) : add timestamp as parameter
@@ -3465,7 +3465,7 @@ final class t3lib_div {
                                // Change the filename
                        $name = explode('.', $lookupFile[0]);
                        $extension = array_pop($name);
-               
+
                        array_push($name, filemtime($path), $extension);
                        $fullName = implode('.', $name);
                                // append potential query string
@@ -3576,37 +3576,106 @@ final class t3lib_div {
         * Usage: 8
         *
         * @param       mixed           Variable to print
-        * @param       mixed           If the parameter is a string it will be used as header. Otherwise number of break tags to apply after (positive integer) or before (negative integer) the output.
+        * @param       string          The header.
         * @return      void
         */
-       public static function debug($var='',$brOrHeader=0)     {
+       public static function debug($var = '', $header = '')   {
                        // buffer the output of debug if no buffering started before
                if (ob_get_level()==0) {
                        ob_start();
                }
+               $debug = '';
 
-               if ($brOrHeader && !self::testInt($brOrHeader)) {
-                       echo '<table class="typo3-debug" border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;"><tr><td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">'.htmlspecialchars((string)$brOrHeader).'</td></tr><tr><td>';
-               } elseif ($brOrHeader<0)        {
-                       for($a=0;$a<abs(intval($brOrHeader));$a++){echo '<br />';}
+               if ($header) {
+                       $debug .= '
+                       <table class="typo3-debug" border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;">
+                               <tr>
+                                       <td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">' .
+                                               htmlspecialchars((string) $header) .
+                                       '</td>
+                               </tr>
+                               <tr>
+                                       <td>';
                }
 
                if (is_array($var))     {
-                       self::print_array($var);
-               } elseif (is_object($var))      {
-                       echo '<b>|Object:<pre>';
-                       print_r($var);
-                       echo '</pre>|</b>';
-               } elseif ((string)$var!='')     {
-                       echo '<b>|'.htmlspecialchars((string)$var).'|</b>';
+                       $debug .= self::view_array($var);
+               } elseif (is_object($var)) {
+                       $debug .=  '<b>|Object:<pre>';
+                       $debug .= print_r($var, TRUE);
+                       $debug .=  '</pre>|</b>';
+               } elseif ((string) $var !== '') {
+                       $debug .= '<b>|' . htmlspecialchars((string)$var) . '|</b>';
                } else {
-                       echo '<b>| debug |</b>';
+                       $debug .= '<b>| debug |</b>';
                }
 
-               if ($brOrHeader && !self::testInt($brOrHeader)) {
-                       echo '</td></tr></table>';
-               } elseif ($brOrHeader>0)        {
-                       for($a=0;$a<intval($brOrHeader);$a++){echo '<br />';}
+               if ($header) {
+                       $debug .=  '
+                                       </td>
+                               </tr>
+                       </table>';
+               }
+
+               if (TYPO3_MODE === 'BE') {
+                       $tabHeader = 'Debug';
+                       if ($header) {
+                               $tabHeader .= ': ' . htmlspecialchars($header);
+                       }
+                       if (is_object($var)) {
+                               $debug = str_replace(
+                                       array('"', "\n", "\r"),
+                                       array('\"', '<br />', ''),
+                                       $debug
+                               );
+                       } else {
+                               $debug = str_replace(
+                                       array('"', "\n", "\r"),
+                                       array('\"', '', ''),
+                                       $debug
+                               );
+                       }
+
+                       $script = '
+                               var TYPO3ViewportInstance = null, tab;
+                               var debugString = "' . $debug . '";
+
+                               if (top && top.TYPO3 && typeof top.TYPO3.Backend === "object") {
+                                       TYPO3ViewportInstance = top.TYPO3.Backend;
+                               } else if (top.TYPO3 && typeof TYPO3.Backend === "object") {
+                                       TYPO3ViewportInstance = TYPO3.Backend;
+                               }
+
+                               if (TYPO3ViewportInstance !== null) {
+                                       if (TYPO3ViewportInstance.DebugConsole.hidden) {
+                                               TYPO3ViewportInstance.DebugConsole.show();
+                                       } else if (TYPO3ViewportInstance.DebugConsole.collapsed) {
+                                               TYPO3ViewportInstance.DebugConsole.expand();
+                                       }
+
+                                       tab = TYPO3ViewportInstance.DebugConsole.add({
+                                               title: "' . $tabHeader . '",
+                                               html: debugString,
+                                               border: false,
+                                               closable: true,
+                                               autoScroll: true,
+                                               listeners: {
+                                                       close: function(tab) {
+                                                               if (tab.ownerCt.items.getCount() === 1) {
+                                                                       tab.ownerCt.hide();
+                                                               }
+                                                       }
+                                               }
+                                       });
+                                       TYPO3ViewportInstance.DebugConsole.setActiveTab(tab);
+                                       TYPO3ViewportInstance.doLayout();
+                               } else {
+                                       document.write(debugString);
+                               }
+                       ';
+                       echo self::wrapJS($script);
+               } else {
+                       echo $debug;
                }
        }
 
index 9ef75c8..2676acb 100644 (file)
@@ -387,6 +387,7 @@ class TYPO3backend {
                        'login_about_to_expire_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire_title'),
                        'refresh_login_refresh_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_refresh_button'),
                        'refresh_direct_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_direct_logout_button'),
+                       'tabs_closeAll' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeAll'),
                );
                $t3LLLfileUpload = array(
                        'windowTitle' => $GLOBALS['LANG']->getLL('fileUpload_windowTitle'),
index d6fb579..f5b0e75 100644 (file)
@@ -35,16 +35,19 @@ TYPO3.BackendSizeManager = function() {
        var resizeBackend = function() {
                var viewportHeight = document.viewport.getHeight();
                var topHeight = Ext.get('typo3-topbar').getHeight();
+               var debugConsole = Ext.get('typo3-debug-console');
+               var consoleHeight = debugConsole.isVisible() ? 0 : debugConsole.getHeight() + debugConsole.getHeight();
                var styles = {
-                       height: (viewportHeight - topHeight) + 'px'
+                       height: (viewportHeight - topHeight - consoleHeight) + 'px'
                }
 
                Ext.get('typo3-side-menu').setStyle(styles);
                Ext.get('content').setStyle(styles);
        }
 
-       Ext.EventManager.on(window, 'resize', resizeBackend);
+       Ext.EventManager.onWindowResize(resizeBackend);
        Ext.onReady(function() {
+               TYPO3.Backend.addListener('resize', resizeBackend);
                resizeBackend();
        });
 }();
index da87a4f..8756fab 100644 (file)
@@ -75,6 +75,13 @@ TYPO3.Viewport = Ext.extend(Ext.Viewport, {
        ModuleMenuContainer: null,
 
        /**
+        * The debug console
+        * 
+        * @var Ext.TabPanel
+        */
+       DebugConsole: null,
+
+       /**
         * Initializes the ExtJS viewport with the given configuration.
         *
         * @return void
@@ -90,6 +97,25 @@ TYPO3.Viewport = Ext.extend(Ext.Viewport, {
                this.Topbar = Ext.ComponentMgr.get('typo3-topbar');
                this.ModuleMenuContainer = Ext.ComponentMgr.get('typo3-module-menu');
 
+               // adds the debug console and some listeners to consider the initial hiding of
+               // the debug console (the viewport needs to be resized if it's expand/collapse)
+               // -> see the TYPO3.BackendSizeManager
+               this.DebugConsole = Ext.ComponentMgr.get('typo3-debug-console');
+               this.DebugConsole.addListener({
+                       'resize': {
+                               scope: this,
+                               fn: function() {
+                                       this.fireEvent('resize');
+                               }
+                       },
+                       'collapse': {
+                               scope: this,
+                               fn: function() {
+                                       this.fireEvent('resize');
+                               }
+                       }
+               });
+               Ext.ComponentMgr.get('typo3-debug-console-closerTab').setTitle(TYPO3.LLL.core.tabs_closeAll);
        },
 
        /**
index e050fa7..36457da 100644 (file)
@@ -73,5 +73,41 @@ TYPO3.Viewport.configuration = {
                        anchor: '100% 100%',
                        border: false
                }]
+       }, {
+               region: 'south',
+               xtype: 'tabpanel',
+               collapsible: true,
+               collapseMode: 'mini',
+               hideCollapseTool: true,
+               animCollapse: false,
+               split: true,
+               autoScroll: true,
+               hidden: true,
+               height: 200,
+               title: 'Debug-Console',
+               id: 'typo3-debug-console',
+               border: false,
+               enableTabScroll: true,
+               items: [{
+                       title: "",
+                       id: 'typo3-debug-console-closerTab',
+                       border: false,
+                       closable: false,
+                       listeners: {
+                               activate: function(tab) {
+                                       var i, id = [], tabCount = tab.ownerCt.items.getCount();
+                                               // get tab id's
+                                       for (var i = 1; i < tabCount; i++) {
+                                               id.push(tab.ownerCt.items.keys[i]);
+                                       }
+                                               // remove all tabs except first
+                                       for (var i = 0; i < id.length; i++) {
+                                               tab.ownerCt.remove(id[i]);
+                                       }
+                                       tab.ownerCt.hide();
+                                       tab.ownerCt.fireEvent("resize");
+                               }
+                       }
+               }]
        }]
-};
+};
\ No newline at end of file
index 6f4eac0..096aee2 100755 (executable)
@@ -263,6 +263,7 @@ Would you like to save now in order to refresh the display?</label>
                        <label index="toolbarItems.shortcutsDelete">Delete Shortcut</label>
                        <label index="toolbarItems.search">Search</label>
                        <label index="toolbarItems.workspace">Workspace</label>
+                       <label index="tabs.closeAll">Close all</label>
                </languageKey>
        </data>
 </T3locallang>
index 34ea945..a143f03 100644 (file)
@@ -801,6 +801,8 @@ $str.=$this->docBodyTagBegin().
                                $this->parseTime().
                                ($this->form?'
 </form>':'');
+                       // if something is in buffer, put it to end of page
+               $str .= ob_get_clean();
 
                if ($this->docType!='xhtml_frames') {