* Raising Extbase and Fluid version numbers to 0.9.12
[Packages/TYPO3.CMS.git] / typo3 / alt_main.php
old mode 100755 (executable)
new mode 100644 (file)
index f80bbd8..651df5e
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Main frameset of the TYPO3 backend
  * Sending the GET var "alt_main.php?edit=[page id]" will load the page id in the editing module configured.
  *
+ *
+ *    IMPORTANT!
+ *
+ *    This file is deprecated since TYPO3 4.2 and will be removed with TYPO3 4.4
+ *
+ *
+ *
+ *
+ *
  * $Id$
  * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
  * XHTML Compliant (almost)
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   67: class SC_alt_main
- *   86:     function init()
- *  108:     function generateJScode()
- *  305:     function main()
- *  379:     function printContent()
+ *   72: class SC_alt_main
+ *   91:     function init()
+ *  113:     function generateJScode()
+ *  386:     function editPageHandling()
+ *  437:     function startModule()
+ *  459:     function main()
+ *  533:     function printContent()
  *
- * TOTAL FUNCTIONS: 4
+ * TOTAL FUNCTIONS: 6
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
 require ('init.php');
 require ('template.php');
-require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
-require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
 require_once ('class.alt_menu_functions.inc');
 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
 
 
 
+
 /**
  * Script Class for rendering of the main frameset for the TYPO3 backend.
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -71,7 +81,19 @@ class SC_alt_main {
                // Internal, dynamic:
        var $content;
        var $mainJScode;
+
+       /**
+        * Object for backend modules, load modules-object
+        *
+        * @var t3lib_loadModules
+        */
        var $loadModules;               // Load modules-object
+
+       /**
+        * Menu functions object
+        *
+        * @var alt_menu_functions
+        */
        var $alt_menuObj;               // Menu functions object.
 
                // Internal, static:
@@ -92,12 +114,12 @@ class SC_alt_main {
                $this->loadModules = t3lib_div::makeInstance('t3lib_loadModules');
                $this->loadModules->load($TBE_MODULES);
 
-                       // Instantiates thee menu object which will generate some JavaScript for the goToModule() JS function in this frameset.
+                       // Instantiates the menu object which will generate some JavaScript for the goToModule() JS function in this frameset.
                $this->alt_menuObj = t3lib_div::makeInstance('alt_menu_functions');
 
                        // Check for distances defined in the styles array:
                if ($TBE_STYLES['dims']['leftMenuFrameW'])              $this->leftMenuFrameW = $TBE_STYLES['dims']['leftMenuFrameW'];
-               if ($TBE_STYLES['dims']['topFrameH'])           $this->topFrameH = $TBE_STYLES['dims']['topFrameH'];
+               if ($TBE_STYLES['dims']['topFrameH'])                   $this->topFrameH = $TBE_STYLES['dims']['topFrameH'];
                if ($TBE_STYLES['dims']['shortcutFrameH'])              $this->shortcutFrameH = $TBE_STYLES['dims']['shortcutFrameH'];
                if ($TBE_STYLES['dims']['selMenuFrame'])                $this->selMenuFrame = $TBE_STYLES['dims']['selMenuFrame'];
        }
