Fixed bug #7896: Hide the page browser if not enough entries are available (Thanks...
[Packages/TYPO3.CMS.git] / typo3 / alt_doc.php
old mode 100755 (executable)
new mode 100644 (file)
index 7d56d58..4541eae
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@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
  *
  *
  *
- *   94: class SC_alt_doc
- *  167:     function preInit()
- *  219:     function doProcessData()
- *  229:     function processData()
- *  346:     function init()
- *  432:     function main()
- *  500:     function printContent()
+ *  105: class SC_alt_doc
+ *  179:     function preInit()
+ *  241:     function doProcessData()
+ *  251:     function processData()
+ *  379:     function init()
+ *  473:     function main()
+ *  551:     function printContent()
  *
  *              SECTION: Sub-content functions, rendering specific parts of the module content.
- *  535:     function makeEditForm()
- *  717:     function makeButtonPanel()
- *  796:     function makeDocSel()
- *  838:     function makeCmenu()
- *  859:     function compileForm($panel,$docSel,$cMenu,$editForm)
- *  921:     function functionMenus()
- *  952:     function shortCutLink()
- *  983:     function tceformMessages()
+ *  587:     function makeEditForm()
+ *  771:     function makeButtonPanel()
+ *  850:     function makeDocSel()
+ *  892:     function makeCmenu()
+ *  914:     function compileForm($panel,$docSel,$cMenu,$editForm, $langSelector='')
+ *  982:     function functionMenus()
+ * 1013:     function shortCutLink()
+ * 1044:     function tceformMessages()
+ *
+ *              SECTION: Localization stuff
+ * 1083:     function languageSwitch($table, $uid, $pid=NULL)
+ * 1179:     function localizationRedirect($justLocalized)
+ * 1213:     function getLanguages($id)
  *
  *              SECTION: Other functions
- * 1021:     function editRegularContentFromId()
- * 1048:     function compileStoreDat()
- * 1061:     function getNewIconMode($table,$key='saveDocNew')
- * 1074:     function closeDocument($code=0)
- * 1106:     function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php')
+ * 1275:     function fixWSversioningInEditConf($mapArray=FALSE)
+ * 1324:     function getRecordForEdit($table,$theUid)
+ * 1358:     function editRegularContentFromId()
+ * 1386:     function compileStoreDat()
+ * 1399:     function getNewIconMode($table,$key='saveDocNew')
+ * 1412:     function closeDocument($code=0)
+ * 1444:     function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php')
  *
- * TOTAL FUNCTIONS: 19
+ * TOTAL FUNCTIONS: 24
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
@@ -74,9 +81,6 @@
 require('init.php');
 require('template.php');
 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml');
-require_once (PATH_t3lib.'class.t3lib_tceforms.php');
-require_once (PATH_t3lib.'class.t3lib_clipboard.php');
-
 
 t3lib_BEfunc::lockRecords();
 
