[BUGFIX] Regression: filelistFolderTree constructor is recursive
[Packages/TYPO3.CMS.git] / typo3 / template.php
index 4876299..c3e0f25 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 /**
  * Contains class with layout/output function for TYPO3 Backend Scripts
  *
- * $Id$
  * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
  * XHTML-trans compliant
  *
  * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *  145: function fw($str)
- *
- *
- *  169: class template
- *  224:     function template()
- *
- *              SECTION: EVALUATION FUNCTIONS
- *  298:     function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE)
- *  315:     function viewPageIcon($id,$backPath,$addParams='hspace="3"')
- *  341:     function issueCommand($params,$rUrl='')
- *  356:     function isCMlayers()
- *  366:     function thisBlur()
- *  376:     function helpStyle()
- *  393:     function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))
- *  419:     function getFileheader($title,$path,$iconfile)
- *  434:     function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")
- *  467:     function makeShortcutUrl($gvList,$setList)
- *  488:     function formWidth($size=48,$textarea=0,$styleOverride='')
- *  513:     function formWidthText($size=48,$styleOverride='',$wrap='')
- *  530:     function redirectUrls($thisLocation='')
- *  554:     function formatTime($tstamp,$type)
- *  571:     function parseTime()
- *
- *              SECTION: PAGE BUILDING FUNCTIONS.
- *  604:     function startPage($title)
- *  686:     function endPage()
- *  720:     function header($text)
- *  741:     function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)
- *  765:     function divider($dist)
- *  781:     function spacer($dist)
- *  800:     function sectionHeader($label,$sH=FALSE,$addAttrib='')
- *  817:     function sectionBegin()
- *  838:     function sectionEnd()
- *  858:     function middle()
- *  867:     function endPageJS()
- *  884:     function docBodyTagBegin()
- *  894:     function docStyle()
- *  936:     function insertStylesAndJS($content)
- *  956:     function initCharset()
- *  968:     function generator()
- *
- *              SECTION: OTHER ELEMENTS
- * 1001:     function icons($type, $styleAttribValue='')
- * 1030:     function t3Button($onClick,$label)
- * 1041:     function dfw($string)
- * 1051:     function rfw($string)
- * 1061:     function wrapInCData($string)
- * 1078:     function wrapScriptTags($string, $linebreak=TRUE)
- * 1117:     function table($arr, $layout='')
- * 1159:     function menuTable($arr1,$arr2=array(), $arr3=array())
- * 1192:     function funcMenu($content,$menu)
- * 1210:     function clearCacheMenu($id,$addSaveOptions=0)
- * 1246:     function getContextMenuCode()
- * 1251:     function showClickmenu(table, uid, listFr, enDisItems, backPath, addParams)
- * 1280:     function showClickmenu_noajax(url)
- * 1287:     function showClickmenu_ajax(t3ajax)
- * 1472:     function getDragDropCode($table)
- * 1483:     function cancelDragEvent(event)
- * 1496:     function mouseMoveEvent (event)
- * 1509:     function dragElement(id,elementID)
- * 1528:     function dropElement(id)
- * 1577:     function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')
- * 1607:     function getTabMenuRaw($menuItems)
- * 1676:     function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)
- * 1801:     function getDynTabMenuJScode()
- * 1892:     function getVersionSelector($id,$noAction=FALSE)
- *
- *
- * 2060: class bigDoc extends template
- *
- *
- * 2069: class noDoc extends template
- *
- *
- * 2078: class smallDoc extends template
- *
- *
- * 2087: class mediumDoc extends template
- *
- * TOTAL FUNCTIONS: 57
- * (This index is automatically created/updated by the extension "extdeveval")
- *
- */
 
 
 
