* When using frontend editing with pop-up window the save-and-view button will not...
[Packages/TYPO3.CMS.git] / typo3 / alt_doc.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Main form rendering script
29 * By sending certain parameters to this script you can bring up a form
30 * which allows the user to edit the content of one or more database records.
31 *
32 * $Id$
33 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
34 * XHTML compliant
35 *
36 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
37 */
38 /**
39 * [CLASS/FUNCTION INDEX of SCRIPT]
40 *
41 *
42 *
43 * 94: class SC_alt_doc
44 * 167: function preInit()
45 * 219: function doProcessData()
46 * 229: function processData()
47 * 346: function init()
48 * 432: function main()
49 * 500: function printContent()
50 *
51 * SECTION: Sub-content functions, rendering specific parts of the module content.
52 * 535: function makeEditForm()
53 * 717: function makeButtonPanel()
54 * 796: function makeDocSel()
55 * 838: function makeCmenu()
56 * 859: function compileForm($panel,$docSel,$cMenu,$editForm)
57 * 921: function functionMenus()
58 * 952: function shortCutLink()
59 * 983: function tceformMessages()
60 *
61 * SECTION: Other functions
62 * 1021: function editRegularContentFromId()
63 * 1048: function compileStoreDat()
64 * 1061: function getNewIconMode($table,$key='saveDocNew')
65 * 1074: function closeDocument($code=0)
66 * 1106: function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php')
67 *
68 * TOTAL FUNCTIONS: 19
69 * (This index is automatically created/updated by the extension "extdeveval")
70 *
71 */
72
73
74 require('init.php');
75 require('template.php');
76 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml');
77 require_once (PATH_t3lib.'class.t3lib_tceforms.php');
78 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
79
80
81 t3lib_BEfunc::lockRecords();
82
83
84
85
86 /**
87 * Script Class: Drawing the editing form for editing records in TYPO3.
88 * Notice: It does NOT use tce_db.php to submit data to, rather it handles submissions itself
89 *
90 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
91 * @package TYPO3
92 * @subpackage core
93 */
94 class SC_alt_doc {
95
96 // Internal, static: GPvars:
97 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.
98 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
99 var $defVals; // Default values for fields (array with tablenames, fields etc. as keys). Can be seen modified internally.
100 var $overrideVals; // Array of values to force being set (as hidden fields). Will be set as $this->defVals IF defVals does not exist.
101 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
102 var $closeDoc; // Close-document command. Not really sure of all options...
103 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).
104
105 var $data; // GPvar (for processing only) : The data array from which the data comes...
106 var $mirror; // GPvar (for processing only) : ?
107 var $cacheCmd; // GPvar (for processing only) : Clear-cache cmd.
108 var $redirect; // GPvar (for processing only) : Redirect (not used???)
109 var $disableRTE; // GPvar (for processing only) : If set, the rich text editor is disabled in the forms.
110 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.
111 var $vC; // GPvar (for processing only) : Verification code, internal stuff.
112
113 var $popViewId; // GPvar (module) : ID for displaying the page in the frontend (used for SAVE/VIEW operations)
114 var $popViewId_addParams; // GPvar (module) : Additional GET vars for the link, eg. "&L=xxx"
115 var $viewUrl; // GPvar (module) : Alternative URL for viewing the frontend pages.
116 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!
117 var $recTitle; // Alternative title for the document handler.
118 var $disHelp; // Disable help... ?
119 var $noView; // If set, then no SAVE/VIEW button is printed
120 var $returnEditConf; // If set, the $this->editconf array is returned to the calling script (used by wizard_add.php for instance)
121
122
123 // Internal, static:
124 var $doc; // Document template object
125 var $content; // Content accumulation
126
127 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.
128 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...
129 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.)
130 var $R_URI; // Set to the URL of this script including variables which is needed to re-display the form. See main()
131
132 var $storeTitle; // Is loaded with the "title" of the currently "open document" - this is used in the Document Selector box. (see makeDocSel())
133 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())
134 var $storeUrl; // Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
135 var $storeUrlMd5; // Hashed value of storeURL (see compileStoreDat())
136
137 var $docDat; // Module session data
138 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".
139
140
141 // Internal: Related to the form rendering:
142 var $elementsData; // Array of the elements to create edit forms for.
143 var $firstEl; // Pointer to the first element in $elementsData
144 var $errorC; // Counter, used to count the number of errors (when users do not have edit permissions)
145 var $newC; // Counter, used to count the number of new record forms displayed
146 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
147 var $viewId_addParams; // Is set to additional parameters (like "&L=xxx") if the record supports it.
148 var $modTSconfig; // Module TSconfig, loaded from main() based on the page id value of viewId
149 var $tceforms; // Contains the instance of TCEforms class.
150 var $generalPathOfForm; // Contains the root-line path of the currently edited record(s) - for display.
151
152
153 // Internal, dynamic:
154 var $dontStoreDocumentRef; // Used internally to disable the storage of the document reference (eg. new records)
155
156
157
158
159
160
161
162 /**
163 * First initialization.
164 *
165 * @return void
166 */
167 function preInit() {
168 global $BE_USER;
169
170 // Setting GPvars:
171 $this->editconf = t3lib_div::_GP('edit');
172 $this->defVals = t3lib_div::_GP('defVals');
173 $this->overrideVals = t3lib_div::_GP('overrideVals');
174 $this->columnsOnly = t3lib_div::_GP('columnsOnly');
175 $this->returnUrl = t3lib_div::_GP('returnUrl');
176 $this->closeDoc = t3lib_div::_GP('closeDoc');
177 $this->doSave = t3lib_div::_GP('doSave');
178 $this->returnEditConf = t3lib_div::_GP('returnEditConf');
179
180 // Setting override values as default if defVals does not exist.
181 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
182 $this->defVals = $this->overrideVals;
183 }
184
185 // Setting return URL
186 $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php';
187
188 // Make R_URL (request url) based on input GETvars:
189 $this->R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
190 $this->R_URL_getvars = t3lib_div::_GET();
191
192 // MAKE url for storing
193 $this->compileStoreDat();
194
195 // Initialize more variables.
196 $this->dontStoreDocumentRef=0;
197 $this->storeTitle='';
198
199 // Get session data for the module:
200 $this->docDat = $BE_USER->getModuleData('alt_doc.php','ses');
201 $this->docHandler = $this->docDat[0];
202
203 // If a request for closing the document has been sent, act accordingly:
204 if ($this->closeDoc>0) {
205 $this->closeDocument($this->closeDoc);
206 }
207
208 // If NO vars are sent to the script, try to read first document:
209 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...
210 $this->setDocument($this->docDat[1]);
211 }
212 }
213
214 /**
215 * Detects, if a save command has been triggered.
216 *
217 * @return boolean True, then save the document (data submitted)
218 */
219 function doProcessData() {
220 $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']);
221 return $out;
222 }
223
224 /**
225 * Do processing of data, submitting it to TCEmain.
226 *
227 * @return void
228 */
229 function processData() {
230 global $BE_USER,$TYPO3_CONF_VARS;
231
232 // GPvars specifically for processing:
233 $this->data = t3lib_div::_GP('data');
234 $this->mirror = t3lib_div::_GP('mirror');
235 $this->cacheCmd = t3lib_div::_GP('cacheCmd');
236 $this->redirect = t3lib_div::_GP('redirect');
237 $this->disableRTE = t3lib_div::_GP('_disableRTE');
238 $this->returnNewPageId = t3lib_div::_GP('returnNewPageId');
239 $this->vC = t3lib_div::_GP('vC');
240
241 // See tce_db.php for relevate options here:
242 // Only options related to $this->data submission are included here.
243 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
244 $tce->stripslashes_values=0;
245
246 // Setting default values specific for the user:
247 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
248 if (is_array($TCAdefaultOverride)) {
249 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
250 }
251
252 // Setting internal vars:
253 if ($BE_USER->uc['neverHideAtCopy']) { $tce->neverHideAtCopy = 1; }
254 $tce->debug=0;
255 $tce->disableRTE = $this->disableRTE;
256
257 // Loading TCEmain with data:
258 $tce->start($this->data,array());
259 if (is_array($this->mirror)) { $tce->setMirror($this->mirror); }
260
261 // If pages are being edited, we set an instruction about updating the page tree after this operation.
262 if (isset($this->data['pages'])) {
263 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
264 }
265
266
267 // Checking referer / executing
268 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
269 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
270 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
271 $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));
272 debug('Error: Referer host did not match with server host.');
273 } else {
274
275 // Perform the saving operation with TCEmain:
276 $tce->process_uploads($_FILES);
277 $tce->process_datamap();
278
279 // If there was saved any new items, load them:
280 if (count($tce->substNEWwithIDs_table)) {
281
282 // Resetting editconf:
283 $this->editconf = array();
284
285 // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
286 foreach($tce->substNEWwithIDs_table as $nKey => $nTable) {
287 $this->editconf[$nTable][$tce->substNEWwithIDs[$nKey]]='edit';
288 if ($nTable=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId) {
289 $this->retUrl.='&id='.$tce->substNEWwithIDs[$nKey];
290 }
291 }
292
293 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
294 $this->R_URL_getvars['edit']=$this->editconf;
295
296 // Unsetting default values since we don't need them anymore.
297 unset($this->R_URL_getvars['defVals']);
298
299 // Re-compile the store* values since editconf changed...
300 $this->compileStoreDat();
301 }
302
303 // If a document is saved and a new one is created right after.
304 if (isset($_POST['_savedoknew_x']) && is_array($this->editconf)) {
305
306 // Finding the current table:
307 reset($this->editconf);
308 $nTable=key($this->editconf);
309
310 // Finding the first id, getting the records pid+uid
311 reset($this->editconf[$nTable]);
312 $nUid=key($this->editconf[$nTable]);
313 $nRec = t3lib_BEfunc::getRecord($nTable,$nUid,'pid,uid');
314
315 // Setting a blank editconf array for a new record:
316 $this->editconf=array();
317 if ($this->getNewIconMode($nTable)=='top') {
318 $this->editconf[$nTable][$nRec['pid']]='new';
319 } else {
320 $this->editconf[$nTable][-$nRec['uid']]='new';
321 }
322
323 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
324 $this->R_URL_getvars['edit']=$this->editconf;
325
326 // Re-compile the store* values since editconf changed...
327 $this->compileStoreDat();
328 }
329
330 $tce->printLogErrorMessages(
331 isset($_POST['_saveandclosedok_x']) ?
332 $this->retUrl :
333 $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?
334 );
335 }
336 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!
337 $this->closeDocument(abs($this->closeDoc));
338 }
339 }
340
341 /**
342 * Initialize the normal module operation
343 *
344 * @return void
345 */
346 function init() {
347 global $BE_USER,$LANG,$BACK_PATH;
348
349 // Setting more GPvars:
350 $this->popViewId = t3lib_div::_GP('popViewId');
351 $this->popViewId_addParams = t3lib_div::_GP('popViewId_addParams');
352 $this->viewUrl = t3lib_div::_GP('viewUrl');
353 $this->editRegularContentFromId = t3lib_div::_GP('editRegularContentFromId');
354 $this->recTitle = t3lib_div::_GP('recTitle');
355 $this->disHelp = t3lib_div::_GP('disHelp');
356 $this->noView = t3lib_div::_GP('noView');
357
358 // Set other internal variables:
359 $this->R_URL_getvars['returnUrl']=$this->retUrl;
360 $this->R_URI = $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars);
361
362 // MENU-ITEMS:
363 // If array, then it's a selector box menu
364 // If empty string it's just a variable, that'll be saved.
365 // Values NOT in this array will not be saved in the settings-array for the module.
366 $this->MOD_MENU = array(
367 'showPalettes' => '',
368 'showDescriptions' => '',
369 'disableRTE' => ''
370 );
371
372 // Setting virtual document name
373 $this->MCONF['name']='xMOD_alt_doc.php';
374
375 // CLEANSE SETTINGS
376 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
377
378 // Create an instance of the document template object
379 $this->doc = t3lib_div::makeInstance('mediumDoc');
380 $this->doc->bodyTagMargins['x']=5;
381 $this->doc->bodyTagMargins['y']=5;
382 $this->doc->backPath = $BACK_PATH;
383 $this->doc->docType = 'xhtml_trans';
384
385 $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);">';
386
387 $this->doc->JScode = $this->doc->wrapScriptTags('
388 function jumpToUrl(URL,formEl) { //
389 if (!TBE_EDITOR_isFormChanged()) {
390 document.location = URL;
391 } else if (formEl && formEl.type=="checkbox") {
392 formEl.checked = formEl.checked ? 0 : 1;
393 }
394 }
395
396 // Object: TS:
397 function typoSetup () { //
398 this.uniqueID = "";
399 }
400 var TS = new typoSetup();
401
402 // Info view:
403 function launchView(table,uid,bP) { //
404 var backPath= bP ? bP : "";
405 var thePreviewWindow="";
406 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");
407 if (thePreviewWindow && thePreviewWindow.focus) {
408 thePreviewWindow.focus();
409 }
410 }
411 function deleteRecord(table,id,url) { //
412 if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')) {
413 document.location = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
414 }
415 return false;
416 }
417 '.(isset($_POST['_savedokview_x']) && $this->popViewId ?
418 'if (window.opener) { '.
419 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams,FALSE).
420 ' } else { '.
421 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams).
422 ' } '
423 : '')
424 ).$this->doc->getDynTabMenuJScode();
425
426 // Setting up the context sensitive menu:
427 $CMparts = $this->doc->getContextMenuCode();
428 $this->doc->JScode.= $CMparts[0];
429 $this->doc->bodyTagAdditions = $CMparts[1];
430 $this->doc->postCode.= $CMparts[2];
431 }
432
433 /**
434 * Main module operation
435 *
436 * @return void
437 */
438 function main() {
439 global $BE_USER,$LANG;
440
441 // Starting content accumulation:
442 $this->content='';
443 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
444
445 // Begin edit:
446 if (is_array($this->editconf)) {
447
448 // Initialize TCEforms (rendering the forms)
449 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
450 $this->tceforms->initDefaultBEMode();
451 $this->tceforms->doSaveFieldName = 'doSave';
452 $this->tceforms->returnUrl = $this->R_URI;
453 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
454 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
455 $this->tceforms->enableClickMenu = TRUE;
456 $this->tceforms->enableTabMenu = TRUE;
457
458 // Clipboard is initialized:
459 $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
460 $this->tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
461
462 // Setting external variables:
463 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text';
464
465 if ($this->editRegularContentFromId) {
466 $this->editRegularContentFromId();
467 }
468
469 // Creating the editing form, wrap it with buttons, document selector etc.
470 $editForm = $this->makeEditForm();
471 if ($editForm) {
472 reset($this->elementsData);
473 $this->firstEl = current($this->elementsData);
474
475 if ($this->viewId) {
476 // Module configuration:
477 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
478 } else $this->modTSconfig=array();
479
480 $panel = $this->makeButtonPanel();
481 $docSel = $this->makeDocSel();
482 $cMenu = $this->makeCmenu();
483
484 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm);
485
486 $this->content.= $this->tceforms->printNeededJSFunctions_top().
487 $formContent.
488 $this->tceforms->printNeededJSFunctions();
489 $this->content.= $this->functionMenus();
490
491 // Add CSH:
492 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;');
493
494 $this->content.= $this->shortCutLink();
495
496 $this->tceformMessages();
497 }
498 }
499 }
500
501 /**
502 * Outputting the accumulated content to screen
503 *
504 * @return void
505 */
506 function printContent() {
507
508 echo $this->content.$this->doc->endPage();
509 }
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530 /***************************
531 *
532 * Sub-content functions, rendering specific parts of the module content.
533 *
534 ***************************/
535
536 /**
537 * Creates the editing form with TCEforms, based on the input from GPvars.
538 *
539 * @return string HTML form elements wrapped in tables
540 */
541 function makeEditForm() {
542 global $BE_USER,$LANG,$TCA;
543
544 // Initialize variables:
545 $this->elementsData=array();
546 $this->errorC=0;
547 $this->newC=0;
548 $thePrevUid='';
549 $editForm='';
550
551 // Traverse the GPvar edit array
552 foreach($this->editconf as $table => $conf) { // Tables:
553 if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
554
555 // Traverse the keys/comments of each table (keys can be a commalist of uids)
556 foreach($conf as $cKey => $cmd) {
557 if ($cmd=='edit' || $cmd=='new') {
558
559 // Get the ids:
560 $ids = t3lib_div::trimExplode(',',$cKey,1);
561
562 // Traverse the ids:
563 foreach($ids as $theUid) {
564
565 // 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...)
566 // First, resetting flags.
567 $hasAccess = 1;
568 $deniedAccessReason = '';
569 $deleteAccess = 0;
570 $this->viewId = 0;
571
572 // If the command is to create a NEW record...:
573 if ($cmd=='new') {
574 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.
575
576 // Find parent page on which the new record reside
577 if ($theUid<0) { // Less than zero - find parent page
578 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
579 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
580 } else { // always a page
581 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
582 }
583
584 // Now, calculate whether the user has access to creating new records on this position:
585 if (is_array($calcPRec)) {
586 $CALC_PERMS = $BE_USER->calcPerms($calcPRec); // Permissions for the parent page
587 if ($table=='pages') { // If pages:
588 $hasAccess = $CALC_PERMS&8 ? 1 : 0;
589 $this->viewId = $calcPRec['pid'];
590 } else {
591 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
592 $this->viewId = $calcPRec['uid'];
593 }
594 }
595 }
596 $this->dontStoreDocumentRef=1; // Don't save this document title in the document selector if the document is new.
597 } else { // Edit:
598 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
599 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
600 if (is_array($calcPRec)) {
601 if ($table=='pages') { // If pages:
602 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
603 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
604 $deleteAccess = $CALC_PERMS&4 ? 1 : 0;
605 $this->viewId = $calcPRec['uid'];
606 } else {
607 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid'])); // Fetching pid-record first.
608 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
609 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
610 $this->viewId = $calcPRec['pid'];
611
612 // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
613 if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0) {
614 $this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']];
615 }
616 }
617
618 // Check internals regarding access:
619 if ($hasAccess) {
620 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
621 $deniedAccessReason = $BE_USER->errorMsg;
622 }
623 } else $hasAccess = 0;
624 }
625
626 // 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:
627
628 if ($hasAccess) {
629 $prevPageID = is_object($trData)?$trData->prevPageID:'';
630 $trData = t3lib_div::makeInstance('t3lib_transferData');
631 $trData->addRawData = TRUE;
632 $trData->defVals = $this->defVals;
633 $trData->lockRecords=1;
634 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
635 $trData->prevPageID = $prevPageID;
636 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':''); // 'new'
637 reset($trData->regTableItems_data);
638 $rec = current($trData->regTableItems_data);
639 $rec['uid'] = $cmd=='new'?uniqid('NEW'):$theUid;
640 $this->elementsData[]=array(
641 'table' => $table,
642 'uid' => $rec['uid'],
643 'cmd' => $cmd,
644 'deleteAccess' => $deleteAccess
645 );
646 if ($cmd=='new') {
647 $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
648 }
649
650 // Now, render the form:
651 if (is_array($rec)) {
652
653 // Setting visual path / title of form:
654 $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
655 if (!$this->storeTitle) {
656 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1);
657 }
658
659 // Setting variables in TCEforms object:
660 $this->tceforms->hiddenFieldList = '';
661 $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
662 if (is_array($this->overrideVals[$table])) {
663 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
664 }
665
666 // Register default language labels, if any:
667 $this->tceforms->registerDefaultLanguageData($table,$rec);
668
669 // Create form for the record (either specific list of fields or the whole record):
670 $panel = '';
671 if ($this->columnsOnly) {
672 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
673 } else {
674 $panel.= $this->tceforms->getMainFields($table,$rec);
675 }
676 $panel = $this->tceforms->wrapTotal($panel,$rec,$table);
677
678 // Setting the pid value for new records:
679 if ($cmd=='new') {
680 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
681 $this->newC++;
682 }
683
684 // Display "is-locked" message:
685 if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid'])) {
686 $lockIcon = '
687
688 <!--
689 Warning box:
690 -->
691 <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
692 <tr>
693 <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
694 <td>'.htmlspecialchars($lockInfo['msg']).'</td>
695 </tr>
696 </table>
697 ';
698 } else $lockIcon = '';
699
700 // Combine it all:
701 $editForm.= $lockIcon.$panel;
702 }
703
704 $thePrevUid = $rec['uid'];
705 } else {
706 $this->errorC++;
707 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'.
708 ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : '');
709 }
710 }
711 }
712 }
713 }
714 }
715 return $editForm;
716 }
717
718 /**
719 * Create the panel of buttons for submitting the form or otherwise perform operations.
720 *
721 * @return string HTML code, comprised of images linked to various actions.
722 */
723 function makeButtonPanel() {
724 global $TCA,$LANG;
725
726 $panel='';
727
728 // Render SAVE type buttons:
729 // The action of each button is decided by its name attribute. (See doProcessData())
730 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly']) {
731
732 // SAVE button:
733 $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).'" />';
734
735 // SAVE / VIEW button:
736 if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
737 $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).'" />';
738 }
739
740 // SAVE / NEW button:
741 if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
742 $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).'" />';
743 }
744
745 // SAVE / CLOSE
746 $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).'" />';
747 }
748
749 // CLOSE button:
750 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
751 '<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="" />'.
752 '</a>';
753
754 // DELETE + UNDO buttons:
755 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1) {
756 if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid'])) {
757
758 // Delete:
759 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
760 $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
761 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
762 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
763 '</a>';
764 }
765
766 // Undo:
767 $undoButton = 0;
768 $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');
769 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
770 $undoButton = 1;
771 }
772 if ($undoButton) {
773 $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;';
774 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
775 '<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="" />'.
776 '</a>';
777 }
778 if ($this->getNewIconMode($this->firstEl['table'],'showHistory')) {
779 $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
780 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
781 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
782 '</a>';
783 }
784
785 // If only SOME fields are shown in the form, this will link the user to the FULL form:
786 if ($this->columnsOnly) {
787 $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
788 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
789 '</a>';
790 }
791 }
792 }
793 return $panel;
794 }
795
796 /**
797 * Create the selector box form element which allows to select between open documents.
798 * Can be disabled through Page TSconfig.
799 *
800 * @return string HTML <select> element (if applicable)
801 */
802 function makeDocSel() {
803 global $BE_USER,$LANG;
804
805 // Render the selector ONLY if it has not been disabled:
806 if (!$this->modTSconfig['properties']['disableDocSelector']) {
807
808 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
809 if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
810 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
811 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
812 }
813
814 // Now, create the document selector box:
815 $docSel='';
816 if (is_array($this->docHandler)) {
817 $opt = array();
818 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
819
820 // Traverse the list of open documents:
821 foreach($this->docHandler as $md5k => $setupArr) {
822 $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
823 $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
824 }
825
826 // Compile the selector box finally:
827 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){document.location=(this.options[this.selectedIndex].value);}';
828 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
829
830 // Add CSH:
831 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE);
832 }
833 } else $docSel='';
834 return $docSel;
835 }
836
837 /**
838 * Create the selector box form element which allows to select a clear-cache operation.
839 * Can be disabled through Page TSconfig.
840 *
841 * @return string HTML <select> element (if applicable)
842 * @see template::clearCacheMenu()
843 */
844 function makeCmenu() {
845
846 // Generate the menu if NOT disabled:
847 if (!$this->modTSconfig['properties']['disableCacheSelector']) {
848 $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
849
850 // Add CSH:
851 $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE);
852 } else $cMenu ='';
853 return $cMenu;
854 }
855
856 /**
857 * Put together the various elements (buttons, selectors, form) into a table
858 *
859 * @param string The button panel HTML
860 * @param string Document selector HTML
861 * @param string Clear-cache menu HTML
862 * @param string HTML form.
863 * @return string Composite HTML
864 */
865 function compileForm($panel,$docSel,$cMenu,$editForm) {
866 global $LANG;
867
868
869 $formContent='';
870 $formContent.='
871
872 <!--
873 Header of the editing page.
874 Contains the buttons for saving/closing, the document selector and menu selector.
875 Shows the path of the editing operation as well.
876 -->
877 <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
878 <tr>
879 <td nowrap="nowrap" valign="top">'.$panel.'</td>
880 <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
881 </tr>
882 <tr>
883 <td colspan="2">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</td>
884 </tr>
885 </table>
886 <img src="clear.gif" width="1" height="4" alt="" /><br />
887
888
889
890
891 <!--
892 EDITING FORM:
893 -->
894
895 '.$editForm.'
896
897
898
899 <!--
900 Saving buttons (same as in top)
901 -->
902
903 '.$panel.
904 '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
905 <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
906
907 if ($this->returnNewPageId) {
908 $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
909 }
910 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
911 if ($this->viewId_addParams) {
912 $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
913 }
914 $formContent.='<input type="hidden" name="closeDoc" value="0" />';
915 $formContent.='<input type="hidden" name="doSave" value="0" />';
916 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
917 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
918
919 return $formContent;
920 }
921
922 /**
923 * Create the checkbox buttons in the bottom of the pages.
924 *
925 * @return string HTML for function menus.
926 */
927 function functionMenus() {
928 global $BE_USER,$LANG;
929
930 $funcMenus = '';
931
932 // Show palettes:
933 $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);
934
935 // Show descriptions/help texts:
936 if ($BE_USER->uc['edit_showFieldHelp']!='text') {
937 $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);
938 }
939
940 // Show disable RTE checkbox:
941 if ($BE_USER->isRTE()) {
942 $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);
943 }
944
945 return '
946
947 <!--
948 Function menus (checkboxes for selecting options):
949 -->
950 '.$funcMenus;
951 }
952
953 /**
954 * Create shortcut and open-in-window link in the bottom of the page
955 *
956 * @return string
957 */
958 function shortCutLink() {
959 global $BE_USER,$LANG;
960
961 // ShortCut
962 if ($this->returnUrl!='close.html') {
963 $content.='<br /><br />';
964
965 // Shortcut:
966 if ($BE_USER->mayMakeShortcut()) {
967 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
968 }
969
970 // Open in new window:
971 $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;';
972 $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
973 '<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="" />'.
974 '</a>';
975 }
976 return '
977
978 <!--
979 Shortcut link:
980 -->
981 '.$content;
982 }
983
984 /**
985 * Reads comment messages from TCEforms and prints them in a HTML comment in the buttom of the page.
986 *
987 * @return void
988 */
989 function tceformMessages() {
990 if (count($this->tceforms->commentMessages)) {
991 $this->content.='
992
993 <!-- TCEFORM messages
994 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
995 -->
996
997 ';
998 }
999 }
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016 /***************************
1017 *
1018 * Other functions
1019 *
1020 ***************************/
1021
1022 /**
1023 * Function, which populates the internal editconf array with editing commands for all tt_content elements from the normal column in normal language from the page pointed to by $this->editRegularContentFromId
1024 *
1025 * @return void
1026 */
1027 function editRegularContentFromId() {
1028 if (t3lib_extMgm::isLoaded('cms')) {
1029 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1030 'uid',
1031 'tt_content',
1032 'pid='.intval($this->editRegularContentFromId).
1033 t3lib_BEfunc::deleteClause('tt_content').
1034 ' AND colPos=0 AND sys_language_uid=0',
1035 '',
1036 'sorting'
1037 );
1038 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
1039 $ecUids=array();
1040 while($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1041 $ecUids[]=$ecRec['uid'];
1042 }
1043 $this->editconf['tt_content'][implode(',',$ecUids)]='edit';
1044 }
1045 }
1046 }
1047
1048 /**
1049 * Populates the variables $this->storeArray, $this->storeUrl, $this->storeUrlMd5
1050 *
1051 * @return void
1052 * @see makeDocSel()
1053 */
1054 function compileStoreDat() {
1055 $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId',$this->R_URL_getvars);
1056 $this->storeUrl = t3lib_div::implodeArrayForUrl('',$this->storeArray);
1057 $this->storeUrlMd5 = md5($this->storeUrl);
1058 }
1059
1060 /**
1061 * Function used to look for configuration of buttons in the form: Fx. disabling buttons or showing them at various positions.
1062 *
1063 * @param string The table for which the configuration may be specific
1064 * @param string The option for look for. Default is checking if the saveDocNew button should be displayed.
1065 * @return string Return value fetched from USER TSconfig
1066 */
1067 function getNewIconMode($table,$key='saveDocNew') {
1068 global $BE_USER;
1069 $TSconfig = $BE_USER->getTSConfig('options.'.$key);
1070 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
1071 return $output;
1072 }
1073
1074 /**
1075 * Handling the closing of a document
1076 *
1077 * @param integer Close code: 0/1 will redirect to $this->retUrl, 3 will clear the docHandler (thus closing all documents) and otehr values will call setDocument with ->retUrl
1078 * @return void
1079 */
1080 function closeDocument($code=0) {
1081 global $BE_USER;
1082
1083 // If current document is found in docHandler, then unset it, possibly unset it ALL and finally, write it to the session data:
1084 if (isset($this->docHandler[$this->storeUrlMd5])) {
1085 unset($this->docHandler[$this->storeUrlMd5]);
1086 if ($code=='3') $this->docHandler=array();
1087 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1]));
1088 }
1089
1090 // 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...)
1091 if ($this->returnEditConf && $this->retUrl!='dummy.php') {
1092 $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf));
1093 }
1094
1095 // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl
1096 if (!$code || $code==1) {
1097 Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl));
1098 exit;
1099 } else {
1100 $this->setDocument('',$this->retUrl);
1101 }
1102 }
1103
1104 /**
1105 * Redirects to the document pointed to by $currentDocFromHandlerMD5 OR $retUrl (depending on some internal calculations).
1106 * Most likely you will get a header-location redirect from this function.
1107 *
1108 * @param string Pointer to the document in the docHandler array
1109 * @param string Alternative/Default retUrl
1110 * @return void
1111 */
1112 function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php') {
1113 if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl,'alt_doc_nodoc.php')) return;
1114
1115 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) {
1116 if (isset($this->docHandler[$currentDocFromHandlerMD5])) {
1117 $setupArr=$this->docHandler[$currentDocFromHandlerMD5];
1118 } else {
1119 reset($this->docHandler);
1120 $setupArr=current($this->docHandler);
1121 }
1122 if ($setupArr[2]) {
1123 $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
1124 $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl);
1125 }
1126 }
1127 Header('Location: '.t3lib_div::locationHeaderUrl($retUrl));
1128 exit;
1129 }
1130 }
1131
1132 // Include extension?
1133 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']) {
1134 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']);
1135 }
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152 // Make instance:
1153 $SOBE = t3lib_div::makeInstance('SC_alt_doc');
1154
1155 // Preprocessing, storing data if submitted to
1156 $SOBE->preInit();
1157 if ($SOBE->doProcessData()) { // Checks, if a save button has been clicked (or the doSave variable is sent)
1158 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
1159 $SOBE->processData();
1160 }
1161
1162 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
1163 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
1164
1165
1166 // Main:
1167 $SOBE->init();
1168 $SOBE->main();
1169 $SOBE->printContent();
1170 ?>