@@ -94,7 +98,7 @@ t3lib_BEfunc::lockRecords();
 class SC_alt_doc {
 
                // Internal, static: GPvars:
-       var $editconf;                  // GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg. "&edit[pages][123]=edit". See t3lib_BEfunc::editOnClick(). Value can be seen modified internally.
+       var $editconf;                  // GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg. "&edit[pages][123]=edit". See t3lib_BEfunc::editOnClick(). Value can be seen modified internally (converting NEW keyword to id, workspace/versioning etc).
        var $columnsOnly;               // Commalist of fieldnames to edit. The point is IF you specify this list, only those fields will be rendered in the form. Otherwise all (available) fields in the record is shown according to the types configuration in $TCA
        var $defVals;                   // Default values for fields (array with tablenames, fields etc. as keys). Can be seen modified internally.
        var $overrideVals;              // Array of values to force being set (as hidden fields). Will be set as $this->defVals IF defVals does not exist.
@@ -106,9 +110,9 @@ class SC_alt_doc {
        var $mirror;                    // GPvar (for processing only) : ?
        var $cacheCmd;                  // GPvar (for processing only) : Clear-cache cmd.
        var $redirect;                  // GPvar (for processing only) : Redirect (not used???)
-       var $disableRTE;                // GPvar (for processing only) : If set, the rich text editor is disabled in the forms.
        var $returnNewPageId;   // GPvar (for processing only) : Boolean: If set, then the GET var "&id=" will be added to the retUrl string so that the NEW id of something is returned to the script calling the form.
        var $vC;                                // GPvar (for processing only) : Verification code, internal stuff.
+       var $uc;                                // GPvar : update BE_USER->uc
 
        var $popViewId;                 // GPvar (module) : ID for displaying the page in the frontend (used for SAVE/VIEW operations)
        var $popViewId_addParams;       // GPvar (module) : Additional GET vars for the link, eg. "&L=xxx"
@@ -118,10 +122,17 @@ class SC_alt_doc {
        var $disHelp;                           // Disable help... ?
        var $noView;                            // If set, then no SAVE/VIEW button is printed
        var $returnEditConf;            // If set, the $this->editconf array is returned to the calling script (used by wizard_add.php for instance)
+       var $localizationMode;          // GP var, localization mode for TCEforms (eg. "text")
 
 
                // Internal, static:
-       var $doc;                               // Document template object
+       /**
+        * document template object
+        *
+        * @var mediumDoc
+        */
+       var $doc;
+       var $template;                  // a static HTML template, usually in templates/alt_doc.html
        var $content;                   // Content accumulation
 
        var $retUrl;                    // Return URL script, processed. This contains the script (if any) that we should RETURN TO from the alt_doc.php script IF we press the close button. Thus this variable is normally passed along from the calling script so we can properly return if needed.
@@ -146,7 +157,13 @@ class SC_alt_doc {
        var $viewId;                    // Is set to the pid value of the last shown record - thus indicating which page to show when clicking the SAVE/VIEW button
        var $viewId_addParams;  // Is set to additional parameters (like "&L=xxx") if the record supports it.
        var $modTSconfig;               // Module TSconfig, loaded from main() based on the page id value of viewId
-       var $tceforms;                  // Contains the instance of TCEforms class.
+
+       /**
+        * instance of TCEforms class
+        *
+        * @var t3lib_TCEforms
+        */
+       var $tceforms;
        var $generalPathOfForm; // Contains the root-line path of the currently edited record(s) - for display.
 
 
@@ -167,6 +184,10 @@ class SC_alt_doc {
        function preInit()      {
                global $BE_USER;
 
+               if (t3lib_div::_GP('justLocalized'))    {
+                       $this->localizationRedirect(t3lib_div::_GP('justLocalized'));
+               }
+
                        // Setting GPvars:
                $this->editconf = t3lib_div::_GP('edit');
                $this->defVals = t3lib_div::_GP('defVals');
@@ -176,6 +197,9 @@ class SC_alt_doc {
                $this->closeDoc = t3lib_div::_GP('closeDoc');
                $this->doSave = t3lib_div::_GP('doSave');
                $this->returnEditConf = t3lib_div::_GP('returnEditConf');
+               $this->localizationMode = t3lib_div::_GP('localizationMode');
+               $this->uc = t3lib_div::_GP('uc');
+
 
                        // Setting override values as default if defVals does not exist.
                if (!is_array($this->defVals) && is_array($this->overrideVals)) {
@@ -185,9 +209,13 @@ class SC_alt_doc {
                        // Setting return URL
                $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php';
 
+                       // Fix $this->editconf if versioning applies to any of the records
+               $this->fixWSversioningInEditConf();
+
                        // Make R_URL (request url) based on input GETvars:
                $this->R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
                $this->R_URL_getvars = t3lib_div::_GET();
+               $this->R_URL_getvars['edit'] = $this->editconf;
 
                        // MAKE url for storing
                $this->compileStoreDat();
@@ -211,16 +239,18 @@ class SC_alt_doc {
                }
        }
 
+
        /**
         * Detects, if a save command has been triggered.
         *
         * @return      boolean         True, then save the document (data submitted)
         */
        function doProcessData()        {
-               $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']);
+               $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']) || isset($_POST['_translation_savedok_x']) || isset($_POST['_translation_savedokclear_x']);
                return $out;
        }
 
+
        /**
         * Do processing of data, submitting it to TCEmain.
         *
@@ -231,10 +261,10 @@ class SC_alt_doc {
 
                        // GPvars specifically for processing:
                $this->data = t3lib_div::_GP('data');
+               $this->cmd = t3lib_div::_GP('cmd');
                $this->mirror = t3lib_div::_GP('mirror');
                $this->cacheCmd = t3lib_div::_GP('cacheCmd');
                $this->redirect = t3lib_div::_GP('redirect');
-               $this->disableRTE = t3lib_div::_GP('_disableRTE');
                $this->returnNewPageId = t3lib_div::_GP('returnNewPageId');
                $this->vC = t3lib_div::_GP('vC');
 
@@ -243,6 +273,14 @@ class SC_alt_doc {
                $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                $tce->stripslashes_values=0;
 
+               if (isset($_POST['_translation_savedok_x']))    {
+                       $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
+               }
+               if (isset($_POST['_translation_savedokclear_x']))       {
+                       $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
+                       $tce->updateModeL10NdiffDataClear = TRUE;
+               }
+
                        // Setting default values specific for the user:
                $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
                if (is_array($TCAdefaultOverride))      {
@@ -250,17 +288,21 @@ class SC_alt_doc {
                }
 
                        // Setting internal vars:
-               if ($BE_USER->uc['neverHideAtCopy'])    {       $tce->neverHideAtCopy = 1;      }
+               if ($BE_USER->uc['neverHideAtCopy'])    {
+                       $tce->neverHideAtCopy = 1;
+               }
                $tce->debug=0;
-               $tce->disableRTE = $this->disableRTE;
+               $tce->disableRTE = !$BE_USER->isRTE();
 
                        // Loading TCEmain with data:
-               $tce->start($this->data,array());
-               if (is_array($this->mirror))    {       $tce->setMirror($this->mirror); }
+               $tce->start($this->data,$this->cmd);
+               if (is_array($this->mirror))    {
+                       $tce->setMirror($this->mirror);
+               }
 
                        // If pages are being edited, we set an instruction about updating the page tree after this operation.
                if (isset($this->data['pages']))        {
-                       t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
+                       t3lib_BEfunc::setUpdateSignal('updatePageTree');
                }
 
 
@@ -275,21 +317,44 @@ class SC_alt_doc {
                                // Perform the saving operation with TCEmain:
                        $tce->process_uploads($_FILES);
                        $tce->process_datamap();
+                       $tce->process_cmdmap();
 
                                // If there was saved any new items, load them:
                        if (count($tce->substNEWwithIDs_table)) {
+                                       // save the expanded/collapsed states for new inline records, if any
+                               t3lib_TCEforms_inline::updateInlineView($this->uc, $tce);
+
+                               $newEditConf = array();
+
+                               foreach($this->editconf as $tableName => $tableCmds) {
+                                       $keys = array_keys($tce->substNEWwithIDs_table, $tableName);
+                                       if(count($keys) > 0) {
+                                               foreach($keys as $key) {
+                                                       $editId = $tce->substNEWwithIDs[$key];
+                                                               // check if the $editId isn't a child record of an IRRE action
+                                                       if (!(is_array($tce->newRelatedIDs[$tableName]) && in_array($editId, $tce->newRelatedIDs[$tableName]))) {
+                                                                       // translate new id to the workspace version:
+                                                               if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $tableName, $editId,'uid')) {
+                                                                       $editId = $versionRec['uid'];
+                                                               }
+                                                               $newEditConf[$tableName][$editId] = 'edit';
+                                                       }
 
-                                       // Resetting editconf:
-                               $this->editconf = array();
-
-                                       // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
-                               foreach($tce->substNEWwithIDs_table as $nKey => $nTable)        {
-                                       $this->editconf[$nTable][$tce->substNEWwithIDs[$nKey]]='edit';
-                                       if ($nTable=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId)   {
-                                               $this->retUrl.='&id='.$tce->substNEWwithIDs[$nKey];
+                                                               // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
+                                                       if ($tableName=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId)        {
+                                                               $this->retUrl.='&id='.$tce->substNEWwithIDs[$key];
+                                                       }
+                                               }
+                                       } else {
+                                               $newEditConf[$tableName] = $tableCmds;
                                        }
                                }
 
+                                       // Resetting editconf if newEditConf has values:
+                               if (count($newEditConf)) {
+                                       $this->editconf = $newEditConf;
+                               }
+
                                        // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
                                $this->R_URL_getvars['edit']=$this->editconf;
 
@@ -300,6 +365,11 @@ class SC_alt_doc {
                                $this->compileStoreDat();
                        }
 
+                               // See if any records was auto-created as new versions?
+                       if (count($tce->autoVersionIdMap))      {
+                               $this->fixWSversioningInEditConf($tce->autoVersionIdMap);
+                       }
+
                                // If a document is saved and a new one is created right after.
                        if (isset($_POST['_savedoknew_x']) && is_array($this->editconf))        {
 
@@ -328,12 +398,12 @@ class SC_alt_doc {
                        }
 
                        $tce->printLogErrorMessages(
-                               isset($_POST['_saveandclosedok_x']) ?
+                               (isset($_POST['_saveandclosedok_x']) || isset($_POST['_translation_savedok_x'])) ?
                                $this->retUrl :
                                $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars)   // popView will not be invoked here, because the information from the submit button for save/view will be lost .... But does it matter if there is an error anyways?
                        );
                }
-               if (isset($_POST['_saveandclosedok_x']) || $this->closeDoc<0)   {       //  || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED because if not, we just get that element re-listed as new. And we don't want that!
+               if ((isset($_POST['_saveandclosedok_x']) || isset($_POST['_translation_savedok_x'])) || $this->closeDoc<0)      {       //  || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED because if not, we just get that element re-listed as new. And we don't want that!
                        $this->closeDocument(abs($this->closeDoc));
                }
        }
@@ -355,6 +425,8 @@ class SC_alt_doc {
                $this->disHelp = t3lib_div::_GP('disHelp');
                $this->noView = t3lib_div::_GP('noView');
 
+               $this->perms_clause = $BE_USER->getPagePermsClause(1);
+
                        // Set other internal variables:
                $this->R_URL_getvars['returnUrl']=$this->retUrl;
                $this->R_URI = $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars);
@@ -364,9 +436,7 @@ class SC_alt_doc {
                        // If empty string it's just a variable, that'll be saved.
                        // Values NOT in this array will not be saved in the settings-array for the module.
                $this->MOD_MENU = array(
-                       'showPalettes' => '',
-                       'showDescriptions' => '',
-                       'disableRTE' => ''
+                       'showPalettes' => ''
                );
 
                        // Setting virtual document name
@@ -376,26 +446,27 @@ class SC_alt_doc {
                $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
 
                        // Create an instance of the document template object
-               $this->doc = t3lib_div::makeInstance('mediumDoc');
-               $this->doc->bodyTagMargins['x']=5;
-               $this->doc->bodyTagMargins['y']=5;
+               $this->doc = $GLOBALS['TBE_TEMPLATE'];
                $this->doc->backPath = $BACK_PATH;
-               $this->doc->docType = 'xhtml_trans';
-
-               $this->doc->form='<form action="'.htmlspecialchars($this->R_URI).'" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" name="editform" onsubmit="return TBE_EDITOR_checkSubmit(1);">';
+               $this->doc->setModuleTemplate('templates/alt_doc.html');
+               $this->doc->form = '<form action="'.htmlspecialchars($this->R_URI).'" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" name="editform" onsubmit="document.editform._scrollPosition.value=(document.documentElement.scrollTop || document.body.scrollTop); return TBE_EDITOR.checkSubmit(1);">';
 
+               $this->doc->getPageRenderer()->loadPrototype();
                $this->doc->JScode = $this->doc->wrapScriptTags('
                        function jumpToUrl(URL,formEl)  {       //
-                               if (!TBE_EDITOR_isFormChanged())        {
-                                       document.location = URL;
+                               if (!TBE_EDITOR.isFormChanged())        {
+                                       window.location.href = URL;
                                } else if (formEl && formEl.type=="checkbox") {
                                        formEl.checked = formEl.checked ? 0 : 1;
                                }
                        }
-
                                // Object: TS:
+                               // passwordDummy and decimalSign are used by tbe_editor.js and have to be declared here as
+                               // TS object overwrites the object declared in tbe_editor.js
                        function typoSetup      ()      {       //
                                this.uniqueID = "";
+                               this.passwordDummy = "********";
+                               this.decimalSign = ".";
                        }
                        var TS = new typoSetup();
 
@@ -403,14 +474,16 @@ class SC_alt_doc {
                        function launchView(table,uid,bP)       {       //
                                var backPath= bP ? bP : "";
                                var thePreviewWindow="";
-                               thePreviewWindow = window.open(backPath+"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(backPath+"show_item.php?table="+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
                                if (thePreviewWindow && thePreviewWindow.focus) {
                                        thePreviewWindow.focus();
                                }
                        }
                        function deleteRecord(table,id,url)     {       //
-                               if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).'))      {
-                                       document.location = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
+                               if (
+                                       '.($GLOBALS['BE_USER']->jsConfirmation(4)?'confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')':'1==1').'
+                               )       {
+                                       window.location.href = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
                                }
                                return false;
                        }
@@ -424,10 +497,8 @@ class SC_alt_doc {
                ).$this->doc->getDynTabMenuJScode();
 
                        // Setting up the context sensitive menu:
-               $CMparts = $this->doc->getContextMenuCode();
-               $this->doc->JScode.= $CMparts[0];
-               $this->doc->bodyTagAdditions = $CMparts[1];
-               $this->doc->postCode.= $CMparts[2];
+               $this->doc->getContextMenuCode();
+               $this->doc->bodyTagAdditions = 'onload="window.scrollTo(0,'.t3lib_div::intInRange(t3lib_div::_GP('_scrollPosition'),0,10000).');"';
        }
 
        /**
@@ -438,10 +509,6 @@ class SC_alt_doc {
        function main() {
                global $BE_USER,$LANG;
 
-                       // Starting content accumulation:
-               $this->content='';
-               $this->content.=$this->doc->startPage('TYPO3 Edit Document');
-
                        // Begin edit:
                if (is_array($this->editconf))  {
 
@@ -449,9 +516,10 @@ class SC_alt_doc {
                        $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
                        $this->tceforms->initDefaultBEMode();
                        $this->tceforms->doSaveFieldName = 'doSave';
+                       $this->tceforms->localizationMode = t3lib_div::inList('text,media',$this->localizationMode) ? $this->localizationMode : '';     // text,media is keywords defined in TYPO3 Core API..., see "l10n_cat"
                        $this->tceforms->returnUrl = $this->R_URI;
                        $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
-                       $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
+                       $this->tceforms->disableRTE = !$BE_USER->isRTE();
                        $this->tceforms->enableClickMenu = TRUE;
                        $this->tceforms->enableTabMenu = TRUE;
 
@@ -460,52 +528,66 @@ class SC_alt_doc {
                        $this->tceforms->clipObj->initializeClipboard();        // Initialize - reads the clipboard content from the user session
 
                                // Setting external variables:
-                       if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions'])      $this->tceforms->edit_showFieldHelp='text';
+                       $this->tceforms->edit_showFieldHelp = $BE_USER->uc['edit_showFieldHelp'];
 
                        if ($this->editRegularContentFromId)    {
                                $this->editRegularContentFromId();
                        }
 
+
                                // Creating the editing form, wrap it with buttons, document selector etc.
                        $editForm = $this->makeEditForm();
-                       if ($editForm)  {
-                               reset($this->elementsData);
-                               $this->firstEl = current($this->elementsData);
-
-                               if ($this->viewId)      {
-                                               // Module configuration:
-                                       $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
-                               } else $this->modTSconfig=array();
-
-                               $panel = $this->makeButtonPanel();
-                               $docSel = $this->makeDocSel();
-                               $cMenu = $this->makeCmenu();
 
-                               $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm);
+                       if ($editForm)  {
+                               $this->firstEl = reset($this->elementsData);
 
-                               $this->content.= $this->tceforms->printNeededJSFunctions_top().
-                                                                       $formContent.
-                                                                       $this->tceforms->printNeededJSFunctions();
-                               $this->content.= $this->functionMenus();
+                                       // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
+                               if ((strcmp($this->docDat[1], $this->storeUrlMd5) || !isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
+                                               $this->docHandler[$this->storeUrlMd5] = array($this->storeTitle, $this->storeArray, $this->storeUrl, $this->firstEl);
+                                               $BE_USER->pushModuleData('alt_doc.php', array($this->docHandler, $this->storeUrlMd5));
+                                               t3lib_BEfunc::setUpdateSignal('tx_opendocs::updateNumber', count($this->docHandler));
+                               }
 
-                                       // Add CSH:
-                               $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;');
 
-                               $this->content.= $this->shortCutLink();
+                                       // Module configuration
+                               $this->modTSconfig = ($this->viewId ? t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc') : array());
 
-                               $this->tceformMessages();
+                               $body.= $this->tceforms->printNeededJSFunctions_top();
+                               $body.= $this->compileForm($editForm);
+                               $body.= $this->tceforms->printNeededJSFunctions();
+                               $body.= $this->functionMenus();
+                               $body.= $this->tceformMessages();
                        }
                }
+
+               // Access check...
+               // The page will show only if there is a valid page and if this page may be viewed by the user
+               $this->pageinfo = t3lib_BEfunc::readPageAccess($this->viewId, $this->perms_clause);
+
+                       // Setting up the buttons and markers for docheader
+               $docHeaderButtons = $this->getButtons();
+               $markers = array(
+                       'LANGSELECTOR' => $this->langSelector(),
+                       'EXTRAHEADER' => $this->extraFormHeaders(),
+                       'CSH' => $docHeaderButtons['csh'],
+                       'CONTENT' => $body
+               );
+
+                       // Build the <body> for the module
+               $this->content = $this->doc->startPage('TYPO3 Edit Document');
+               $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
        }
 
+
        /**
         * Outputting the accumulated content to screen
         *
         * @return      void
         */
        function printContent() {
-
-               echo $this->content.$this->doc->endPage();
+               echo $this->content;
        }
 
 
@@ -586,7 +668,8 @@ class SC_alt_doc {
                                                                                $CALC_PERMS = $BE_USER->calcPerms($calcPRec);   // Permissions for the parent page
                                                                                if ($table=='pages')    {       // If pages:
                                                                                        $hasAccess = $CALC_PERMS&8 ? 1 : 0;
-                                                                                       $this->viewId = $calcPRec['pid'];
+                                                                                       #$this->viewId = $calcPRec['pid'];
+                                                                                       $this->viewId = 0;
                                                                                } else {
                                                                                        $hasAccess = $CALC_PERMS&16 ? 1 : 0;
                                                                                        $this->viewId = $calcPRec['uid'];
@@ -631,21 +714,22 @@ class SC_alt_doc {
                                                                $trData->addRawData = TRUE;
                                                                $trData->defVals = $this->defVals;
                                                                $trData->lockRecords=1;
-                                                               $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
+                                                               $trData->disableRTE = !$BE_USER->isRTE();
                                                                $trData->prevPageID = $prevPageID;
                                                                $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':'');      // 'new'
                                                                reset($trData->regTableItems_data);
                                                                $rec = current($trData->regTableItems_data);
-                                                               $rec['uid'] = $cmd=='new'?uniqid('NEW'):$theUid;
+                                                               $rec['uid'] = $cmd=='new' ? uniqid('NEW') : $theUid;
+                                                               if ($cmd=='new')        {
+                                                                       $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
+                                                               }
                                                                $this->elementsData[]=array(
                                                                        'table' => $table,
                                                                        'uid' => $rec['uid'],
+                                                                       'pid' => $rec['pid'],
                                                                        'cmd' => $cmd,
                                                                        'deleteAccess' => $deleteAccess
                                                                );
-                                                               if ($cmd=='new')        {
-                                                                       $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
-                                                               }
 
                                                                        // Now, render the form:
                                                                if (is_array($rec))     {
@@ -653,7 +737,7 @@ class SC_alt_doc {
                                                                                // Setting visual path / title of form:
                                                                        $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
                                                                        if (!$this->storeTitle) {
-                                                                               $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1);
+                                                                               $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,TRUE);
                                                                        }
 
                                                                                // Setting variables in TCEforms object:
@@ -669,7 +753,11 @@ class SC_alt_doc {
                                                                                // Create form for the record (either specific list of fields or the whole record):
                                                                        $panel = '';
                                                                        if ($this->columnsOnly) {
-                                                                               $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
+                                                                               if(is_array($this->columnsOnly)){
+                                                                                       $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly[$table]);
+                                                                               } else {
+                                                                                       $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
+                                                                               }
                                                                        } else {
                                                                                $panel.= $this->tceforms->getMainFields($table,$rec);
                                                                        }
@@ -682,75 +770,90 @@ class SC_alt_doc {
                                                                        }
 
                                                                                // Display "is-locked" message:
-                                                                       if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid']))       {
-                                                                               $lockIcon = '
-
-                                                                                       <!--
-                                                                                               Warning box:
-                                                                                       -->
-                                                                                       <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
-                                                                                               <tr>
-                                                                                                       <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
-                                                                                                       <td>'.htmlspecialchars($lockInfo['msg']).'</td>
-                                                                                               </tr>
-                                                                                       </table>
-                                                                               ';
-                                                                       } else $lockIcon = '';
+                                                                       if ($lockInfo = t3lib_BEfunc::isRecordLocked($table, $rec['uid'])) {
+                                                                               $lockedMessage = t3lib_div::makeInstance(
+                                                                                       't3lib_FlashMessage',
+                                                                                       htmlspecialchars($lockInfo['msg']),
+                                                                                       '',
+                                                                                       t3lib_FlashMessage::WARNING
+                                                                               );
+                                                                               t3lib_FlashMessageQueue::addMessage($lockedMessage);
+                                                                       }
 
                                                                                // Combine it all:
-                                                                       $editForm.= $lockIcon.$panel;
+                                                                       $editForm .= $panel;
                                                                }
 
                                                                $thePrevUid = $rec['uid'];
                                                        } else {
                                                                $this->errorC++;
                                                                $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'.
-                                                                                       ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : '');
+                                                                       ($deniedAccessReason ? 'Reason: ' . htmlspecialchars($deniedAccessReason) . '<br /><br />' : '');
                                                        }
                                                }
                                        }
                                }
                        }
                }
+
                return $editForm;
        }
 
        /**
         * Create the panel of buttons for submitting the form or otherwise perform operations.
         *
-        * @return      string          HTML code, comprised of images linked to various actions.
+        * @return      array   all available buttons as an assoc. array
         */
-       function makeButtonPanel()      {
+       protected function getButtons() {
                global $TCA,$LANG;
-
-               $panel='';
+               $buttons = array(
+                       'save' => '',
+                       'save_view' => '',
+                       'save_new' => '',
+                       'save_close' => '',
+                       'close' => '',
+                       'delete' => '',
+                       'undo' => '',
+                       'history' => '',
+                       'columns_only' => '',
+                       'csh' => '',
+                       'translation_save' => '',
+                       'translation_saveclear' => ''
+               );
 
                        // Render SAVE type buttons:
                        // The action of each button is decided by its name attribute. (See doProcessData())
                if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'])       {
 
                                // SAVE button:
-                       $panel.= '<input type="image" class="c-inputButton" name="_savedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" />';
+                       $buttons['save'] = '<input type="image" class="c-inputButton" name="_savedok" src="' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/savedok.gif', '', 1) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', 1) . '" />';
 
                                // SAVE / VIEW button:
-                       if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
-                               $panel.= '<input type="image" class="c-inputButton" name="_savedokview"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedokshow.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow',1).'" />';
+                       if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms') && $this->getNewIconMode($this->firstEl['table'], 'saveDocView')) {
+                               $buttons['save_view'] = '<input type="image" class="c-inputButton" name="_savedokview" src="' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/savedokshow.gif', '', 1) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow', 1) . '" />';
                        }
 
                                // SAVE / NEW button:
                        if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