@@ -126,19 +39,6 @@ if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
 
 
 /**
- * Deprecated fontwrap function. Is just transparent now.
- *
- * @param      string          Input string
- * @return     string          Output string (in the old days this was wrapped in <font> tags)
- * @deprecated since TYPO3 3.6, will be removed in TYPO3 4.6
- */
-function fw($str) {
-       t3lib_div::logDeprecatedFunction();
-       return $str;
-}
-
-
-/**
  * TYPO3 Backend Template Class
  *
  * This class contains functions for starting and ending the HTML of backend modules
@@ -182,7 +82,7 @@ class template {
        var $endJS=1;                                   // If set, then a JavaScript section will be outputted in the bottom of page which will try and update the top.busy session expiry object.
 
                // TYPO3 Colorscheme.
-               // If you want to change this, please do so through a skin using the global var $TBE_STYLES
+               // If you want to change this, please do so through a skin using the global var $GLOBALS['TBE_STYLES']
        var $bgColor = '#F7F3EF';               // Light background color
        var $bgColor2 = '#9BA1A8';              // Steel-blue
        var $bgColor3 = '#F6F2E6';              // dok.color
@@ -225,7 +125,7 @@ class template {
        );
 
                // DEV:
-       var $parseTimeFlag = 0;                 // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to false when releasing TYPO3. Only for dev.
+       var $parseTimeFlag = 0;                 // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to FALSE when releasing TYPO3. Only for dev.
 
                // INTERNAL
        var $charset = 'iso-8859-1';    // Default charset. see function initCharset()
@@ -236,7 +136,7 @@ class template {
        var $pageHeaderBlock = '';
        var $endOfPageJsBlock = '';
 
-       var $hasDocheader = true;
+       var $hasDocheader = TRUE;
 
        /**
         * @var t3lib_PageRenderer
@@ -244,6 +144,8 @@ class template {
        protected $pageRenderer;
        protected $pageHeaderFooterTemplateFile = '';   // alternative template file
 
+       protected $extDirectStateProvider = FALSE;
+
        /**
         * Whether flashmessages should be rendered or not
         *
@@ -253,13 +155,11 @@ class template {
 
        /**
         * Constructor
-        * Imports relevant parts from global $TBE_STYLES (colorscheme)
+        * Imports relevant parts from global $GLOBALS['TBE_STYLES'] (colorscheme)
         *
         * @return      void
         */
