Documentation TYPO3 par Ameos

alt_doc.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00074 require('init.php');
00075 require('template.php');
00076 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml');
00077 require_once (PATH_t3lib.'class.t3lib_tceforms.php');
00078 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
00079 
00080 
00081 t3lib_BEfunc::lockRecords();
00082 
00083 
00084 
00085 
00094 class SC_alt_doc {
00095 
00096                 // Internal, static: GPvars:
00097         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.
00098         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
00099         var $defVals;                   // Default values for fields (array with tablenames, fields etc. as keys). Can be seen modified internally.
00100         var $overrideVals;              // Array of values to force being set (as hidden fields). Will be set as $this->defVals IF defVals does not exist.
00101         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
00102         var $closeDoc;                  // Close-document command. Not really sure of all options...
00103         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).
00104 
00105         var $data;                              // GPvar (for processing only) : The data array from which the data comes...
00106         var $mirror;                    // GPvar (for processing only) : ?
00107         var $cacheCmd;                  // GPvar (for processing only) : Clear-cache cmd.
00108         var $redirect;                  // GPvar (for processing only) : Redirect (not used???)
00109         var $disableRTE;                // GPvar (for processing only) : If set, the rich text editor is disabled in the forms.
00110         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.
00111         var $vC;                                // GPvar (for processing only) : Verification code, internal stuff.
00112 
00113         var $popViewId;                 // GPvar (module) : ID for displaying the page in the frontend (used for SAVE/VIEW operations)
00114         var $popViewId_addParams;       // GPvar (module) : Additional GET vars for the link, eg. "&L=xxx"
00115         var $viewUrl;                   // GPvar (module) : Alternative URL for viewing the frontend pages.
00116         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!
00117         var $recTitle;                          // Alternative title for the document handler.
00118         var $disHelp;                           // Disable help... ?
00119         var $noView;                            // If set, then no SAVE/VIEW button is printed
00120         var $returnEditConf;            // If set, the $this->editconf array is returned to the calling script (used by wizard_add.php for instance)
00121 
00122 
00123                 // Internal, static:
00124         var $doc;                               // Document template object
00125         var $content;                   // Content accumulation
00126 
00127         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.
00128         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...
00129         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.)
00130         var $R_URI;                             // Set to the URL of this script including variables which is needed to re-display the form. See main()
00131 
00132         var $storeTitle;                // Is loaded with the "title" of the currently "open document" - this is used in the Document Selector box. (see makeDocSel())
00133         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())
00134         var $storeUrl;                  // Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
00135         var $storeUrlMd5;               // Hashed value of storeURL (see compileStoreDat())
00136 
00137         var $docDat;                    // Module session data
00138         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".
00139 
00140 
00141                 // Internal: Related to the form rendering:
00142         var $elementsData;              // Array of the elements to create edit forms for.
00143         var $firstEl;                   // Pointer to the first element in $elementsData
00144         var $errorC;                    // Counter, used to count the number of errors (when users do not have edit permissions)
00145         var $newC;                              // Counter, used to count the number of new record forms displayed
00146         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
00147         var $viewId_addParams;  // Is set to additional parameters (like "&L=xxx") if the record supports it.
00148         var $modTSconfig;               // Module TSconfig, loaded from main() based on the page id value of viewId
00149         var $tceforms;                  // Contains the instance of TCEforms class.
00150         var $generalPathOfForm; // Contains the root-line path of the currently edited record(s) - for display.
00151 
00152 
00153                 // Internal, dynamic:
00154         var $dontStoreDocumentRef;      // Used internally to disable the storage of the document reference (eg. new records)
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00167         function preInit()      {
00168                 global $BE_USER;
00169 
00170                         // Setting GPvars:
00171                 $this->editconf = t3lib_div::_GP('edit');
00172                 $this->defVals = t3lib_div::_GP('defVals');
00173                 $this->overrideVals = t3lib_div::_GP('overrideVals');
00174                 $this->columnsOnly = t3lib_div::_GP('columnsOnly');
00175                 $this->returnUrl = t3lib_div::_GP('returnUrl');
00176                 $this->closeDoc = t3lib_div::_GP('closeDoc');
00177                 $this->doSave = t3lib_div::_GP('doSave');
00178                 $this->returnEditConf = t3lib_div::_GP('returnEditConf');
00179 
00180                         // Setting override values as default if defVals does not exist.
00181                 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
00182                         $this->defVals = $this->overrideVals;
00183                 }
00184 
00185                         // Setting return URL
00186                 $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php';
00187 
00188                         // Make R_URL (request url) based on input GETvars:
00189                 $this->R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
00190                 $this->R_URL_getvars = t3lib_div::_GET();
00191 
00192                         // MAKE url for storing
00193                 $this->compileStoreDat();
00194 
00195                         // Initialize more variables.
00196                 $this->dontStoreDocumentRef=0;
00197                 $this->storeTitle='';
00198 
00199                         // Get session data for the module:
00200                 $this->docDat = $BE_USER->getModuleData('alt_doc.php','ses');
00201                 $this->docHandler = $this->docDat[0];
00202 
00203                         // If a request for closing the document has been sent, act accordingly:
00204                 if ($this->closeDoc>0)  {
00205                         $this->closeDocument($this->closeDoc);
00206                 }
00207 
00208                         // If NO vars are sent to the script, try to read first document:
00209                 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...
00210                         $this->setDocument($this->docDat[1]);
00211                 }
00212         }
00213 
00219         function doProcessData()        {
00220                 $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']);
00221                 return $out;
00222         }
00223 
00229         function processData()  {
00230                 global $BE_USER,$TYPO3_CONF_VARS;
00231 
00232                         // GPvars specifically for processing:
00233                 $this->data = t3lib_div::_GP('data');
00234                 $this->mirror = t3lib_div::_GP('mirror');
00235                 $this->cacheCmd = t3lib_div::_GP('cacheCmd');
00236                 $this->redirect = t3lib_div::_GP('redirect');
00237                 $this->disableRTE = t3lib_div::_GP('_disableRTE');
00238                 $this->returnNewPageId = t3lib_div::_GP('returnNewPageId');
00239                 $this->vC = t3lib_div::_GP('vC');
00240 
00241                         // See tce_db.php for relevate options here:
00242                         // Only options related to $this->data submission are included here.
00243                 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00244                 $tce->stripslashes_values=0;
00245 
00246                         // Setting default values specific for the user:
00247                 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
00248                 if (is_array($TCAdefaultOverride))      {
00249                         $tce->setDefaultsFromUserTS($TCAdefaultOverride);
00250                 }
00251 
00252                         // Setting internal vars:
00253                 if ($BE_USER->uc['neverHideAtCopy'])    {       $tce->neverHideAtCopy = 1;      }
00254                 $tce->debug=0;
00255                 $tce->disableRTE = $this->disableRTE;
00256 
00257                         // Loading TCEmain with data:
00258                 $tce->start($this->data,array());
00259                 if (is_array($this->mirror))    {       $tce->setMirror($this->mirror); }
00260 
00261                         // If pages are being edited, we set an instruction about updating the page tree after this operation.
00262                 if (isset($this->data['pages']))        {
00263                         t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
00264                 }
00265 
00266 
00267                         // Checking referer / executing
00268                 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
00269                 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
00270                 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])    {
00271                         $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));
00272                         debug('Error: Referer host did not match with server host.');
00273                 } else {
00274 
00275                                 // Perform the saving operation with TCEmain:
00276                         $tce->process_uploads($_FILES);
00277                         $tce->process_datamap();
00278 
00279                                 // If there was saved any new items, load them:
00280                         if (count($tce->substNEWwithIDs_table)) {
00281 
00282                                         // Resetting editconf:
00283                                 $this->editconf = array();
00284 
00285                                         // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
00286                                 foreach($tce->substNEWwithIDs_table as $nKey => $nTable)        {
00287                                         $this->editconf[$nTable][$tce->substNEWwithIDs[$nKey]]='edit';
00288                                         if ($nTable=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId)   {
00289                                                 $this->retUrl.='&id='.$tce->substNEWwithIDs[$nKey];
00290                                         }
00291                                 }
00292 
00293                                         // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
00294                                 $this->R_URL_getvars['edit']=$this->editconf;
00295 
00296                                         // Unsetting default values since we don't need them anymore.
00297                                 unset($this->R_URL_getvars['defVals']);
00298 
00299                                         // Re-compile the store* values since editconf changed...
00300                                 $this->compileStoreDat();
00301                         }
00302 
00303                                 // If a document is saved and a new one is created right after.
00304                         if (isset($_POST['_savedoknew_x']) && is_array($this->editconf))        {
00305 
00306                                         // Finding the current table:
00307                                 reset($this->editconf);
00308                                 $nTable=key($this->editconf);
00309 
00310                                         // Finding the first id, getting the records pid+uid
00311                                 reset($this->editconf[$nTable]);
00312                                 $nUid=key($this->editconf[$nTable]);
00313                                 $nRec = t3lib_BEfunc::getRecord($nTable,$nUid,'pid,uid');
00314 
00315                                         // Setting a blank editconf array for a new record:
00316                                 $this->editconf=array();
00317                                 if ($this->getNewIconMode($nTable)=='top')      {
00318                                         $this->editconf[$nTable][$nRec['pid']]='new';
00319                                 } else {
00320                                         $this->editconf[$nTable][-$nRec['uid']]='new';
00321                                 }
00322 
00323                                         // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
00324                                 $this->R_URL_getvars['edit']=$this->editconf;
00325 
00326                                         // Re-compile the store* values since editconf changed...
00327                                 $this->compileStoreDat();
00328                         }
00329 
00330                         $tce->printLogErrorMessages(
00331                                 isset($_POST['_saveandclosedok_x']) ?
00332                                 $this->retUrl :
00333                                 $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?
00334                         );
00335                 }
00336                 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!
00337                         $this->closeDocument(abs($this->closeDoc));
00338                 }
00339         }
00340 
00346         function init() {
00347                 global $BE_USER,$LANG,$BACK_PATH;
00348 
00349                         // Setting more GPvars:
00350                 $this->popViewId = t3lib_div::_GP('popViewId');
00351                 $this->popViewId_addParams = t3lib_div::_GP('popViewId_addParams');
00352                 $this->viewUrl = t3lib_div::_GP('viewUrl');
00353                 $this->editRegularContentFromId = t3lib_div::_GP('editRegularContentFromId');
00354                 $this->recTitle = t3lib_div::_GP('recTitle');
00355                 $this->disHelp = t3lib_div::_GP('disHelp');
00356                 $this->noView = t3lib_div::_GP('noView');
00357 
00358                         // Set other internal variables:
00359                 $this->R_URL_getvars['returnUrl']=$this->retUrl;
00360                 $this->R_URI = $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars);
00361 
00362                         // MENU-ITEMS:
00363                         // If array, then it's a selector box menu
00364                         // If empty string it's just a variable, that'll be saved.
00365                         // Values NOT in this array will not be saved in the settings-array for the module.
00366                 $this->MOD_MENU = array(
00367                         'showPalettes' => '',
00368                         'showDescriptions' => '',
00369                         'disableRTE' => ''
00370                 );
00371 
00372                         // Setting virtual document name
00373                 $this->MCONF['name']='xMOD_alt_doc.php';
00374 
00375                         // CLEANSE SETTINGS
00376                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00377 
00378                         // Create an instance of the document template object
00379                 $this->doc = t3lib_div::makeInstance('mediumDoc');
00380                 $this->doc->bodyTagMargins['x']=5;
00381                 $this->doc->bodyTagMargins['y']=5;
00382                 $this->doc->backPath = $BACK_PATH;
00383                 $this->doc->docType = 'xhtml_trans';
00384 
00385                 $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);">';
00386 
00387                 $this->doc->JScode = $this->doc->wrapScriptTags('
00388                         function jumpToUrl(URL,formEl)  {       //
00389                                 if (!TBE_EDITOR_isFormChanged())        {
00390                                         document.location = URL;
00391                                 } else if (formEl && formEl.type=="checkbox") {
00392                                         formEl.checked = formEl.checked ? 0 : 1;
00393                                 }
00394                         }
00395 
00396                                 // Object: TS:
00397                         function typoSetup      ()      {       //
00398                                 this.uniqueID = "";
00399                         }
00400                         var TS = new typoSetup();
00401 
00402                                 // Info view:
00403                         function launchView(table,uid,bP)       {       //
00404                                 var backPath= bP ? bP : "";
00405                                 var thePreviewWindow="";
00406                                 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");
00407                                 if (thePreviewWindow && thePreviewWindow.focus) {
00408                                         thePreviewWindow.focus();
00409                                 }
00410                         }
00411                         function deleteRecord(table,id,url)     {       //
00412                                 if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).'))      {
00413                                         document.location = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
00414                                 }
00415                                 return false;
00416                         }
00417                 '.(isset($_POST['_savedokview_x']) && $this->popViewId ? t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams) : '')
00418                 ).$this->doc->getDynTabMenuJScode();
00419 
00420                         // Setting up the context sensitive menu:
00421                 $CMparts = $this->doc->getContextMenuCode();
00422                 $this->doc->JScode.= $CMparts[0];
00423                 $this->doc->bodyTagAdditions = $CMparts[1];
00424                 $this->doc->postCode.= $CMparts[2];
00425         }
00426 
00432         function main() {
00433                 global $BE_USER,$LANG;
00434 
00435                         // Starting content accumulation:
00436                 $this->content='';
00437                 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
00438 
00439                         // Begin edit:
00440                 if (is_array($this->editconf))  {
00441 
00442                                 // Initialize TCEforms (rendering the forms)
00443                         $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00444                         $this->tceforms->initDefaultBEMode();
00445                         $this->tceforms->doSaveFieldName = 'doSave';
00446                         $this->tceforms->returnUrl = $this->R_URI;
00447                         $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
00448                         $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00449                         $this->tceforms->enableClickMenu = TRUE;
00450                         $this->tceforms->enableTabMenu = TRUE;
00451 
00452                                 // Clipboard is initialized:
00453                         $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');          // Start clipboard
00454                         $this->tceforms->clipObj->initializeClipboard();        // Initialize - reads the clipboard content from the user session
00455 
00456                                 // Setting external variables:
00457                         if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions'])      $this->tceforms->edit_showFieldHelp='text';
00458 
00459                         if ($this->editRegularContentFromId)    {
00460                                 $this->editRegularContentFromId();
00461                         }
00462 
00463                                 // Creating the editing form, wrap it with buttons, document selector etc.
00464                         $editForm = $this->makeEditForm();
00465                         if ($editForm)  {
00466                                 reset($this->elementsData);
00467                                 $this->firstEl = current($this->elementsData);
00468 
00469                                 if ($this->viewId)      {
00470                                                 // Module configuration:
00471                                         $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
00472                                 } else $this->modTSconfig=array();
00473 
00474                                 $panel = $this->makeButtonPanel();
00475                                 $docSel = $this->makeDocSel();
00476                                 $cMenu = $this->makeCmenu();
00477 
00478                                 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm);
00479 
00480                                 $this->content.= $this->tceforms->printNeededJSFunctions_top().
00481                                                                         $formContent.
00482                                                                         $this->tceforms->printNeededJSFunctions();
00483                                 $this->content.= $this->functionMenus();
00484 
00485                                         // Add CSH:
00486                                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;');
00487 
00488                                 $this->content.= $this->shortCutLink();
00489 
00490                                 $this->tceformMessages();
00491                         }
00492                 }
00493         }
00494 
00500         function printContent() {
00501 
00502                 echo $this->content.$this->doc->endPage();
00503         }
00504 
00505 
00506 
00507 
00508 
00509 
00510 
00511 
00512 
00513 
00514 
00515 
00516 
00517 
00518 
00519 
00520 
00521 
00522 
00523 
00524         /***************************
00525          *
00526          * Sub-content functions, rendering specific parts of the module content.
00527          *
00528          ***************************/
00529 
00535         function makeEditForm() {
00536                 global $BE_USER,$LANG,$TCA;
00537 
00538                         // Initialize variables:
00539                 $this->elementsData=array();
00540                 $this->errorC=0;
00541                 $this->newC=0;
00542                 $thePrevUid='';
00543                 $editForm='';
00544 
00545                         // Traverse the GPvar edit array
00546                 foreach($this->editconf as $table => $conf)     {       // Tables:
00547                         if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
00548 
00549                                         // Traverse the keys/comments of each table (keys can be a commalist of uids)
00550                                 foreach($conf as $cKey => $cmd) {
00551                                         if ($cmd=='edit' || $cmd=='new')        {
00552 
00553                                                         // Get the ids:
00554                                                 $ids = t3lib_div::trimExplode(',',$cKey,1);
00555 
00556                                                         // Traverse the ids:
00557                                                 foreach($ids as $theUid)        {
00558 
00559                                                                 // 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...)
00560                                                                 // First, resetting flags.
00561                                                         $hasAccess = 1;
00562                                                         $deniedAccessReason = '';
00563                                                         $deleteAccess = 0;
00564                                                         $this->viewId = 0;
00565 
00566                                                                 // If the command is to create a NEW record...:
00567                                                         if ($cmd=='new')        {
00568                                                                 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.
00569 
00570                                                                                 // Find parent page on which the new record reside
00571                                                                         if ($theUid<0)  {       // Less than zero - find parent page
00572                                                                                 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
00573                                                                                 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
00574                                                                         } else {        // always a page
00575                                                                                 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
00576                                                                         }
00577 
00578                                                                                 // Now, calculate whether the user has access to creating new records on this position:
00579                                                                         if (is_array($calcPRec))        {
00580                                                                                 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);   // Permissions for the parent page
00581                                                                                 if ($table=='pages')    {       // If pages:
00582                                                                                         $hasAccess = $CALC_PERMS&8 ? 1 : 0;
00583                                                                                         $this->viewId = $calcPRec['pid'];
00584                                                                                 } else {
00585                                                                                         $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00586                                                                                         $this->viewId = $calcPRec['uid'];
00587                                                                                 }
00588                                                                         }
00589                                                                 }
00590                                                                 $this->dontStoreDocumentRef=1;          // Don't save this document title in the document selector if the document is new.
00591                                                         } else {        // Edit:
00592                                                                 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
00593                                                                 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
00594                                                                 if (is_array($calcPRec))        {
00595                                                                         if ($table=='pages')    {       // If pages:
00596                                                                                 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00597                                                                                 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
00598                                                                                 $deleteAccess = $CALC_PERMS&4 ? 1 : 0;
00599                                                                                 $this->viewId = $calcPRec['uid'];
00600                                                                         } else {
00601                                                                                 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));   // Fetching pid-record first.
00602                                                                                 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00603                                                                                 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
00604                                                                                 $this->viewId = $calcPRec['pid'];
00605 
00606                                                                                         // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
00607                                                                                 if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0)        {
00608                                                                                         $this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']];
00609                                                                                 }
00610                                                                         }
00611 
00612                                                                                 // Check internals regarding access:
00613                                                                         if ($hasAccess) {
00614                                                                                 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
00615                                                                                 $deniedAccessReason = $BE_USER->errorMsg;
00616                                                                         }
00617                                                                 } else $hasAccess = 0;
00618                                                         }
00619 
00620                                                         // 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:
00621 
00622                                                         if ($hasAccess) {
00623                                                                 $prevPageID = is_object($trData)?$trData->prevPageID:'';
00624                                                                 $trData = t3lib_div::makeInstance('t3lib_transferData');
00625                                                                 $trData->addRawData = TRUE;
00626                                                                 $trData->defVals = $this->defVals;
00627                                                                 $trData->lockRecords=1;
00628                                                                 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00629                                                                 $trData->prevPageID = $prevPageID;
00630                                                                 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':'');      // 'new'
00631                                                                 reset($trData->regTableItems_data);
00632                                                                 $rec = current($trData->regTableItems_data);
00633                                                                 $rec['uid'] = $cmd=='new'?uniqid('NEW'):$theUid;
00634                                                                 $this->elementsData[]=array(
00635                                                                         'table' => $table,
00636                                                                         'uid' => $rec['uid'],
00637                                                                         'cmd' => $cmd,
00638                                                                         'deleteAccess' => $deleteAccess
00639                                                                 );
00640                                                                 if ($cmd=='new')        {
00641                                                                         $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
00642                                                                 }
00643 
00644                                                                         // Now, render the form:
00645                                                                 if (is_array($rec))     {
00646 
00647                                                                                 // Setting visual path / title of form:
00648                                                                         $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
00649                                                                         if (!$this->storeTitle) {
00650                                                                                 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1);
00651                                                                         }
00652 
00653                                                                                 // Setting variables in TCEforms object:
00654                                                                         $this->tceforms->hiddenFieldList = '';
00655                                                                         $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
00656                                                                         if (is_array($this->overrideVals[$table]))      {
00657                                                                                 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
00658                                                                         }
00659 
00660                                                                                 // Register default language labels, if any:
00661                                                                         $this->tceforms->registerDefaultLanguageData($table,$rec);
00662 
00663                                                                                 // Create form for the record (either specific list of fields or the whole record):
00664                                                                         $panel = '';
00665                                                                         if ($this->columnsOnly) {
00666                                                                                 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
00667                                                                         } else {
00668                                                                                 $panel.= $this->tceforms->getMainFields($table,$rec);
00669                                                                         }
00670                                                                         $panel = $this->tceforms->wrapTotal($panel,$rec,$table);
00671 
00672                                                                                 // Setting the pid value for new records:
00673                                                                         if ($cmd=='new')        {
00674                                                                                 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00675                                                                                 $this->newC++;
00676                                                                         }
00677 
00678                                                                                 // Display "is-locked" message:
00679                                                                         if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid']))       {
00680                                                                                 $lockIcon = '
00681 
00682                                                                                         <!--
00683                                                                                                 Warning box:
00684                                                                                         -->
00685                                                                                         <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
00686                                                                                                 <tr>
00687                                                                                                         <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
00688                                                                                                         <td>'.htmlspecialchars($lockInfo['msg']).'</td>
00689                                                                                                 </tr>
00690                                                                                         </table>
00691                                                                                 ';
00692                                                                         } else $lockIcon = '';
00693 
00694                                                                                 // Combine it all:
00695                                                                         $editForm.= $lockIcon.$panel;
00696                                                                 }
00697 
00698                                                                 $thePrevUid = $rec['uid'];
00699                                                         } else {
00700                                                                 $this->errorC++;
00701                                                                 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'.
00702                                                                                         ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : '');
00703                                                         }
00704                                                 }
00705                                         }
00706                                 }
00707                         }
00708                 }
00709                 return $editForm;
00710         }
00711 
00717         function makeButtonPanel()      {
00718                 global $TCA,$LANG;
00719 
00720                 $panel='';
00721 
00722                         // Render SAVE type buttons:
00723                         // The action of each button is decided by its name attribute. (See doProcessData())
00724                 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'])       {
00725 
00726                                 // SAVE button:
00727                         $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).'" />';
00728 
00729                                 // SAVE / VIEW button:
00730                         if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
00731                                 $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).'" />';
00732                         }
00733 
00734                                 // SAVE / NEW button:
00735                         if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
00736                                 $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).'" />';
00737                         }
00738 
00739                                 // SAVE / CLOSE
00740                         $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).'" />';
00741                 }
00742 
00743                         // CLOSE button:
00744                 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
00745                                 '<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="" />'.
00746                                 '</a>';
00747 
00748                         // DELETE + UNDO buttons:
00749                 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1)      {
00750                         if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid']))  {
00751 
00752                                         // Delete:
00753                                 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
00754                                         $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
00755                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00756                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
00757                                                         '</a>';
00758                                 }
00759 
00760                                         // Undo:
00761                                 $undoButton = 0;
00762                                 $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename="'.$GLOBALS['TYPO3_DB']->quoteStr($this->firstEl['table'], 'sys_history').'" AND recuid="'.intval($this->firstEl['uid']).'"', '', 'tstamp DESC', '1');
00763                                 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes))     {
00764                                         $undoButton = 1;
00765                                 }
00766                                 if ($undoButton) {
00767                                         $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;';
00768                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00769                                                         '<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="" />'.
00770                                                         '</a>';
00771                                 }
00772                                 if ($this->getNewIconMode($this->firstEl['table'],'showHistory'))       {
00773                                         $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
00774                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00775                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
00776                                                         '</a>';
00777                                 }
00778 
00779                                         // If only SOME fields are shown in the form, this will link the user to the FULL form:
00780                                 if ($this->columnsOnly) {
00781                                         $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
00782                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
00783                                                         '</a>';
00784                                 }
00785                         }
00786                 }
00787                 return $panel;
00788         }
00789 
00796         function makeDocSel()   {
00797                 global $BE_USER,$LANG;
00798 
00799                         // Render the selector ONLY if it has not been disabled:
00800                 if (!$this->modTSconfig['properties']['disableDocSelector'])    {
00801 
00802                                 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
00803                         if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef)       {
00804                                 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
00805                                 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
00806                         }
00807 
00808                                 // Now, create the document selector box:
00809                         $docSel='';
00810                         if (is_array($this->docHandler))        {
00811                                 $opt = array();
00812                                 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
00813 
00814                                         // Traverse the list of open documents:
00815                                 foreach($this->docHandler as $md5k => $setupArr)        {
00816                                         $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
00817                                         $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
00818                                 }
00819 
00820                                         // Compile the selector box finally:
00821                                 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){document.location=(this.options[this.selectedIndex].value);}';
00822                                 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
00823 
00824                                         // Add CSH:
00825                                 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00826                         }
00827                 } else $docSel='';
00828                 return $docSel;
00829         }
00830 
00838         function makeCmenu()    {
00839 
00840                         // Generate the menu if NOT disabled:
00841                 if (!$this->modTSconfig['properties']['disableCacheSelector'])  {
00842                         $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
00843 
00844                                 // Add CSH:
00845                         $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00846                 } else $cMenu ='';
00847                 return $cMenu;
00848         }
00849 
00859         function compileForm($panel,$docSel,$cMenu,$editForm)   {
00860                 global $LANG;
00861 
00862 
00863                 $formContent='';
00864                 $formContent.='
00865 
00866                         <!--
00867                                 Header of the editing page.
00868                                 Contains the buttons for saving/closing, the document selector and menu selector.
00869                                 Shows the path of the editing operation as well.
00870                         -->
00871                         <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
00872                                 <tr>
00873                                         <td nowrap="nowrap" valign="top">'.$panel.'</td>
00874                                         <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
00875                                 </tr>
00876                                 <tr>
00877                                         <td colspan="2">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</td>
00878                                 </tr>
00879                         </table>
00880                         <img src="clear.gif" width="1" height="4" alt="" /><br />
00881 
00882 
00883 
00884 
00885                         <!--
00886                                 EDITING FORM:
00887                         -->
00888 
00889                         '.$editForm.'
00890 
00891 
00892 
00893                         <!--
00894                                 Saving buttons (same as in top)
00895                         -->
00896 
00897                         '.$panel.
00898                         '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
00899                         <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
00900 
00901                 if ($this->returnNewPageId)     {
00902                         $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
00903                 }
00904                 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
00905                 if ($this->viewId_addParams) {
00906                         $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
00907                 }
00908                 $formContent.='<input type="hidden" name="closeDoc" value="0" />';
00909                 $formContent.='<input type="hidden" name="doSave" value="0" />';
00910                 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00911                 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00912 
00913                 return $formContent;
00914         }
00915 
00921         function functionMenus()        {
00922                 global $BE_USER,$LANG;
00923 
00924                 $funcMenus = '';
00925 
00926                         // Show palettes:
00927                 $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);
00928 
00929                         // Show descriptions/help texts:
00930                 if ($BE_USER->uc['edit_showFieldHelp']!='text') {
00931                         $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);
00932                 }
00933 
00934                         // Show disable RTE checkbox:
00935                 if ($BE_USER->isRTE())  {
00936                         $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);
00937                 }
00938 
00939                 return '
00940 
00941                                 <!--
00942                                         Function menus (checkboxes for selecting options):
00943                                 -->
00944                                 '.$funcMenus;
00945         }
00946 
00952         function shortCutLink() {
00953                 global $BE_USER,$LANG;
00954 
00955                         // ShortCut
00956                 if ($this->returnUrl!='close.html')     {
00957                         $content.='<br /><br />';
00958 
00959                                 // Shortcut:
00960                         if ($BE_USER->mayMakeShortcut())        {
00961                                 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
00962                         }
00963 
00964                                 // Open in new window:
00965                         $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;';
00966                         $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00967                                         '<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="" />'.
00968                                         '</a>';
00969                 }
00970                 return '
00971 
00972                                 <!--
00973                                         Shortcut link:
00974                                 -->
00975                                 '.$content;
00976         }
00977 
00983         function tceformMessages()      {
00984                 if (count($this->tceforms->commentMessages))    {
00985                         $this->content.='
00986 
00987 <!-- TCEFORM messages
00988 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
00989 -->
00990 
00991 ';
00992                 }
00993         }
00994 
00995 
00996 
00997 
00998 
00999 
01000 
01001 
01002 
01003 
01004 
01005 
01006 
01007 
01008 
01009 
01010         /***************************
01011          *
01012          * Other functions
01013          *
01014          ***************************/
01015 
01021         function editRegularContentFromId()     {
01022                 if (t3lib_extMgm::isLoaded('cms'))      {
01023                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01024                                                 'uid',
01025                                                 'tt_content',
01026                                                 'pid='.intval($this->editRegularContentFromId).
01027                                                         t3lib_BEfunc::deleteClause('tt_content').
01028                                                         ' AND colPos=0 AND sys_language_uid=0',
01029                                                 '',
01030                                                 'sorting'
01031                                         );
01032                         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
01033                                 $ecUids=array();
01034                                 while($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))     {
01035                                         $ecUids[]=$ecRec['uid'];
01036                                 }
01037                                 $this->editconf['tt_content'][implode(',',$ecUids)]='edit';
01038                         }
01039                 }
01040         }
01041 
01048         function compileStoreDat()      {
01049                 $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId',$this->R_URL_getvars);
01050                 $this->storeUrl = t3lib_div::implodeArrayForUrl('',$this->storeArray);
01051                 $this->storeUrlMd5 = md5($this->storeUrl);
01052         }
01053 
01061         function getNewIconMode($table,$key='saveDocNew')       {
01062                 global $BE_USER;
01063                 $TSconfig = $BE_USER->getTSConfig('options.'.$key);
01064                 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
01065                 return $output;
01066         }
01067 
01074         function closeDocument($code=0) {
01075                 global $BE_USER;
01076 
01077                         // If current document is found in docHandler, then unset it, possibly unset it ALL and finally, write it to the session data:
01078                 if (isset($this->docHandler[$this->storeUrlMd5]))       {
01079                         unset($this->docHandler[$this->storeUrlMd5]);
01080                         if ($code=='3') $this->docHandler=array();
01081                         $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1]));
01082                 }
01083 
01084                         // 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...)
01085                 if ($this->returnEditConf && $this->retUrl!='dummy.php')        {
01086                         $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf));
01087                 }
01088 
01089                         // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl
01090                 if (!$code || $code==1) {
01091                         Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl));
01092                         exit;
01093                 } else {
01094                         $this->setDocument('',$this->retUrl);
01095                 }
01096         }
01097 
01106         function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php')  {
01107                 if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl,'alt_doc_nodoc.php'))     return;
01108 
01109                 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) {
01110                         if (isset($this->docHandler[$currentDocFromHandlerMD5]))        {
01111                                 $setupArr=$this->docHandler[$currentDocFromHandlerMD5];
01112                         } else {
01113                                 reset($this->docHandler);
01114                                 $setupArr=current($this->docHandler);
01115                         }
01116                         if ($setupArr[2])       {
01117                                 $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
01118                                 $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl);
01119                         }
01120                 }
01121                 Header('Location: '.t3lib_div::locationHeaderUrl($retUrl));
01122                 exit;
01123         }
01124 }
01125 
01126 // Include extension?
01127 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php'])       {
01128         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']);
01129 }
01130 
01131 
01132 
01133 
01134 
01135 
01136 
01137 
01138 
01139 
01140 
01141 
01142 
01143 
01144 
01145 
01146 // Make instance:
01147 $SOBE = t3lib_div::makeInstance('SC_alt_doc');
01148 
01149 // Preprocessing, storing data if submitted to
01150 $SOBE->preInit();
01151 if ($SOBE->doProcessData())     {               // Checks, if a save button has been clicked (or the doSave variable is sent)
01152         require_once (PATH_t3lib.'class.t3lib_tcemain.php');
01153         $SOBE->processData();
01154 }
01155 
01156 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
01157 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
01158 
01159 
01160 // Main:
01161 $SOBE->init();
01162 $SOBE->main();
01163 $SOBE->printContent();
01164 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6