-                               $panel.= '<input type="image" class="c-inputButton" name="_savedoknew"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedoknew.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveNewDoc',1).'" />';
+                               $buttons['save_new'] = '<input type="image" class="c-inputButton" name="_savedoknew" src="' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/savedoknew.gif', '', 1) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveNewDoc', 1) . '" />';
                        }
 
                                // SAVE / CLOSE
-                       $panel.= '<input type="image" class="c-inputButton" name="_saveandclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" />';
+                       $buttons['save_close'] = '<input type="image" class="c-inputButton" name="_saveandclosedok" src="' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/saveandclosedok.gif', '', 1) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', 1) . '" />';
+
+                               // FINISH TRANSLATION / SAVE / CLOSE
+                       if ($GLOBALS['TYPO3_CONF_VARS']['BE']['explicitConfirmationOfTranslation'])     {
+                               $buttons['translation_save'] = '<input type="image" class="c-inputButton" name="_translation_savedok" src="' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/translationsavedok.gif', '', 1) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.translationSaveDoc', 1) . '" />';
+                               $buttons['translation_saveclear'] = '<input type="image" class="c-inputButton" name="_translation_savedokclear" src="' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/translationsavedok_clear.gif', '', 1) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.translationSaveDocClear', 1) . '" />';
+                       }
                }
 
                        // CLOSE button:
-               $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
+               $buttons['close'] = '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
                                '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" alt="" />'.
                                '</a>';
 
+
                        // DELETE + UNDO buttons:
                if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1)      {
                        if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid']))  {
@@ -758,163 +861,105 @@ class SC_alt_doc {
                                        // Delete:
                                if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
                                        $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
-                                       $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
+                                       $buttons['delete'] = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
                                                        '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
                                                        '</a>';
                                }
 
                                        // Undo:
-                               $undoButton = 0;
                                $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->firstEl['table'], 'sys_history').' AND recuid='.intval($this->firstEl['uid']), '', 'tstamp DESC', '1');
                                if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes))     {
-                                       $undoButton = 1;
-                               }
-                               if ($undoButton) {
-                                       $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&revert=ALL_FIELDS&sumUp=-1&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
-                                       $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
-                                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/undo.gif','width="21" height="16"').' class="c-inputButton" title="'.htmlspecialchars(sprintf($LANG->getLL('undoLastChange'),t3lib_BEfunc::calcAge(time()-$undoButtonR['tstamp'],$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))).'" alt="" />'.
-                                                       '</a>';
+                                       $aOnClick = 'window.location.href=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&revert=ALL_FIELDS&sumUp=-1&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
+                                       $buttons['undo'] = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
+                                               '<img' .
+                                                       t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/undo.gif', 'width="21" height="16"') .
+                                                       ' class="c-inputButton"' .
+                                                       ' title="' . htmlspecialchars(sprintf($LANG->getLL('undoLastChange'), t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp'], $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) .
+                                                       '" alt="" />' .
+                                               '</a>';
                                }
                                if ($this->getNewIconMode($this->firstEl['table'],'showHistory'))       {
-                                       $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
-                                       $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
+                                       $aOnClick = 'window.location.href=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
+                                       $buttons['history'] = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
                                                        '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
                                                        '</a>';
                                }
 
                                        // If only SOME fields are shown in the form, this will link the user to the FULL form:
                                if ($this->columnsOnly) {
-                                       $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
+                                       $buttons['columns_only'] = '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
                                                        '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
                                                        '</a>';
                                }
                        }
                }