-       function template()     {
-               global $TBE_STYLES;
-
+       function __construct()  {
                        // Initializes the page rendering object:
                $this->getPageRenderer();
 
@@ -276,27 +176,27 @@ class template {
                $this->bodyTagId = preg_replace('/[^A-Za-z0-9-]/','-',$this->scriptID);
 
                        // Individual configuration per script? If so, make a recursive merge of the arrays:
-               if (is_array($TBE_STYLES['scriptIDindex'][$this->scriptID]))    {
-                       $ovr = $TBE_STYLES['scriptIDindex'][$this->scriptID];           // Make copy
-                       $TBE_STYLES = t3lib_div::array_merge_recursive_overrule($TBE_STYLES,$ovr);              // merge styles.
-                       unset($TBE_STYLES['scriptIDindex'][$this->scriptID]);   // Have to unset - otherwise the second instantiation will do it again!
+               if (is_array($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID])) {
+                       $ovr = $GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID];                // Make copy
+                       $GLOBALS['TBE_STYLES'] = t3lib_div::array_merge_recursive_overrule($GLOBALS['TBE_STYLES'],$ovr);                // merge styles.
+                       unset($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID]);        // Have to unset - otherwise the second instantiation will do it again!
                }
 
                        // Color scheme:
-               if ($TBE_STYLES['mainColors']['bgColor'])       $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
-               if ($TBE_STYLES['mainColors']['bgColor1'])      $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
-               if ($TBE_STYLES['mainColors']['bgColor2'])      $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
-               if ($TBE_STYLES['mainColors']['bgColor3'])      $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
-               if ($TBE_STYLES['mainColors']['bgColor4'])      $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
-               if ($TBE_STYLES['mainColors']['bgColor5'])      $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
-               if ($TBE_STYLES['mainColors']['bgColor6'])      $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
-               if ($TBE_STYLES['mainColors']['hoverColor'])    $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor'])    $this->bgColor=$GLOBALS['TBE_STYLES']['mainColors']['bgColor'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor1'])   $this->bgColor1=$GLOBALS['TBE_STYLES']['mainColors']['bgColor1'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor2'])   $this->bgColor2=$GLOBALS['TBE_STYLES']['mainColors']['bgColor2'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor3'])   $this->bgColor3=$GLOBALS['TBE_STYLES']['mainColors']['bgColor3'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor4'])   $this->bgColor4=$GLOBALS['TBE_STYLES']['mainColors']['bgColor4'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor5'])   $this->bgColor5=$GLOBALS['TBE_STYLES']['mainColors']['bgColor5'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor6'])   $this->bgColor6=$GLOBALS['TBE_STYLES']['mainColors']['bgColor6'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['hoverColor']) $this->hoverColor=$GLOBALS['TBE_STYLES']['mainColors']['hoverColor'];
 
                        // Main Stylesheets:
-               if ($TBE_STYLES['stylesheet'])  $this->styleSheetFile = $TBE_STYLES['stylesheet'];
-               if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
-               if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post'];
-               if ($TBE_STYLES['inDocStyles_TBEstyle'])        $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle'];
+               if ($GLOBALS['TBE_STYLES']['stylesheet'])       $this->styleSheetFile = $GLOBALS['TBE_STYLES']['stylesheet'];
+               if ($GLOBALS['TBE_STYLES']['stylesheet2'])      $this->styleSheetFile2 = $GLOBALS['TBE_STYLES']['stylesheet2'];
+               if ($GLOBALS['TBE_STYLES']['styleSheetFile_post'])      $this->styleSheetFile_post = $GLOBALS['TBE_STYLES']['styleSheetFile_post'];
+               if ($GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'])     $this->inDocStyles_TBEstyle = $GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'];
 
                        // include all stylesheets
                foreach ($this->getSkinStylesheetDirectories() as $stylesheetDirectory) {
@@ -304,9 +204,21 @@ class template {
                }
 
                        // Background image
-               if ($TBE_STYLES['background'])  $this->backGroundImage = $TBE_STYLES['background'];
+               if ($GLOBALS['TBE_STYLES']['background'])       $this->backGroundImage = $GLOBALS['TBE_STYLES']['background'];
        }
 
+       /**
+        * Compatibility constructor.
+        *
+        * @deprecated since TYPO3 4.6 and will be removed in TYPO3 4.8. Use __construct() instead.
+        */
+       public function template() {
+               t3lib_div::logDeprecatedFunction();
+                       // Note: we cannot call $this->__construct() here because it would call the derived class constructor and cause recursion
+                       // This code uses official PHP behavior (http://www.php.net/manual/en/language.oop5.basic.php) when $this in the
+                       // statically called non-static method inherits $this from the caller's scope.
+               template::__construct();
+       }
 
        /**
         * Gets instance of PageRenderer
@@ -337,7 +249,14 @@ class template {
 
 
 
-
+   /**
+        * Sets inclusion of StateProvider
+        *
+        * @return void
+        */
+       public function setExtDirectStateProvider() {
+               $this->extDirectStateProvider = TRUE;
+       }
 
 
 
@@ -360,7 +279,7 @@ class template {
         * The link will load the top frame with the parameter "&item" which is the table,uid and listFr arguments imploded by "|": rawurlencode($table.'|'.$uid.'|'.$listFr)
         *
         * @param       string          String to be wrapped in link, typ. image tag.
-        * @param       string          Table name/File path. If the icon is for a database record, enter the tablename from $TCA. If a file then enter the absolute filepath
+        * @param       string          Table name/File path. If the icon is for a database record, enter the tablename from $GLOBALS['TCA']. If a file then enter the absolute filepath
         * @param       integer         If icon is for database record this is the UID for the record from $table
         * @param       boolean         Tells the top frame script that the link is coming from a "list" frame which means a frame from within the backend content frame.
         * @param       string          Additional GET parameters for the link to alt_clickmenu.php
@@ -386,13 +305,14 @@ class template {
         * @return      string          HTML string with linked icon(s)
         */
        function viewPageIcon($id,$backPath,$addParams='hspace="3"')    {
-               global $BE_USER;
-               $str = '';
+
                        // If access to Web>List for user, then link to that module.
-               $str .= t3lib_extMgm::createListViewLink(
-                       $id,
-                       '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')),
-                       $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', TRUE)
+               $str = t3lib_BEfunc::getListViewLink(
+                       array(
+                               'id' => $id,
+                               'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
+                       ),
+                       $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
                );
 
                        // Make link to view page
@@ -413,15 +333,18 @@ class template {
         */
        function issueCommand($params,$rUrl='') {
                $rUrl = $rUrl ? $rUrl : t3lib_div::getIndpEnv('REQUEST_URI');
-               return $this->backPath.'tce_db.php?'.
-                               $params.
-                               '&redirect='.($rUrl==-1?"'+T3_THIS_LOCATION+'":rawurlencode($rUrl)).
-                               '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()).
+               $commandUrl = $this->backPath.'tce_db.php?' .
+                               $params .
+                               '&redirect=' . ($rUrl==-1 ? "'+T3_THIS_LOCATION+'" : rawurlencode($rUrl)) .
+                               '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()) .
+                               t3lib_BEfunc::getUrlToken('tceAction') .
                                '&prErr=1&uPT=1';
+
+               return $commandUrl;
        }
 
        /**
-        * Returns true if click-menu layers can be displayed for the current user/browser
+        * Returns TRUE if click-menu layers can be displayed for the current user/browser
         * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
         *
         * @return      boolean
@@ -463,15 +386,14 @@ class template {
         * @param       string          Table name
         * @param       array           Record row
         * @param       string          Alt text
-        * @param       boolean         Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
+        * @param       boolean         Set $noViewPageIcon TRUE if you don't want a magnifier-icon for viewing the page in the frontend
         * @param       array           $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
         * @return      string          HTML content
         */
        function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))     {
-               global $TCA;
                if (is_array($row) && $row['uid'])      {
                        $iconImgTag=t3lib_iconWorks::getSpriteIconForRecord($table, $row , array('title' => htmlspecialchars($path)));
-                       $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
+                       $title = strip_tags(t3lib_BEfunc::getRecordTitle($table, $row));
                        $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'');
                        if ($table=='pages')    $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
                } else {
@@ -748,9 +670,10 @@ class template {
                                $headerStart = '<!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
-                               // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
-                       case 'html_5':
+                               break;
+                       case 'html5':
                        default:
+                                       // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
                                $headerStart = '<!DOCTYPE html>' . LF;
                                $htmlTag = '<html>';
                                // disable rendering of XHTML tags
@@ -781,7 +704,7 @@ class template {
                $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
 
                        // Add the XML prologue for XHTML doctypes
-               if (strpos($this->doctype, 'xhtml') !== FALSE) {
+               if (strpos($this->docType, 'xhtml') !== FALSE) {
                                // Put the XML prologue before or after the doctype declaration according to browser
                        if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
                                $headerStart = $headerStart . LF . $xmlPrologue;
@@ -807,6 +730,9 @@ class template {
                // add docstyles
                $this->docStyle();
 
+          if ($this->extDirectStateProvider) {
+                       $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ExtDirect.StateProvider.js');
+               }
 
                        // add jsCode for overriding the console with a debug panel connection
                $this->pageRenderer->addJsInlineCode(
@@ -822,7 +748,7 @@ class template {
                                                                info: Ext.log,
                                                                warn: Ext.log,
                                                                error: Ext.log
-                                                       }
+                                                       };
                                                }
                                        }
                                });
@@ -905,12 +831,11 @@ $str.=$this->docBodyTagBegin().
 
 <!-- Wrapping DIV-section for whole page END -->
 </div>':'') . $this->endOfPageJsBlock ;
-
                }
 
 
                        // Logging: Can't find better place to put it:
-               if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session', 'template', 0, array('_FLUSH' => true));
+               if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session', 'template', 0, array('_FLUSH' => TRUE));
 
                return $str;
        }
@@ -1033,7 +958,7 @@ $str.=$this->docBodyTagBegin().
 
        /**
         * Begins an output section.
-        * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
+        * Returns the <div>-begin tag AND sets the ->sectionFlag TRUE (if the ->sectionFlag is not already set!)
         * You can call this function even if a section is already begun since the function will only return something if the sectionFlag is not already set!
         *
         * @return      string          HTML content
@@ -1072,20 +997,8 @@ $str.=$this->docBodyTagBegin().
        }
 
        /**
-        * Originally it printed a kind of divider.
-        * Deprecated. Just remove function calls to it or call the divider() function instead.
-        *
-        * @return      void
-        * @internal
-        * @deprecated since TYPO3 3.6, will be removed in TYPO3 4.6
-        */
-       function middle()       {
-               t3lib_div::logDeprecatedFunction();
-       }
-
-       /**
         * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
-        * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
+        * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to FALSE)
         *
         * @return      string          HTML content (<script> tag section)
         */
@@ -1222,7 +1135,7 @@ $str.=$this->docBodyTagBegin().
                                $skinStylesheetDirs = $this->stylesheetsSkins;
 
                                        // skins can add custom stylesheetDirectories using
-                                       // $TBE_STYLES['skins'][$_EXTKEY]['stylesheetDirectories']
+                                       // $GLOBALS['TBE_STYLES']['skins'][$_EXTKEY]['stylesheetDirectories']
                                if (is_array($skin['stylesheetDirectories'])) {
                                        $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']);
                                }
@@ -1265,7 +1178,7 @@ $str.=$this->docBodyTagBegin().
         * @return      string          <meta> tag with name "generator"
         */
        function generator()    {
-               $str = 'TYPO3 '.TYPO3_branch.', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2009, extensions are copyright of their respective owners.';
+               $str = 'TYPO3 '.TYPO3_branch.', ' . TYPO3_URL_GENERAL . ', &#169; Kasper Sk&#229;rh&#248;j 1998-2009, extensions are copyright of their respective owners.';
                return '<meta name="generator" content="'.$str .'" />';
        }
 
@@ -1518,28 +1431,37 @@ $str.=$this->docBodyTagBegin().
         * @return      string          <select> tag with content - a selector box for clearing the cache
         */
        function clearCacheMenu($id,$addSaveOptions=0)  {
-               global $BE_USER;
                $opt=array();
                if ($addSaveOptions)    {
                        $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
                        $opt[]='<option value="TBE_EDITOR.checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
                        $opt[]='<option value="document.editform.closeDoc.value=-2; TBE_EDITOR.checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'</option>';
-                       if ($BE_USER->uc['allSaveFunctions'])   $opt[]='<option value="document.editform.closeDoc.value=-3; TBE_EDITOR.checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseAllDocs',1).'</option>';
+                       if ($GLOBALS['BE_USER']->uc['allSaveFunctions']) {
+                               $opt[] = '<option value="document.editform.closeDoc.value=-3; TBE_EDITOR.checkAndDoSubmit(1);">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseAllDocs', 1) . '</option>';
+                       }
                        $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
                        $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
                        $opt[]='<option value=""></option>';
                }
                $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
                if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
-               if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.clearCache.pages')) $opt[]='<option value="pages">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_pages',1).'</option>';
-               if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.clearCache.all')) $opt[]='<option value="all">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all',1).'</option>';
+               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.pages')) {
+                       $opt[] = '<option value="pages">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_pages', 1) . '</option>';
+               }
+               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.clearCache.all')) {
+                       $opt[] = '<option value="all">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all', 1) . '</option>';
+               }
 
                $onChange = 'if (!this.options[this.selectedIndex].value) {
                                this.selectedIndex=0;
                        } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
                                eval(this.options[this.selectedIndex].value);
