Fixed bug #14717: [Usability] Add delay to close the context menu
[Packages/TYPO3.CMS.git] / typo3 / backend.php
index 331ee73..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
@@ -59,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;
 
        /**
@@ -148,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');
        }
 
        /**
@@ -185,6 +187,7 @@ class TYPO3backend {
         * @return      void
         */
        public function render()        {
+               $this->executeHook('renderPreProcess');
 
                if (t3lib_div::makeInstance('DonateWindow')->isDonateWindowAllowed()) {
                        $this->pageRenderer->addJsFile('js/donate.js');
@@ -244,8 +247,20 @@ class TYPO3backend {
                foreach ($this->jsFiles as $jsFile) {
                        $this->pageRenderer->addJsFile($jsFile);
                }
-                       // we mustn't compress this file
-               $this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Backend', NULL, FALSE);
+
+                       // 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);
@@ -262,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;
        }
 
@@ -300,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
@@ -374,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(
@@ -485,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 . ';
                ');
 
@@ -569,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() {
@@ -691,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);
+                       }
+               }
+       }
 }