-               return $panel;
+
+                       // add the CSH icon
+               $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'], '', TRUE);
+               $buttons['shortcut'] = $this->shortCutLink();
+               $buttons['open_in_new_window'] = $this->openInNewWindowLink();
+               return $buttons;
        }
 
        /**
-        * Create the selector box form element which allows to select between open documents.
-        * Can be disabled through Page TSconfig.
-        *
-        * @return      string          HTML <select> element  (if applicable)
+        * Returns the language switch/selector for editing,
+        * show only when a single record is edited
+        * - multiple records are too confusing
+        * @return      string          the HTML
         */
-       function makeDocSel()   {
-               global $BE_USER,$LANG;
-
-                       // Render the selector ONLY if it has not been disabled:
-               if (!$this->modTSconfig['properties']['disableDocSelector'])    {
-
-                               // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
-                       if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef)       {
-                               $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
-                               $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
-                       }
-
-                               // Now, create the document selector box:
-                       $docSel='';
-                       if (is_array($this->docHandler))        {
-                               $opt = array();
-                               $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
-
-                                       // Traverse the list of open documents:
-                               foreach($this->docHandler as $md5k => $setupArr)        {
-                                       $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
-                                       $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
-                               }
-
-                                       // Compile the selector box finally:
-                               $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){document.location=(this.options[this.selectedIndex].value);}';
-                               $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
-
-                                       // Add CSH:
-                               $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE);
-                       }
-               } else $docSel='';
-               return $docSel;
+       function langSelector() {
+               $langSelector = '';
+               if (count($this->elementsData) == 1) {
+                       $langSelector = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']);
+               }
+               return $langSelector;
        }
 
+
        /**
-        * Create the selector box form element which allows to select a clear-cache operation.
-        * Can be disabled through Page TSconfig.
+        * Compiles the extra form headers if the tceforms
         *
-        * @return      string          HTML <select> element (if applicable)
-        * @see template::clearCacheMenu()
+        * @return      string          the HTML
         */
-       function makeCmenu()    {
+       function extraFormHeaders() {
+               $extraTemplate = '';
 
-                       // Generate the menu if NOT disabled:
-               if (!$this->modTSconfig['properties']['disableCacheSelector'])  {
-                       $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
-
-                               // Add CSH:
-                       $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE);
-               } else $cMenu ='';
-               return $cMenu;
+               if (is_array($this->tceforms->extraFormHeaders)) {
+                       $extraTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###DOCHEADER_EXTRAHEADER###');
+                       $extraTemplate = t3lib_parsehtml::substituteMarker($extraTemplate, '###EXTRAHEADER###', implode(chr(10), $this->tceforms->extraFormHeaders));
+               }
+               return $extraTemplate;
        }
 
+
        /**
         * Put together the various elements (buttons, selectors, form) into a table
         *
-        * @param       string          The button panel HTML
-        * @param       string          Document selector HTML
-        * @param       string          Clear-cache menu HTML
         * @param       string          HTML form.
         * @return      string          Composite HTML
         */