@@ -110,7 +132,7 @@ class SC_alt_main {
        function generateJScode()       {
                global $BE_USER,$LANG;
 
-               $pt3=t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
+               $pt3 = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
                $goToModule_switch = $this->alt_menuObj->topMenu($this->loadModules->modules,0,"",4);
                $fsMod = implode(chr(10),$this->alt_menuObj->fsMod);
 
@@ -118,6 +140,11 @@ class SC_alt_main {
                $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
                $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
 
+               $menuFrameName = 'menu';
+               if ($GLOBALS['BE_USER']->uc['noMenuMode'] === 'icons') {
+                       $menuFrameName = 'topmenuFrame';
+               }
+
                $this->mainJScode='
        /**
         * Function similar to PHPs  rawurlencode();
@@ -155,7 +182,8 @@ class SC_alt_main {
         */
        function typoSetup()    {       //
                this.PATH_typo3 = "'.$pt3.'";
-               this.username = "'.$BE_USER->user['username'].'";
+               this.PATH_typo3_enc = "'.rawurlencode($pt3).'";
+               this.username = "'.htmlspecialchars($BE_USER->user['username']).'";
                this.uniqueID = "'.t3lib_div::shortMD5(uniqid('')).'";
                this.navFrameWidth = 0;
        }
@@ -170,6 +198,7 @@ class SC_alt_main {
                this.openRefreshWindow = busy_OpenRefreshWindow;
                this.busyloadTime=0;
                this.openRefreshW=0;
+               this.reloginCancelled=0;
        }
        function busy_loginRefreshed()  {       //
                var date = new Date();
@@ -179,20 +208,21 @@ class SC_alt_main {
        function busy_checkLoginTimeout()       {       //
                var date = new Date();
                var theTime = Math.floor(date.getTime()/1000);
-               if (theTime > this.busyloadTime+'.intval($BE_USER->auth_timeout_field).'-10)    {
+               if (theTime > this.busyloadTime+'.intval($BE_USER->auth_timeout_field).'-30)    {
                        return true;
                }
        }
        function busy_OpenRefreshWindow()       {       //
-               vHWin=window.open("login_frameset.php","relogin","height=350,width=700,status=0,menubar=0");
+               vHWin=window.open("login_frameset.php","relogin_"+TS.uniqueID,"height=350,width=700,status=0,menubar=0,location=1");
                vHWin.focus();
                this.openRefreshW=1;
        }
        function busy_checkLoginTimeout_timer() {       //
-
-               if (busy.checkLoginTimeout())   {
-                       if (!busy.openRefreshW && confirm('.$GLOBALS['LANG']->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login')).'))   {
+               if (busy.checkLoginTimeout() && !busy.reloginCancelled && !busy.openRefreshW)   {
+                       if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login')).')) {
                                busy.openRefreshWindow();
+                       } else  {
+                               busy.reloginCancelled = 1;
                        }
                }
                window.setTimeout("busy_checkLoginTimeout_timer();",2*1000);    // Each 2nd second is enough for checking. The popup will be triggered 10 seconds before the login expires (see above, busy_checkLoginTimeout())
@@ -209,7 +239,7 @@ class SC_alt_main {
        function launchView(table,uid,bP)       {       //
                var backPath= bP ? bP : "";
                var thePreviewWindow="";
-               thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+escape(table)+"&uid="+escape(uid),"ShowItem"+TS.uniqueID,"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
+               thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=400,width=550,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
                if (thePreviewWindow && thePreviewWindow.focus) {
                        thePreviewWindow.focus();
                }
@@ -234,7 +264,7 @@ class SC_alt_main {
        /**
         * Loads a page id for editing in the page edit module:
         */
-       function loadEditId(id) {       //
+       function loadEditId(id,addGetVars)      {       //
                top.fsMod.recentIds["web"]=id;
                top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_0";         // For highlighting
 
@@ -242,7 +272,7 @@ class SC_alt_main {
                        top.content.nav_frame.refresh_nav();
                }
 
-               top.goToModule("'.$pageModule.'");
+               top.goToModule("'.$pageModule.'", 0, addGetVars?addGetVars:"");
        }
 
        /**
@@ -287,7 +317,9 @@ class SC_alt_main {
         */
        var currentlyHighLightedId = "";
        var currentlyHighLighted_restoreValue = "";
-       function highlightModuleMenuItem(trId, mainModule)      {
+       var currentlyHighLightedMain = "";
+       function highlightModuleMenuItem(trId, mainModule)      {       //
+               currentlyHighLightedMain = mainModule;
                        // Get document object:
                if (top.menu && top.menu.document)      {
                        var docObj = top.menu.document;
@@ -313,20 +345,35 @@ class SC_alt_main {
        }
 
        /**
-        * Function used to switch switch module.
+        * Function restoring previous selection in left menu after clearing cache
         */
-       var currentModuleLoaded = "";
-       function goToModule(modName,cMR_flag)   {       //
-               var cMR = 0;
-               if (cMR_flag)   cMR = 1;
-
-               currentModuleLoaded = modName;
+       function restoreHighlightedModuleMenuItem() {   //
+               if (currentlyHighLightedId) {
+                       highlightModuleMenuItem(currentlyHighLightedId,currentlyHighLightedMain);
+               }
+       }
 
-               switch(modName) {'.$goToModule_switch.'
+       /**
+        * Wrapper for the actual goToModule function in the menu frame
+        */
+       var currentModuleLoaded = "";
+       function goToModule(modName, cMR_flag, addGetVars)      {       //
+               if (top.'.$menuFrameName.' && top.'.$menuFrameName.'.goToModule) {
+                       currentModuleLoaded = modName;
+                       top.'.$menuFrameName.'.goToModule(modName, cMR_flag, addGetVars);
+               } else {
+                       window.setTimeout(function() { top.goToModule(modName, cMR_flag, addGetVars); }, 500);
                }
        }
 
        /**
+        * reloads the menu frame
+        */
+       function refreshMenu() {
+               top.'.$menuFrameName.'.location.href = top.'.$menuFrameName.'.document.URL
+       }
+
+       /**
         * Frameset Module object
         *
         * Used in main modules with a frameset for submodules to keep the ID between modules
@@ -338,6 +385,7 @@ class SC_alt_main {
                this.recentIds=new Array();                                     // used by frameset modules to track the most recent used id for list frame.
                this.navFrameHighlightedID=new Array();         // used by navigation frames to track which row id was highlighted last time
                this.currentMainLoaded="";
+               this.currentBank="0";
        }
        var fsMod = new fsModules();
        '.$fsMod.'
@@ -346,17 +394,21 @@ class SC_alt_main {
        var condensedMode = '.($BE_USER->uc['condensedMode']?1:0).';
        var currentSubScript = "";
        var currentSubNavScript = "";
+
+               // Used for tab-panels:
+       var DTM_currentTabs = new Array();
                ';
 
                        // Check editing of page:
                $this->editPageHandling();
+               $this->startModule();
        }
 
        /**
         * Checking if the "&edit" variable was sent so we can open for editing the page.
         * Code based on code from "alt_shortcut.php"
         *
-        * @return void
+        * @return      void
         */
        function editPageHandling()     {
                global $BE_USER;
@@ -364,7 +416,7 @@ class SC_alt_main {
                if (!t3lib_extMgm::isLoaded('cms'))     return;
 
                        // EDIT page:
-               $editId = ereg_replace('[^[:alnum:]_]','',t3lib_div::_GET('edit'));
+               $editId = preg_replace('/[^[:alnum:]_]/','',t3lib_div::_GET('edit'));
                $theEditRec = '';
 
                if ($editId)    {
@@ -372,12 +424,13 @@ class SC_alt_main {
                                // Looking up the page to edit, checking permissions:
                        $where = ' AND ('.$BE_USER->getPagePermsClause(2).' OR '.$BE_USER->getPagePermsClause(16).')';
                        if (t3lib_div::testInt($editId))        {
-                               $theEditRec = t3lib_BEfunc::getRecord('pages',$editId,'*',$where);
+                               $theEditRec = t3lib_BEfunc::getRecordWSOL('pages',$editId,'*',$where);
                        } else {
                                $records = t3lib_BEfunc::getRecordsByField('pages','alias',$editId,$where);
                                if (is_array($records)) {
                                        reset($records);
                                        $theEditRec = current($records);
+                                       t3lib_BEfunc::workspaceOL('pages', $theEditRec);
                                }
                        }
 
@@ -404,12 +457,39 @@ class SC_alt_main {
        }
 
        /**
+        * Sets the startup module from either GETvars module and mpdParams or user configuration.
+        *
+        * @return      void
+        */
+       function startModule() {
+               global $BE_USER;
+               $module = preg_replace('/[^[:alnum:]_]/','',t3lib_div::_GET('module'));
+
+               if (!$module)   {
+                       if ($BE_USER->uc['startModule'])        {
+                               $module = $BE_USER->uc['startModule'];
+                       } elseif ($BE_USER->uc['startInTaskCenter'])    {
+                               $module = 'user_task';
+                       }
+               }
+
+               $params = t3lib_div::_GET('modParams');
+               if ($module) {
+                       $this->mainJScode.='
+               // open in module:
+       top.goToModule(\''.$module.'\',false,'.t3lib_div::quoteJSvalue($params).');
+                       ';
+               }
+       }
+
+
+       /**
         * Creates the header and frameset of the backend interface
         *
         * @return      void
         */
        function main() {
-               global $BE_USER,$TYPO3_CONF_VARS,$TYPO_VERSION;
+               global $BE_USER,$TYPO3_CONF_VARS;
 
                        // Set doktype:
                $GLOBALS['TBE_TEMPLATE']->docType='xhtml_frames';
@@ -418,18 +498,19 @@ class SC_alt_main {
                $this->generateJScode();
                $GLOBALS['TBE_TEMPLATE']->JScode= '
                        <script type="text/javascript" src="md5.js"></script>
-                       <script type="text/javascript" src="t3lib/jsfunc.evalfield.js"></script>
+                       <script type="text/javascript" src="../t3lib/jsfunc.evalfield.js"></script>
+                       <script type="text/javascript" src="js/backend.js"></script>
                        ';
                $GLOBALS['TBE_TEMPLATE']->JScode.=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->mainJScode);
 
                        // Title:
-               $title = $TYPO3_CONF_VARS['SYS']['sitename'] ? $TYPO3_CONF_VARS['SYS']['sitename'].' [TYPO3 '.$TYPO_VERSION.']' : 'TYPO3 '.$TYPO_VERSION;
+               $title = $TYPO3_CONF_VARS['SYS']['sitename'] ? $TYPO3_CONF_VARS['SYS']['sitename'].' [TYPO3 '.TYPO3_version.']' : 'TYPO3 '.TYPO3_version;
 
                        // Start page header:
                $this->content.=$GLOBALS['TBE_TEMPLATE']->startPage($title);
 
                        // Creates frameset
-               $fr_content = '<frame name="content" src="'.($BE_USER->uc['startInTaskCenter']&&t3lib_extMgm::isLoaded('taskcenter')?t3lib_extMgm::extRelPath('taskcenter').'task/frameset.php':'alt_intro.php').'" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />';
+               $fr_content = '<frame name="content" src="alt_intro.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize" />';
                $fr_toplogo = '<frame name="toplogo" src="alt_toplogo.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
                $fr_topmenu = '<frame name="topmenuFrame" src="alt_topmenu_dummy.php" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" noresize="noresize" />';
 
@@ -487,21 +568,13 @@ class SC_alt_main {
        }
 }
 
-// Include extension?
+
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php'])     {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_main.php']);
 }
 
 
 
-
-
-
-
-
-
-
-
 // ******************************
 // Starting document output
 // ******************************
@@ -511,4 +584,5 @@ $SOBE = t3lib_div::makeInstance('SC_alt_main');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>
\ No newline at end of file