-                       }else{
-                               window.location.href=\''.$this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
+                       } else {
+                               window.location.href=\'' . $this->backPath .
+                                               'tce_db.php?vC=' . $GLOBALS['BE_USER']->veriCode() .
+                                               t3lib_BEfunc::getUrlToken('tceAction') .
+                                               '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) .
+                                               '&cacheCmd=\'+this.options[this.selectedIndex].value;
                        }';
                $af_content = '<select name="cacheCmd" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
 
@@ -1612,7 +1534,6 @@ $str.=$this->docBodyTagBegin().
        protected function loadCshJavascript() {
                $this->pageRenderer->loadExtJS();
                $this->pageRenderer->addJsFile($this->backPath .'../t3lib/js/extjs/contexthelp.js');
-               $this->pageRenderer->addJsFile($this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.CSH', NULL, FALSE);
                $this->pageRenderer->addExtDirectCode();
        }
 
@@ -1873,13 +1794,11 @@ $str.=$this->docBodyTagBegin().
         * The return value is not needed anymore
         *
         * @deprecated since TYPO3 4.5, as the getDynTabMenu() function includes the function automatically since TYPO3 4.3
-        * @return      string          JavaScript section for the HTML header. (return value is deprecated since TYPO3 4.3, will be removed in TYPO3 4.5)
+        * @return      void
         */
-       function getDynTabMenuJScode()  {
+       function getDynTabMenuJScode() {
                t3lib_div::logDeprecatedFunction();
                $this->loadJavascriptLib('js/tabmenu.js');
-               // return value deprecated since TYPO3 4.3
-               return '';
        }
 
        /**
@@ -1913,14 +1832,14 @@ $str.=$this->docBodyTagBegin().
                }
                if (t3lib_div::isFirstPartOfStr($filename, 'EXT:')) {
                        $filename = t3lib_div::getFileAbsFileName($filename, TRUE, TRUE);
-               } else if (!t3lib_div::isAbsPath($filename)) {
+               } elseif (!t3lib_div::isAbsPath($filename)) {
                        $filename = t3lib_div::resolveBackPath($this->backPath . $filename);
-               } else if (!t3lib_div::isAllowedAbsPath($filename)) {
+               } elseif (!t3lib_div::isAllowedAbsPath($filename)) {
                        $filename = '';
                }
                $htmlTemplate = '';
                if ($filename !== '') {
-                       $htmlTemplate = t3lib_div::getURL($filename);
+                       $htmlTemplate = t3lib_div::getUrl($filename);
                }
                return $htmlTemplate;
        }
@@ -1951,20 +1870,6 @@ $str.=$this->docBodyTagBegin().
                $moduleBody = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###FULLDOC###');
                        // Add CSS
                $this->inDocStylesArray[] = 'html { overflow: hidden; }';
-                       // Add JS code to the <head> for IE
-               $this->JScode.= $this->wrapScriptTags('
-                               // workaround since IE6 cannot deal with relative height for scrolling elements
-                       function resizeDocBody()        {
-                               $("typo3-docbody").style.height = (document.body.offsetHeight - parseInt($("typo3-docheader").getStyle("height")));
-                       }
-                       if (Prototype.Browser.IE) {
-                               var version = parseFloat(navigator.appVersion.split(\';\')[1].strip().split(\' \')[1]);
-                               if (version == 6) {
-                                       Event.observe(window, "resize", resizeDocBody, false);
-                                       Event.observe(window, "load", resizeDocBody, false);
-                               }
-                       }
-               ');
 
                        // Get the page path for the docheader
                $markerArray['PAGEPATH'] = $this->getPagePath($pageRecord);
@@ -2030,7 +1935,7 @@ $str.=$this->docBodyTagBegin().
                                // Get the template for each float
                        $buttonTemplate = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
                                // Fill the button markers in this float
-                       $buttonTemplate = t3lib_parsehtml::substituteMarkerArray($buttonTemplate, $buttons, '###|###', true);
+                       $buttonTemplate = t3lib_parsehtml::substituteMarkerArray($buttonTemplate, $buttons, '###|###', TRUE);
                                // getting the wrap for each group
                        $buttonWrap = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
                                // looping through the groups (max 6) and remove the empty groups
@@ -2104,7 +2009,7 @@ $str.=$this->docBodyTagBegin().
         * @return      string  Page info
         */
        protected function getPageInfo($pageRecord) {
-               global $BE_USER;
+
                                // Add icon with clickmenu, etc:
                if ($pageRecord['uid']) {       // If there IS a real page
                        $alttext = t3lib_BEfunc::getRecordIconAltText($pageRecord, 'pages');
@@ -2116,7 +2021,7 @@ $str.=$this->docBodyTagBegin().
                } else {        // On root-level of page tree
                                // Make Icon
                        $iconImg = t3lib_iconWorks::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])));