-       function compileForm($panel,$docSel,$cMenu,$editForm)   {
+       function compileForm($editForm) {
                global $LANG;
 
-
-               $formContent='';
-               $formContent.='
-
-                       <!--
-                               Header of the editing page.
-                               Contains the buttons for saving/closing, the document selector and menu selector.
-                               Shows the path of the editing operation as well.
-                       -->
-                       <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
-                               <tr>
-                                       <td nowrap="nowrap" valign="top">'.$panel.'</td>
-                                       <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
-                               </tr>
-                               <tr>
-                                       <td colspan="2">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</td>
-                               </tr>
-                       </table>
-                       <img src="clear.gif" width="1" height="4" alt="" /><br />
-
-
-
-
-                       <!--
-                               EDITING FORM:
-                       -->
-
+               $formContent = '
+                       <!-- EDITING FORM -->
                        '.$editForm.'
 
-
-
-                       <!--
-                               Saving buttons (same as in top)
-                       -->
-
-                       '.$panel.
-                       '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
+                       <input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
                        <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
 
                if ($this->returnNewPageId)     {
-                       $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
+                       $formContent .= '<input type="hidden" name="returnNewPageId" value="1" />';
                }
-               $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
+               $formContent .= '<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
                if ($this->viewId_addParams) {
-                       $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
+                       $formContent .= '<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
                }
-               $formContent.='<input type="hidden" name="closeDoc" value="0" />';
-               $formContent.='<input type="hidden" name="doSave" value="0" />';
-               $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
-               $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
+               $formContent .= '
+                       <input type="hidden" name="closeDoc" value="0" />
+                       <input type="hidden" name="doSave" value="0" />
+                       <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />
+                       <input type="hidden" name="_scrollPosition" value="" />';
 
                return $formContent;
        }
@@ -925,84 +970,258 @@ class SC_alt_doc {
         * @return      string          HTML for function menus.
         */
        function functionMenus()        {
-               global $BE_USER,$LANG;
-
-               $funcMenus = '';
+               global $LANG;
 
                        // Show palettes:
-               $funcMenus.= '<br /><br />'.t3lib_BEfunc::getFuncCheck('','SET[showPalettes]',$this->MOD_SETTINGS['showPalettes'],'alt_doc.php',t3lib_div::implodeArrayForUrl('',array_merge($this->R_URL_getvars,array('SET'=>'')))).$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1);
-
-                       // Show descriptions/help texts:
-               if ($BE_USER->uc['edit_showFieldHelp']!='text') {
-                       $funcMenus.= '<br />'.t3lib_BEfunc::getFuncCheck('','SET[showDescriptions]',$this->MOD_SETTINGS['showDescriptions'],'alt_doc.php',t3lib_div::implodeArrayForUrl('',array_merge($this->R_URL_getvars,array('SET'=>'')))).$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions',1);
-               }
-
-                       // Show disable RTE checkbox:
-               if ($BE_USER->isRTE())  {
-                       $funcMenus.= '<br />'.t3lib_BEfunc::getFuncCheck('','SET[disableRTE]',$this->MOD_SETTINGS['disableRTE'],'alt_doc.php',t3lib_div::implodeArrayForUrl('',array_merge($this->R_URL_getvars,array('SET'=>'')))).$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE',1);
-               }
-
                return '
-
-                               <!--
-                                       Function menus (checkboxes for selecting options):
-                               -->
-                               '.$funcMenus;
+                               <!-- Function menus (checkboxes for selecting options): -->
+                               <br />'.t3lib_BEfunc::getFuncCheck('','SET[showPalettes]',$this->MOD_SETTINGS['showPalettes'],'alt_doc.php',t3lib_div::implodeArrayForUrl('',array_merge($this->R_URL_getvars,array('SET'=>''))),'id="checkShowPalettes"').'<label for="checkShowPalettes">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1).'</label>';
        }
 
+
        /**
-        * Create shortcut and open-in-window link in the bottom of the page
+        * Create shortcut icon
         *
         * @return      string
         */
        function shortCutLink() {
                global $BE_USER,$LANG;
 
-                       // ShortCut
-               if ($this->returnUrl!='close.html')     {
-                       $content.='<br /><br />';
+               if ($this->returnUrl == 'close.html' || !$BE_USER->mayMakeShortcut()) {
+                       return '';
+               }
+               return $this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
+       }
 
-                               // Shortcut:
-                       if ($BE_USER->mayMakeShortcut())        {
-                               $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
-                       }
 
-                               // Open in new window:
-                       $aOnClick = 'vHWin=window.open(\''.t3lib_div::linkThisScript(array('returnUrl'=>'close.html')).'\',\''.md5($this->R_URI).'\',\''.($BE_USER->uc['edit_wideDocument']?'width=670,height=500':'width=600,height=400').',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
-                       $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
-                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/open_in_new_window.gif','width="19" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.openInNewWindow',1).'" alt="" />'.
-                                       '</a>';
+       /**
+        * Creates open-in-window link
+        *
+        * @return      string
+        */
+       function openInNewWindowLink()  {
+               global $BE_USER, $LANG;
+               if ($this->returnUrl == 'close.html') {
+                       return '';
                }
-               return '
-
-                               <!--
-                                       Shortcut link:
-                               -->
-                               '.$content;
+               $aOnClick = 'vHWin=window.open(\''.t3lib_div::linkThisScript(array('returnUrl'=>'close.html')).'\',\''.md5($this->R_URI).'\',\'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
+               return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
+                               '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/open_in_new_window.gif','width="19" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.openInNewWindow',1).'" alt="" /></a>';
        }
 
+
        /**
-        * Reads comment messages from TCEforms and prints them in a HTML comment in the buttom of the page.
+        * Reads comment messages from TCEforms and prints them in a HTML comment in the bottom of the page.
         *
         * @return      void
         */
        function tceformMessages()      {
                if (count($this->tceforms->commentMessages))    {
-                       $this->content.='
+                       $tceformMessages = '
+                               <!-- TCEFORM messages
+                               '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
+                               -->
+                       ';
+               }
+               return $tceformMessages;
+       }
+
+
+
 
-<!-- TCEFORM messages
-'.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
--->
 
