Added support for XML based locallang files (step 1, basic code)
[Packages/TYPO3.CMS.git] / typo3 / alt_doc.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 <kasper@typo3.com>
37 */
38 /**
39 * [CLASS/FUNCTION INDEX of SCRIPT]
40 *
41 *
42 *
43 * 93: class SC_alt_doc
44 * 164: function preInit()
45 * 216: function doProcessData()
46 * 228: function processData()
47 * 345: function init()
48 * 424: function main()
49 * 481: function printContent()
50 *
51 * SECTION: Sub-content functions, rendering specific parts of the module content.
52 * 516: function makeEditForm()
53 * 680: function makeButtonPanel()
54 * 759: function makeDocSel()
55 * 798: function makeCmenu()
56 * 816: function compileForm($panel,$docSel,$cMenu,$editForm)
57 * 875: function functionMenus()
58 * 906: function shortCutLink()
59 * 937: function tceformMessages()
60 *
61 * SECTION: Other functions
62 * 975: function editRegularContentFromId()
63 * 1002: function compileStoreDat()
64 * 1015: function getNewIconMode($table,$key='saveDocNew')
65 * 1028: function closeDocument($code=0)
66 * 1060: 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.php');
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 <kasper@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 $viewUrl; // GPvar (module) : Alternative URL for viewing the frontend pages.
115 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!
116 var $recTitle; // Alternative title for the document handler.
117 var $disHelp; // Disable help... ?
118 var $noView; // If set, then no SAVE/VIEW button is printed
119 var $returnEditConf; // If set, the $this->editconf array is returned to the calling script (used by wizard_add.php for instance)
120
121
122 // Internal, static:
123 var $doc; // Document template object
124 var $content; // Content accumulation
125
126 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.
127 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...
128 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.)
129 var $R_URI; // Set to the URL of this script including variables which is needed to re-display the form. See main()
130
131 var $storeTitle; // Is loaded with the "title" of the currently "open document" - this is used in the Document Selector box. (see makeDocSel())
132 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())
133 var $storeUrl; // Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
134 var $storeUrlMd5; // Hashed value of storeURL (see compileStoreDat())
135
136 var $docDat; // Module session data
137 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".
138
139
140 // Internal: Related to the form rendering:
141 var $elementsData; // Array of the elements to create edit forms for.
142 var $firstEl; // Pointer to the first element in $elementsData
143 var $errorC; // Counter, used to count the number of errors (when users do not have edit permissions)
144 var $newC; // Counter, used to count the number of new record forms displayed
145 var $viewId; // Is set the the pid value of the last shown record - thus indicating which page to show when clicking the SAVE/VIEW button
146 var $modTSconfig; // Module TSconfig, loaded from main() based on the page id value of viewId
147 var $tceforms; // Contains the instance of TCEforms class.
148 var $generalPathOfForm; // Contains the root-line path of the currently edited record(s) - for display.
149
150
151 // Internal, dynamic:
152 var $dontStoreDocumentRef; // Used internally to disable the storage of the document reference (eg. new records)
153
154
155
156
157
158
159
160 /**
161 * First initialization.
162 *
163 * @return void
164 */
165 function preInit() {
166 global $BE_USER;
167
168 // Setting GPvars:
169 $this->editconf = t3lib_div::_GP('edit');
170 $this->defVals = t3lib_div::_GP('defVals');
171 $this->overrideVals = t3lib_div::_GP('overrideVals');
172 $this->columnsOnly = t3lib_div::_GP('columnsOnly');
173 $this->returnUrl = t3lib_div::_GP('returnUrl');
174 $this->closeDoc = t3lib_div::_GP('closeDoc');
175 $this->doSave = t3lib_div::_GP('doSave');
176 $this->returnEditConf = t3lib_div::_GP('returnEditConf');
177
178 // Setting override values as default if defVals does not exist.
179 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
180 $this->defVals = $this->overrideVals;
181 }
182
183 // Setting return URL
184 $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php';
185
186 // Make R_URL (request url) based on input GETvars:
187 $this->R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
188 $this->R_URL_getvars = t3lib_div::_GET();
189
190 // MAKE url for storing
191 $this->compileStoreDat();
192
193 // Initialize more variables.
194 $this->dontStoreDocumentRef=0;
195 $this->storeTitle='';
196
197 // Get session data for the module:
198 $this->docDat = $BE_USER->getModuleData('alt_doc.php','ses');
199 $this->docHandler = $this->docDat[0];
200
201 // If a request for closing the document has been sent, act accordingly:
202 if ($this->closeDoc>0) {
203 $this->closeDocument($this->closeDoc);
204 }
205
206 // If NO vars are sent to the script, try to read first document:
207 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...
208 $this->setDocument($this->docDat[1]);
209 }
210 }
211
212 /**
213 * Detects, if a save command has been triggered.
214 *
215 * @return boolean True, then save the document (data submitted)
216 */
217 function doProcessData() {
218 global $HTTP_POST_VARS;
219
220 $out = $this->doSave || isset($HTTP_POST_VARS['_savedok_x']) || isset($HTTP_POST_VARS['_saveandclosedok_x']) || isset($HTTP_POST_VARS['_savedokview_x']) || isset($HTTP_POST_VARS['_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,$HTTP_POST_VARS,$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($GLOBALS['HTTP_POST_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($HTTP_POST_VARS['_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($HTTP_POST_VARS['_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($HTTP_POST_VARS['_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,$HTTP_POST_VARS;
348
349 // Setting more GPvars:
350 $this->popViewId = t3lib_div::_GP('popViewId');
351 $this->viewUrl = t3lib_div::_GP('viewUrl');
352 $this->editRegularContentFromId = t3lib_div::_GP('editRegularContentFromId');
353 $this->recTitle = t3lib_div::_GP('recTitle');
354 $this->disHelp = t3lib_div::_GP('disHelp');
355 $this->noView = t3lib_div::_GP('noView');
356
357 // Set other internal variables:
358 $this->R_URL_getvars['returnUrl']=$this->retUrl;
359 $this->R_URI = $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars);
360
361 // MENU-ITEMS:
362 // If array, then it's a selector box menu
363 // If empty string it's just a variable, that'll be saved.
364 // Values NOT in this array will not be saved in the settings-array for the module.
365 $this->MOD_MENU = array(
366 'showPalettes' => '',
367 'showDescriptions' => '',
368 'disableRTE' => ''
369 );
370
371 // Setting virtual document name
372 $this->MCONF['name']='xMOD_alt_doc.php';
373
374 // CLEANSE SETTINGS
375 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
376
377 // Create an instance of the document template object
378 $this->doc = t3lib_div::makeInstance('bigDoc');
379 $this->doc->bodyTagMargins['x']=5;
380 $this->doc->bodyTagMargins['y']=5;
381 $this->doc->backPath = $BACK_PATH;
382 $this->doc->docType = 'xhtml_trans';
383
384 $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);">';
385
386 $this->doc->JScode = $this->doc->wrapScriptTags('
387 function jumpToUrl(URL,formEl) { //
388 if (!TBE_EDITOR_isFormChanged()) {
389 document.location = URL;
390 } else if (formEl && formEl.type=="checkbox") {
391 formEl.checked = formEl.checked ? 0 : 1;
392 }
393 }
394
395 // Object: TS:
396 function typoSetup () { //
397 this.uniqueID = "";
398 }
399 var TS = new typoSetup();
400
401 // Info view:
402 function launchView(table,uid,bP) { //
403 var backPath= bP ? bP : "";
404 var thePreviewWindow="";
405 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");
406 if (thePreviewWindow && thePreviewWindow.focus) {
407 thePreviewWindow.focus();
408 }
409 }
410 function deleteRecord(table,id,url) { //
411 if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')) {
412 document.location = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
413 }
414 return false;
415 }
416 '.(isset($HTTP_POST_VARS['_savedokview_x']) && $this->popViewId ? t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl) : '')
417 );
418
419 // Setting up the context sensitive menu:
420 $CMparts = $this->doc->getContextMenuCode();
421 $this->doc->JScode.= $CMparts[0];
422 $this->doc->bodyTagAdditions = $CMparts[1];
423 $this->doc->postCode.= $CMparts[2];
424 }
425
426 /**
427 * Main module operation
428 *
429 * @return void
430 */
431 function main() {
432 global $BE_USER,$LANG;
433
434 // Starting content accumulation:
435 $this->content='';
436 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
437
438 // Begin edit:
439 if (is_array($this->editconf)) {
440
441 // Initialize TCEforms (rendering the forms)
442 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
443 $this->tceforms->initDefaultBEMode();
444 $this->tceforms->doSaveFieldName = 'doSave';
445 $this->tceforms->returnUrl = $this->R_URI;
446 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
447 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
448 $this->tceforms->enableClickMenu = TRUE;
449
450 // Clipboard is initialized:
451 $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
452 $this->tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
453
454 // Setting external variables:
455 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text';
456
457 if ($this->editRegularContentFromId) {
458 $this->editRegularContentFromId();
459 }
460
461 // Creating the editing form, wrap it with buttons, document selector etc.
462 $editForm = $this->makeEditForm();
463 if ($editForm) {
464 reset($this->elementsData);
465 $this->firstEl = current($this->elementsData);
466
467 if ($this->viewId) {
468 // Module configuration:
469 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
470 } else $this->modTSconfig=array();
471
472 $panel = $this->makeButtonPanel();
473 $docSel = $this->makeDocSel();
474 $cMenu = $this->makeCmenu();
475
476 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm);
477
478 $this->content.= $this->tceforms->printNeededJSFunctions_top().
479 $formContent.
480 $this->tceforms->printNeededJSFunctions();
481 $this->content.= $this->functionMenus();
482
483 // Add CSH:
484 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|');
485
486 $this->content.= $this->shortCutLink();
487
488 $this->tceformMessages();
489 }
490 }
491 }
492
493 /**
494 * Outputting the accumulated content to screen
495 *
496 * @return void
497 */
498 function printContent() {
499
500 echo $this->content.$this->doc->endPage();
501 }
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522 /***************************
523 *
524 * Sub-content functions, rendering specific parts of the module content.
525 *
526 ***************************/
527
528 /**
529 * Creates the editing form with TCEforms, based on the input from GPvars.
530 *
531 * @return string HTML form elements wrapped in tables
532 */
533 function makeEditForm() {
534 global $BE_USER,$LANG,$TCA;
535
536 // Initialize variables:
537 $this->elementsData=array();
538 $this->errorC=0;
539 $this->newC=0;
540 $thePrevUid='';
541 $editForm='';
542
543 // Traverse the GPvar edit array
544 foreach($this->editconf as $table => $conf) { // Tables:
545 if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
546
547 // Traverse the keys/comments of each table (keys can be a commalist of uids)
548 foreach($conf as $cKey => $cmd) {
549 if ($cmd=='edit' || $cmd=='new') {
550
551 // Get the ids:
552 $ids = t3lib_div::trimExplode(',',$cKey,1);
553
554 // Traverse the ids:
555 foreach($ids as $theUid) {
556
557 // 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...)
558 // First, resetting flags.
559 $hasAccess = 1;
560 $deleteAccess=0;
561 $this->viewId=0;
562
563 // If the command is to create a NEW record...:
564 if ($cmd=='new') {
565 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.
566
567 // Find parent page on which the new record reside
568 if ($theUid<0) { // Less than zero - find parent page
569 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
570 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
571 } else { // always a page
572 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
573 }
574
575 // Now, calculate whether the user has access to creating new records on this position:
576 if (is_array($calcPRec)) {
577 $CALC_PERMS = $BE_USER->calcPerms($calcPRec); // Permissions for the parent page
578 if ($table=='pages') { // If pages:
579 $hasAccess = $CALC_PERMS&8 ? 1 : 0;
580 $this->viewId = $calcPRec['pid'];
581 } else {
582 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
583 $this->viewId = $calcPRec['uid'];
584 }
585 }
586 }
587 $this->dontStoreDocumentRef=1; // Don't save this document title in the document selector if the document is new.
588 } else { // Edit:
589 $calcPRec=t3lib_BEfunc::getRecord($table,$theUid);
590 if (is_array($calcPRec)) {
591 if ($table=='pages') { // If pages:
592 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
593 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
594 $deleteAccess = $CALC_PERMS&4 ? 1 : 0;
595 $this->viewId = $calcPRec['uid'];
596 } else {
597 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid'])); // Fetching pid-record first.
598 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
599 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
600 $this->viewId = $calcPRec['pid'];
601 }
602 } else $hasAccess=0;
603 }
604
605 // 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:
606
607 if ($hasAccess) {
608 $prevPageID = is_object($trData)?$trData->prevPageID:'';
609 $trData = t3lib_div::makeInstance('t3lib_transferData');
610 $trData->defVals = $this->defVals;
611 $trData->lockRecords=1;
612 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
613 $trData->prevPageID = $prevPageID;
614 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':''); // 'new'
615 reset($trData->regTableItems_data);
616 $rec = current($trData->regTableItems_data);
617 $rec['uid'] = $cmd=='new'?uniqid('NEW'):$theUid;
618 $this->elementsData[]=array(
619 'table' => $table,
620 'uid' => $rec['uid'],
621 'cmd' => $cmd,
622 'deleteAccess' => $deleteAccess
623 );
624 if ($cmd=='new') {
625 $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
626 }
627
628 // Now, render the form:
629 if (is_array($rec)) {
630
631 // Setting visual path / title of form:
632 $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
633 if (!$this->storeTitle) {
634 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1);
635 }
636
637 // Setting variables in TCEforms object:
638 $this->tceforms->hiddenFieldList = '';
639 $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
640 if (is_array($this->overrideVals[$table])) {
641 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
642 }
643
644 // Create form for the record (either specific list of fields or the whole record):
645 $panel = '';
646 if ($this->columnsOnly) {
647 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
648 } else {
649 $panel.= $this->tceforms->getMainFields($table,$rec);
650 }
651 $panel = $this->tceforms->wrapTotal($panel,$rec,$table);
652
653 // Setting the pid value for new records:
654 if ($cmd=='new') {
655 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
656 $this->newC++;
657 }
658
659 // Display "is-locked" message:
660 if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid'])) {
661 $lockIcon = '
662
663 <!--
664 Warning box:
665 -->
666 <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
667 <tr>
668 <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
669 <td>'.htmlspecialchars($lockInfo['msg']).'</td>
670 </tr>
671 </table>
672 ';
673 } else $lockIcon = '';
674
675 // Combine it all:
676 $editForm.= $lockIcon.$panel;
677 }
678
679 $thePrevUid = $rec['uid'];
680 } else {
681 $this->errorC++;
682 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />';
683 }
684 }
685 }
686 }
687 }
688 }
689 return $editForm;
690 }
691
692 /**
693 * Create the panel of buttons for submitting the form or otherwise perform operations.
694 *
695 * @return string HTML code, comprised of images linked to various actions.
696 */
697 function makeButtonPanel() {
698 global $TCA,$LANG;
699
700 $panel='';
701
702 // Render SAVE type buttons:
703 // The action of each button is decided by its name attribute. (See doProcessData())
704 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly']) {
705
706 // SAVE button:
707 $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).'" />';
708
709 // SAVE / VIEW button:
710 if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
711 $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).'" />';
712 }
713
714 // SAVE / NEW button:
715 if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
716 $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).'" />';
717 }
718
719 // SAVE / CLOSE
720 $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).'" />';
721 }
722
723 // CLOSE button:
724 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
725 '<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="" />'.
726 '</a>';
727
728 // DELETE + UNDO buttons:
729 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1) {
730 if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid'])) {
731
732 // Delete:
733 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
734 $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
735 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
736 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
737 '</a>';
738 }
739
740 // Undo:
741 $undoButton = 0;
742 $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename="'.$GLOBALS['TYPO3_DB']->quoteStr($this->firstEl['table'], 'sys_history').'" AND recuid="'.intval($this->firstEl['uid']).'"', '', 'tstamp DESC', '1');
743 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
744 $undoButton = 1;
745 }
746 if ($undoButton) {
747 $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;';
748 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
749 '<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="" />'.
750 '</a>';
751 }
752 if ($this->getNewIconMode($this->firstEl['table'],'showHistory')) {
753 $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
754 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
755 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
756 '</a>';
757 }
758
759 // If only SOME fields are shown in the form, this will link the user to the FULL form:
760 if ($this->columnsOnly) {
761 $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
762 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
763 '</a>';
764 }
765 }
766 }
767 return $panel;
768 }
769
770 /**
771 * Create the selector box form element which allows to select between open documents.
772 * Can be disabled through Page TSconfig.
773 *
774 * @return string HTML <select> element (if applicable)
775 */
776 function makeDocSel() {
777 global $BE_USER,$LANG;
778
779 // Render the selector ONLY if it has not been disabled:
780 if (!$this->modTSconfig['properties']['disableDocSelector']) {
781
782 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
783 if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
784 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
785 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
786 }
787
788 // Now, create the document selector box:
789 $docSel='';
790 if (is_array($this->docHandler)) {
791 $opt = array();
792 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
793
794 // Traverse the list of open documents:
795 foreach($this->docHandler as $md5k => $setupArr) {
796 $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
797 $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
798 }
799
800 // Compile the selector box finally:
801 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){document.location=(this.options[this.selectedIndex].value);}';
802 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
803
804 // Add CSH:
805 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'');
806 }
807 } else $docSel='';
808 return $docSel;
809 }
810
811 /**
812 * Create the selector box form element which allows to select a clear-cache operation.
813 * Can be disabled through Page TSconfig.
814 *
815 * @return string HTML <select> element (if applicable)
816 * @see template::clearCacheMenu()
817 */
818 function makeCmenu() {
819
820 // Generate the menu if NOT disabled:
821 if (!$this->modTSconfig['properties']['disableCacheSelector']) {
822 $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
823
824 // Add CSH:
825 $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'');
826 } else $cMenu ='';
827 return $cMenu;
828 }
829
830 /**
831 * Put together the various elements (buttons, selectors, form) into a table
832 *
833 * @param string The button panel HTML
834 * @param string Document selector HTML
835 * @param string Clear-cache menu HTML
836 * @param string HTML form.
837 * @return string Composite HTML
838 */
839 function compileForm($panel,$docSel,$cMenu,$editForm) {
840 global $LANG;
841
842
843 $formContent='';
844 $formContent.='
845
846 <!--
847 Header of the editing page.
848 Contains the buttons for saving/closing, the document selector and menu selector.
849 Shows the path of the editing operation as well.
850 -->
851 <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
852 <tr>
853 <td nowrap="nowrap" valign="top">'.$panel.'</td>
854 <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
855 </tr>
856 <tr>
857 <td colspan="2">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</td>
858 </tr>
859 </table>
860 <img src="clear.gif" width="1" height="4" alt="" /><br />
861
862
863
864
865 <!--
866 EDITING FORM:
867 -->
868
869 '.$editForm.'
870
871
872
873 <!--
874 Saving buttons (same as in top)
875 -->
876
877 '.$panel.
878 '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
879 <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
880
881 if ($this->returnNewPageId) {
882 $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
883 }
884 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
885 $formContent.='<input type="hidden" name="closeDoc" value="0" />';
886 $formContent.='<input type="hidden" name="doSave" value="0" />';
887 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
888 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
889
890 return $formContent;
891 }
892
893 /**
894 * Create the checkbox buttons in the bottom of the pages.
895 *
896 * @return string HTML for function menus.
897 */
898 function functionMenus() {
899 global $BE_USER,$LANG;
900
901 $funcMenus = '';
902
903 // Show palettes:
904 $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);
905
906 // Show descriptions/help texts:
907 if ($BE_USER->uc['edit_showFieldHelp']!='text') {
908 $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);
909 }
910
911 // Show disable RTE checkbox:
912 if ($BE_USER->isRTE()) {
913 $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);
914 }
915
916 return '
917
918 <!--
919 Function menus (checkboxes for selecting options):
920 -->
921 '.$funcMenus;
922 }
923
924 /**
925 * Create shortcut and open-in-window link in the bottom of the page
926 *
927 * @return string
928 */
929 function shortCutLink() {
930 global $BE_USER,$LANG;
931
932 // ShortCut
933 if ($this->returnUrl!='close.html') {
934 $content.='<br /><br />';
935
936 // Shortcut:
937 if ($BE_USER->mayMakeShortcut()) {
938 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,popViewId,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
939 }
940
941 // Open in new window:
942 $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;';
943 $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
944 '<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="" />'.
945 '</a>';
946 }
947 return '
948
949 <!--
950 Shortcut link:
951 -->
952 '.$content;
953 }
954
955 /**
956 * Reads comment messages from TCEforms and prints them in a HTML comment in the buttom of the page.
957 *
958 * @return void
959 */
960 function tceformMessages() {
961 if (count($this->tceforms->commentMessages)) {
962 $this->content.='
963
964 <!-- TCEFORM messages
965 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
966 -->
967
968 ';
969 }
970 }
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987 /***************************
988 *
989 * Other functions
990 *
991 ***************************/
992
993 /**
994 * 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
995 *
996 * @return void
997 */
998 function editRegularContentFromId() {
999 if (t3lib_extMgm::isLoaded('cms')) {
1000 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1001 'uid',
1002 'tt_content',
1003 'pid='.intval($this->editRegularContentFromId).
1004 t3lib_BEfunc::deleteClause('tt_content').
1005 ' AND colPos=0 AND sys_language_uid=0',
1006 '',
1007 'sorting'
1008 );
1009 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
1010 $ecUids=array();
1011 while($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1012 $ecUids[]=$ecRec['uid'];
1013 }
1014 $this->editconf['tt_content'][implode(',',$ecUids)]='edit';
1015 }
1016 }
1017 }
1018
1019 /**
1020 * Populates the variables $this->storeArray, $this->storeUrl, $this->storeUrlMd5
1021 *
1022 * @return void
1023 * @see makeDocSel()
1024 */
1025 function compileStoreDat() {
1026 $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId',$this->R_URL_getvars);
1027 $this->storeUrl = t3lib_div::implodeArrayForUrl('',$this->storeArray);
1028 $this->storeUrlMd5 = md5($this->storeUrl);
1029 }
1030
1031 /**
1032 * Function used to look for configuration of buttons in the form: Fx. disabling buttons or showing them at various positions.
1033 *
1034 * @param string The table for which the configuration may be specific
1035 * @param string The option for look for. Default is checking if the saveDocNew button should be displayed.
1036 * @return string Return value fetched from USER TSconfig
1037 */
1038 function getNewIconMode($table,$key='saveDocNew') {
1039 global $BE_USER;
1040 $TSconfig = $BE_USER->getTSConfig('options.'.$key);
1041 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
1042 return $output;
1043 }
1044
1045 /**
1046 * Handling the closing of a document
1047 *
1048 * @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
1049 * @return void
1050 */
1051 function closeDocument($code=0) {
1052 global $BE_USER;
1053
1054 // If current document is found in docHandler, then unset it, possibly unset it ALL and finally, write it to the session data:
1055 if (isset($this->docHandler[$this->storeUrlMd5])) {
1056 unset($this->docHandler[$this->storeUrlMd5]);
1057 if ($code=='3') $this->docHandler=array();
1058 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1]));
1059 }
1060
1061 // 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...)
1062 if ($this->returnEditConf && $this->retUrl!='dummy.php') {
1063 $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf));
1064 }
1065
1066 // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl
1067 if (!$code || $code==1) {
1068 Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl));
1069 exit;
1070 } else {
1071 $this->setDocument('',$this->retUrl);
1072 }
1073 }
1074
1075 /**
1076 * Redirects to the document pointed to by $currentDocFromHandlerMD5 OR $retUrl (depending on some internal calculations).
1077 * Most likely you will get a header-location redirect from this function.
1078 *
1079 * @param string Pointer to the document in the docHandler array
1080 * @param string Alternative/Default retUrl
1081 * @return void
1082 */
1083 function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php') {
1084 if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl,'alt_doc_nodoc.php')) return;
1085
1086 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) {
1087 if (isset($this->docHandler[$currentDocFromHandlerMD5])) {
1088 $setupArr=$this->docHandler[$currentDocFromHandlerMD5];
1089 } else {
1090 reset($this->docHandler);
1091 $setupArr=current($this->docHandler);
1092 }
1093 if ($setupArr[2]) {
1094 $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
1095 $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl);
1096 }
1097 }
1098 Header('Location: '.t3lib_div::locationHeaderUrl($retUrl));
1099 exit;
1100 }
1101 }
1102
1103 // Include extension?
1104 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']) {
1105 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']);
1106 }
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123 // Make instance:
1124 $SOBE = t3lib_div::makeInstance('SC_alt_doc');
1125
1126 // Preprocessing, storing data if submitted to
1127 $SOBE->preInit();
1128 if ($SOBE->doProcessData()) { // Checks, if a save button has been clicked (or the doSave variable is sent)
1129 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
1130 $SOBE->processData();
1131 }
1132
1133 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
1134 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
1135
1136
1137 // Main:
1138 $SOBE->init();
1139 $SOBE->main();
1140 $SOBE->printContent();
1141 ?>