-                       if($BE_USER->user['admin']) {
+                       if ($GLOBALS['BE_USER']->user['admin']) {
                                $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', 0);
                        } else {
                                $theIcon = $iconImg;
@@ -2130,11 +2035,73 @@ $str.=$this->docBodyTagBegin().
                return $pageInfo;
        }
 
+       /**
+        * Makes a collapseable section. See reports module for an example
+        *
+        * @param  string  $title
+        * @param  string  $html
+        * @param  string  $id
+        * @param  string $saveStatePointer
+        * @return string
+        */
+       public function collapseableSection($title, $html, $id, $saveStatePointer = '') {
+               $hasSave = $saveStatePointer ? TRUE : FALSE;
+               $collapsedStyle =  $collapsedClass = '';
 
+               if ($hasSave) {
+                       /** @var $settings extDirect_DataProvider_BackendUserSettings */
+                       $settings = t3lib_div::makeInstance('extDirect_DataProvider_BackendUserSettings');
+                       $value = $settings->get($saveStatePointer . '.' . $id);
+                       if ($value) {
+                               $collapsedStyle = ' style="display: none"';
+                               $collapsedClass = ' collapsed';
+                       } else {
+                               $collapsedStyle = '';
+                               $collapsedClass = ' expanded';
+                       }
+               }
 
+               $this->pageRenderer->loadExtJS();
+               $this->pageRenderer->addExtOnReadyCode('
+                       Ext.select("h2.section-header").each(function(element){
+                               element.on("click", function(event, tag) {
+                                       var state = 0,
+                                               el = Ext.fly(tag),
+                                               div = el.next("div"),
+                                               saveKey = el.getAttribute("rel");
+                                       if (el.hasClass("collapsed")) {
+                                               el.removeClass("collapsed").addClass("expanded");
+                                               div.slideIn("t", {
+                                                       easing: "easeIn",
+                                                       duration: .5
+                                               });
+                                       } else {
+                                               el.removeClass("expanded").addClass("collapsed");
+                                               div.slideOut("t", {
+                                                       easing: "easeOut",
+                                                       duration: .5,
+                                                       remove: false,
+                                                       useDisplay: true
+                                               });
+                                               state = 1;
+                                       }
+                                       if (saveKey) {
+                                               try {
+                                                       top.TYPO3.BackendUserSettings.ExtDirect.set(saveKey + "." + tag.id, state, function(response) {});
+                                               } catch(e) {}
+                                       }
+                               });
+                       });
+               ');
+               return '
+                 <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2>
+                 <div' . $collapsedStyle  . '>' . $html . '</div>
+               ';
 
+       }
 
-               }
+
+}
 
 
 // ******************************