[TASK] BACK_PATH DocumentTemplate
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / EditDocumentController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Form\DataPreprocessor;
18 use TYPO3\CMS\Backend\Form\FormEngine;
19 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
20 use TYPO3\CMS\Backend\Utility\BackendUtility;
21 use TYPO3\CMS\Backend\Utility\IconUtility;
22 use TYPO3\CMS\Core\DataHandling\DataHandler;
23 use TYPO3\CMS\Core\Html\HtmlParser;
24 use TYPO3\CMS\Core\Messaging\FlashMessage;
25 use TYPO3\CMS\Core\Messaging\FlashMessageService;
26 use TYPO3\CMS\Core\Page\PageRenderer;
27 use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
28 use TYPO3\CMS\Core\Type\Bitmask\Permission;
29 use TYPO3\CMS\Core\Utility\GeneralUtility;
30 use TYPO3\CMS\Core\Utility\HttpUtility;
31 use TYPO3\CMS\Core\Utility\MathUtility;
32 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
33 use TYPO3\CMS\Frontend\Page\PageRepository;
34
35 /**
36 * Script Class: Drawing the editing form for editing records in TYPO3.
37 * Notice: It does NOT use tce_db.php to submit data to, rather it handles submissions itself
38 */
39 class EditDocumentController {
40
41 /**
42 * GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg.
43 * "&edit[pages][123]=edit". See \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick(). Value can be seen modified
44 * internally (converting NEW keyword to id, workspace/versioning etc).
45 *
46 * @var array
47 */
48 public $editconf;
49
50 /**
51 * Commalist of fieldnames to edit. The point is IF you specify this list, only those
52 * fields will be rendered in the form. Otherwise all (available) fields in the record
53 * is shown according to the types configuration in $GLOBALS['TCA']
54 *
55 * @var bool
56 */
57 public $columnsOnly;
58
59 /**
60 * Default values for fields (array with tablenames, fields etc. as keys).
61 * Can be seen modified internally.
62 *
63 * @var array
64 */
65 public $defVals;
66
67 /**
68 * Array of values to force being set (as hidden fields). Will be set as $this->defVals
69 * IF defVals does not exist.
70 *
71 * @var array
72 */
73 public $overrideVals;
74
75 /**
76 * If set, this value will be set in $this->retUrl (which is used quite many places
77 * as the return URL). If not set, "dummy.php" will be set in $this->retUrl
78 *
79 * @var string
80 */
81 public $returnUrl;
82
83 /**
84 * Close-document command. Not really sure of all options...
85 *
86 * @var int
87 */
88 public $closeDoc;
89
90 /**
91 * Quite simply, if this variable is set, then the processing of incoming data will be performed
92 * as if a save-button is pressed. Used in the forms as a hidden field which can be set through
93 * JavaScript if the form is somehow submitted by JavaScript).
94 *
95 * @var bool
96 */
97 public $doSave;
98
99 /**
100 * The data array from which the data comes...
101 *
102 * @var array
103 */
104 public $data;
105
106 /**
107 * @var string
108 */
109 public $cmd;
110
111 /**
112 * @var array
113 */
114 public $mirror;
115
116 /**
117 * Clear-cache cmd.
118 *
119 * @var string
120 */
121 public $cacheCmd;
122
123 /**
124 * Redirect (not used???)
125 *
126 * @var string
127 */
128 public $redirect;
129
130 /**
131 * Boolean: If set, then the GET var "&id=" will be added to the
132 * retUrl string so that the NEW id of something is returned to the script calling the form.
133 *
134 * @var bool
135 */
136 public $returnNewPageId;
137
138 /**
139 * @var string
140 */
141 public $vC;
142
143 /**
144 * update BE_USER->uc
145 *
146 * @var array
147 */
148 public $uc;
149
150 /**
151 * ID for displaying the page in the frontend (used for SAVE/VIEW operations)
152 *
153 * @var int
154 */
155 public $popViewId;
156
157 /**
158 * Additional GET vars for the link, eg. "&L=xxx"
159 *
160 * @var string
161 */
162 public $popViewId_addParams;
163
164 /**
165 * Alternative URL for viewing the frontend pages.
166 *
167 * @var string
168 */
169 public $viewUrl;
170
171 /**
172 * If this is pointing to a page id it will automatically load all content elements
173 * (NORMAL column/default language) from that page into the form!
174 *
175 * @var int
176 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
177 */
178 public $editRegularContentFromId;
179
180 /**
181 * Alternative title for the document handler.
182 *
183 * @var string
184 */
185 public $recTitle;
186
187 /**
188 * If set, then no SAVE/VIEW button is printed
189 *
190 * @var bool
191 */
192 public $noView;
193
194 /**
195 * @var string
196 */
197 public $perms_clause;
198
199 /**
200 * If set, the $this->editconf array is returned to the calling script
201 * (used by wizard_add.php for instance)
202 *
203 * @var bool
204 */
205 public $returnEditConf;
206
207 /**
208 * localization mode for TCEforms (eg. "text")
209 *
210 * @var string
211 */
212 public $localizationMode;
213
214 /**
215 * Workspace used for the editing action.
216 *
217 * @var NULL|integer
218 */
219 protected $workspace;
220
221 /**
222 * document template object
223 *
224 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
225 */
226 public $doc;
227
228 /**
229 * a static HTML template, usually in templates/alt_doc.html
230 *
231 * @var string
232 */
233 public $template;
234
235 /**
236 * Content accumulation
237 *
238 * @var string
239 */
240 public $content;
241
242 /**
243 * Return URL script, processed. This contains the script (if any) that we should
244 * RETURN TO from the FormEngine script IF we press the close button. Thus this
245 * variable is normally passed along from the calling script so we can properly return if needed.
246 *
247 * @var string
248 */
249 public $retUrl;
250
251 /**
252 * Contains the parts of the REQUEST_URI (current url). By parts we mean the result of resolving
253 * REQUEST_URI (current url) by the parse_url() function. The result is an array where eg. "path"
254 * is the script path and "query" is the parameters...
255 *
256 * @var array
257 */
258 public $R_URL_parts;
259
260 /**
261 * Contains the current GET vars array; More specifically this array is the foundation for creating
262 * the R_URI internal var (which becomes the "url of this script" to which we submit the forms etc.)
263 *
264 * @var array
265 */
266 public $R_URL_getvars;
267
268 /**
269 * Set to the URL of this script including variables which is needed to re-display the form. See main()
270 *
271 * @var string
272 */
273 public $R_URI;
274
275 /**
276 * @var array
277 */
278 public $MCONF;
279
280 /**
281 * @var array
282 */
283 public $pageinfo;
284
285 /**
286 * Is loaded with the "title" of the currently "open document" - this is used in the
287 * Document Selector box. (see makeDocSel())
288 *
289 * @var string
290 */
291 public $storeTitle;
292
293 /**
294 * Contains an array with key/value pairs of GET parameters needed to reach the
295 * current document displayed - used in the Document Selector box. (see compileStoreDat())
296 *
297 * @var array
298 */
299 public $storeArray;
300
301 /**
302 * Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
303 *
304 * @var string
305 */
306 public $storeUrl;
307
308 /**
309 * Hashed value of storeURL (see compileStoreDat())
310 *
311 * @var string
312 */
313 public $storeUrlMd5;
314
315 /**
316 * Module session data
317 *
318 * @var array
319 */
320 public $docDat;
321
322 /**
323 * An array of the "open documents" - keys are md5 hashes (see $storeUrlMd5) identifying
324 * the various documents on the GET parameter list needed to open it. The values are
325 * arrays with 0,1,2 keys with information about the document (see compileStoreDat()).
326 * The docHandler variable is stored in the $docDat session data, key "0".
327 *
328 * @var array
329 */
330 public $docHandler;
331
332 /**
333 * Array of the elements to create edit forms for.
334 *
335 * @var array
336 */
337 public $elementsData;
338
339 /**
340 * Pointer to the first element in $elementsData
341 *
342 * @var array
343 */
344 public $firstEl;
345
346 /**
347 * Counter, used to count the number of errors (when users do not have edit permissions)
348 *
349 * @var int
350 */
351 public $errorC;
352
353 /**
354 * Counter, used to count the number of new record forms displayed
355 *
356 * @var int
357 */
358 public $newC;
359
360 /**
361 * Is set to the pid value of the last shown record - thus indicating which page to
362 * show when clicking the SAVE/VIEW button
363 *
364 * @var int
365 */
366 public $viewId;
367
368 /**
369 * Is set to additional parameters (like "&L=xxx") if the record supports it.
370 *
371 * @var string
372 */
373 public $viewId_addParams;
374
375 /**
376 * Module TSconfig, loaded from main() based on the page id value of viewId
377 *
378 * @var array
379 */
380 public $modTSconfig;
381
382 /**
383 * instance of TCEforms class
384 *
385 * @var \TYPO3\CMS\Backend\Form\FormEngine
386 */
387 public $tceforms;
388
389 /**
390 * Contains the root-line path of the currently edited record(s) - for display.
391 *
392 * @var string
393 */
394 public $generalPathOfForm;
395
396 /**
397 * Used internally to disable the storage of the document reference (eg. new records)
398 *
399 * @var bool
400 */
401 public $dontStoreDocumentRef;
402
403 /**
404 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
405 */
406 protected $signalSlotDispatcher;
407
408 /**
409 * Stores information needed to preview the currently saved record
410 *
411 * @var array
412 */
413 protected $previewData = [];
414
415 /**
416 * Constructor
417 */
418 public function __construct() {
419 $GLOBALS['SOBE'] = $this;
420 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_alt_doc.xlf');
421 }
422
423 /**
424 * Get the SignalSlot dispatcher
425 *
426 * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
427 */
428 protected function getSignalSlotDispatcher() {
429 if (!isset($this->signalSlotDispatcher)) {
430 $this->signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
431 }
432 return $this->signalSlotDispatcher;
433 }
434
435 /**
436 * Emits a signal after a function was executed
437 *
438 * @param string $signalName
439 */
440 protected function emitFunctionAfterSignal($signalName) {
441 $this->getSignalSlotDispatcher()->dispatch(__CLASS__, $signalName . 'After', array($this));
442 }
443
444 /**
445 * First initialization.
446 *
447 * @return void
448 */
449 public function preInit() {
450 if (GeneralUtility::_GP('justLocalized')) {
451 $this->localizationRedirect(GeneralUtility::_GP('justLocalized'));
452 }
453 // Setting GPvars:
454 $this->editconf = GeneralUtility::_GP('edit');
455 $this->defVals = GeneralUtility::_GP('defVals');
456 $this->overrideVals = GeneralUtility::_GP('overrideVals');
457 $this->columnsOnly = GeneralUtility::_GP('columnsOnly');
458 $this->returnUrl = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
459 $this->closeDoc = GeneralUtility::_GP('closeDoc');
460 $this->doSave = GeneralUtility::_GP('doSave');
461 $this->returnEditConf = GeneralUtility::_GP('returnEditConf');
462 $this->localizationMode = GeneralUtility::_GP('localizationMode');
463 $this->workspace = GeneralUtility::_GP('workspace');
464 $this->uc = GeneralUtility::_GP('uc');
465 // Setting override values as default if defVals does not exist.
466 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
467 $this->defVals = $this->overrideVals;
468 }
469 // Setting return URL
470 $this->retUrl = $this->returnUrl ?: BackendUtility::getModuleUrl('dummy');
471 // Fix $this->editconf if versioning applies to any of the records
472 $this->fixWSversioningInEditConf();
473 // Make R_URL (request url) based on input GETvars:
474 $this->R_URL_parts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
475 $this->R_URL_getvars = GeneralUtility::_GET();
476 $this->R_URL_getvars['edit'] = $this->editconf;
477 // MAKE url for storing
478 $this->compileStoreDat();
479 // Initialize more variables.
480 $this->dontStoreDocumentRef = 0;
481 $this->storeTitle = '';
482 // Get session data for the module:
483 $this->docDat = $this->getBackendUser()->getModuleData('FormEngine', 'ses');
484 $this->docHandler = $this->docDat[0];
485 // If a request for closing the document has been sent, act accordingly:
486 if ($this->closeDoc > 0) {
487 $this->closeDocument($this->closeDoc);
488 }
489 // If NO vars are sent to the script, try to read first document:
490 // Added !is_array($this->editconf) because editConf must not be set either.
491 // Anyways I can't figure out when this situation here will apply...
492 if (is_array($this->R_URL_getvars) && count($this->R_URL_getvars) < 2 && !is_array($this->editconf)) {
493 $this->setDocument($this->docDat[1]);
494 }
495
496 // Sets a temporary workspace, this request is based on
497 if ($this->workspace !== NULL) {
498 $this->getBackendUser()->setTemporaryWorkspace($this->workspace);
499 }
500
501 $this->emitFunctionAfterSignal(__FUNCTION__);
502 }
503
504 /**
505 * Detects, if a save command has been triggered.
506 *
507 * @return bool TRUE, then save the document (data submitted)
508 */
509 public function doProcessData() {
510 $out = $this->doSave || isset($_POST['_savedok']) || isset($_POST['_saveandclosedok']) || isset($_POST['_savedokview']) || isset($_POST['_savedoknew']) || isset($_POST['_translation_savedok_x']) || isset($_POST['_translation_savedokclear_x']);
511 return $out;
512 }
513
514 /**
515 * Do processing of data, submitting it to TCEmain.
516 *
517 * @return void
518 */
519 public function processData() {
520 $beUser = $this->getBackendUser();
521 // GPvars specifically for processing:
522 $control = GeneralUtility::_GP('control');
523 $this->data = GeneralUtility::_GP('data');
524 $this->cmd = GeneralUtility::_GP('cmd');
525 $this->mirror = GeneralUtility::_GP('mirror');
526 $this->cacheCmd = GeneralUtility::_GP('cacheCmd');
527 $this->redirect = GeneralUtility::_GP('redirect');
528 $this->returnNewPageId = GeneralUtility::_GP('returnNewPageId');
529 $this->vC = GeneralUtility::_GP('vC');
530 // See tce_db.php for relevate options here:
531 // Only options related to $this->data submission are included here.
532 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
533 $tce = GeneralUtility::makeInstance(DataHandler::class);
534 $tce->stripslashes_values = FALSE;
535
536 if (!empty($control)) {
537 $tce->setControl($control);
538 }
539 if (isset($_POST['_translation_savedok_x'])) {
540 $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
541 }
542 if (isset($_POST['_translation_savedokclear_x'])) {
543 $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
544 $tce->updateModeL10NdiffDataClear = TRUE;
545 }
546 // Setting default values specific for the user:
547 $TCAdefaultOverride = $beUser->getTSConfigProp('TCAdefaults');
548 if (is_array($TCAdefaultOverride)) {
549 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
550 }
551 // Setting internal vars:
552 if ($beUser->uc['neverHideAtCopy']) {
553 $tce->neverHideAtCopy = 1;
554 }
555 // Loading TCEmain with data:
556 $tce->start($this->data, $this->cmd);
557 if (is_array($this->mirror)) {
558 $tce->setMirror($this->mirror);
559 }
560 // Checking referer / executing
561 $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER'));
562 $httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
563 if ($httpHost != $refInfo['host'] && $this->vC != $beUser->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
564 $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));
565 debug('Error: Referer host did not match with server host.');
566 } else {
567 // Perform the saving operation with TCEmain:
568 $tce->process_uploads($_FILES);
569 $tce->process_datamap();
570 $tce->process_cmdmap();
571 // If pages are being edited, we set an instruction about updating the page tree after this operation.
572 if ($tce->pagetreeNeedsRefresh && (isset($this->data['pages']) || $beUser->workspace != 0 && !empty($this->data))) {
573 BackendUtility::setUpdateSignal('updatePageTree');
574 }
575 // If there was saved any new items, load them:
576 if (!empty($tce->substNEWwithIDs_table)) {
577 // save the expanded/collapsed states for new inline records, if any
578 FormEngineUtility::updateInlineView($this->uc, $tce);
579 $newEditConf = array();
580 foreach ($this->editconf as $tableName => $tableCmds) {
581 $keys = array_keys($tce->substNEWwithIDs_table, $tableName);
582 if (!empty($keys)) {
583 foreach ($keys as $key) {
584 $editId = $tce->substNEWwithIDs[$key];
585 // Check if the $editId isn't a child record of an IRRE action
586 if (!(is_array($tce->newRelatedIDs[$tableName]) && in_array($editId, $tce->newRelatedIDs[$tableName]))) {
587 // Translate new id to the workspace version:
588 if ($versionRec = BackendUtility::getWorkspaceVersionOfRecord($beUser->workspace, $tableName, $editId, 'uid')) {
589 $editId = $versionRec['uid'];
590 }
591 $newEditConf[$tableName][$editId] = 'edit';
592 }
593 // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records!
594 if ($tableName == 'pages' && $this->retUrl != BackendUtility::getModuleUrl('dummy') && $this->returnNewPageId) {
595 $this->retUrl .= '&id=' . $tce->substNEWwithIDs[$key];
596 }
597 }
598 } else {
599 $newEditConf[$tableName] = $tableCmds;
600 }
601 }
602 // Resetting editconf if newEditConf has values:
603 if (!empty($newEditConf)) {
604 $this->editconf = $newEditConf;
605 }
606 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
607 $this->R_URL_getvars['edit'] = $this->editconf;
608 // Unsetting default values since we don't need them anymore.
609 unset($this->R_URL_getvars['defVals']);
610 // Re-compile the store* values since editconf changed...
611 $this->compileStoreDat();
612 }
613 // See if any records was auto-created as new versions?
614 if (!empty($tce->autoVersionIdMap)) {
615 $this->fixWSversioningInEditConf($tce->autoVersionIdMap);
616 }
617 // If a document is saved and a new one is created right after.
618 if (isset($_POST['_savedoknew']) && is_array($this->editconf)) {
619 // Finding the current table:
620 reset($this->editconf);
621 $nTable = key($this->editconf);
622 // Finding the first id, getting the records pid+uid
623 reset($this->editconf[$nTable]);
624 $nUid = key($this->editconf[$nTable]);
625 $nRec = BackendUtility::getRecord($nTable, $nUid, 'pid,uid');
626 // Setting a blank editconf array for a new record:
627 $this->editconf = array();
628 if ($this->getNewIconMode($nTable) == 'top') {
629 $this->editconf[$nTable][$nRec['pid']] = 'new';
630 } else {
631 $this->editconf[$nTable][-$nRec['uid']] = 'new';
632 }
633 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
634 $this->R_URL_getvars['edit'] = $this->editconf;
635 // Re-compile the store* values since editconf changed...
636 $this->compileStoreDat();
637 }
638 // If a preview is requested
639 if (isset($_POST['_savedokview'])) {
640 // Get the first table and id of the data array from DataHandler
641 $table = reset(array_keys($this->data));
642 $id = reset(array_keys($this->data[$table]));
643 if (!MathUtility::canBeInterpretedAsInteger($id)) {
644 $id = $tce->substNEWwithIDs[$id];
645 }
646 // Store this information for later use
647 $this->previewData['table'] = $table;
648 $this->previewData['id'] = $id;
649 }
650 $tce->printLogErrorMessages(isset($_POST['_saveandclosedok']) || isset($_POST['_translation_savedok_x']) ? $this->retUrl : $this->R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $this->R_URL_getvars));
651 }
652 // || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED
653 // because if not, we just get that element re-listed as new. And we don't want that!
654 if (isset($_POST['_saveandclosedok']) || isset($_POST['_translation_savedok_x']) || $this->closeDoc < 0) {
655 $this->closeDocument(abs($this->closeDoc));
656 }
657 }
658
659 /**
660 * Initialize the normal module operation
661 *
662 * @return void
663 */
664 public function init() {
665 $beUser = $this->getBackendUser();
666 // Setting more GPvars:
667 $this->popViewId = GeneralUtility::_GP('popViewId');
668 $this->popViewId_addParams = GeneralUtility::_GP('popViewId_addParams');
669 $this->viewUrl = GeneralUtility::_GP('viewUrl');
670 $this->editRegularContentFromId = GeneralUtility::_GP('editRegularContentFromId');
671 $this->recTitle = GeneralUtility::_GP('recTitle');
672 $this->noView = GeneralUtility::_GP('noView');
673 $this->perms_clause = $beUser->getPagePermsClause(1);
674 // Set other internal variables:
675 $this->R_URL_getvars['returnUrl'] = $this->retUrl;
676 $this->R_URI = $this->R_URL_parts['path'] . '?' . ltrim(GeneralUtility::implodeArrayForUrl('', $this->R_URL_getvars), '&');
677 // Setting virtual document name
678 $this->MCONF['name'] = 'xMOD_alt_doc.php';
679
680 // Create an instance of the document template object
681 $this->doc = $GLOBALS['TBE_TEMPLATE'];
682 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
683 $pageRenderer->addInlineLanguageLabelFile('EXT:lang/locallang_alt_doc.xlf');
684 $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/alt_doc.html');
685 $this->doc->form = '<form action="' . htmlspecialchars($this->R_URI) . '" method="post" enctype="multipart/form-data" name="editform" onsubmit="document.editform._scrollPosition.value=(document.documentElement.scrollTop || document.body.scrollTop); return TBE_EDITOR.checkSubmit(1);">';
686 // override the default jumpToUrl
687 $this->doc->JScodeArray['jumpToUrl'] = '
688 function jumpToUrl(URL,formEl) {
689 if (!TBE_EDITOR.isFormChanged()) {
690 window.location.href = URL;
691 } else if (formEl && formEl.type=="checkbox") {
692 formEl.checked = formEl.checked ? 0 : 1;
693 }
694 }
695 ';
696 // define the window size of the element browser
697 $popupWindowWidth = 700;
698 $popupWindowHeight = 750;
699 $popupWindowSize = trim($beUser->getTSConfigVal('options.popupWindowSize'));
700 if (!empty($popupWindowSize)) {
701 list($popupWindowWidth, $popupWindowHeight) = GeneralUtility::intExplode('x', $popupWindowSize);
702 }
703 $t3Configuration = array(
704 'PopupWindow' => array(
705 'width' => $popupWindowWidth,
706 'height' => $popupWindowHeight
707 ),
708 );
709 $javascript = '
710 TYPO3.configuration = ' . json_encode($t3Configuration) . ';
711 // Object: TS:
712 // passwordDummy and decimalSign are used by tbe_editor.js and have to be declared here as
713 // TS object overwrites the object declared in tbe_editor.js
714 function typoSetup() { //
715 this.uniqueID = "";
716 this.passwordDummy = "********";
717 this.PATH_typo3 = "";
718 this.decimalSign = ".";
719 }
720 var TS = new typoSetup();
721
722 // Info view:
723 function launchView(table,uid,bP) { //
724 var backPath= bP ? bP : "";
725 var thePreviewWindow="";
726 thePreviewWindow = window.open(backPath+' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('show_item', array(), '') . '&table=') . '+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
727 if (thePreviewWindow && thePreviewWindow.focus) {
728 thePreviewWindow.focus();
729 }
730 }
731 function deleteRecord(table,id,url) { //
732 window.location.href = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1' . BackendUtility::getUrlToken('tceAction') . '&redirect="+escape(url)+"&vC=' . $beUser->veriCode() . '&prErr=1&uPT=1";
733 }
734 ';
735
736 $previewCode = isset($_POST['_savedokview']) && $this->popViewId ? $this->generatePreviewCode() : '';
737
738 $this->doc->JScode = $this->doc->wrapScriptTags($javascript . $previewCode);
739 // Setting up the context sensitive menu:
740 $this->doc->getContextMenuCode();
741 $this->doc->bodyTagAdditions = 'onload="window.scrollTo(0,' . MathUtility::forceIntegerInRange(GeneralUtility::_GP('_scrollPosition'), 0, 10000) . ');"';
742
743 $this->emitFunctionAfterSignal(__FUNCTION__);
744 }
745
746 /**
747 * @return string
748 */
749 protected function generatePreviewCode() {
750 $currentPageId = MathUtility::convertToPositiveInteger($this->popViewId);
751 $table = $this->previewData['table'];
752 $recordId = $this->previewData['id'];
753
754 $pageTsConfig = BackendUtility::getPagesTSconfig($currentPageId);
755 $previewConfiguration = isset($pageTsConfig['TCEMAIN.']['preview.'][$table . '.'])
756 ? $pageTsConfig['TCEMAIN.']['preview.'][$table . '.']
757 : array();
758
759 $recordArray = BackendUtility::getRecord($table, $recordId);
760
761 // find the right preview page id
762 $previewPageId = 0;
763 if (isset($previewConfiguration['previewPageId'])) {
764 $previewPageId = $previewConfiguration['previewPageId'];
765 }
766 // if no preview page was configured
767 if (!$previewPageId) {
768 $rootPageData = NULL;
769 $rootLine = BackendUtility::BEgetRootLine($currentPageId);
770 $currentPage = reset($rootLine);
771 if ((int)$currentPage['doktype'] === PageRepository::DOKTYPE_DEFAULT) {
772 // try the current page
773 $previewPageId = $currentPageId;
774 } else {
775 // or search for the root page
776 foreach ($rootLine as $page) {
777 if ($page['is_siteroot']) {
778 $rootPageData = $page;
779 break;
780 }
781 }
782 $previewPageId = isset($rootPageData)
783 ? (int)$rootPageData['uid']
784 : $currentPageId;
785 }
786 }
787
788 $linkParameters = [
789 'no_cache' => 1,
790 ];
791
792 // language handling
793 $languageField = isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
794 ? $GLOBALS['TCA'][$table]['ctrl']['languageField']
795 : '';
796 if ($languageField && !empty($recordArray[$languageField])) {
797 $l18nPointer = isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
798 ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
799 : '';
800 if (
801 $l18nPointer && !empty($recordArray[$l18nPointer])
802 && isset($previewConfiguration['useDefaultLanguageRecord'])
803 && !$previewConfiguration['useDefaultLanguageRecord']
804 ) {
805 // use parent record
806 $recordId = $recordArray[$l18nPointer];
807 }
808 $linkParameters['L'] = $recordArray[$languageField];
809 }
810
811 // map record data to GET parameters
812 if (isset($previewConfiguration['fieldToParameterMap.'])) {
813 foreach ($previewConfiguration['fieldToParameterMap.'] as $field => $parameterName) {
814 $value = $recordArray[$field];
815 if ($field === 'uid') {
816 $value = $recordId;
817 }
818 $linkParameters[$parameterName] = $value;
819 }
820 }
821
822 // add/override parameters by configuration
823 if (isset($previewConfiguration['additionalGetParameters.'])) {
824 $linkParameters = array_replace($linkParameters, $previewConfiguration['additionalGetParameters.']);
825 }
826
827 $this->popViewId = $previewPageId;
828 $this->popViewId_addParams = GeneralUtility::implodeArrayForUrl('', $linkParameters, '', FALSE, TRUE);
829
830 $previewPageRootline = BackendUtility::BEgetRootLine($this->popViewId);
831 return '
832 if (window.opener) {
833 '
834 . BackendUtility::viewOnClick($this->popViewId, '', $previewPageRootline, '', $this->viewUrl, $this->popViewId_addParams, FALSE)
835 . '
836 } else {
837 '
838 . BackendUtility::viewOnClick($this->popViewId, '', $previewPageRootline, '', $this->viewUrl, $this->popViewId_addParams)
839 . '
840 }';
841 }
842
843 /**
844 * Main module operation
845 *
846 * @return void
847 */
848 public function main() {
849 $body = '';
850 // Begin edit:
851 if (is_array($this->editconf)) {
852 // Initialize TCEforms (rendering the forms)
853 $this->tceforms = GeneralUtility::makeInstance(FormEngine::class);
854 $this->tceforms->doSaveFieldName = 'doSave';
855 $this->tceforms->localizationMode = GeneralUtility::inList('text,media', $this->localizationMode) ? $this->localizationMode : '';
856 // text,media is keywords defined in TYPO3 Core API..., see "l10n_cat"
857 $this->tceforms->returnUrl = $this->R_URI;
858 if ($this->editRegularContentFromId) {
859 $this->editRegularContentFromId();
860 }
861 // Creating the editing form, wrap it with buttons, document selector etc.
862 $editForm = $this->makeEditForm();
863 if ($editForm) {
864 $this->firstEl = reset($this->elementsData);
865 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
866 if (($this->docDat[1] !== $this->storeUrlMd5 || !isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
867 $this->docHandler[$this->storeUrlMd5] = array($this->storeTitle, $this->storeArray, $this->storeUrl, $this->firstEl);
868 $this->getBackendUser()->pushModuleData('FormEngine', array($this->docHandler, $this->storeUrlMd5));
869 BackendUtility::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler));
870 }
871 // Module configuration
872 $this->modTSconfig = $this->viewId ? BackendUtility::getModTSconfig($this->viewId, 'mod.xMOD_alt_doc') : array();
873 $body = $this->tceforms->printNeededJSFunctions_top();
874 $body .= $this->compileForm($editForm);
875 $body .= $this->tceforms->printNeededJSFunctions();
876 }
877 }
878 // Access check...
879 // The page will show only if there is a valid page and if this page may be viewed by the user
880 $this->pageinfo = BackendUtility::readPageAccess($this->viewId, $this->perms_clause);
881 // Setting up the buttons and markers for docheader
882 $docHeaderButtons = $this->getButtons();
883 $markers = array(
884 'LANGSELECTOR' => $this->langSelector(),
885 'EXTRAHEADER' => $this->extraFormHeaders(),
886 'CSH' => $docHeaderButtons['csh'],
887 'CONTENT' => $body
888 );
889 // Build the <body> for the module
890 $this->content = $this->doc->startPage('TYPO3 Edit Document');
891 $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
892 $this->content .= $this->doc->endPage();
893 $this->content = $this->doc->insertStylesAndJS($this->content);
894 }
895
896 /**
897 * Outputting the accumulated content to screen
898 *
899 * @return void
900 */
901 public function printContent() {
902 echo $this->content;
903 }
904
905 /***************************
906 *
907 * Sub-content functions, rendering specific parts of the module content.
908 *
909 ***************************/
910 /**
911 * Creates the editing form with TCEforms, based on the input from GPvars.
912 *
913 * @return string HTML form elements wrapped in tables
914 */
915 public function makeEditForm() {
916 // Initialize variables:
917 $this->elementsData = array();
918 $this->errorC = 0;
919 $this->newC = 0;
920 $thePrevUid = '';
921 $editForm = '';
922 $trData = NULL;
923 $beUser = $this->getBackendUser();
924 // Traverse the GPvar edit array
925 // Tables:
926 foreach ($this->editconf as $table => $conf) {
927 if (is_array($conf) && $GLOBALS['TCA'][$table] && $beUser->check('tables_modify', $table)) {
928 // Traverse the keys/comments of each table (keys can be a commalist of uids)
929 foreach ($conf as $cKey => $cmd) {
930 if ($cmd == 'edit' || $cmd == 'new') {
931 // Get the ids:
932 $ids = GeneralUtility::trimExplode(',', $cKey, TRUE);
933 // Traverse the ids:
934 foreach ($ids as $theUid) {
935 // Checking if the user has permissions? (Only working as a precaution,
936 // because the final permission check is always down in TCE. But it's
937 // good to notify the user on beforehand...)
938 // First, resetting flags.
939 $hasAccess = 1;
940 $deniedAccessReason = '';
941 $deleteAccess = 0;
942 $this->viewId = 0;
943 // If the command is to create a NEW record...:
944 if ($cmd == 'new') {
945 // NOTICE: the id values in this case points to the page uid onto which the
946 // record should be create OR (if the id is negativ) to a record from the
947 // same table AFTER which to create the record.
948 if ((int)$theUid) {
949 // Find parent page on which the new record reside
950 // Less than zero - find parent page
951 if ($theUid < 0) {
952 $calcPRec = BackendUtility::getRecord($table, abs($theUid));
953 $calcPRec = BackendUtility::getRecord('pages', $calcPRec['pid']);
954 } else {
955 // always a page
956 $calcPRec = BackendUtility::getRecord('pages', abs($theUid));
957 }
958 // Now, calculate whether the user has access to creating new records on this position:
959 if (is_array($calcPRec)) {
960 // Permissions for the parent page
961 $CALC_PERMS = $beUser->calcPerms($calcPRec);
962 if ($table == 'pages') {
963 // If pages:
964 $hasAccess = $CALC_PERMS & Permission::PAGE_NEW ? 1 : 0;
965 $this->viewId = 0;
966 } else {
967 $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
968 $this->viewId = $calcPRec['uid'];
969 }
970 }
971 }
972 // Don't save this document title in the document selector if the document is new.
973 $this->dontStoreDocumentRef = 1;
974 } else {
975 // Edit:
976 $calcPRec = BackendUtility::getRecord($table, $theUid);
977 BackendUtility::fixVersioningPid($table, $calcPRec);
978 if (is_array($calcPRec)) {
979 if ($table == 'pages') { // If pages:
980 $CALC_PERMS = $beUser->calcPerms($calcPRec);
981 $hasAccess = $CALC_PERMS & Permission::PAGE_EDIT ? 1 : 0;
982 $deleteAccess = $CALC_PERMS & Permission::PAGE_DELETE ? 1 : 0;
983 $this->viewId = $calcPRec['uid'];
984 } else {
985 // Fetching pid-record first
986 $CALC_PERMS = $beUser->calcPerms(BackendUtility::getRecord('pages', $calcPRec['pid']));
987 $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
988 $deleteAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
989 $this->viewId = $calcPRec['pid'];
990 // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
991 if ($GLOBALS['TCA'][$table]['ctrl']['languageField'] && $calcPRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
992 $this->viewId_addParams = '&L=' . $calcPRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
993 }
994 }
995 // Check internals regarding access:
996 $isRootLevelRestrictionIgnored = BackendUtility::isRootLevelRestrictionIgnored($table);
997 if ($hasAccess || (int)$calcPRec['pid'] === 0 && $isRootLevelRestrictionIgnored) {
998 $hasAccess = $beUser->recordEditAccessInternals($table, $calcPRec);
999 $deniedAccessReason = $beUser->errorMsg;
1000 }
1001 } else {
1002 $hasAccess = 0;
1003 }
1004 }
1005 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['makeEditForm_accessCheck'])) {
1006 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['makeEditForm_accessCheck'] as $_funcRef) {
1007 $_params = array(
1008 'table' => $table,
1009 'uid' => $theUid,
1010 'cmd' => $cmd,
1011 'hasAccess' => $hasAccess
1012 );
1013 $hasAccess = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1014 }
1015 }
1016 // AT THIS POINT we have checked the access status of the editing/creation of
1017 // records and we can now proceed with creating the form elements:
1018 if ($hasAccess) {
1019 /** @var DataPreprocessor $trData */
1020 $prevPageID = is_object($trData) ? $trData->prevPageID : '';
1021 $trData = GeneralUtility::makeInstance(DataPreprocessor::class);
1022 $trData->addRawData = TRUE;
1023 $trData->defVals = $this->defVals;
1024 $trData->lockRecords = 1;
1025 $trData->prevPageID = $prevPageID;
1026 // 'new'
1027 $trData->fetchRecord($table, $theUid, $cmd == 'new' ? 'new' : '');
1028 $rec = reset($trData->regTableItems_data);
1029 $rec['uid'] = $cmd == 'new' ? uniqid('NEW', TRUE) : $theUid;
1030 if ($cmd == 'new') {
1031 $rec['pid'] = $theUid == 'prev' ? $thePrevUid : $theUid;
1032 }
1033 $this->elementsData[] = array(
1034 'table' => $table,
1035 'uid' => $rec['uid'],
1036 'pid' => $rec['pid'],
1037 'cmd' => $cmd,
1038 'deleteAccess' => $deleteAccess
1039 );
1040 // Now, render the form:
1041 if (is_array($rec)) {
1042 // Setting visual path / title of form:
1043 $this->generalPathOfForm = $this->tceforms->getRecordPath($table, $rec);
1044 if (!$this->storeTitle) {
1045 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : BackendUtility::getRecordTitle($table, $rec, TRUE);
1046 }
1047 // Setting variables in TCEforms object:
1048 if (is_array($this->overrideVals) && is_array($this->overrideVals[$table])) {
1049 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
1050 }
1051 // Create form for the record (either specific list of fields or the whole record):
1052 $panel = '';
1053 if ($this->columnsOnly) {
1054 if (is_array($this->columnsOnly)) {
1055 $panel .= $this->tceforms->getListedFields($table, $rec, $this->columnsOnly[$table]);
1056 } else {
1057 $panel .= $this->tceforms->getListedFields($table, $rec, $this->columnsOnly);
1058 }
1059 } else {
1060 $panel .= $this->tceforms->getMainFields($table, $rec);
1061 }
1062 $panel = $this->tceforms->wrapTotal($panel, $rec, $table);
1063 // Setting the pid value for new records:
1064 if ($cmd == 'new') {
1065 $panel .= '<input type="hidden" name="data[' . $table . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
1066 $this->newC++;
1067 }
1068 // Display "is-locked" message:
1069 if ($lockInfo = BackendUtility::isRecordLocked($table, $rec['uid'])) {
1070 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
1071 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, htmlspecialchars($lockInfo['msg']), '', FlashMessage::WARNING);
1072 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
1073 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1074 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
1075 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1076 $defaultFlashMessageQueue->enqueue($flashMessage);
1077 }
1078 // Combine it all:
1079 $editForm .= $panel;
1080 }
1081 $thePrevUid = $rec['uid'];
1082 } else {
1083 $this->errorC++;
1084 $editForm .= $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.noEditPermission', TRUE) . '<br /><br />' . ($deniedAccessReason ? 'Reason: ' . htmlspecialchars($deniedAccessReason) . '<br /><br />' : '');
1085 }
1086 }
1087 }
1088 }
1089 }
1090 }
1091 return $editForm;
1092 }
1093
1094 /**
1095 * Create the panel of buttons for submitting the form or otherwise perform operations.
1096 *
1097 * @return array All available buttons as an assoc. array
1098 */
1099 protected function getButtons() {
1100 $lang = $this->getLanguageService();
1101 $buttons = array(
1102 'save' => '',
1103 'save_view' => '',
1104 'save_new' => '',
1105 'save_close' => '',
1106 'close' => '',
1107 'delete' => '',
1108 'undo' => '',
1109 'history' => '',
1110 'columns_only' => '',
1111 'csh' => '',
1112 'translation_save' => '',
1113 'translation_saveclear' => ''
1114 );
1115 // Render SAVE type buttons:
1116 // The action of each button is decided by its name attribute. (See doProcessData())
1117 if (!$this->errorC && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly']) {
1118 // SAVE button:
1119 $buttons['save'] = IconUtility::getSpriteIcon('actions-document-save', array('html' => '<input type="submit" name="_savedok" class="c-inputButton" value="" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" />'));
1120 // SAVE / VIEW button:
1121 if ($this->viewId && !$this->noView && $this->getNewIconMode($this->firstEl['table'], 'saveDocView')) {
1122 $pagesTSconfig = BackendUtility::getPagesTSconfig($this->pageinfo['uid']);
1123 if (isset($pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
1124 $excludeDokTypes = GeneralUtility::intExplode(',', $pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'], TRUE);
1125 } else {
1126 // exclude sysfolders, spacers and recycler by default
1127 $excludeDokTypes = array(PageRepository::DOKTYPE_RECYCLER, PageRepository::DOKTYPE_SYSFOLDER, PageRepository::DOKTYPE_SPACER);
1128 }
1129 if (!in_array((int)$this->pageinfo['doktype'], $excludeDokTypes, TRUE) || isset($pagesTSconfig['TCEMAIN.']['preview.'][$this->firstEl['table'].'.']['previewPageId'])) {
1130 $buttons['save_view'] = IconUtility::getSpriteIcon('actions-document-save-view', array('html' => '<input onclick="window.open(\'\', \'newTYPO3frontendWindow\');" type="submit" class="c-inputButton" name="_savedokview" value="" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDocShow', TRUE) . '" />'));
1131 }
1132 }
1133 // SAVE / NEW button:
1134 if (count($this->elementsData) === 1 && $this->getNewIconMode($this->firstEl['table'])) {
1135 $buttons['save_new'] = IconUtility::getSpriteIcon('actions-document-save-new', array('html' => '<input type="submit" class="c-inputButton" name="_savedoknew" value="" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveNewDoc', TRUE) . '" />'));
1136 }
1137 // SAVE / CLOSE
1138 $buttons['save_close'] = IconUtility::getSpriteIcon('actions-document-save-close', array('html' => '<input type="submit" class="c-inputButton" name="_saveandclosedok" value="" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" />'));
1139 // FINISH TRANSLATION / SAVE / CLOSE
1140 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['explicitConfirmationOfTranslation']) {
1141 $buttons['translation_save'] = '<input type="image" class="c-inputButton" name="_translation_savedok" src="sysext/t3skin/images/icons/actions/document-save-translation.png" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.translationSaveDoc', TRUE) . '" /> ';
1142 $buttons['translation_saveclear'] = '<input type="image" class="c-inputButton" name="_translation_savedokclear" src="sysext/t3skin/images/icons/actions/document-save-cleartranslationcache.png" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.translationSaveDocClear', TRUE) . '" />';
1143 }
1144 }
1145 // CLOSE button:
1146 $buttons['close'] = '<a href="#" class="t3js-editform-close" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
1147 // DELETE + UNDO buttons:
1148 if (!$this->errorC && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData) === 1) {
1149 if ($this->firstEl['cmd'] != 'new' && MathUtility::canBeInterpretedAsInteger($this->firstEl['uid'])) {
1150 // Delete:
1151 if ($this->firstEl['deleteAccess'] && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'], 'disableDelete')) {
1152 $buttons['delete'] = '<a href="#" class="t3js-editform-delete-record" data-return-url="' . htmlspecialchars($this->retUrl) . '" data-uid="' . htmlspecialchars($this->firstEl['uid']) . '" data-table="' . htmlspecialchars($this->firstEl['table']) . '" title="' . $lang->getLL('deleteItem', TRUE) . '">' . IconUtility::getSpriteIcon('actions-edit-delete') . '</a>';
1153 }
1154 // Undo:
1155 $undoRes = $this->getDatabaseConnection()->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $this->getDatabaseConnection()->fullQuoteStr($this->firstEl['table'], 'sys_history') . ' AND recuid=' . (int)$this->firstEl['uid'], '', 'tstamp DESC', '1');
1156 if ($undoButtonR = $this->getDatabaseConnection()->sql_fetch_assoc($undoRes)) {
1157 $aOnClick = 'window.location.href=' .
1158 GeneralUtility::quoteJSvalue(
1159 BackendUtility::getModuleUrl(
1160 'record_history',
1161 array(
1162 'element' => $this->firstEl['table'] . ':' . $this->firstEl['uid'],
1163 'revert' => 'ALL_FIELDS',
1164 'sumUp' => -1,
1165 'returnUrl' => $this->R_URI,
1166 )
1167 )
1168 ) . '; return false;';
1169 $buttons['undo'] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"' . ' title="' . htmlspecialchars(sprintf($lang->getLL('undoLastChange'), BackendUtility::calcAge(($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp']), $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')))) . '">' . IconUtility::getSpriteIcon('actions-edit-undo') . '</a>';
1170 }
1171 if ($this->getNewIconMode($this->firstEl['table'], 'showHistory')) {
1172 $aOnClick = 'window.location.href=' .
1173 GeneralUtility::quoteJSvalue(
1174 BackendUtility::getModuleUrl(
1175 'record_history',
1176 array(
1177 'element' => $this->firstEl['table'] . ':' . $this->firstEl['uid'],
1178 'returnUrl' => $this->R_URI,
1179 )
1180 )
1181 ) . '; return false;';
1182 $buttons['history'] = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . IconUtility::getSpriteIcon('actions-document-history-open') . '</a>';
1183 }
1184 // If only SOME fields are shown in the form, this will link the user to the FULL form:
1185 if ($this->columnsOnly) {
1186 $buttons['columns_only'] = '<a href="' . htmlspecialchars(($this->R_URI . '&columnsOnly=')) . '" title="' . $lang->getLL('editWholeRecord', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-open') . '</a>';
1187 }
1188 }
1189 }
1190 // add the CSH icon
1191 $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'TCEforms');
1192 $buttons['shortcut'] = $this->shortCutLink();
1193 $buttons['open_in_new_window'] = $this->openInNewWindowLink();
1194
1195 return $buttons;
1196 }
1197
1198 /**
1199 * Returns the language switch/selector for editing,
1200 * show only when a single record is edited
1201 * - multiple records are too confusing
1202 *
1203 * @return string The HTML
1204 */
1205 public function langSelector() {
1206 $langSelector = '';
1207 if (count($this->elementsData) === 1) {
1208 $langSelector = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']);
1209 }
1210 return $langSelector;
1211 }
1212
1213 /**
1214 * Compiles the extra form headers if the tceforms
1215 *
1216 * @return string The HTML
1217 */
1218 public function extraFormHeaders() {
1219 $extraTemplate = '';
1220 if (is_array($this->tceforms->extraFormHeaders)) {
1221 $extraTemplate = HtmlParser::getSubpart($this->doc->moduleTemplate, '###DOCHEADER_EXTRAHEADER###');
1222 $extraTemplate = HtmlParser::substituteMarker($extraTemplate, '###EXTRAHEADER###', implode(LF, $this->tceforms->extraFormHeaders));
1223 }
1224 return $extraTemplate;
1225 }
1226
1227 /**
1228 * Put together the various elements (buttons, selectors, form) into a table
1229 *
1230 * @param string $editForm HTML form.
1231 * @return string Composite HTML
1232 */
1233 public function compileForm($editForm) {
1234 $formContent = '
1235 <!-- EDITING FORM -->
1236 ' . $editForm . '
1237
1238 <input type="hidden" name="returnUrl" value="' . htmlspecialchars($this->retUrl) . '" />
1239 <input type="hidden" name="viewUrl" value="' . htmlspecialchars($this->viewUrl) . '" />';
1240 if ($this->returnNewPageId) {
1241 $formContent .= '<input type="hidden" name="returnNewPageId" value="1" />';
1242 }
1243 $formContent .= '<input type="hidden" name="popViewId" value="' . htmlspecialchars($this->viewId) . '" />';
1244 if ($this->viewId_addParams) {
1245 $formContent .= '<input type="hidden" name="popViewId_addParams" value="' . htmlspecialchars($this->viewId_addParams) . '" />';
1246 }
1247 $formContent .= '
1248 <input type="hidden" name="closeDoc" value="0" />
1249 <input type="hidden" name="doSave" value="0" />
1250 <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
1251 <input type="hidden" name="_scrollPosition" value="" />' . FormEngine::getHiddenTokenField('editRecord');
1252 return $formContent;
1253 }
1254
1255 /**
1256 * Create shortcut icon
1257 *
1258 * @return string
1259 */
1260 public function shortCutLink() {
1261 if ($this->returnUrl === 'sysext/backend/Resources/Private/Templates/Close.html' || !$this->getBackendUser()->mayMakeShortcut()) {
1262 return '';
1263 }
1264 return $this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,noView', '', $this->MCONF['name'], 1);
1265 }
1266
1267 /**
1268 * Creates open-in-window link
1269 *
1270 * @return string
1271 */
1272 public function openInNewWindowLink() {
1273 if ($this->returnUrl === 'sysext/backend/Resources/Private/Templates/Close.html') {
1274 return '';
1275 }
1276 $aOnClick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript(array('returnUrl' => 'sysext/backend/Resources/Private/Templates/Close.html'))) . ',' . GeneralUtility::quoteJSvalue(md5($this->R_URI)) . ',\'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
1277 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.openInNewWindow', TRUE) . '">' . IconUtility::getSpriteIcon('actions-window-open') . '</a>';
1278 }
1279
1280 /***************************
1281 *
1282 * Localization stuff
1283 *
1284 ***************************/
1285 /**
1286 * Make selector box for creating new translation for a record or switching to edit the record in an existing language.
1287 * Displays only languages which are available for the current page.
1288 *
1289 * @param string $table Table name
1290 * @param int $uid Uid for which to create a new language
1291 * @param int $pid Pid of the record
1292 * @return string <select> HTML element (if there were items for the box anyways...)
1293 */
1294 public function languageSwitch($table, $uid, $pid = NULL) {
1295 $content = '';
1296 $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
1297 $transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
1298 // Table editable and activated for languages?
1299 if ($this->getBackendUser()->check('tables_modify', $table) && $languageField && $transOrigPointerField && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable']) {
1300 if (is_null($pid)) {
1301 $row = BackendUtility::getRecord($table, $uid, 'pid');
1302 $pid = $row['pid'];
1303 }
1304 // Get all avalibale languages for the page
1305 $langRows = $this->getLanguages($pid);
1306 // Page available in other languages than default language?
1307 if (is_array($langRows) && count($langRows) > 1) {
1308 $rowsByLang = array();
1309 $fetchFields = 'uid,' . $languageField . ',' . $transOrigPointerField;
1310 // Get record in current language
1311 $rowCurrent = BackendUtility::getLiveVersionOfRecord($table, $uid, $fetchFields);
1312 if (!is_array($rowCurrent)) {
1313 $rowCurrent = BackendUtility::getRecord($table, $uid, $fetchFields);
1314 }
1315 $currentLanguage = $rowCurrent[$languageField];
1316 // Disabled for records with [all] language!
1317 if ($currentLanguage > -1) {
1318 // Get record in default language if needed
1319 if ($currentLanguage && $rowCurrent[$transOrigPointerField]) {
1320 $rowsByLang[0] = BackendUtility::getLiveVersionOfRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
1321 if (!is_array($rowsByLang[0])) {
1322 $rowsByLang[0] = BackendUtility::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
1323 }
1324 } else {
1325 $rowsByLang[$rowCurrent[$languageField]] = $rowCurrent;
1326 }
1327 if ($rowCurrent[$transOrigPointerField] || $currentLanguage === '0') {
1328 // Get record in other languages to see what's already available
1329 $translations = $this->getDatabaseConnection()->exec_SELECTgetRows($fetchFields, $table, 'pid=' . (int)$pid . ' AND ' . $languageField . '>0' . ' AND ' . $transOrigPointerField . '=' . (int)$rowsByLang[0]['uid'] . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
1330 foreach ($translations as $row) {
1331 $rowsByLang[$row[$languageField]] = $row;
1332 }
1333 }
1334 $langSelItems = array();
1335 foreach ($langRows as $lang) {
1336 if ($this->getBackendUser()->checkLanguageAccess($lang['uid'])) {
1337 $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' [' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.new', TRUE) . ']';
1338 // Create url for creating a localized record
1339 if ($newTranslation) {
1340 $redirectUrl = BackendUtility::getModuleUrl('record_edit', array(
1341 'justLocalized' => $table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid'],
1342 'returnUrl' => $this->retUrl
1343 )) . BackendUtility::getUrlToken('editRecord');
1344 $href = $this->doc->issueCommand('&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'], $redirectUrl);
1345 } else {
1346 $href = BackendUtility::getModuleUrl('record_edit', array(
1347 'edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']' => 'edit',
1348 'returnUrl' => $this->retUrl
1349 )) . BackendUtility::getUrlToken('editRecord');
1350 }
1351 $langSelItems[$lang['uid']] = '
1352 <option value="' . htmlspecialchars($href) . '"' . ($currentLanguage == $lang['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars(($lang['title'] . $newTranslation)) . '</option>';
1353 }
1354 }
1355 // If any languages are left, make selector:
1356 if (count($langSelItems) > 1) {
1357 $onChange = 'if(this.options[this.selectedIndex].value){window.location.href=(this.options[this.selectedIndex].value);}';
1358 $content = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_general.xlf:LGL.language', TRUE) . ' <select name="_langSelector" onchange="' . htmlspecialchars($onChange) . '">
1359 ' . implode('', $langSelItems) . '
1360 </select>';
1361 }
1362 }
1363 }
1364 }
1365 return $content;
1366 }
1367
1368 /**
1369 * Redirects to FormEngine with new parameters to edit a just created localized record
1370 *
1371 * @param string $justLocalized String passed by GET &justLocalized=
1372 * @return void
1373 */
1374 public function localizationRedirect($justLocalized) {
1375 list($table, $orig_uid, $language) = explode(':', $justLocalized);
1376 if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
1377 $localizedRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid', $table, $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int)$language . ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int)$orig_uid . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
1378 if (is_array($localizedRecord)) {
1379 // Create parameters and finally run the classic page module for creating a new page translation
1380 $location = BackendUtility::getModuleUrl('record_edit', array(
1381 'edit[' . $table . '][' . $localizedRecord['uid'] . ']' => 'edit',
1382 'returnUrl' => GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'))
1383 ));
1384 HttpUtility::redirect($location . BackendUtility::getUrlToken('editRecord'));
1385 }
1386 }
1387 }
1388
1389 /**
1390 * Returns sys_language records available for record translations on given page.
1391 *
1392 * @param int $id Page id: If zero, the query will select all sys_language records from root level which are NOT hidden. If set to another value, the query will select all sys_language records that has a pages_language_overlay record on that page (and is not hidden, unless you are admin user)
1393 * @return array Language records including faked record for default language
1394 */
1395 public function getLanguages($id) {
1396 $modSharedTSconfig = BackendUtility::getModTSconfig($id, 'mod.SHARED');
1397 // Fallback non sprite-configuration
1398 if (preg_match('/\\.gif$/', $modSharedTSconfig['properties']['defaultLanguageFlag'])) {
1399 $modSharedTSconfig['properties']['defaultLanguageFlag'] = str_replace('.gif', '', $modSharedTSconfig['properties']['defaultLanguageFlag']);
1400 }
1401 $languages = array(
1402 0 => array(
1403 'uid' => 0,
1404 'pid' => 0,
1405 'hidden' => 0,
1406 'title' => $modSharedTSconfig['properties']['defaultLanguageLabel'] !== ''
1407 ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $this->getLanguageService()->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')'
1408 : $this->getLanguageService()->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
1409 'flag' => $modSharedTSconfig['properties']['defaultLanguageFlag']
1410 )
1411 );
1412 $exQ = $this->getBackendUser()->isAdmin() ? '' : ' AND sys_language.hidden=0';
1413 if ($id) {
1414 $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('sys_language.*', 'pages_language_overlay,sys_language', 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid=' . (int)$id . BackendUtility::deleteClause('pages_language_overlay') . $exQ, 'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.language_isocode,sys_language.static_lang_isocode,sys_language.flag', 'sys_language.title');
1415 } else {
1416 $rows = $this->getDatabaseConnection()->exec_SELECTgetRows('sys_language.*', 'sys_language', 'sys_language.hidden=0', '', 'sys_language.title');
1417 }
1418 if ($rows) {
1419 foreach ($rows as $row) {
1420 $languages[$row['uid']] = $row;
1421 }
1422 }
1423 return $languages;
1424 }
1425
1426 /***************************
1427 *
1428 * Other functions
1429 *
1430 ***************************/
1431 /**
1432 * Fix $this->editconf if versioning applies to any of the records
1433 *
1434 * @param array|bool $mapArray Mapping between old and new ids if auto-versioning has been performed.
1435 * @return void
1436 */
1437 public function fixWSversioningInEditConf($mapArray = FALSE) {
1438 // Traverse the editConf array
1439 if (is_array($this->editconf)) {
1440 // Tables:
1441 foreach ($this->editconf as $table => $conf) {
1442 if (is_array($conf) && $GLOBALS['TCA'][$table]) {
1443 // Traverse the keys/comments of each table (keys can be a commalist of uids)
1444 $newConf = array();
1445 foreach ($conf as $cKey => $cmd) {
1446 if ($cmd == 'edit') {
1447 // Traverse the ids:
1448 $ids = GeneralUtility::trimExplode(',', $cKey, TRUE);
1449 foreach ($ids as $idKey => $theUid) {
1450 if (is_array($mapArray)) {
1451 if ($mapArray[$table][$theUid]) {
1452 $ids[$idKey] = $mapArray[$table][$theUid];
1453 }
1454 } else {
1455 // Default, look for versions in workspace for record:
1456 $calcPRec = $this->getRecordForEdit($table, $theUid);
1457 if (is_array($calcPRec)) {
1458 // Setting UID again if it had changed, eg. due to workspace versioning.
1459 $ids[$idKey] = $calcPRec['uid'];
1460 }
1461 }
1462 }
1463 // Add the possibly manipulated IDs to the new-build newConf array:
1464 $newConf[implode(',', $ids)] = $cmd;
1465 } else {
1466 $newConf[$cKey] = $cmd;
1467 }
1468 }
1469 // Store the new conf array:
1470 $this->editconf[$table] = $newConf;
1471 }
1472 }
1473 }
1474 }
1475
1476 /**
1477 * Get record for editing.
1478 *
1479 * @param string $table Table name
1480 * @param int $theUid Record UID
1481 * @return array Returns record to edit, FALSE if none
1482 */
1483 public function getRecordForEdit($table, $theUid) {
1484 // Fetch requested record:
1485 $reqRecord = BackendUtility::getRecord($table, $theUid, 'uid,pid');
1486 if (is_array($reqRecord)) {
1487 // If workspace is OFFLINE:
1488 if ($this->getBackendUser()->workspace != 0) {
1489 // Check for versioning support of the table:
1490 if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
1491 // If the record is already a version of "something" pass it by.
1492 if ($reqRecord['pid'] == -1) {
1493 // (If it turns out not to be a version of the current workspace there will be trouble, but that is handled inside TCEmain then and in the interface it would clearly be an error of links if the user accesses such a scenario)
1494 return $reqRecord;
1495 } else {
1496 // The input record was online and an offline version must be found or made:
1497 // Look for version of this workspace:
1498 $versionRec = BackendUtility::getWorkspaceVersionOfRecord($this->getBackendUser()->workspace, $table, $reqRecord['uid'], 'uid,pid,t3ver_oid');
1499 return is_array($versionRec) ? $versionRec : $reqRecord;
1500 }
1501 } else {
1502 // This means that editing cannot occur on this record because it was not supporting versioning which is required inside an offline workspace.
1503 return FALSE;
1504 }
1505 } else {
1506 // In ONLINE workspace, just return the originally requested record:
1507 return $reqRecord;
1508 }
1509 } else {
1510 // Return FALSE because the table/uid was not found anyway.
1511 return FALSE;
1512 }
1513 }
1514
1515 /**
1516 * 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
1517 *
1518 * @return void
1519 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
1520 */
1521 public function editRegularContentFromId() {
1522 GeneralUtility::logDeprecatedFunction();
1523 $dbConnection = $this->getDatabaseConnection();
1524 $res = $dbConnection->exec_SELECTquery('uid', 'tt_content', 'pid=' . (int)$this->editRegularContentFromId . BackendUtility::deleteClause('tt_content') . BackendUtility::versioningPlaceholderClause('tt_content') . ' AND colPos=0 AND sys_language_uid=0', '', 'sorting');
1525 if ($dbConnection->sql_num_rows($res)) {
1526 $ecUids = array();
1527 while ($ecRec = $dbConnection->sql_fetch_assoc($res)) {
1528 $ecUids[] = $ecRec['uid'];
1529 }
1530 $this->editconf['tt_content'][implode(',', $ecUids)] = 'edit';
1531 }
1532 $dbConnection->sql_free_result($res);
1533 }
1534
1535 /**
1536 * Populates the variables $this->storeArray, $this->storeUrl, $this->storeUrlMd5
1537 *
1538 * @return void
1539 * @see makeDocSel()
1540 */
1541 public function compileStoreDat() {
1542 $this->storeArray = GeneralUtility::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,noView,editRegularContentFromId,workspace', $this->R_URL_getvars);
1543 $this->storeUrl = GeneralUtility::implodeArrayForUrl('', $this->storeArray);
1544 $this->storeUrlMd5 = md5($this->storeUrl);
1545 }
1546
1547 /**
1548 * Function used to look for configuration of buttons in the form: Fx. disabling buttons or showing them at various positions.
1549 *
1550 * @param string $table The table for which the configuration may be specific
1551 * @param string $key The option for look for. Default is checking if the saveDocNew button should be displayed.
1552 * @return string Return value fetched from USER TSconfig
1553 */
1554 public function getNewIconMode($table, $key = 'saveDocNew') {
1555 $TSconfig = $this->getBackendUser()->getTSConfig('options.' . $key);
1556 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
1557 return $output;
1558 }
1559
1560 /**
1561 * Handling the closing of a document
1562 *
1563 * @param int $code Close code: 0/1 will redirect to $this->retUrl, 3 will clear the docHandler (thus closing all documents) and other values will call setDocument with ->retUrl
1564 * @return void
1565 */
1566 public function closeDocument($code = 0) {
1567 // If current document is found in docHandler,
1568 // then unset it, possibly unset it ALL and finally, write it to the session data
1569 if (isset($this->docHandler[$this->storeUrlMd5])) {
1570 // add the closing document to the recent documents
1571 $recentDocs = $this->getBackendUser()->getModuleData('opendocs::recent');
1572 if (!is_array($recentDocs)) {
1573 $recentDocs = array();
1574 }
1575 $closedDoc = $this->docHandler[$this->storeUrlMd5];
1576 $recentDocs = array_merge(array($this->storeUrlMd5 => $closedDoc), $recentDocs);
1577 if (count($recentDocs) > 8) {
1578 $recentDocs = array_slice($recentDocs, 0, 8);
1579 }
1580 // remove it from the list of the open documents
1581 unset($this->docHandler[$this->storeUrlMd5]);
1582 if ($code == '3') {
1583 $recentDocs = array_merge($this->docHandler, $recentDocs);
1584 $this->docHandler = array();
1585 }
1586 $this->getBackendUser()->pushModuleData('opendocs::recent', $recentDocs);
1587 $this->getBackendUser()->pushModuleData('FormEngine', array($this->docHandler, $this->docDat[1]));
1588 BackendUtility::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler));
1589 }
1590 // 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...)
1591 if ($this->returnEditConf && $this->retUrl != BackendUtility::getModuleUrl('dummy')) {
1592 $this->retUrl .= '&returnEditConf=' . rawurlencode(json_encode($this->editconf));
1593 }
1594 // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl
1595 if (!$code || $code == 1) {
1596 HttpUtility::redirect($this->retUrl);
1597 } else {
1598 $this->setDocument('', $this->retUrl);
1599 }
1600 }
1601
1602 /**
1603 * Redirects to the document pointed to by $currentDocFromHandlerMD5 OR $retUrl (depending on some internal calculations).
1604 * Most likely you will get a header-location redirect from this function.
1605 *
1606 * @param string $currentDocFromHandlerMD5 Pointer to the document in the docHandler array
1607 * @param string $retUrl Alternative/Default retUrl
1608 * @return void
1609 */
1610 public function setDocument($currentDocFromHandlerMD5 = '', $retUrl = '') {
1611 if ($retUrl === '') {
1612 return;
1613 }
1614 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && !empty($this->docHandler)) {
1615 if (isset($this->docHandler[$currentDocFromHandlerMD5])) {
1616 $setupArr = $this->docHandler[$currentDocFromHandlerMD5];
1617 } else {
1618 $setupArr = reset($this->docHandler);
1619 }
1620 if ($setupArr[2]) {
1621 $sParts = parse_url(GeneralUtility::getIndpEnv('REQUEST_URI'));
1622 $retUrl = $sParts['path'] . '?' . $setupArr[2] . '&returnUrl=' . rawurlencode($retUrl);
1623 }
1624 }
1625 HttpUtility::redirect($retUrl);
1626 }
1627
1628 /**
1629 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
1630 */
1631 protected function getBackendUser() {
1632 return $GLOBALS['BE_USER'];
1633 }
1634
1635 /**
1636 * Returns LanguageService
1637 *
1638 * @return \TYPO3\CMS\Lang\LanguageService
1639 */
1640 protected function getLanguageService() {
1641 return $GLOBALS['LANG'];
1642 }
1643
1644 /**
1645 * Returns the database connection
1646 *
1647 * @return \TYPO3\CMS\Core\Database\DatabaseConnection
1648 */
1649 protected function getDatabaseConnection() {
1650 return $GLOBALS['TYPO3_DB'];
1651 }
1652
1653 }