Documentation TYPO3 par Ameos

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 ***************************************************************/
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 ?
00418                         'if (window.opener) { '.
00419                                 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams,FALSE).
00420                                 ' } else { '.
00421                                 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams).
00422                                 ' } '
00423                         : '')
00424                 ).$this->doc->getDynTabMenuJScode();
00425 
00426                         // Setting up the context sensitive menu:
00427                 $CMparts = $this->doc->getContextMenuCode();
00428                 $this->doc->JScode.= $CMparts[0];
00429                 $this->doc->bodyTagAdditions = $CMparts[1];
00430                 $this->doc->postCode.= $CMparts[2];
00431         }
00432 
00438         function main() {
00439                 global $BE_USER,$LANG;
00440 
00441                         // Starting content accumulation:
00442                 $this->content='';
00443                 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
00444 
00445                         // Begin edit:
00446                 if (is_array($this->editconf))  {
00447 
00448                                 // Initialize TCEforms (rendering the forms)
00449                         $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00450                         $this->tceforms->initDefaultBEMode();
00451                         $this->tceforms->doSaveFieldName = 'doSave';
00452                         $this->tceforms->returnUrl = $this->R_URI;
00453                         $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
00454                         $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00455                         $this->tceforms->enableClickMenu = TRUE;
00456                         $this->tceforms->enableTabMenu = TRUE;
00457 
00458                                 // Clipboard is initialized:
00459                         $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');          // Start clipboard
00460                         $this->tceforms->clipObj->initializeClipboard();        // Initialize - reads the clipboard content from the user session
00461 
00462                                 // Setting external variables:
00463                         if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions'])      $this->tceforms->edit_showFieldHelp='text';
00464 
00465                         if ($this->editRegularContentFromId)    {
00466                                 $this->editRegularContentFromId();
00467                         }
00468 
00469                                 // Creating the editing form, wrap it with buttons, document selector etc.
00470                         $editForm = $this->makeEditForm();
00471                         if ($editForm)  {
00472                                 reset($this->elementsData);
00473                                 $this->firstEl = current($this->elementsData);
00474 
00475                                 if ($this->viewId)      {
00476                                                 // Module configuration:
00477                                         $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
00478                                 } else $this->modTSconfig=array();
00479 
00480                                 $panel = $this->makeButtonPanel();
00481                                 $docSel = $this->makeDocSel();
00482                                 $cMenu = $this->makeCmenu();
00483 
00484                                 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm);
00485 
00486                                 $this->content.= $this->tceforms->printNeededJSFunctions_top().
00487                                                                         $formContent.
00488                                                                         $this->tceforms->printNeededJSFunctions();
00489                                 $this->content.= $this->functionMenus();
00490 
00491                                         // Add CSH:
00492                                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;');
00493 
00494                                 $this->content.= $this->shortCutLink();
00495 
00496                                 $this->tceformMessages();
00497                         }
00498                 }
00499         }
00500 
00506         function printContent() {
00507 
00508                 echo $this->content.$this->doc->endPage();
00509         }
00510 
00511 
00512 
00513 
00514 
00515 
00516 
00517 
00518 
00519 
00520 
00521 
00522 
00523 
00524 
00525 
00526 
00527 
00528 
00529 
00530         /***************************
00531          *
00532          * Sub-content functions, rendering specific parts of the module content.
00533          *
00534          ***************************/
00535 
00541         function makeEditForm() {
00542                 global $BE_USER,$LANG,$TCA;
00543 
00544                         // Initialize variables:
00545                 $this->elementsData=array();
00546                 $this->errorC=0;
00547                 $this->newC=0;
00548                 $thePrevUid='';
00549                 $editForm='';
00550 
00551                         // Traverse the GPvar edit array
00552                 foreach($this->editconf as $table => $conf)     {       // Tables:
00553                         if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
00554 
00555                                         // Traverse the keys/comments of each table (keys can be a commalist of uids)
00556                                 foreach($conf as $cKey => $cmd) {
00557                                         if ($cmd=='edit' || $cmd=='new')        {
00558 
00559                                                         // Get the ids:
00560                                                 $ids = t3lib_div::trimExplode(',',$cKey,1);
00561 
00562                                                         // Traverse the ids:
00563                                                 foreach($ids as $theUid)        {
00564 
00565                                                                 // 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...)
00566                                                                 // First, resetting flags.
00567                                                         $hasAccess = 1;
00568                                                         $deniedAccessReason = '';
00569                                                         $deleteAccess = 0;
00570                                                         $this->viewId = 0;
00571 
00572                                                                 // If the command is to create a NEW record...:
00573                                                         if ($cmd=='new')        {
00574                                                                 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.
00575 
00576                                                                                 // Find parent page on which the new record reside
00577                                                                         if ($theUid<0)  {       // Less than zero - find parent page
00578                                                                                 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
00579                                                                                 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
00580                                                                         } else {        // always a page
00581                                                                                 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
00582                                                                         }
00583 
00584                                                                                 // Now, calculate whether the user has access to creating new records on this position:
00585                                                                         if (is_array($calcPRec))        {
00586                                                                                 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);   // Permissions for the parent page
00587                                                                                 if ($table=='pages')    {       // If pages:
00588                                                                                         $hasAccess = $CALC_PERMS&8 ? 1 : 0;
00589                                                                                         $this->viewId = $calcPRec['pid'];
00590                                                                                 } else {
00591                                                                                         $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00592                                                                                         $this->viewId = $calcPRec['uid'];
00593                                                                                 }
00594                                                                         }
00595                                                                 }
00596                                                                 $this->dontStoreDocumentRef=1;          // Don't save this document title in the document selector if the document is new.
00597                                                         } else {        // Edit:
00598                                                                 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
00599                                                                 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
00600                                                                 if (is_array($calcPRec))        {
00601                                                                         if ($table=='pages')    {       // If pages:
00602                                                                                 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00603                                                                                 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
00604                                                                                 $deleteAccess = $CALC_PERMS&4 ? 1 : 0;
00605                                                                                 $this->viewId = $calcPRec['uid'];
00606                                                                         } else {
00607                                                                                 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));   // Fetching pid-record first.
00608                                                                                 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00609                                                                                 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
00610                                                                                 $this->viewId = $calcPRec['pid'];
00611 
00612                                                                                         // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
00613                                                                                 if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0)        {
00614                                                                                         $this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']];
00615                                                                                 }
00616                                                                         }
00617 
00618                                                                                 // Check internals regarding access:
00619                                                                         if ($hasAccess) {
00620                                                                                 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
00621                                                                                 $deniedAccessReason = $BE_USER->errorMsg;
00622                                                                         }
00623                                                                 } else $hasAccess = 0;
00624                                                         }
00625 
00626                                                         // 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:
00627 
00628                                                         if ($hasAccess) {
00629                                                                 $prevPageID = is_object($trData)?$trData->prevPageID:'';
00630                                                                 $trData = t3lib_div::makeInstance('t3lib_transferData');
00631                                                                 $trData->addRawData = TRUE;
00632                                                                 $trData->defVals = $this->defVals;
00633                                                                 $trData->lockRecords=1;
00634                                                                 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00635                                                                 $trData->prevPageID = $prevPageID;
00636                                                                 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':'');      // 'new'
00637                                                                 reset($trData->regTableItems_data);
00638                                                                 $rec = current($trData->regTableItems_data);
00639                                                                 $rec['uid'] = $cmd=='new'?uniqid('NEW'):$theUid;
00640                                                                 $this->elementsData[]=array(
00641                                                                         'table' => $table,
00642                                                                         'uid' => $rec['uid'],
00643                                                                         'cmd' => $cmd,
00644                                                                         'deleteAccess' => $deleteAccess
00645                                                                 );
00646                                                                 if ($cmd=='new')        {
00647                                                                         $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
00648                                                                 }
00649 
00650                                                                         // Now, render the form:
00651                                                                 if (is_array($rec))     {
00652 
00653                                                                                 // Setting visual path / title of form:
00654                                                                         $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
00655                                                                         if (!$this->storeTitle) {
00656                                                                                 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1);
00657                                                                         }
00658 
00659                                                                                 // Setting variables in TCEforms object:
00660                                                                         $this->tceforms->hiddenFieldList = '';
00661                                                                         $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
00662                                                                         if (is_array($this->overrideVals[$table]))      {
00663                                                                                 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
00664                                                                         }
00665 
00666                                                                                 // Register default language labels, if any:
00667                                                                         $this->tceforms->registerDefaultLanguageData($table,$rec);
00668 
00669                                                                                 // Create form for the record (either specific list of fields or the whole record):
00670                                                                         $panel = '';
00671                                                                         if ($this->columnsOnly) {
00672                                                                                 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
00673                                                                         } else {
00674                                                                                 $panel.= $this->tceforms->getMainFields($table,$rec);
00675                                                                         }
00676                                                                         $panel = $this->tceforms->wrapTotal($panel,$rec,$table);
00677 
00678                                                                                 // Setting the pid value for new records:
00679                                                                         if ($cmd=='new')        {
00680                                                                                 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00681                                                                                 $this->newC++;
00682                                                                         }
00683 
00684                                                                                 // Display "is-locked" message:
00685                                                                         if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid']))       {
00686                                                                                 $lockIcon = '
00687 
00688                                                                                         <!--
00689                                                                                                 Warning box:
00690                                                                                         -->
00691                                                                                         <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
00692                                                                                                 <tr>
00693                                                                                                         <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
00694                                                                                                         <td>'.htmlspecialchars($lockInfo['msg']).'</td>
00695                                                                                                 </tr>
00696                                                                                         </table>
00697                                                                                 ';
00698                                                                         } else $lockIcon = '';
00699 
00700                                                                                 // Combine it all:
00701                                                                         $editForm.= $lockIcon.$panel;
00702                                                                 }
00703 
00704                                                                 $thePrevUid = $rec['uid'];
00705                                                         } else {
00706                                                                 $this->errorC++;
00707                                                                 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'.
00708                                                                                         ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : '');
00709                                                         }
00710                                                 }
00711                                         }
00712                                 }
00713                         }
00714                 }
00715                 return $editForm;
00716         }
00717 
00723         function makeButtonPanel()      {
00724                 global $TCA,$LANG;
00725 
00726                 $panel='';
00727 
00728                         // Render SAVE type buttons:
00729                         // The action of each button is decided by its name attribute. (See doProcessData())
00730                 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'])       {
00731 
00732                                 // SAVE button:
00733                         $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).'" />';
00734 
00735                                 // SAVE / VIEW button:
00736                         if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
00737                                 $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).'" />';
00738                         }
00739 
00740                                 // SAVE / NEW button:
00741                         if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
00742                                 $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).'" />';
00743                         }
00744 
00745                                 // SAVE / CLOSE
00746                         $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).'" />';
00747                 }
00748 
00749                         // CLOSE button:
00750                 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
00751                                 '<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="" />'.
00752                                 '</a>';
00753 
00754                         // DELETE + UNDO buttons:
00755                 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1)      {
00756                         if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid']))  {
00757 
00758                                         // Delete:
00759                                 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
00760                                         $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
00761                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00762                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
00763                                                         '</a>';
00764                                 }
00765 
00766                                         // Undo:
00767                                 $undoButton = 0;
00768                                 $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');
00769                                 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes))     {
00770                                         $undoButton = 1;
00771                                 }
00772                                 if ($undoButton) {
00773                                         $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;';
00774                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00775                                                         '<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="" />'.
00776                                                         '</a>';
00777                                 }
00778                                 if ($this->getNewIconMode($this->firstEl['table'],'showHistory'))       {
00779                                         $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
00780                                         $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00781                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
00782                                                         '</a>';
00783                                 }
00784 
00785                                         // If only SOME fields are shown in the form, this will link the user to the FULL form:
00786                                 if ($this->columnsOnly) {
00787                                         $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
00788                                                         '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
00789                                                         '</a>';
00790                                 }
00791                         }
00792                 }
00793                 return $panel;
00794         }
00795 
00802         function makeDocSel()   {
00803                 global $BE_USER,$LANG;
00804 
00805                         // Render the selector ONLY if it has not been disabled:
00806                 if (!$this->modTSconfig['properties']['disableDocSelector'])    {
00807 
00808                                 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
00809                         if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef)       {
00810                                 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
00811                                 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
00812                         }
00813 
00814                                 // Now, create the document selector box:
00815                         $docSel='';
00816                         if (is_array($this->docHandler))        {
00817                                 $opt = array();
00818                                 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
00819 
00820                                         // Traverse the list of open documents:
00821                                 foreach($this->docHandler as $md5k => $setupArr)        {
00822                                         $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
00823                                         $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
00824                                 }
00825 
00826                                         // Compile the selector box finally:
00827                                 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){document.location=(this.options[this.selectedIndex].value);}';
00828                                 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
00829 
00830                                         // Add CSH:
00831                                 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00832                         }
00833                 } else $docSel='';
00834                 return $docSel;
00835         }
00836 
00844         function makeCmenu()    {
00845 
00846                         // Generate the menu if NOT disabled:
00847                 if (!$this->modTSconfig['properties']['disableCacheSelector'])  {
00848                         $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
00849 
00850                                 // Add CSH:
00851                         $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00852                 } else $cMenu ='';
00853                 return $cMenu;
00854         }
00855 
00865         function compileForm($panel,$docSel,$cMenu,$editForm)   {
00866                 global $LANG;
00867 
00868 
00869                 $formContent='';
00870                 $formContent.='
00871 
00872                         <!--
00873                                 Header of the editing page.
00874                                 Contains the buttons for saving/closing, the document selector and menu selector.
00875                                 Shows the path of the editing operation as well.
00876                         -->
00877                         <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
00878                                 <tr>
00879                                         <td nowrap="nowrap" valign="top">'.$panel.'</td>
00880                                         <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
00881                                 </tr>
00882                                 <tr>
00883                                         <td colspan="2">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</td>
00884                                 </tr>
00885                         </table>
00886                         <img src="clear.gif" width="1" height="4" alt="" /><br />
00887 
00888 
00889 
00890 
00891                         <!--
00892                                 EDITING FORM:
00893                         -->
00894 
00895                         '.$editForm.'
00896 
00897 
00898 
00899                         <!--
00900                                 Saving buttons (same as in top)
00901                         -->
00902 
00903                         '.$panel.
00904                         '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
00905                         <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
00906 
00907                 if ($this->returnNewPageId)     {
00908                         $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
00909                 }
00910                 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
00911                 if ($this->viewId_addParams) {
00912                         $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
00913                 }
00914                 $formContent.='<input type="hidden" name="closeDoc" value="0" />';
00915                 $formContent.='<input type="hidden" name="doSave" value="0" />';
00916                 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00917                 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00918 
00919                 return $formContent;
00920         }
00921 
00927         function functionMenus()        {
00928                 global $BE_USER,$LANG;
00929 
00930                 $funcMenus = '';
00931 
00932                         // Show palettes:
00933                 $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);
00934 
00935                         // Show descriptions/help texts:
00936                 if ($BE_USER->uc['edit_showFieldHelp']!='text') {
00937                         $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);
00938                 }
00939 
00940                         // Show disable RTE checkbox:
00941                 if ($BE_USER->isRTE())  {
00942                         $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);
00943                 }
00944 
00945                 return '
00946 
00947                                 <!--
00948                                         Function menus (checkboxes for selecting options):
00949                                 -->
00950                                 '.$funcMenus;
00951         }
00952 
00958         function shortCutLink() {
00959                 global $BE_USER,$LANG;
00960 
00961                         // ShortCut
00962                 if ($this->returnUrl!='close.html')     {
00963                         $content.='<br /><br />';
00964 
00965                                 // Shortcut:
00966                         if ($BE_USER->mayMakeShortcut())        {
00967                                 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
00968                         }
00969 
00970                                 // Open in new window:
00971                         $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;';
00972                         $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00973                                         '<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="" />'.
00974                                         '</a>';
00975                 }
00976                 return '
00977 
00978                                 <!--
00979                                         Shortcut link:
00980                                 -->
00981                                 '.$content;
00982         }
00983 
00989         function tceformMessages()      {
00990                 if (count($this->tceforms->commentMessages))    {
00991                         $this->content.='
00992 
00993 <!-- TCEFORM messages
00994 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
00995 -->
00996 
00997 ';
00998                 }
00999         }
01000 
01001 
01002 
01003 
01004 
01005 
01006 
01007 
01008 
01009 
01010 
01011 
01012 
01013 
01014 
01015 
01016         /***************************
01017          *
01018          * Other functions
01019          *
01020          ***************************/
01021 
01027         function editRegularContentFromId()     {
01028                 if (t3lib_extMgm::isLoaded('cms'))      {
01029                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01030                                                 'uid',
01031                                                 'tt_content',
01032                                                 'pid='.intval($this->editRegularContentFromId).
01033                                                         t3lib_BEfunc::deleteClause('tt_content').
01034                                                         ' AND colPos=0 AND sys_language_uid=0',
01035                                                 '',
01036                                                 'sorting'
01037                                         );
01038                         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
01039                                 $ecUids=array();
01040                                 while($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))     {
01041                                         $ecUids[]=$ecRec['uid'];
01042                                 }
01043                                 $this->editconf['tt_content'][implode(',',$ecUids)]='edit';
01044                         }
01045                 }
01046         }
01047 
01054         function compileStoreDat()      {
01055                 $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId',$this->R_URL_getvars);
01056                 $this->storeUrl = t3lib_div::implodeArrayForUrl('',$this->storeArray);
01057                 $this->storeUrlMd5 = md5($this->storeUrl);
01058         }
01059 
01067         function getNewIconMode($table,$key='saveDocNew')       {
01068                 global $BE_USER;
01069                 $TSconfig = $BE_USER->getTSConfig('options.'.$key);
01070                 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
01071                 return $output;
01072         }
01073 
01080         function closeDocument($code=0) {
01081                 global $BE_USER;
01082 
01083                         // If current document is found in docHandler, then unset it, possibly unset it ALL and finally, write it to the session data:
01084                 if (isset($this->docHandler[$this->storeUrlMd5]))       {
01085                         unset($this->docHandler[$this->storeUrlMd5]);
01086                         if ($code=='3') $this->docHandler=array();
01087                         $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1]));
01088                 }
01089 
01090                         // 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...)
01091                 if ($this->returnEditConf && $this->retUrl!='dummy.php')        {
01092                         $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf));
01093                 }
01094 
01095                         // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl
01096                 if (!$code || $code==1) {
01097                         Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl));
01098                         exit;
01099                 } else {
01100                         $this->setDocument('',$this->retUrl);
01101                 }
01102         }
01103 
01112         function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php')  {
01113                 if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl,'alt_doc_nodoc.php'))     return;
01114 
01115                 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) {
01116                         if (isset($this->docHandler[$currentDocFromHandlerMD5]))        {
01117                                 $setupArr=$this->docHandler[$currentDocFromHandlerMD5];
01118                         } else {
01119                                 reset($this->docHandler);
01120                                 $setupArr=current($this->docHandler);
01121                         }
01122                         if ($setupArr[2])       {
01123                                 $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
01124                                 $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl);
01125                         }
01126                 }
01127                 Header('Location: '.t3lib_div::locationHeaderUrl($retUrl));
01128                 exit;
01129         }
01130 }
01131 
01132 // Include extension?
01133 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php'])       {
01134         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']);
01135 }
01136 
01137 
01138 
01139 
01140 
01141 
01142 
01143 
01144 
01145 
01146 
01147 
01148 
01149 
01150 
01151 
01152 // Make instance:
01153 $SOBE = t3lib_div::makeInstance('SC_alt_doc');
01154 
01155 // Preprocessing, storing data if submitted to
01156 $SOBE->preInit();
01157 if ($SOBE->doProcessData())     {               // Checks, if a save button has been clicked (or the doSave variable is sent)
01158         require_once (PATH_t3lib.'class.t3lib_tcemain.php');
01159         $SOBE->processData();
01160 }
01161 
01162 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
01163 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
01164 
01165 
01166 // Main:
01167 $SOBE->init();
01168 $SOBE->main();
01169 $SOBE->printContent();
01170 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6