/src/typo3_src-4.2.0alpha1/typo3/alt_doc.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00081 require('init.php');
00082 require('template.php');
00083 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml');
00084 require_once (PATH_t3lib.'class.t3lib_tceforms.php');
00085 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
00086 
00087 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
00088 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00089 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
00090 
00091 
00092 t3lib_BEfunc::lockRecords();
00093 
00094 
00095 
00096 
00105 class SC_alt_doc {
00106 
00107                 // Internal, static: GPvars:
00108         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).
00109         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
00110         var $defVals;                   // Default values for fields (array with tablenames, fields etc. as keys). Can be seen modified internally.
00111         var $overrideVals;              // Array of values to force being set (as hidden fields). Will be set as $this->defVals IF defVals does not exist.
00112         var $returnUrl;                 // If set, this value will be set in $this->retUrl (which is used quite many places as the return URL). If not set, "dummy.php" will be set in $this->retUrl
00113         var $closeDoc;                  // Close-document command. Not really sure of all options...
00114         var $doSave;                    // Quite simply, if this variable is set, then the processing of incoming data will be performed - as if a save-button is pressed. Used in the forms as a hidden field which can be set through JavaScript if the form is somehow submitted by JavaScript).
00115 
00116         var $data;                              // GPvar (for processing only) : The data array from which the data comes...
00117         var $mirror;                    // GPvar (for processing only) : ?
00118         var $cacheCmd;                  // GPvar (for processing only) : Clear-cache cmd.
00119         var $redirect;                  // GPvar (for processing only) : Redirect (not used???)
00120         var $disableRTE;                // GPvar (for processing only) : If set, the rich text editor is disabled in the forms.
00121         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.
00122         var $vC;                                // GPvar (for processing only) : Verification code, internal stuff.
00123         var $uc;                                // GPvar : update BE_USER->uc
00124         
00125         var $popViewId;                 // GPvar (module) : ID for displaying the page in the frontend (used for SAVE/VIEW operations)
00126         var $popViewId_addParams;       // GPvar (module) : Additional GET vars for the link, eg. "&L=xxx"
00127         var $viewUrl;                   // GPvar (module) : Alternative URL for viewing the frontend pages.
00128         var $editRegularContentFromId;          // If this is pointing to a page id it will automatically load all content elements (NORMAL column/default language) from that page into the form!
00129         var $recTitle;                          // Alternative title for the document handler.
00130         var $disHelp;                           // Disable help... ?
00131         var $noView;                            // If set, then no SAVE/VIEW button is printed
00132         var $returnEditConf;            // If set, the $this->editconf array is returned to the calling script (used by wizard_add.php for instance)
00133         var $localizationMode;          // GP var, localization mode for TCEforms (eg. "text")
00134 
00135 
00136                 // Internal, static:
00142         var $doc;
00143         var $content;                   // Content accumulation
00144 
00145         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.
00146         var $R_URL_parts;               // Contains the parts of the REQUEST_URI (current url). By parts we mean the result of resolving REQUEST_URI (current url) by the parse_url() function. The result is an array where eg. "path" is the script path and "query" is the parameters...
00147         var $R_URL_getvars;             // Contains the current GET vars array; More specifically this array is the foundation for creating the R_URI internal var (which becomes the "url of this script" to which we submit the forms etc.)
00148         var $R_URI;                             // Set to the URL of this script including variables which is needed to re-display the form. See main()
00149 
00150         var $storeTitle;                // Is loaded with the "title" of the currently "open document" - this is used in the Document Selector box. (see makeDocSel())
00151         var $storeArray;                // Contains an array with key/value pairs of GET parameters needed to reach the current document displayed - used in the Document Selector box. (see compileStoreDat())
00152         var $storeUrl;                  // Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
00153         var $storeUrlMd5;               // Hashed value of storeURL (see compileStoreDat())
00154 
00155         var $docDat;                    // Module session data
00156         var $docHandler;                // An array of the "open documents" - keys are md5 hashes (see $storeUrlMd5) identifying the various documents on the GET parameter list needed to open it. The values are arrays with 0,1,2 keys with information about the document (see compileStoreDat()). The docHandler variable is stored in the $docDat session data, key "0".
00157 
00158 
00159                 // Internal: Related to the form rendering:
00160         var $elementsData;              // Array of the elements to create edit forms for.
00161         var $firstEl;                   // Pointer to the first element in $elementsData
00162         var $errorC;                    // Counter, used to count the number of errors (when users do not have edit permissions)
00163         var $newC;                              // Counter, used to count the number of new record forms displayed
00164         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
00165         var $viewId_addParams;  // Is set to additional parameters (like "&L=xxx") if the record supports it.
00166         var $modTSconfig;               // Module TSconfig, loaded from main() based on the page id value of viewId
00167 
00173         var $tceforms;
00174         var $generalPathOfForm; // Contains the root-line path of the currently edited record(s) - for display.
00175 
00176 
00177                 // Internal, dynamic:
00178         var $dontStoreDocumentRef;      // Used internally to disable the storage of the document reference (eg. new records)
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00191         function preInit()      {
00192                 global $BE_USER;
00193 
00194                 if (t3lib_div::_GP('justLocalized'))    {
00195                         $this->localizationRedirect(t3lib_div::_GP('justLocalized'));
00196                 }
00197 
00198                         // Setting GPvars:
00199                 $this->editconf = t3lib_div::_GP('edit');
00200                 $this->defVals = t3lib_div::_GP('defVals');
00201                 $this->overrideVals = t3lib_div::_GP('overrideVals');
00202                 $this->columnsOnly = t3lib_div::_GP('columnsOnly');
00203                 $this->returnUrl = t3lib_div::_GP('returnUrl');
00204                 $this->closeDoc = t3lib_div::_GP('closeDoc');
00205                 $this->doSave = t3lib_div::_GP('doSave');
00206                 $this->returnEditConf = t3lib_div::_GP('returnEditConf');
00207                 $this->localizationMode = t3lib_div::_GP('localizationMode');
00208                 $this->uc = t3lib_div::_GP('uc');
00209 
00210 
00211                         // Setting override values as default if defVals does not exist.
00212                 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
00213                         $this->defVals = $this->overrideVals;
00214                 }
00215 
00216                         // Setting return URL
00217                 $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php';
00218 
00219                         // Fix $this->editconf if versioning applies to any of the records
00220                 $this->fixWSversioningInEditConf();
00221 
00222                         // Make R_URL (request url) based on input GETvars:
00223                 $this->R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
00224                 $this->R_URL_getvars = t3lib_div::_GET();
00225                 $this->R_URL_getvars['edit'] = $this->editconf;
00226 
00227                         // MAKE url for storing
00228                 $this->compileStoreDat();
00229 
00230                         // Initialize more variables.
00231                 $this->dontStoreDocumentRef=0;
00232                 $this->storeTitle='';
00233 
00234                         // Get session data for the module:
00235                 $this->docDat = $BE_USER->getModuleData('alt_doc.php','ses');
00236                 $this->docHandler = $this->docDat[0];
00237 
00238                         // If a request for closing the document has been sent, act accordingly:
00239                 if ($this->closeDoc>0)  {
00240                         $this->closeDocument($this->closeDoc);
00241                 }
00242 
00243                         // If NO vars are sent to the script, try to read first document:
00244                 if (is_array($this->R_URL_getvars) && count($this->R_URL_getvars)<2 && !is_array($this->editconf))      {       // Added !is_array($this->editconf) because editConf must not be set either. Anyways I can't figure out when this situation here will apply...
00245                         $this->setDocument($this->docDat[1]);
00246                 }
00247         }
00248 
00254         function doProcessData()        {
00255                 $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']);
00256                 return $out;
00257         }
00258 
00264         function processData()  {
00265                 global $BE_USER,$TYPO3_CONF_VARS;
00266 
00267                         // GPvars specifically for processing:
00268                 $this->data = t3lib_div::_GP('data');
00269                 $this->cmd = t3lib_div::_GP('cmd');
00270                 $this->mirror = t3lib_div::_GP('mirror');
00271                 $this->cacheCmd = t3lib_div::_GP('cacheCmd');
00272                 $this->redirect = t3lib_div::_GP('redirect');
00273                 $this->disableRTE = t3lib_div::_GP('_disableRTE');
00274                 $this->returnNewPageId = t3lib_div::_GP('returnNewPageId');
00275                 $this->vC = t3lib_div::_GP('vC');
00276 
00277                         // See tce_db.php for relevate options here:
00278                         // Only options related to $this->data submission are included here.
00279                 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00280                 $tce->stripslashes_values=0;
00281 
00282                         // Setting default values specific for the user:
00283                 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
00284                 if (is_array($TCAdefaultOverride))      {
00285                         $tce->setDefaultsFromUserTS($TCAdefaultOverride);
00286                 }
00287 
00288                         // Setting internal vars:
00289                 if ($BE_USER->uc['neverHideAtCopy'])    {       $tce->neverHideAtCopy = 1;      }
00290                 $tce->debug=0;
00291                 $tce->disableRTE = $this->disableRTE;
00292 
00293                         // Loading TCEmain with data:
00294                 $tce->start($this->data,$this->cmd);
00295                 if (is_array($this->mirror))    {       $tce->setMirror($this->mirror); }
00296 
00297                         // If pages are being edited, we set an instruction about updating the page tree after this operation.
00298                 if (isset($this->data['pages']))        {
00299                         t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
00300                 }
00301 
00302 
00303                         // Checking referer / executing
00304                 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
00305                 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
00306                 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])    {
00307                         $tce->log('',0,0,0,1,"Referer host '%s' and server host '%s' did not match and veriCode was not valid either!",1,array($refInfo['host'],$httpHost));
00308                         debug('Error: Referer host did not match with server host.');
00309                 } else {
00310 
00311                                 // Perform the saving operation with TCEmain:
00312                         $tce->process_uploads($_FILES);
00313                         $tce->process_datamap();
00314                         $tce->process_cmdmap();
00315 
00316                                 // If there was saved any new items, load them:
00317                         if (count($tce->substNEWwithIDs_table)) {
00318                                         // save the expanded/collapsed states for new inline records, if any
00319                                 t3lib_TCEforms_inline::updateInlineView($this->uc, $tce);
00320 
00321                                 $newEditConf = array();
00322 
00323                                 foreach($this->editconf as $tableName => $tableCmds) {
00324                                         $keys = array_keys($tce->substNEWwithIDs_table, $tableName);
00325                                         if(count($keys) > 0) {
00326                                                 foreach($keys as $key) {
00327                                                         $editId = $tce->substNEWwithIDs[$key];
00328                                                                 // check if the $editId isn't a child record of an IRRE action
00329                                                         if (!(is_array($tce->newRelatedIDs[$tableName]) && in_array($editId, $tce->newRelatedIDs[$tableName]))) {
00330                                                                         // translate new id to the workspace version:
00331                                                                 if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $tableName, $editId,'uid')) {
00332                                                                         $editId = $versionRec['uid'];
00333                                                                 }
00334                                                                 $newEditConf[$tableName][$editId] = 'edit';
00335                                                         }
00336         
00337                                                                 // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
00338                                                         if ($tableName=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId)        {
00339                                                                 $this->retUrl.='&id='.$tce->substNEWwithIDs[$key];
00340                                                         }
00341                                                 }
00342                                         } else {
00343                                                 $newEditConf[$tableName] = $tableCmds;
00344                                         }
00345                                 }
00346 
00347                                         // Resetting editconf if newEditConf has values:
00348                                 if (count($newEditConf)) {
00349                                         $this->editconf = $newEditConf;
00350                                 }
00351                                 
00352                                         // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
00353                                 $this->R_URL_getvars['edit']=$this->editconf;
00354 
00355                                         // Unsetting default values since we don't need them anymore.
00356                                 unset($this->R_URL_getvars['defVals']);
00357 
00358                                         // Re-compile the store* values since editconf changed...
00359                                 $this->compileStoreDat();
00360                         }
00361 
00362                                 // See if any records was auto-created as new versions?
00363                         if (count($tce->autoVersionIdMap))      {
00364                                 $this->fixWSversioningInEditConf($tce->autoVersionIdMap);
00365                         }
00366 
00367                                 // If a document is saved and a new one is created right after.
00368                         if (isset($_POST['_savedoknew_x']) && is_array($this->editconf))        {
00369 
00370                                         // Finding the current table:
00371                                 reset($this->editconf);
00372                                 $nTable=key($this->editconf);
00373 
00374                                         // Finding the first id, getting the records pid+uid
00375                                 reset($this->editconf[$nTable]);
00376                                 $nUid=key($this->editconf[$nTable]);
00377                                 $nRec = t3lib_BEfunc::getRecord($nTable,$nUid,'pid,uid');
00378 
00379                                         // Setting a blank editconf array for a new record:
00380                                 $this->editconf=array();
00381                                 if ($this->getNewIconMode($nTable)=='top')      {
00382                                         $this->editconf[$nTable][$nRec['pid']]='new';
00383                                 } else {
00384                                         $this->editconf[$nTable][-$nRec['uid']]='new';
00385                                 }
00386 
00387                                         // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
00388                                 $this->R_URL_getvars['edit']=$this->editconf;
00389 
00390                                         // Re-compile the store* values since editconf changed...
00391                                 $this->compileStoreDat();
00392                         }
00393 
00394                         $tce->printLogErrorMessages(
00395                                 isset($_POST['_saveandclosedok_x']) ?
00396                                 $this->retUrl :
00397                                 $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?
00398                         );
00399                 }
00400                 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!
00401                         $this->closeDocument(abs($this->closeDoc));
00402                 }
00403         }
00404 
00410         function init() {
00411                 global $BE_USER,$LANG,$BACK_PATH;
00412 
00413                         // Setting more GPvars:
00414                 $this->popViewId = t3lib_div::_GP('popViewId');
00415                 $this->popViewId_addParams = t3lib_div::_GP('popViewId_addParams');
00416                 $this->viewUrl = t3lib_div::_GP('viewUrl');
00417                 $this->editRegularContentFromId = t3lib_div::_GP('editRegularContentFromId');
00418                 $this->recTitle = t3lib_div::_GP('recTitle');
00419                 $this->disHelp = t3lib_div::_GP('disHelp');
00420                 $this->noView = t3lib_div::_GP('noView');
00421 
00422                         // Set other internal variables:
00423                 $this->R_URL_getvars['returnUrl']=$this->retUrl;
00424                 $this->R_URI = $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars);
00425 
00426                         // MENU-ITEMS:
00427                         // If array, then it's a selector box menu
00428                         // If empty string it's just a variable, that'll be saved.
00429                         // Values NOT in this array will not be saved in the settings-array for the module.
00430                 $this->MOD_MENU = array(
00431                         'showPalettes' => '',
00432                         'showDescriptions' => '',
00433                         'disableRTE' => ''
00434                 );
00435 
00436                         // Setting virtual document name
00437                 $this->MCONF['name']='xMOD_alt_doc.php';
00438 
00439                         // CLEANSE SETTINGS
00440                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00441 
00442                         // Create an instance of the document template object
00443                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00444                 $this->doc->bodyTagMargins['x']=5;
00445                 $this->doc->bodyTagMargins['y']=5;
00446                 $this->doc->backPath = $BACK_PATH;
00447                 $this->doc->docType = 'xhtml_trans';
00448 
00449                 $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);">';
00450 
00451                 $this->doc->JScode = $this->doc->wrapScriptTags('
00452                         function jumpToUrl(URL,formEl)  {       //
00453                                 if (!TBE_EDITOR.isFormChanged())        {
00454                                         window.location.href = URL;
00455                                 } else if (formEl && formEl.type=="checkbox") {
00456                                         formEl.checked = formEl.checked ? 0 : 1;
00457                                 }
00458                         }
00459 
00460                                 // Object: TS:
00461                         function typoSetup      ()      {       //
00462                                 this.uniqueID = "";
00463                         }
00464                         var TS = new typoSetup();
00465 
00466                                 // Info view:
00467                         function launchView(table,uid,bP)       {       //
00468                                 var backPath= bP ? bP : "";
00469                                 var thePreviewWindow="";
00470                                 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");
00471                                 if (thePreviewWindow && thePreviewWindow.focus) {
00472                                         thePreviewWindow.focus();
00473                                 }
00474                         }
00475                         function deleteRecord(table,id,url)     {       //
00476                                 if (
00477                                         '.($GLOBALS['BE_USER']->jsConfirmation(4)?'confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')':'1==1').'
00478                                 )       {
00479                                         window.location.href = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
00480                                 }
00481                                 return false;
00482                         }
00483                 '.(isset($_POST['_savedokview_x']) && $this->popViewId ?
00484                         'if (window.opener) { '.
00485                                 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams,FALSE).
00486                                 ' } else { '.
00487                                 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams).
00488                                 ' } '
00489                         : '')
00490                 ).$this->doc->getDynTabMenuJScode();
00491 
00492                         // Setting up the context sensitive menu:
00493                 $CMparts = $this->doc->getContextMenuCode();
00494                 $this->doc->JScode.= $CMparts[0];
00495                 $this->doc->bodyTagAdditions = $CMparts[1];
00496                 $this->doc->postCode.= $CMparts[2];
00497         }
00498 
00504         function main() {
00505                 global $BE_USER,$LANG;
00506 
00507                         // Starting content accumulation:
00508                 $this->content='';
00509                 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
00510 
00511                         // Begin edit:
00512                 if (is_array($this->editconf))  {
00513                         
00514                                 // Initialize TCEforms (rendering the forms)
00515                         $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00516                         $this->tceforms->initDefaultBEMode();
00517                         $this->tceforms->doSaveFieldName = 'doSave';
00518                         $this->tceforms->localizationMode = t3lib_div::inList('text,media',$this->localizationMode) ? $this->localizationMode : '';     // text,media is keywords defined in TYPO3 Core API..., see "l10n_cat"
00519                         $this->tceforms->returnUrl = $this->R_URI;
00520                         $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
00521                         $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00522                         $this->tceforms->enableClickMenu = TRUE;
00523                         $this->tceforms->enableTabMenu = TRUE;
00524 
00525                                 // Clipboard is initialized:
00526                         $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');          // Start clipboard
00527                         $this->tceforms->clipObj->initializeClipboard();        // Initialize - reads the clipboard content from the user session
00528 
00529                                 // Setting external variables:
00530                         if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions'])      $this->tceforms->edit_showFieldHelp='text';
00531 
00532                         if ($this->editRegularContentFromId)    {
00533                                 $this->editRegularContentFromId();
00534                         }
00535 
00536                                 // Creating the editing form, wrap it with buttons, document selector etc.
00537                         $editForm = $this->makeEditForm();
00538 
00539                         if ($editForm)  {
00540                                 reset($this->elementsData);
00541                                 $this->firstEl = current($this->elementsData);
00542 
00543                                         // language switch/selector for editing
00544                                         // show only when a single record is edited - multiple records are too confusing
00545                                 if (count($this->elementsData)==1) {
00546                                         $languageSwitch = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']);
00547                                 }
00548 
00549 
00550                                 if ($this->viewId)      {
00551                                                 // Module configuration:
00552                                         $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
00553                                 } else $this->modTSconfig=array();
00554 
00555                                 $panel = $this->makeButtonPanel();
00556                                 $docSel = $this->makeDocSel();
00557                                 $cMenu = $this->makeCmenu();
00558 
00559                                 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm,$languageSwitch);
00560 
00561                                 $this->content.= $this->tceforms->printNeededJSFunctions_top().
00562                                                                         $formContent.
00563                                                                         $this->tceforms->printNeededJSFunctions();
00564                                 $this->content.= $this->functionMenus();
00565 
00566                                         // Add CSH:
00567                                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;');
00568 
00569                                 $this->content.= $this->shortCutLink();
00570 
00571                                 $this->tceformMessages();
00572                         }
00573                 }
00574         }
00575 
00576 
00582         function printContent() {
00583                 $this->content.= $this->doc->endPage();
00584                 $this->content = $this->doc->insertStylesAndJS($this->content);
00585                 echo $this->content;
00586         }
00587 
00588 
00589 
00590 
00591 
00592 
00593 
00594 
00595 
00596 
00597 
00598 
00599 
00600 
00601 
00602 
00603 
00604 
00605 
00606 
00607         /***************************
00608          *
00609          * Sub-content functions, rendering specific parts of the module content.
00610          *
00611          ***************************/
00612 
00618         function makeEditForm() {
00619                 global $BE_USER,$LANG,$TCA;
00620 
00621                         // Initialize variables:
00622                 $this->elementsData=array();
00623                 $this->errorC=0;
00624                 $this->newC=0;
00625                 $thePrevUid='';
00626                 $editForm='';
00627 
00628                         // Traverse the GPvar edit array
00629                 foreach($this->editconf as $table => $conf)     {       // Tables:
00630                         if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
00631 
00632                                         // Traverse the keys/comments of each table (keys can be a commalist of uids)
00633                                 foreach($conf as $cKey => $cmd) {
00634                                         if ($cmd=='edit' || $cmd=='new')        {
00635 
00636                                                         // Get the ids:
00637                                                 $ids = t3lib_div::trimExplode(',',$cKey,1);
00638 
00639                                                         // Traverse the ids:
00640                                                 foreach($ids as $theUid)        {
00641 
00642                                                                 // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...)
00643                                                                 // First, resetting flags.
00644                                                         $hasAccess = 1;
00645                                                         $deniedAccessReason = '';
00646                                                         $deleteAccess = 0;
00647                                                         $this->viewId = 0;
00648 
00649                                                                 // If the command is to create a NEW record...:
00650                                                         if ($cmd=='new')        {
00651                                                                 if (intval($theUid))    {               // NOTICE: the id values in this case points to the page uid onto which the record should be create OR (if the id is negativ) to a record from the same table AFTER which to create the record.
00652 
00653                                                                                 // Find parent page on which the new record reside
00654                                                                         if ($theUid<0)  {       // Less than zero - find parent page
00655                                                                                 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
00656                                                                                 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
00657                                                                         } else {        // always a page
00658                                                                                 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
00659                                                                         }
00660 
00661                                                                                 // Now, calculate whether the user has access to creating new records on this position:
00662                                                                         if (is_array($calcPRec))        {
00663                                                                                 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);   // Permissions for the parent page
00664                                                                                 if ($table=='pages')    {       // If pages:
00665                                                                                         $hasAccess = $CALC_PERMS&8 ? 1 : 0;
00666                                                                                         $this->viewId = $calcPRec['pid'];
00667                                                                                 } else {
00668                                                                                         $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00669                                                                                         $this->viewId = $calcPRec['uid'];
00670                                                                                 }
00671                                                                         }
00672                                                                 }
00673                                                                 $this->dontStoreDocumentRef=1;          // Don't save this document title in the document selector if the document is new.
00674                                                         } else {        // Edit:
00675                                                                 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
00676                                                                 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
00677                                                                 if (is_array($calcPRec))        {
00678                                                                         if ($table=='pages')    {       // If pages:
00679                                                                                 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00680                                                                                 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
00681                                                                                 $deleteAccess = $CALC_PERMS&4 ? 1 : 0;
00682                                                                                 $this->viewId = $calcPRec['uid'];
00683                                                                         } else {
00684                                                                                 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));   // Fetching pid-record first.
00685                                                                                 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00686                                                                                 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
00687                                                                                 $this->viewId = $calcPRec['pid'];
00688 
00689                                                                                         // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
00690                                                                                 if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0)        {
00691                                                                                         $this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']];
00692                                                                                 }
00693                                                                         }
00694 
00695                                                                                 // Check internals regarding access:
00696                                                                         if ($hasAccess) {
00697                                                                                 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
00698                                                                                 $deniedAccessReason = $BE_USER->errorMsg;
00699                                                                         }
00700                                                                 } else $hasAccess = 0;
00701                                                         }
00702 
00703                                                         // AT THIS POINT we have checked the access status of the editing/creation of records and we can now proceed with creating the form elements:
00704 
00705                                                         if ($hasAccess) {
00706                                                                 $prevPageID = is_object($trData)?$trData->prevPageID:'';
00707                                                                 $trData = t3lib_div::makeInstance('t3lib_transferData');
00708                                                                 $trData->addRawData = TRUE;
00709                                                                 $trData->defVals = $this->defVals;
00710                                                                 $trData->lockRecords=1;
00711                                                                 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00712                                                                 $trData->prevPageID = $prevPageID;
00713                                                                 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':'');      // 'new'
00714                                                                 reset($trData->regTableItems_data);
00715                                                                 $rec = current($trData->regTableItems_data);
00716                                                                 $rec['uid'] = $cmd=='new' ? uniqid('NEW') : $theUid;
00717                                                                 if ($cmd=='new')        {
00718                                                                         $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
00719                                                                 }
00720                                                                 $this->elementsData[]=array(
00721                                                                         'table' => $table,
00722                                                                         'uid' => $rec['uid'],
00723                                                                         'pid' => $rec['pid'],
00724                                                                         'cmd' => $cmd,
00725                                                                         'deleteAccess' => $deleteAccess
00726                                                                 );
00727 
00728                                                                         // Now, render the form:
00729                                                                 if (is_array($rec))     {
00730 
00731                                                                                 // Setting visual path / title of form:
00732                                                                         $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
00733                                                                         if (!$this->storeTitle) {
00734                                                                                 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,TRUE);
00735                                                                         }
00736 
00737                                                                                 // Setting variables in TCEforms object:
00738                                                                         $this->tceforms->hiddenFieldList = '';
00739                                                                         $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
00740                                                                         if (is_array($this->overrideVals[$table]))      {
00741                                                                                 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
00742                                                                         }
00743 
00744                                                                                 // Register default language labels, if any:
00745                                                                         $this->tceforms->registerDefaultLanguageData($table,$rec);
00746 
00747                                                                                 // Create form for the record (either specific list of fields or the whole record):
00748                                                                         $panel = '';
00749                                                                         if ($this->columnsOnly) {
00750                                                                                 if(is_array($this->columnsOnly)){
00751                                                                                         $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly[$table]);
00752                                                                                 } else {
00753                                                                                         $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
00754                                                                                 }
00755                                                                         } else {
00756                                                                                 $panel.= $this->tceforms->getMainFields($table,$rec);
00757                                                                         }
00758                                                                         $panel = $this->tceforms->wrapTotal($panel,$rec,$table);
00759 
00760                                                                                 // Setting the pid value for new records:
00761                                                                         if ($cmd=='new')        {
00762                                                                                 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00763                                                                                 $this->newC++;
00764                                                                         }
00765 
00766                                                                                 // Display "is-locked" message:
00767                                                                         if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid']))       {
00768                                                                                 $lockIcon = '
00769 
00770                                                                                         <!--
00771                                                                                                 Warning box:
00772                                                                                         -->
00773                                                                                         <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
00774                                                                                                 <tr>
00775                                                                                                         <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
00776                                                                                                         <td>'.htmlspecialchars($lockInfo['msg']).'</td>
00777                                                                                                 </tr>
00778                                                                                         </table>
00779                                                                                 ';
00780                                                                         } else $lockIcon = '';
00781 
00782                                                                                 // Combine it all:
00783                                                                         $editForm.= $lockIcon.$panel;
00784                                                                 }
00785 
00786                                                                 $thePrevUid = $rec['uid'];
00787                                                         } else {
00788                                                                 $this->errorC++;
00789                                                                 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'.
00790                                                                                         ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : '');
00791                                                         }
00792                                                 }
00793                                         }
00794                                 }
00795                         }
00796                 }
00797 
00798                 return $editForm;
00799         }
00800 
00806         function makeButtonPanel()      {
00807                 global $TCA,$LANG;
00808 
00809                 $panel='';
00810 
00811                         // Render SAVE type buttons:
00812                         // The action of each button is decided by its name attribute. (See doProcessData())
00813                 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'])       {
00814 
00815                                 // SAVE button:
00816                         $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).'" />';
00817 
00818                                 // SAVE / VIEW button:
00819                         if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
00820                                 $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).'" />';
00821                         }
00822 
00823                                 // SAVE / NEW button:
00824                         if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
00825                                 $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).'" />';
00826                         }
00827 
00828                                 // SAVE / CLOSE
00829                         $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).'" />';
00830                 }
00831 
00832                         // CLOSE button:
00833                 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
00834                                 '<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="" />'.
00835                                 '</a>';
00836 
00837                         // DELETE + UNDO buttons:
00838                 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1)      {
00839                         if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid']))  {
00840 
00841                                         // Delete:
00842                                 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
00843                                         $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
00844                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00845                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
00846                                                         '</a>';
00847                                 }
00848 
00849                                         // Undo:
00850                                 $undoButton = 0;
00851                                 $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');
00852                                 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes))     {
00853                                         $undoButton = 1;
00854                                 }
00855                                 if ($undoButton) {
00856                                         $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;';
00857                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00858                                                         '<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="" />'.
00859                                                         '</a>';
00860                                 }
00861                                 if ($this->getNewIconMode($this->firstEl['table'],'showHistory'))       {
00862                                         $aOnClick = 'window.location.href=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
00863                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00864                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
00865                                                         '</a>';
00866                                 }
00867 
00868                                         // If only SOME fields are shown in the form, this will link the user to the FULL form:
00869                                 if ($this->columnsOnly) {
00870                                         $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
00871                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
00872                                                         '</a>';
00873                                 }
00874                         }
00875                 }
00876                 return $panel;
00877         }
00878 
00885         function makeDocSel()   {
00886                 global $BE_USER,$LANG;
00887 
00888                         // Render the selector ONLY if it has not been disabled:
00889                 if (!$this->modTSconfig['properties']['disableDocSelector'])    {
00890 
00891                                 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
00892                         if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef)       {
00893                                 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
00894                                 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
00895                         }
00896 
00897                                 // Now, create the document selector box:
00898                         $docSel='';
00899                         if (is_array($this->docHandler))        {
00900                                 $opt = array();
00901                                 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
00902 
00903                                         // Traverse the list of open documents:
00904                                 foreach($this->docHandler as $md5k => $setupArr)        {
00905                                         $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
00906                                         $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
00907                                 }
00908 
00909                                         // Compile the selector box finally:
00910                                 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR.isFormChanged()){window.location.href=(this.options[this.selectedIndex].value);}';
00911                                 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
00912 
00913                                         // Add CSH:
00914                                 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00915                         }
00916                 } else $docSel='';
00917                 return $docSel;
00918         }
00919 
00927         function makeCmenu()    {
00928 
00929                         // Generate the menu if NOT disabled:
00930                 if (!$this->modTSconfig['properties']['disableCacheSelector'])  {
00931                         $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
00932 
00933                                 // Add CSH:
00934                         $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00935                 } else $cMenu ='';
00936                 return $cMenu;
00937         }
00938 
00949         function compileForm($panel,$docSel,$cMenu,$editForm, $langSelector='') {
00950                 global $LANG;
00951 
00952 
00953                 $formContent='';
00954                 $formContent.='
00955 
00956                         <!--
00957                                 Header of the editing page.
00958                                 Contains the buttons for saving/closing, the document selector and menu selector.
00959                                 Shows the path of the editing operation as well.
00960                         -->
00961                         <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
00962                                 <tr>
00963                                         <td nowrap="nowrap" valign="top">'.$panel.'</td>
00964                                         <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
00965                                 </tr>';
00966 
00967                 if ($langSelector) {
00968                         $langSelector ='<div id="typo3-altdoc-lang-selector">'.$langSelector.'</div>';
00969                 }
00970 
00971                 if (is_array($this->tceforms->extraFormHeaders))        {
00972                         $formContent .= implode(chr(10), $this->tceforms->extraFormHeaders);
00973                 }
00974 
00975                 $pagePath = '<div id="typo3-altdoc-page-path">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</div>';
00976 
00977                 $formContent.='
00978                                 <tr>
00979                                         <td colspan="2"><div id="typo3-altdoc-header-info-options">'.$pagePath.$langSelector.'</div></td>
00980                                 </tr>
00981                         </table>
00982 
00983 
00984 
00985 
00986                         <!--
00987                                 EDITING FORM:
00988                         -->
00989 
00990                         '.$editForm.'
00991 
00992 
00993 
00994                         <!--
00995                                 Saving buttons (same as in top)
00996                         -->
00997 
00998                         '.$panel.
00999                         '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
01000                         <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
01001 
01002                 if ($this->returnNewPageId)     {
01003                         $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
01004                 }
01005                 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
01006                 if ($this->viewId_addParams) {
01007                         $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
01008                 }
01009                 $formContent.='<input type="hidden" name="closeDoc" value="0" />';
01010                 $formContent.='<input type="hidden" name="doSave" value="0" />';
01011                 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
01012                 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
01013 
01014                 return $formContent;
01015         }
01016 
01022         function functionMenus()        {
01023                 global $BE_USER,$LANG;
01024 
01025                 $funcMenus = '';
01026 
01027                         // Show palettes:
01028                 $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'=>''))),'id="checkShowPalettes"').'<label for="checkShowPalettes">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1).'</label>';
01029 
01030                         // Show descriptions/help texts:
01031                 if ($BE_USER->uc['edit_showFieldHelp']!='text') {
01032                         $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'=>''))),'id="checkShowDescriptions"').'<label for="checkShowDescriptions">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions',1).'</label>';
01033                 }
01034 
01035                         // Show disable RTE checkbox:
01036                 if ($BE_USER->isRTE())  {
01037                         $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'=>''))),'id="checkDisableRTE"').'<label for="checkDisableRTE">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE',1).'</label>';
01038                 }
01039 
01040                 return '
01041 
01042                                 <!--
01043                                         Function menus (checkboxes for selecting options):
01044                                 -->
01045                                 '.$funcMenus;
01046         }
01047 
01053         function shortCutLink() {
01054                 global $BE_USER,$LANG;
01055 
01056                         // ShortCut
01057                 if ($this->returnUrl!='close.html')     {
01058                         $content.='<br /><br />';
01059 
01060                                 // Shortcut:
01061                         if ($BE_USER->mayMakeShortcut())        {
01062                                 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
01063                         }
01064 
01065                                 // Open in new window:
01066                         $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;';
01067                         $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
01068                                         '<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="" />'.
01069                                         '</a>';
01070                 }
01071                 return '
01072 
01073                                 <!--
01074                                         Shortcut link:
01075                                 -->
01076                                 '.$content;
01077         }
01078 
01084         function tceformMessages()      {
01085                 if (count($this->tceforms->commentMessages))    {
01086                         $this->content.='
01087 
01088 <!-- TCEFORM messages
01089 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
01090 -->
01091 
01092 ';
01093                 }
01094         }
01095 
01096 
01097 
01098 
01099 
01100 
01101 
01102 
01103 
01104 
01105 
01106 
01107 
01108         /***************************
01109          *
01110          * Localization stuff
01111          *
01112          ***************************/
01113 
01123         function languageSwitch($table, $uid, $pid=NULL)        {
01124                 global $TCA;
01125 
01126                 $content = '';
01127 
01128                 $languageField = $TCA[$table]['ctrl']['languageField'];
01129                 $transOrigPointerField = $TCA[$ta