-';
+
+
+
+
+
+
+
+
+       /***************************
+        *
+        * Localization stuff
+        *
+        ***************************/
+
+       /**
+        * Make selector box for creating new translation for a record or switching to edit the record in an existing language.
+        * Displays only languages which are available for the current page.
+        *
+        * @param       string          Table name
+        * @param       integer         uid for which to create a new language
+        * @param       integer         pid of the record
+        * @return      string          <select> HTML element (if there were items for the box anyways...)
+        */
+       function languageSwitch($table, $uid, $pid=NULL)        {
+               global $TCA;
+
+               $content = '';
+
+               $languageField = $TCA[$table]['ctrl']['languageField'];
+               $transOrigPointerField = $TCA[$table]['ctrl']['transOrigPointerField'];
+
+                       // table editable and activated for languages?
+               if ($GLOBALS['BE_USER']->check('tables_modify',$table) && $languageField && $transOrigPointerField && !$TCA[$table]['ctrl']['transOrigPointerTable'])   {
+
+                       if(is_null($pid)) {
+                               $row = t3lib_befunc::getRecord($table, $uid, 'pid');
+                               $pid = $row['pid'];
+                       }
+
+                               // get all avalibale languages for the page
+                       $langRows = $this->getLanguages($pid);
+
+                               // page available in other languages than default language?
+                       if (is_array($langRows) && count($langRows)>1) {
+
+                               $rowsByLang = array();
+                               $fetchFields = 'uid,'.$languageField.','.$transOrigPointerField;
+
+                                       // get record in current language
+                               $rowCurrent = t3lib_befunc::getRecord($table, $uid, $fetchFields);
+                               $currentLanguage = $rowCurrent[$languageField];
+
+                               if ($currentLanguage>-1)        {       // Disabled for records with [all] language!
+                                               // get record in default language if needed
+                                       if ($currentLanguage) {
+                                               $rowsByLang[0] = t3lib_befunc::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
+                                       } else {
+                                               $rowsByLang[0] = $rowCurrent;
+                                       }
+
+                                               // get record in other languages to see what's already available
+                                       $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                                               $fetchFields,
+                                               $table,
+                                               'pid='.intval($pid).
+                                                       ' AND '.$languageField.'>0'.
+                                                       ' AND '.$transOrigPointerField.'='.intval($rowsByLang[0]['uid']).
+                                                       t3lib_BEfunc::deleteClause($table).
+                                                       t3lib_BEfunc::versioningPlaceholderClause($table)
+                                       );
+                                       foreach ($translations as $row) {
+                                               $rowsByLang[$row[$languageField]] = $row;
+                                       }
+
+                                       $langSelItems=array();
+                                       foreach ($langRows as $lang) {
+                                               if ($GLOBALS['BE_USER']->checkLanguageAccess($lang['uid']))     {
+
+                                                       $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' ['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.new',1).']';
+
+                                                               // create url for creating a localized record
+                                                       if($newTranslation) {
+                                                               $href = $this->doc->issueCommand(
+                                                                       '&cmd['.$table.']['.$rowsByLang[0]['uid'].'][localize]='.$lang['uid'],
+                                                                       $this->backPath.'alt_doc.php?justLocalized='.rawurlencode($table.':'.$rowsByLang[0]['uid'].':'.$lang['uid']).'&returnUrl='.rawurlencode($this->retUrl)
+                                                               );
+
+                                                               // create edit url
+                                                       } else {
+                                                               $href = $this->backPath.'alt_doc.php?';
+                                                               $href .= '&edit['.$table.']['.$rowsByLang[$lang['uid']]['uid'].']=edit';
+                                                               $href .= '&returnUrl='.rawurlencode($this->retUrl);
+                                                       }
+
+                                                       $langSelItems[$lang['uid']]='
+                                                                       <option value="'.htmlspecialchars($href).'"'.($currentLanguage==$lang['uid']?' selected="selected"':'').'>'.htmlspecialchars($lang['title'].$newTranslation).'</option>';
+                                               }
+                                       }
+
+                                               // If any languages are left, make selector:
+                                       if (count($langSelItems)>1)             {
+                                               $onChange = 'if(this.options[this.selectedIndex].value){window.location.href=(this.options[this.selectedIndex].value);}';
+                                               $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.language',1).' <select name="_langSelector" onchange="'.htmlspecialchars($onChange).'">
+                                                               '.implode('',$langSelItems).'
+                                                       </select>';
+                                       }
+                               }
+                       }
                }
+               return $content;
        }
 
 
+       /**
+        * Redirects to alt_doc with new parameters to edit a just created localized record
+        *
+        * @param       string          String passed by GET &justLocalized=
+        * @return      void
+        */
+       function localizationRedirect($justLocalized)   {
+               global $TCA;
+
+               list($table,$orig_uid,$language) = explode(':',$justLocalized);
+
+               if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'])     {
+                       list($localizedRecord) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                                       'uid',
+                                       $table,
+                                       $TCA[$table]['ctrl']['languageField'].'='.intval($language).' AND '.
+                                               $TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($orig_uid).
+                                               t3lib_BEfunc::deleteClause($table).
+                                               t3lib_BEfunc::versioningPlaceholderClause($table)
+                               );
+
+                       if (is_array($localizedRecord)) {
+                                       // Create parameters and finally run the classic page module for creating a new page translation
+                               $params = '&edit['.$table.']['.$localizedRecord['uid'].']=edit';
+                               $returnUrl = '&returnUrl='.rawurlencode(t3lib_div::_GP('returnUrl'));
+                               $location = $GLOBALS['BACK_PATH'].'alt_doc.php?'.$params.$returnUrl;
+
+                               t3lib_utility_Http::redirect($location);
+                       }
+               }
+       }
 
 
+       /**
+        * Returns sys_language records.
+        *
+        * @param       integer         Page id: If zero, the query will select all sys_language records from root level which are NOT hidden. If set to another value, the query will select all sys_language records that has a pages_language_overlay record on that page (and is not hidden, unless you are admin user)
+        * @return      array           Language records including faked record for default language
+        */
+       function getLanguages($id)      {
+               global $LANG;
 
+               $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($id, 'mod.SHARED');
 
+               $languages = array(
+                       0 => array(
+                               'uid' => 0,
+                               'pid' => 0,
+                               'hidden' => 0,
+                               'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'].' ('.$GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage').')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage'),
+                               'flag' => $modSharedTSconfig['properties']['defaultLanguageFlag'],
+                       )
+               );
+
+               $exQ = $GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0';
+               if ($id)        {
+                       $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                                                       'sys_language.*',
+                                                       'pages_language_overlay,sys_language',
+                                                       'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid='.intval($id).$exQ,
+                                                       'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.static_lang_isocode,sys_language.flag',
+                                                       'sys_language.title'
+                                               );
+               } else {
+                       $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                                                       'sys_language.*',
+                                                       'sys_language',
+                                                       'sys_language.hidden=0',
+                                                       '',
+                                                       'sys_language.title'
+                                               );
+               }
+               if ($rows) {
+                       foreach ($rows as $row) {
+                               $languages[$row['uid']] = $row;
+                       }
+               }
+               return $languages;
+       }
 
 
 
