Fixed bug #14717: [Usability] Add delay to close the context menu
[Packages/TYPO3.CMS.git] / typo3 / backend.php
index 9ef75c8..1d7f410 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2007-2009 Ingo Renner <ingo@typo3.org>
+*  (c) 2007-2010 Ingo Renner <ingo@typo3.org>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -31,6 +31,7 @@ require_once('interfaces/interface.backend_toolbaritem.php');
 
 require('classes/class.typo3logo.php');
 require('classes/class.modulemenu.php');
+require_once('classes/class.donatewindow.php');
 
        // core toolbar items
 require('classes/class.workspaceselector.php');
@@ -58,7 +59,7 @@ class TYPO3backend {
        protected $jsFiles;
        protected $jsFilesAfterInline;
        protected $toolbarItems;
-       private   $menuWidthDefault = 160; // intentionally private as nobody should modify defaults
+       private   $menuWidthDefault = 190; // intentionally private as nobody should modify defaults
        protected $menuWidth;
 
        /**
@@ -78,7 +79,7 @@ class TYPO3backend {
        /**
         * Pagerenderer
         *
-        * @var $pageRenderer t3lib_PageRenderer
+        * @var t3lib_PageRenderer
         */
        protected $pageRenderer;
 
@@ -127,10 +128,11 @@ class TYPO3backend {
                        'js/iecompatibility.js',
                        'js/flashupload.js',
                        '../t3lib/jsfunc.evalfield.js',
-                       'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Backend',
                        '../t3lib/js/extjs/ux/flashmessages.js',
+                       '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js',
                        'js/backend.js',
                        'js/loginrefresh.js',
+                       'js/extjs/debugPanel.js',
                        'js/extjs/viewport.js',
                        'js/extjs/viewportConfiguration.js',
                );
@@ -146,6 +148,8 @@ class TYPO3backend {
                if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth) {
                        $this->menuWidth = (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
                }
+
+               $this->executeHook('constructPostProcess');
        }
 
        /**
@@ -183,6 +187,11 @@ class TYPO3backend {
         * @return      void
         */
        public function render()        {
+               $this->executeHook('renderPreProcess');
+
+               if (t3lib_div::makeInstance('DonateWindow')->isDonateWindowAllowed()) {
+                       $this->pageRenderer->addJsFile('js/donate.js');
+               }
 
                        // prepare the scaffolding, at this point extension may still add javascript and css
                $logo         = t3lib_div::makeInstance('TYPO3Logo');
@@ -239,6 +248,20 @@ class TYPO3backend {
                        $this->pageRenderer->addJsFile($jsFile);
                }
 
+                       // Those lines can be removed once we have at least one official ExtDirect router within the backend.
+               $hasExtDirectRouter = FALSE;
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'] as $key => $value) {
+                               if (strpos($key, 'TYPO3.Backend') !== FALSE) {
+                                       $hasExtDirectRouter = TRUE;
+                                       break;
+                               }
+                       }
+               }
+               if ($hasExtDirectRouter) {
+                       $this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Backend', NULL, FALSE);
+               }
+
                $this->generateJavascript();
                $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js);
 
@@ -254,6 +277,9 @@ class TYPO3backend {
                $this->content .= $backendScaffolding;
                $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
 
+               $hookConfiguration = array('content' => &$this->content);
+               $this->executeHook('renderPostProcess', $hookConfiguration);
+
                echo $this->content;
        }
 
@@ -292,17 +318,10 @@ class TYPO3backend {
        protected function getLoggedInUserLabel() {
                global $BE_USER, $BACK_PATH;
 
-               $icon = '<img'.t3lib_iconWorks::skinImg(
-                       '',
-                       $BE_USER->isAdmin() ?
-                               'gfx/i/be_users_admin.gif' :
-                               'gfx/i/be_users.gif',
-                       'width="18" height="16"'
-               )
-               .' title="" alt="" />';
+                $icon = t3lib_iconWorks::getSpriteIcon('status-user-'. ($BE_USER->isAdmin() ? 'admin' : 'backend'));
 
                $label = $GLOBALS['BE_USER']->user['realName'] ?
-                       $BE_USER->user['realName'].' ['.$BE_USER->user['username'].']' :
+                       $BE_USER->user['realName'] . ' (' . $BE_USER->user['username'] . ')' :
                        $BE_USER->user['username'];
 
                        // Link to user setup if it's loaded and user has access
@@ -366,6 +385,7 @@ class TYPO3backend {
                        'veriCode' => $GLOBALS['BE_USER']->veriCode(),
                        'denyFileTypes' => PHP_EXTENSIONS_DEFAULT,
                        'moduleMenuWidth' => $this->menuWidth - 1,
+                       'topBarHeight' => (int) $GLOBALS['TBE_STYLES']['dims']['topFrameH'],
                        'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
                );
                $t3LLLcore = array(
@@ -387,6 +407,14 @@ 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'),
+                       'tabs_closeOther' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeOther'),
+                       'tabs_close' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.close'),
+                       'donateWindow_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.title'),
+                       'donateWindow_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.message'),
+                       'donateWindow_button_donate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_donate'),
+                       'donateWindow_button_disable' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_disable'),
+                       'donateWindow_button_postpone' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_postpone'),
                );
                $t3LLLfileUpload = array(
                        'windowTitle' => $GLOBALS['LANG']->getLL('fileUpload_windowTitle'),
@@ -469,8 +497,7 @@ class TYPO3backend {
        var fsMod = new fsModules();' . $moduleFramesHelper . ';';
 
                        // add goToModule code
-               $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
-               $pageRenderer->addExtOnReadyCode('
+               $this->pageRenderer->addExtOnReadyCode('
                        top.goToModule = ' . $goToModuleSwitch . ';
                ');
 
@@ -553,8 +580,7 @@ class TYPO3backend {
 
                $moduleParameters = t3lib_div::_GET('modParams');
                if($startModule) {
-                       $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
-                       $pageRenderer->addExtOnReadyCode('
+                       $this->pageRenderer->addExtOnReadyCode('
                        // start in module:
                function startInModule(modName, cMR_flag, addGetVars)   {
                        Ext.onReady(function() {
@@ -675,6 +701,28 @@ class TYPO3backend {
                        unset($toolbarItem);
                }
        }
+
+       /**
+        * Executes defined hooks functions for the given identifier.
+        *
+        * These hook identifiers are valid:
+        *      + constructPostProcess
+        *      + renderPreProcess
+        *      + renderPostProcess
+        *
+        * @param string $identifier Specific hook identifier
+        * @param array $hookConfiguration Additional configuration passed to hook functions
+        * @return void
+        */
+       protected function executeHook($identifier, array $hookConfiguration = array()) {
+               $options =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php'];
+
+               if(isset($options[$identifier]) && is_array($options[$identifier])) {
+                       foreach($options[$identifier] as $hookFunction) {
+                               t3lib_div::callUserFunction($hookFunction, $hookConfiguration, $this);
+                       }
+               }
+       }
 }