@@ -1020,6 +1239,90 @@ class SC_alt_doc {
         ***************************/
 
        /**
+        * Fix $this->editconf if versioning applies to any of the records
+        *
+        * @param       array           Mapping between old and new ids if auto-versioning has been performed.
+        * @return      void
+        */
+       function fixWSversioningInEditConf($mapArray=FALSE)     {
+               global $TCA,$BE_USER;
+
+                       // Traverse the editConf array
+               if (is_array($this->editconf))  {
+                       foreach($this->editconf as $table => $conf)     {       // Tables:
+                               if (is_array($conf) && $TCA[$table])    {
+
+                                               // Traverse the keys/comments of each table (keys can be a commalist of uids)
+                                       $newConf = array();
+                                       foreach($conf as $cKey => $cmd) {
+                                               if ($cmd=='edit')       {
+                                                               // Traverse the ids:
+                                                       $ids = t3lib_div::trimExplode(',', $cKey, 1);
+                                                       foreach($ids as $idKey => $theUid)      {
+                                                               if (is_array($mapArray))        {
+                                                                       if ($mapArray[$table][$theUid]) {
+                                                                               $ids[$idKey] = $mapArray[$table][$theUid];
+                                                                       }
+                                                               } else {        // Default, look for versions in workspace for record:
+                                                                       $calcPRec = $this->getRecordForEdit($table,$theUid);
+                                                                       if (is_array($calcPRec))        {
+                                                                                       // Setting UID again if it had changed, eg. due to workspace versioning.
+                                                                               $ids[$idKey] = $calcPRec['uid'];
+                                                                       }
+                                                               }
+       #else unset($ids[$idKey]);
+                                                       }
+
+                                                               // Add the possibly manipulated IDs to the new-build newConf array:
+                                                       $newConf[implode(',',$ids)] = $cmd;
+                                               } else {
+                                                       $newConf[$cKey] = $cmd;
+                                               }
+                                       }
+                                               // Store the new conf array:
+                                       $this->editconf[$table] = $newConf;
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Get record for editing.
+        *
+        * @param       string          Table name
+        * @param       integer         Record UID
+        * @return      array           Returns record to edit, false if none
+        */
+       function getRecordForEdit($table,$theUid)       {
+               global $TCA;
+
+                       // Fetch requested record:
+               $reqRecord = t3lib_BEfunc::getRecord($table,$theUid,'uid,pid');
+
+               if (is_array($reqRecord))       {
+                               // If workspace is OFFLINE:
+                       if ($GLOBALS['BE_USER']->workspace!=0)  {
+
+                                       // Check for versioning support of the table:
+                               if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS'])       {
+
+                                               // If the record is already a version of "something" pass it by.
+                                       if ($reqRecord['pid']==-1)      {
+
+                                                       // (If it turns out not to be a version of the current workspace there will be trouble, but that is handled inside TCEmain then and in the interface it would clearly be an error of links if the user accesses such a scenario)
+                                               return $reqRecord;
+                                       } else {        // The input record was online and an offline version must be found or made:
+
+                                                       // Look for version of this workspace:
+                                               $versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $reqRecord['uid'],'uid,pid,t3ver_oid');
+                                               return is_array($versionRec) ? $versionRec : $reqRecord;
+                                       }
+                               } else return FALSE;            // This means that editing cannot occur on this record because it was not supporting versioning which is required inside an offline workspace.
+                       } else return $reqRecord;       // In ONLINE workspace, just return the originally requested record:
+               } else return FALSE;    // Return false because the table/uid was not found anyway.
+       }
+
+       /**
         * Function, which populates the internal editconf array with editing commands for all tt_content elements from the normal column in normal language from the page pointed to by $this->editRegularContentFromId
         *
         * @return      void
@@ -1031,6 +1334,7 @@ class SC_alt_doc {
                                                'tt_content',
                                                'pid='.intval($this->editRegularContentFromId).
                                                        t3lib_BEfunc::deleteClause('tt_content').
+                                                       t3lib_BEfunc::versioningPlaceholderClause('tt_content').
                                                        ' AND colPos=0 AND sys_language_uid=0',
                                                '',
                                                'sorting'
@@ -1064,9 +1368,8 @@ class SC_alt_doc {
         * @param       string          The option for look for. Default is checking if the saveDocNew button should be displayed.
         * @return      string          Return value fetched from USER TSconfig
         */
-       function getNewIconMode($table,$key='saveDocNew')       {
-               global $BE_USER;
-               $TSconfig = $BE_USER->getTSConfig('options.'.$key);
+       function getNewIconMode($table, $key = 'saveDocNew') {
+               $TSconfig = $GLOBALS['BE_USER']->getTSConfig('options.'.$key);
                $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
                return $output;
        }
@@ -1080,13 +1383,33 @@ class SC_alt_doc {
        function closeDocument($code=0) {
                global $BE_USER;
 
-                       // If current document is found in docHandler, then unset it, possibly unset it ALL and finally, write it to the session data:
-               if (isset($this->docHandler[$this->storeUrlMd5]))       {
+                       // If current document is found in docHandler,
+                       // then unset it, possibly unset it ALL and finally, write it to the session data
+               if (isset($this->docHandler[$this->storeUrlMd5])) {
+
+                               // add the closing document to the recent documents
+                       $recentDocs = $BE_USER->getModuleData('opendocs::recent');
+                       if (!is_array($recentDocs)) {
+                               $recentDocs = array();
+                       }
+                       $closedDoc = $this->docHandler[$this->storeUrlMd5];
+                       $recentDocs = array_merge(array($this->storeUrlMd5 => $closedDoc), $recentDocs);
+                       if (count($recentDocs) > 8) {
+                               $recentDocs = array_slice($recentDocs, 0, 8);
+                       }
+
+                               // remove it from the list of the open documents
                        unset($this->docHandler[$this->storeUrlMd5]);
-                       if ($code=='3') $this->docHandler=array();
-                       $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1]));
+                       if ($code == '3') {
+                               $recentDocs = array_merge($this->docHandler, $recentDocs);
+                               $this->docHandler = array();
+                       }
+                       $BE_USER->pushModuleData('opendocs::recent', $recentDocs);
+                       $BE_USER->pushModuleData('alt_doc.php', array($this->docHandler, $this->docDat[1]));
+                       t3lib_BEfunc::setUpdateSignal('tx_opendocs::updateNumber', count($this->docHandler));
                }
 
+
                        // If ->returnEditConf is set, then add the current content of editconf to the ->retUrl variable: (used by other scripts, like wizard_add, to know which records was created or so...)
                if ($this->returnEditConf && $this->retUrl!='dummy.php')        {
                        $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf));
@@ -1094,8 +1417,7 @@ class SC_alt_doc {
 
                        // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl
                if (!$code || $code==1) {
-                       Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl));
-                       exit;
+                       t3lib_utility_Http::redirect($this->retUrl);
                } else {
                        $this->setDocument('',$this->retUrl);
                }
@@ -1124,47 +1446,30 @@ class SC_alt_doc {
                                $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl);
                        }
                }
-               Header('Location: '.t3lib_div::locationHeaderUrl($retUrl));
-               exit;
+               t3lib_utility_Http::redirect($retUrl);
        }
 }
 
-// Include extension?
+
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php'])      {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']);
 }
 
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
 // Make instance:
 $SOBE = t3lib_div::makeInstance('SC_alt_doc');
 
 // Preprocessing, storing data if submitted to
 $SOBE->preInit();
 if ($SOBE->doProcessData())    {               // Checks, if a save button has been clicked (or the doSave variable is sent)
-       require_once (PATH_t3lib.'class.t3lib_tcemain.php');
        $SOBE->processData();
 }
 
-require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
-require_once (PATH_t3lib.'class.t3lib_transferdata.php');
-
 
 // Main:
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
-?>
+
+?>
\ No newline at end of file