2 namespace TYPO3\CMS\Backend\Controller
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use Psr\Http\Message\ResponseInterface
;
18 use Psr\Http\Message\ServerRequestInterface
;
19 use TYPO3\CMS\Backend\Form\Exception\AccessDeniedException
;
20 use TYPO3\CMS\Backend\Form\FormDataCompiler
;
21 use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord
;
22 use TYPO3\CMS\Backend\Form\FormResultCompiler
;
23 use TYPO3\CMS\Backend\Form\NodeFactory
;
24 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility
;
25 use TYPO3\CMS\Backend\Template\Components\ButtonBar
;
26 use TYPO3\CMS\Backend\Template\ModuleTemplate
;
27 use TYPO3\CMS\Backend\Utility\BackendUtility
;
28 use TYPO3\CMS\Core\Database\ConnectionPool
;
29 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction
;
30 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
;
31 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction
;
32 use TYPO3\CMS\Core\DataHandling\DataHandler
;
33 use TYPO3\CMS\Core\Http\HtmlResponse
;
34 use TYPO3\CMS\Core\Imaging\Icon
;
35 use TYPO3\CMS\Core\Messaging\FlashMessage
;
36 use TYPO3\CMS\Core\Messaging\FlashMessageQueue
;
37 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
38 use TYPO3\CMS\Core\Page\PageRenderer
;
39 use TYPO3\CMS\Core\Type\Bitmask\Permission
;
40 use TYPO3\CMS\Core\Utility\GeneralUtility
;
41 use TYPO3\CMS\Core\Utility\HttpUtility
;
42 use TYPO3\CMS\Core\Utility\MathUtility
;
43 use TYPO3\CMS\Core\Utility\PathUtility
;
44 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher
;
45 use TYPO3\CMS\Frontend\Page\CacheHashCalculator
;
46 use TYPO3\CMS\Frontend\Page\PageRepository
;
49 * Script Class: Drawing the editing form for editing records in TYPO3.
50 * Notice: It does NOT use tce_db.php to submit data to, rather it handles submissions itself
52 class EditDocumentController
54 const DOCUMENT_CLOSE_MODE_DEFAULT
= 0;
55 const DOCUMENT_CLOSE_MODE_REDIRECT
= 1; // works like DOCUMENT_CLOSE_MODE_DEFAULT
56 const DOCUMENT_CLOSE_MODE_CLEAR_ALL
= 3;
57 const DOCUMENT_CLOSE_MODE_NO_REDIRECT
= 4;
60 * GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg.
61 * "&edit[pages][123]=edit". See \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick(). Value can be seen
62 * modified internally (converting NEW keyword to id, workspace/versioning etc).
69 * Commalist of fieldnames to edit. The point is IF you specify this list, only those
70 * fields will be rendered in the form. Otherwise all (available) fields in the record
71 * is shown according to the types configuration in $GLOBALS['TCA']
78 * Default values for fields (array with tablenames, fields etc. as keys).
79 * Can be seen modified internally.
86 * Array of values to force being set (as hidden fields). Will be set as $this->defVals
87 * IF defVals does not exist.
94 * If set, this value will be set in $this->retUrl (which is used quite many places
95 * as the return URL). If not set, "dummy.php" will be set in $this->retUrl
102 * Close-document command. Not really sure of all options...
109 * Quite simply, if this variable is set, then the processing of incoming data will be performed
110 * as if a save-button is pressed. Used in the forms as a hidden field which can be set through
111 * JavaScript if the form is somehow submitted by JavaScript).
118 * The data array from which the data comes...
142 * Redirect (not used???)
149 * Boolean: If set, then the GET var "&id=" will be added to the
150 * retUrl string so that the NEW id of something is returned to the script calling the form.
154 public $returnNewPageId;
164 * ID for displaying the page in the frontend (used for SAVE/VIEW operations)
171 * Additional GET vars for the link, eg. "&L=xxx"
175 public $popViewId_addParams;
178 * Alternative URL for viewing the frontend pages.
185 * Alternative title for the document handler.
192 * If set, then no SAVE/VIEW button is printed
201 public $perms_clause;
204 * If set, the $this->editconf array is returned to the calling script
205 * (used by wizard_add.php for instance)
209 public $returnEditConf;
212 * Workspace used for the editing action.
216 protected $workspace;
219 * document template object
221 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
226 * a static HTML template, usually in templates/alt_doc.html
233 * Content accumulation
240 * Return URL script, processed. This contains the script (if any) that we should
241 * RETURN TO from the FormEngine script IF we press the close button. Thus this
242 * variable is normally passed along from the calling script so we can properly return if needed.
249 * Contains the parts of the REQUEST_URI (current url). By parts we mean the result of resolving
250 * REQUEST_URI (current url) by the parse_url() function. The result is an array where eg. "path"
251 * is the script path and "query" is the parameters...
258 * Contains the current GET vars array; More specifically this array is the foundation for creating
259 * the R_URI internal var (which becomes the "url of this script" to which we submit the forms etc.)
263 public $R_URL_getvars;
266 * Set to the URL of this script including variables which is needed to re-display the form. See main()
283 * Is loaded with the "title" of the currently "open document" - this is used in the
284 * Document Selector box. (see makeDocSel())
288 public $storeTitle = '';
291 * Contains an array with key/value pairs of GET parameters needed to reach the
292 * current document displayed - used in the Document Selector box. (see compileStoreDat())
299 * Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
306 * Hashed value of storeURL (see compileStoreDat())
313 * Module session data
320 * An array of the "open documents" - keys are md5 hashes (see $storeUrlMd5) identifying
321 * the various documents on the GET parameter list needed to open it. The values are
322 * arrays with 0,1,2 keys with information about the document (see compileStoreDat()).
323 * The docHandler variable is stored in the $docDat session data, key "0".
330 * Array of the elements to create edit forms for.
334 public $elementsData;
337 * Pointer to the first element in $elementsData
344 * Counter, used to count the number of errors (when users do not have edit permissions)
351 * Counter, used to count the number of new record forms displayed
358 * Is set to the pid value of the last shown record - thus indicating which page to
359 * show when clicking the SAVE/VIEW button
366 * Is set to additional parameters (like "&L=xxx") if the record supports it.
370 public $viewId_addParams;
373 * Module TSconfig, loaded from main() based on the page id value of viewId
380 * @var FormResultCompiler
382 protected $formResultCompiler;
385 * Used internally to disable the storage of the document reference (eg. new records)
389 public $dontStoreDocumentRef = 0;
392 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
394 protected $signalSlotDispatcher;
397 * Stores information needed to preview the currently saved record
401 protected $previewData = [];
404 * ModuleTemplate object
406 * @var ModuleTemplate
408 protected $moduleTemplate;
413 public function __construct()
415 $this->moduleTemplate
= GeneralUtility
::makeInstance(ModuleTemplate
::class);
416 $this->moduleTemplate
->setUiBlock(true);
417 $GLOBALS['SOBE'] = $this;
418 $this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf');
422 * Get the SignalSlot dispatcher
424 * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
426 protected function getSignalSlotDispatcher()
428 if (!isset($this->signalSlotDispatcher
)) {
429 $this->signalSlotDispatcher
= GeneralUtility
::makeInstance(Dispatcher
::class);
431 return $this->signalSlotDispatcher
;
435 * Emits a signal after a function was executed
437 * @param string $signalName
439 protected function emitFunctionAfterSignal($signalName)
441 $this->getSignalSlotDispatcher()->dispatch(__CLASS__
, $signalName . 'After', [$this]);
445 * First initialization.
447 public function preInit()
449 if (GeneralUtility
::_GP('justLocalized')) {
450 $this->localizationRedirect(GeneralUtility
::_GP('justLocalized'));
453 $this->editconf
= GeneralUtility
::_GP('edit');
454 $this->defVals
= GeneralUtility
::_GP('defVals');
455 $this->overrideVals
= GeneralUtility
::_GP('overrideVals');
456 $this->columnsOnly
= GeneralUtility
::_GP('columnsOnly');
457 $this->returnUrl
= GeneralUtility
::sanitizeLocalUrl(GeneralUtility
::_GP('returnUrl'));
458 $this->closeDoc
= (int)GeneralUtility
::_GP('closeDoc');
459 $this->doSave
= (bool)GeneralUtility
::_GP('doSave');
460 $this->returnEditConf
= GeneralUtility
::_GP('returnEditConf');
461 $this->workspace
= GeneralUtility
::_GP('workspace');
462 $this->uc
= GeneralUtility
::_GP('uc');
463 // Setting override values as default if defVals does not exist.
464 if (!is_array($this->defVals
) && is_array($this->overrideVals
)) {
465 $this->defVals
= $this->overrideVals
;
467 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
468 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
469 // Setting return URL
470 $this->retUrl
= $this->returnUrl ?
: (string)$uriBuilder->buildUriFromRoute('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 // Get session data for the module:
480 $this->docDat
= $this->getBackendUser()->getModuleData('FormEngine', 'ses');
481 $this->docHandler
= $this->docDat
[0];
482 // If a request for closing the document has been sent, act accordingly:
483 if ((int)$this->closeDoc
> self
::DOCUMENT_CLOSE_MODE_DEFAULT
) {
484 $this->closeDocument($this->closeDoc
);
486 // If NO vars are sent to the script, try to read first document:
487 // Added !is_array($this->editconf) because editConf must not be set either.
488 // Anyways I can't figure out when this situation here will apply...
489 if (is_array($this->R_URL_getvars
) && count($this->R_URL_getvars
) < 2 && !is_array($this->editconf
)) {
490 $this->setDocument($this->docDat
[1]);
493 // Sets a temporary workspace, this request is based on
494 if ($this->workspace
!== null) {
495 $this->getBackendUser()->setTemporaryWorkspace($this->workspace
);
498 $this->emitFunctionAfterSignal(__FUNCTION__
);
502 * Detects, if a save command has been triggered.
504 * @return bool TRUE, then save the document (data submitted)
506 public function doProcessData()
509 ||
isset($_POST['_savedok'])
510 ||
isset($_POST['_saveandclosedok'])
511 ||
isset($_POST['_savedokview'])
512 ||
isset($_POST['_savedoknew'])
513 ||
isset($_POST['_duplicatedoc'])
514 ||
isset($_POST['_translation_savedok'])
515 ||
isset($_POST['_translation_savedokclear']);
520 * Do processing of data, submitting it to DataHandler.
522 public function processData()
524 $beUser = $this->getBackendUser();
525 // GPvars specifically for processing:
526 $control = GeneralUtility
::_GP('control');
527 $this->data
= GeneralUtility
::_GP('data');
528 $this->cmd
= GeneralUtility
::_GP('cmd');
529 $this->mirror
= GeneralUtility
::_GP('mirror');
530 $this->cacheCmd
= GeneralUtility
::_GP('cacheCmd');
531 $this->redirect
= GeneralUtility
::_GP('redirect');
532 $this->returnNewPageId
= GeneralUtility
::_GP('returnNewPageId');
533 // See tce_db.php for relevate options here:
534 // Only options related to $this->data submission are included here.
535 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
536 $tce = GeneralUtility
::makeInstance(DataHandler
::class);
538 if (!empty($control)) {
539 $tce->setControl($control);
541 if (isset($_POST['_translation_savedok'])) {
542 $tce->updateModeL10NdiffData
= 'FORCE_FFUPD';
544 if (isset($_POST['_translation_savedokclear'])) {
545 $tce->updateModeL10NdiffData
= 'FORCE_FFUPD';
546 $tce->updateModeL10NdiffDataClear
= true;
548 // Setting default values specific for the user:
549 $TCAdefaultOverride = $beUser->getTSConfigProp('TCAdefaults');
550 if (is_array($TCAdefaultOverride)) {
551 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
553 // Setting internal vars:
554 if ($beUser->uc
['neverHideAtCopy']) {
555 $tce->neverHideAtCopy
= 1;
557 // Loading DataHandler with data:
558 $tce->start($this->data
, $this->cmd
);
559 if (is_array($this->mirror
)) {
560 $tce->setMirror($this->mirror
);
563 // Perform the saving operation with DataHandler:
564 if ($this->doSave
=== true) {
565 $tce->process_uploads($_FILES);
566 $tce->process_datamap();
567 $tce->process_cmdmap();
569 // If pages are being edited, we set an instruction about updating the page tree after this operation.
570 if ($tce->pagetreeNeedsRefresh
571 && (isset($this->data
['pages']) ||
$beUser->workspace
!= 0 && !empty($this->data
))
573 BackendUtility
::setUpdateSignal('updatePageTree');
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);
580 foreach ($this->editconf
as $tableName => $tableCmds) {
581 $keys = array_keys($tce->substNEWwithIDs_table
, $tableName);
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])
587 && in_array($editId, $tce->newRelatedIDs
[$tableName]))
589 // Translate new id to the workspace version:
590 if ($versionRec = BackendUtility
::getWorkspaceVersionOfRecord(
596 $editId = $versionRec['uid'];
598 $newEditConf[$tableName][$editId] = 'edit';
600 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
601 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
602 // Traverse all new records and forge the content of ->editconf so we can continue to EDIT
604 if ($tableName === 'pages'
605 && $this->retUrl
!= (string)$uriBuilder->buildUriFromRoute('dummy')
606 && $this->returnNewPageId
608 $this->retUrl
.= '&id=' . $tce->substNEWwithIDs
[$key];
612 $newEditConf[$tableName] = $tableCmds;
615 // Resetting editconf if newEditConf has values:
616 if (!empty($newEditConf)) {
617 $this->editconf
= $newEditConf;
619 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
620 $this->R_URL_getvars
['edit'] = $this->editconf
;
621 // Unsetting default values since we don't need them anymore.
622 unset($this->R_URL_getvars
['defVals']);
623 // Re-compile the store* values since editconf changed...
624 $this->compileStoreDat();
626 // See if any records was auto-created as new versions?
627 if (!empty($tce->autoVersionIdMap
)) {
628 $this->fixWSversioningInEditConf($tce->autoVersionIdMap
);
630 // If a document is saved and a new one is created right after.
631 if (isset($_POST['_savedoknew']) && is_array($this->editconf
)) {
632 $this->closeDocument(self
::DOCUMENT_CLOSE_MODE_NO_REDIRECT
);
633 // Finding the current table:
634 reset($this->editconf
);
635 $nTable = key($this->editconf
);
636 // Finding the first id, getting the records pid+uid
637 reset($this->editconf
[$nTable]);
638 $nUid = key($this->editconf
[$nTable]);
639 $recordFields = 'pid,uid';
640 if (!empty($GLOBALS['TCA'][$nTable]['ctrl']['versioningWS'])) {
641 $recordFields .= ',t3ver_oid';
643 $nRec = BackendUtility
::getRecord($nTable, $nUid, $recordFields);
644 // Determine insertion mode ('top' is self-explaining,
645 // otherwise new elements are inserted after one using a negative uid)
646 $insertRecordOnTop = ($this->getNewIconMode($nTable) === 'top');
647 // Setting a blank editconf array for a new record:
648 $this->editconf
= [];
649 // Determine related page ID for regular live context
650 if ($nRec['pid'] != -1) {
651 if ($insertRecordOnTop) {
652 $relatedPageId = $nRec['pid'];
654 $relatedPageId = -$nRec['uid'];
657 // Determine related page ID for workspace context
658 if ($insertRecordOnTop) {
659 // Fetch live version of workspace version since the pid value is always -1 in workspaces
660 $liveRecord = BackendUtility
::getRecord($nTable, $nRec['t3ver_oid'], $recordFields);
661 $relatedPageId = $liveRecord['pid'];
663 // Use uid of live version of workspace version
664 $relatedPageId = -$nRec['t3ver_oid'];
667 $this->editconf
[$nTable][$relatedPageId] = 'new';
668 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
669 $this->R_URL_getvars
['edit'] = $this->editconf
;
670 // Re-compile the store* values since editconf changed...
671 $this->compileStoreDat();
673 // If a document should be duplicated.
674 if (isset($_POST['_duplicatedoc']) && is_array($this->editconf
)) {
675 $this->closeDocument(self
::DOCUMENT_CLOSE_MODE_NO_REDIRECT
);
676 // Finding the current table:
677 reset($this->editconf
);
678 $nTable = key($this->editconf
);
679 // Finding the first id, getting the records pid+uid
680 reset($this->editconf
[$nTable]);
681 $nUid = key($this->editconf
[$nTable]);
682 if (!MathUtility
::canBeInterpretedAsInteger($nUid)) {
683 $nUid = $tce->substNEWwithIDs
[$nUid];
686 $recordFields = 'pid,uid';
687 if (!empty($GLOBALS['TCA'][$nTable]['ctrl']['versioningWS'])) {
688 $recordFields .= ',t3ver_oid';
690 $nRec = BackendUtility
::getRecord($nTable, $nUid, $recordFields);
692 // Setting a blank editconf array for a new record:
693 $this->editconf
= [];
695 if ($nRec['pid'] != -1) {
696 $relatedPageId = -$nRec['uid'];
698 $relatedPageId = -$nRec['t3ver_oid'];
701 /** @var $duplicateTce \TYPO3\CMS\Core\DataHandling\DataHandler */
702 $duplicateTce = GeneralUtility
::makeInstance(DataHandler
::class);
707 'copy' => $relatedPageId
712 $duplicateTce->start([], $duplicateCmd);
713 $duplicateTce->process_cmdmap();
715 $duplicateMappingArray = $duplicateTce->copyMappingArray
;
716 $duplicateUid = $duplicateMappingArray[$nTable][$nUid];
718 if ($nTable === 'pages') {
719 BackendUtility
::setUpdateSignal('updatePageTree');
722 $this->editconf
[$nTable][$duplicateUid] = 'edit';
723 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
724 $this->R_URL_getvars
['edit'] = $this->editconf
;
725 // Re-compile the store* values since editconf changed...
726 $this->compileStoreDat();
728 // Inform the user of the duplication
729 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
730 $flashMessage = GeneralUtility
::makeInstance(
732 $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.recordDuplicated'),
736 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
737 $flashMessageService = GeneralUtility
::makeInstance(FlashMessageService
::class);
738 /** @var $defaultFlashMessageQueue FlashMessageQueue */
739 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
740 $defaultFlashMessageQueue->enqueue($flashMessage);
742 // If a preview is requested
743 if (isset($_POST['_savedokview'])) {
744 // Get the first table and id of the data array from DataHandler
745 $table = reset(array_keys($this->data
));
746 $id = reset(array_keys($this->data
[$table]));
747 if (!MathUtility
::canBeInterpretedAsInteger($id)) {
748 $id = $tce->substNEWwithIDs
[$id];
750 // Store this information for later use
751 $this->previewData
['table'] = $table;
752 $this->previewData
['id'] = $id;
754 $tce->printLogErrorMessages();
756 // || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED
757 // because if not, we just get that element re-listed as new. And we don't want that!
758 if ((int)$this->closeDoc
< self
::DOCUMENT_CLOSE_MODE_DEFAULT
759 ||
isset($_POST['_saveandclosedok'])
760 ||
isset($_POST['_translation_savedok'])
762 $this->closeDocument(abs($this->closeDoc
));
767 * Initialize the normal module operation
769 public function init()
771 $beUser = $this->getBackendUser();
772 // Setting more GPvars:
773 $this->popViewId
= GeneralUtility
::_GP('popViewId');
774 $this->popViewId_addParams
= GeneralUtility
::_GP('popViewId_addParams');
775 $this->viewUrl
= GeneralUtility
::_GP('viewUrl');
776 $this->recTitle
= GeneralUtility
::_GP('recTitle');
777 $this->noView
= GeneralUtility
::_GP('noView');
778 $this->perms_clause
= $beUser->getPagePermsClause(Permission
::PAGE_SHOW
);
779 // Set other internal variables:
780 $this->R_URL_getvars
['returnUrl'] = $this->retUrl
;
781 $this->R_URI
= $this->R_URL_parts
['path'] . '?' . ltrim(GeneralUtility
::implodeArrayForUrl(
785 // Setting virtual document name
786 $this->MCONF
['name'] = 'xMOD_alt_doc.php';
788 // Create an instance of the document template object
789 $this->doc
= $GLOBALS['TBE_TEMPLATE'];
790 $pageRenderer = GeneralUtility
::makeInstance(PageRenderer
::class);
791 $pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf');
792 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
793 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
794 // override the default jumpToUrl
795 $this->moduleTemplate
->addJavaScriptCode(
798 function jumpToUrl(URL,formEl) {
799 if (!TBE_EDITOR.isFormChanged()) {
800 window.location.href = URL;
801 } else if (formEl && formEl.type=="checkbox") {
802 formEl.checked = formEl.checked ? 0 : 1;
807 function launchView(table,uid) {
808 console.warn(\'Calling launchView() has been deprecated in v9 and will be removed in v10.0\');
809 var thePreviewWindow = window.open(
810 ' . GeneralUtility
::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('show_item') . '&table=') . ' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
811 "ShowItem" + Math.random().toString(16).slice(2),
812 "height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0"
814 if (thePreviewWindow && thePreviewWindow.focus) {
815 thePreviewWindow.focus();
818 function deleteRecord(table,id,url) {
819 window.location.href = ' . GeneralUtility
::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1&redirect="+escape(url);
821 ' . (isset($_POST['_savedokview']) && $this->popViewId ?
$this->generatePreviewCode() : '')
823 // Setting up the context sensitive menu:
824 $this->moduleTemplate
->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
826 $this->emitFunctionAfterSignal(__FUNCTION__
);
832 protected function generatePreviewCode()
834 $table = $this->previewData
['table'];
835 $recordId = $this->previewData
['id'];
837 if ($table === 'pages') {
838 $currentPageId = $recordId;
840 $currentPageId = MathUtility
::convertToPositiveInteger($this->popViewId
);
843 $pageTsConfig = BackendUtility
::getPagesTSconfig($currentPageId);
844 $previewConfiguration = $pageTsConfig['TCEMAIN.']['preview.'][$table . '.'] ??
[];
846 $recordArray = BackendUtility
::getRecord($table, $recordId);
848 // find the right preview page id
850 if (isset($previewConfiguration['previewPageId'])) {
851 $previewPageId = $previewConfiguration['previewPageId'];
853 // if no preview page was configured
854 if (!$previewPageId) {
855 $rootPageData = null;
856 $rootLine = BackendUtility
::BEgetRootLine($currentPageId);
857 $currentPage = reset($rootLine);
858 // Allow all doktypes below 200
859 // This makes custom doktype work as well with opening a frontend page.
860 if ((int)$currentPage['doktype'] <= PageRepository
::DOKTYPE_SPACER
) {
861 // try the current page
862 $previewPageId = $currentPageId;
864 // or search for the root page
865 foreach ($rootLine as $page) {
866 if ($page['is_siteroot']) {
867 $rootPageData = $page;
871 $previewPageId = isset($rootPageData)
872 ?
(int)$rootPageData['uid']
877 $linkParameters = [];
880 $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'] ??
'';
881 if ($languageField && !empty($recordArray[$languageField])) {
882 $l18nPointer = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ??
'';
883 if ($l18nPointer && !empty($recordArray[$l18nPointer])
884 && isset($previewConfiguration['useDefaultLanguageRecord'])
885 && !$previewConfiguration['useDefaultLanguageRecord']
888 $recordId = $recordArray[$l18nPointer];
890 $linkParameters['L'] = $recordArray[$languageField];
893 // map record data to GET parameters
894 if (isset($previewConfiguration['fieldToParameterMap.'])) {
895 foreach ($previewConfiguration['fieldToParameterMap.'] as $field => $parameterName) {
896 $value = $recordArray[$field];
897 if ($field === 'uid') {
900 $linkParameters[$parameterName] = $value;
904 // add/override parameters by configuration
905 if (isset($previewConfiguration['additionalGetParameters.'])) {
906 $additionalGetParameters = [];
907 $this->parseAdditionalGetParameters(
908 $additionalGetParameters,
909 $previewConfiguration['additionalGetParameters.']
911 $linkParameters = array_replace($linkParameters, $additionalGetParameters);
914 if (!empty($previewConfiguration['useCacheHash'])) {
915 /** @var CacheHashCalculator */
916 $cacheHashCalculator = GeneralUtility
::makeInstance(CacheHashCalculator
::class);
917 $fullLinkParameters = GeneralUtility
::implodeArrayForUrl('', array_merge($linkParameters, ['id' => $previewPageId]));
918 $cacheHashParameters = $cacheHashCalculator->getRelevantParameters($fullLinkParameters);
919 $linkParameters['cHash'] = $cacheHashCalculator->calculateCacheHash($cacheHashParameters);
921 $linkParameters['no_cache'] = 1;
924 $this->popViewId
= $previewPageId;
925 $this->popViewId_addParams
= GeneralUtility
::implodeArrayForUrl('', $linkParameters, '', false, true);
926 $anchorSection = $table === 'tt_content' ?
'#c' . $recordId : '';
928 $previewPageRootline = BackendUtility
::BEgetRootLine($this->popViewId
);
932 . BackendUtility
::viewOnClick(
935 $previewPageRootline,
938 $this->popViewId_addParams
,
944 . BackendUtility
::viewOnClick(
947 $previewPageRootline,
950 $this->popViewId_addParams
957 * Migrates a set of (possibly nested) GET parameters in TypoScript syntax to a plain array
959 * This basically removes the trailing dots of sub-array keys in TypoScript.
960 * The result can be used to create a query string with GeneralUtility::implodeArrayForUrl().
962 * @param array $parameters Should be an empty array by default
963 * @param array $typoScript The TypoScript configuration
965 protected function parseAdditionalGetParameters(array &$parameters, array $typoScript)
967 foreach ($typoScript as $key => $value) {
968 if (is_array($value)) {
969 $key = rtrim($key, '.');
970 $parameters[$key] = [];
971 $this->parseAdditionalGetParameters($parameters[$key], $value);
973 $parameters[$key] = $value;
979 * Main module operation
981 public function main()
985 if (is_array($this->editconf
)) {
986 /** @var FormResultCompiler formResultCompiler */
987 $this->formResultCompiler
= GeneralUtility
::makeInstance(FormResultCompiler
::class);
989 // Creating the editing form, wrap it with buttons, document selector etc.
990 $editForm = $this->makeEditForm();
992 $this->firstEl
= reset($this->elementsData
);
993 // Checking if the currently open document is stored in the list of "open documents" - if not, add it:
994 if (($this->docDat
[1] !== $this->storeUrlMd5
995 ||
!isset($this->docHandler
[$this->storeUrlMd5
]))
996 && !$this->dontStoreDocumentRef
998 $this->docHandler
[$this->storeUrlMd5
] = [
1004 $this->getBackendUser()->pushModuleData('FormEngine', [$this->docHandler
, $this->storeUrlMd5
]);
1005 BackendUtility
::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler
));
1007 // Module configuration
1008 $this->modTSconfig
= $this->viewId ? BackendUtility
::getModTSconfig(
1012 $body = $this->formResultCompiler
->addCssFiles();
1013 $body .= $this->compileForm($editForm);
1014 $body .= $this->formResultCompiler
->printNeededJSFunctions();
1019 // The page will show only if there is a valid page and if this page may be viewed by the user
1020 $this->pageinfo
= BackendUtility
::readPageAccess($this->viewId
, $this->perms_clause
);
1021 if ($this->pageinfo
) {
1022 $this->moduleTemplate
->getDocHeaderComponent()->setMetaInformation($this->pageinfo
);
1024 // Setting up the buttons and markers for docheader
1025 $this->getButtons();
1026 $this->languageSwitch($this->firstEl
['table'], $this->firstEl
['uid'], $this->firstEl
['pid']);
1027 $this->moduleTemplate
->setContent($body);
1030 /***************************
1032 * Sub-content functions, rendering specific parts of the module content.
1034 ***************************/
1036 * Creates the editing form with FormEnigne, based on the input from GPvars.
1038 * @return string HTML form elements wrapped in tables
1040 public function makeEditForm()
1042 // Initialize variables:
1043 $this->elementsData
= [];
1048 $beUser = $this->getBackendUser();
1049 // Traverse the GPvar edit array
1051 foreach ($this->editconf
as $table => $conf) {
1052 if (is_array($conf) && $GLOBALS['TCA'][$table] && $beUser->check('tables_modify', $table)) {
1053 // Traverse the keys/comments of each table (keys can be a commalist of uids)
1054 foreach ($conf as $cKey => $command) {
1055 if ($command === 'edit' ||
$command === 'new') {
1057 $ids = GeneralUtility
::trimExplode(',', $cKey, true);
1058 // Traverse the ids:
1059 foreach ($ids as $theUid) {
1060 // Don't save this document title in the document selector if the document is new.
1061 if ($command === 'new') {
1062 $this->dontStoreDocumentRef
= 1;
1065 /** @var TcaDatabaseRecord $formDataGroup */
1066 $formDataGroup = GeneralUtility
::makeInstance(TcaDatabaseRecord
::class);
1067 /** @var FormDataCompiler $formDataCompiler */
1068 $formDataCompiler = GeneralUtility
::makeInstance(FormDataCompiler
::class, $formDataGroup);
1069 /** @var NodeFactory $nodeFactory */
1070 $nodeFactory = GeneralUtility
::makeInstance(NodeFactory
::class);
1073 // Reset viewId - it should hold data of last entry only
1075 $this->viewId_addParams
= '';
1077 $formDataCompilerInput = [
1078 'tableName' => $table,
1079 'vanillaUid' => (int)$theUid,
1080 'command' => $command,
1081 'returnUrl' => $this->R_URI
,
1083 if (is_array($this->overrideVals
) && is_array($this->overrideVals
[$table])) {
1084 $formDataCompilerInput['overrideValues'] = $this->overrideVals
[$table];
1087 $formData = $formDataCompiler->compile($formDataCompilerInput);
1089 // Set this->viewId if possible
1090 if ($command === 'new'
1091 && $table !== 'pages'
1092 && !empty($formData['parentPageRow']['uid'])
1094 $this->viewId
= $formData['parentPageRow']['uid'];
1096 if ($table === 'pages') {
1097 $this->viewId
= $formData['databaseRow']['uid'];
1098 } elseif (!empty($formData['parentPageRow']['uid'])) {
1099 $this->viewId
= $formData['parentPageRow']['uid'];
1100 // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
1101 if (!empty($formData['processedTca']['ctrl']['languageField'])
1102 && is_array($formData['databaseRow'][$formData['processedTca']['ctrl']['languageField']])
1103 && $formData['databaseRow'][$formData['processedTca']['ctrl']['languageField']][0] > 0
1105 $this->viewId_addParams
= '&L=' . $formData['databaseRow'][$formData['processedTca']['ctrl']['languageField']][0];
1110 // Determine if delete button can be shown
1111 $deleteAccess = false;
1112 if ($command === 'edit') {
1113 $permission = $formData['userPermissionOnPage'];
1114 if ($formData['tableName'] === 'pages') {
1115 $deleteAccess = $permission & Permission
::PAGE_DELETE ?
true : false;
1117 $deleteAccess = $permission & Permission
::CONTENT_EDIT ?
true : false;
1121 // Display "is-locked" message:
1122 if ($command === 'edit') {
1123 $lockInfo = BackendUtility
::isRecordLocked($table, $formData['databaseRow']['uid']);
1125 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
1126 $flashMessage = GeneralUtility
::makeInstance(
1127 FlashMessage
::class,
1130 FlashMessage
::WARNING
1132 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
1133 $flashMessageService = GeneralUtility
::makeInstance(FlashMessageService
::class);
1134 /** @var $defaultFlashMessageQueue FlashMessageQueue */
1135 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1136 $defaultFlashMessageQueue->enqueue($flashMessage);
1141 if (!$this->storeTitle
) {
1142 $this->storeTitle
= $this->recTitle
1143 ?
htmlspecialchars($this->recTitle
)
1144 : BackendUtility
::getRecordTitle($table, FormEngineUtility
::databaseRowCompatibility($formData['databaseRow']), true);
1147 $this->elementsData
[] = [
1149 'uid' => $formData['databaseRow']['uid'],
1150 'pid' => $formData['databaseRow']['pid'],
1152 'deleteAccess' => $deleteAccess
1155 if ($command !== 'new') {
1156 BackendUtility
::lockRecords($table, $formData['databaseRow']['uid'], $table === 'tt_content' ?
$formData['databaseRow']['pid'] : 0);
1159 // Set list if only specific fields should be rendered. This will trigger
1160 // ListOfFieldsContainer instead of FullRecordContainer in OuterWrapContainer
1161 if ($this->columnsOnly
) {
1162 if (is_array($this->columnsOnly
)) {
1163 $formData['fieldListToRender'] = $this->columnsOnly
[$table];
1165 $formData['fieldListToRender'] = $this->columnsOnly
;
1169 $formData['renderType'] = 'outerWrapContainer';
1170 $formResult = $nodeFactory->create($formData)->render();
1172 $html = $formResult['html'];
1174 $formResult['html'] = '';
1175 $formResult['doSaveFieldName'] = 'doSave';
1177 // @todo: Put all the stuff into FormEngine as final "compiler" class
1178 // @todo: This is done here for now to not rewrite addCssFiles()
1179 // @todo: and printNeededJSFunctions() now
1180 $this->formResultCompiler
->mergeResult($formResult);
1182 // Seems the pid is set as hidden field (again) at end?!
1183 if ($command === 'new') {
1184 // @todo: looks ugly
1186 . '<input type="hidden"'
1187 . ' name="data[' . htmlspecialchars($table) . '][' . htmlspecialchars($formData['databaseRow']['uid']) . '][pid]"'
1188 . ' value="' . (int)$formData['databaseRow']['pid'] . '" />';
1193 } catch (AccessDeniedException
$e) {
1195 // Try to fetch error message from "recordInternals" be user object
1196 // @todo: This construct should be logged and localized and de-uglified
1197 $message = $beUser->errorMsg
;
1198 if (empty($message)) {
1199 // Create message from exception.
1200 $message = $e->getMessage() . ' ' . $e->getCode();
1202 $editForm .= htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.noEditPermission'))
1203 . '<br /><br />' . htmlspecialchars($message) . '<br /><br />';
1205 } // End of for each uid
1214 * Create the panel of buttons for submitting the form or otherwise perform operations.
1216 * @return array All available buttons as an assoc. array
1218 protected function getButtons()
1220 $lang = $this->getLanguageService();
1221 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1222 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
1223 // Render SAVE type buttons:
1224 // The action of each button is decided by its name attribute. (See doProcessData())
1225 $buttonBar = $this->moduleTemplate
->getDocHeaderComponent()->getButtonBar();
1226 if (!$this->errorC
&& !$GLOBALS['TCA'][$this->firstEl
['table']]['ctrl']['readOnly']) {
1227 $saveSplitButton = $buttonBar->makeSplitButton();
1229 $saveButton = $buttonBar->makeInputButton()
1230 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveDoc'))
1231 ->setName('_savedok')
1233 ->setForm('EditDocumentController')
1234 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon('actions-document-save', Icon
::SIZE_SMALL
));
1235 $saveSplitButton->addItem($saveButton, true);
1237 // SAVE / VIEW button:
1238 if ($this->viewId
&& !$this->noView
&& $this->getNewIconMode($this->firstEl
['table'], 'saveDocView')) {
1239 $pagesTSconfig = BackendUtility
::getPagesTSconfig($this->pageinfo
['uid']);
1240 if (isset($pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'])) {
1241 $excludeDokTypes = GeneralUtility
::intExplode(
1243 $pagesTSconfig['TCEMAIN.']['preview.']['disableButtonForDokType'],
1247 // exclude sysfolders, spacers and recycler by default
1248 $excludeDokTypes = [
1249 PageRepository
::DOKTYPE_RECYCLER
,
1250 PageRepository
::DOKTYPE_SYSFOLDER
,
1251 PageRepository
::DOKTYPE_SPACER
1254 if (!in_array((int)$this->pageinfo
['doktype'], $excludeDokTypes, true)
1255 ||
isset($pagesTSconfig['TCEMAIN.']['preview.'][$this->firstEl
['table'] . '.']['previewPageId'])
1257 $saveAndOpenButton = $buttonBar->makeInputButton()
1258 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveDocShow'))
1259 ->setName('_savedokview')
1261 ->setForm('EditDocumentController')
1262 ->setOnClick("window.open('', 'newTYPO3frontendWindow');")
1263 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1264 'actions-document-save-view',
1267 $saveSplitButton->addItem($saveAndOpenButton);
1270 // SAVE / NEW button:
1271 if (count($this->elementsData
) === 1 && $this->getNewIconMode($this->firstEl
['table'])) {
1272 $saveAndNewButton = $buttonBar->makeInputButton()
1273 ->setName('_savedoknew')
1274 ->setClasses('t3js-editform-submitButton')
1276 ->setForm('EditDocumentController')
1277 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveNewDoc'))
1278 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1279 'actions-document-save-new',
1282 $saveSplitButton->addItem($saveAndNewButton);
1285 $saveAndCloseButton = $buttonBar->makeInputButton()
1286 ->setName('_saveandclosedok')
1287 ->setClasses('t3js-editform-submitButton')
1289 ->setForm('EditDocumentController')
1290 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveCloseDoc'))
1291 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1292 'actions-document-save-close',
1295 $saveSplitButton->addItem($saveAndCloseButton);
1296 // FINISH TRANSLATION / SAVE / CLOSE
1297 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['explicitConfirmationOfTranslation']) {
1298 $saveTranslationButton = $buttonBar->makeInputButton()
1299 ->setName('_translation_savedok')
1301 ->setForm('EditDocumentController')
1302 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.translationSaveDoc'))
1303 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1304 'actions-document-save-cleartranslationcache',
1307 $saveSplitButton->addItem($saveTranslationButton);
1308 $saveAndClearTranslationButton = $buttonBar->makeInputButton()
1309 ->setName('_translation_savedokclear')
1311 ->setForm('EditDocumentController')
1312 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.translationSaveDocClear'))
1313 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1314 'actions-document-save-cleartranslationcache',
1317 $saveSplitButton->addItem($saveAndClearTranslationButton);
1319 $buttonBar->addButton($saveSplitButton, ButtonBar
::BUTTON_POSITION_LEFT
, 2);
1322 $closeButton = $buttonBar->makeLinkButton()
1324 ->setClasses('t3js-editform-close')
1325 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.closeDoc'))
1326 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1330 $buttonBar->addButton($closeButton);
1331 // DUPLICATE button:
1332 $record = BackendUtility
::getRecord($this->firstEl
['table'], $this->firstEl
['uid']);
1333 $l18nParent = $record['l18n_parent'] ??
0;
1334 $sysLanguageUid = $record['sys_language_uid'] ??
0;
1335 $showDuplicateButton = false;
1336 if ($this->firstEl
['cmd'] !== 'new' && MathUtility
::canBeInterpretedAsInteger($this->firstEl
['uid'])) {
1337 // Special case: pages
1338 if ($this->firstEl
['table'] === 'pages') {
1339 // show button only, if record is in default language
1340 $showDuplicateButton = (int)$sysLanguageUid === 0;
1343 if ((int)$sysLanguageUid === 0) {
1344 // show button, if record is in default language
1345 $showDuplicateButton = true;
1347 // show button, if record is NOT in default language AND has no parent
1348 $showDuplicateButton = (int)$l18nParent === 0;
1352 if ($showDuplicateButton) {
1353 $duplicateButton = $buttonBar->makeLinkButton()
1355 ->setClasses('t3js-editform-duplicate')
1356 ->setShowLabelText(true)
1357 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.duplicateDoc'))
1358 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1359 'actions-document-duplicates-select',
1362 $buttonBar->addButton($duplicateButton, ButtonBar
::BUTTON_POSITION_LEFT
, 3);
1364 // DELETE + UNDO buttons:
1366 && !$GLOBALS['TCA'][$this->firstEl
['table']]['ctrl']['readOnly']
1367 && count($this->elementsData
) === 1
1369 if ($this->firstEl
['cmd'] !== 'new' && MathUtility
::canBeInterpretedAsInteger($this->firstEl
['uid'])) {
1371 if ($this->firstEl
['deleteAccess']
1372 && !$GLOBALS['TCA'][$this->firstEl
['table']]['ctrl']['readOnly']
1373 && !$this->getDisableDelete()
1375 $returnUrl = $this->retUrl
;
1376 if ($this->firstEl
['table'] === 'pages') {
1377 parse_str((string)parse_url($returnUrl, PHP_URL_QUERY
), $queryParams);
1378 if (isset($queryParams['route'])
1379 && isset($queryParams['id'])
1380 && (string)$this->firstEl
['uid'] === (string)$queryParams['id']
1382 // TODO: Use the page's pid instead of 0, this requires a clean API to manipulate the page
1383 // tree from the outside to be able to mark the pid as active
1384 $returnUrl = (string)$uriBuilder->buildUriFromRoutePath($queryParams['route'], ['id' => 0]);
1387 $deleteButton = $buttonBar->makeLinkButton()
1389 ->setClasses('t3js-editform-delete-record')
1390 ->setTitle($lang->getLL('deleteItem'))
1391 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1392 'actions-edit-delete',
1395 ->setDataAttributes([
1396 'return-url' => $returnUrl,
1397 'uid' => $this->firstEl
['uid'],
1398 'table' => $this->firstEl
['table']
1400 $buttonBar->addButton($deleteButton, ButtonBar
::BUTTON_POSITION_LEFT
, 4);
1403 if ($this->getNewIconMode($this->firstEl
['table'], 'showHistory')) {
1404 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
1405 ->getQueryBuilderForTable('sys_history');
1406 $undoButtonR = $queryBuilder->select('tstamp')
1407 ->from('sys_history')
1409 $queryBuilder->expr()->eq(
1411 $queryBuilder->createNamedParameter($this->firstEl
['table'], \PDO
::PARAM_STR
)
1413 $queryBuilder->expr()->eq(
1415 $queryBuilder->createNamedParameter($this->firstEl
['uid'], \PDO
::PARAM_INT
)
1418 ->orderBy('tstamp', 'DESC')
1422 if ($undoButtonR !== false) {
1423 $aOnClick = 'window.location.href=' .
1424 GeneralUtility
::quoteJSvalue(
1425 (string)$uriBuilder->buildUriFromRoute(
1428 'element' => $this->firstEl
['table'] . ':' . $this->firstEl
['uid'],
1429 'revert' => 'ALL_FIELDS',
1430 'returnUrl' => $this->R_URI
,
1433 ) . '; return false;';
1435 $undoButton = $buttonBar->makeLinkButton()
1437 ->setOnClick($aOnClick)
1440 $lang->getLL('undoLastChange'),
1441 BackendUtility
::calcAge(
1442 ($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp']),
1443 $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears')
1447 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1448 'actions-document-history-open',
1451 $buttonBar->addButton($undoButton, ButtonBar
::BUTTON_POSITION_LEFT
, 3);
1454 if ($this->getNewIconMode($this->firstEl
['table'], 'showHistory')) {
1455 $aOnClick = 'window.location.href=' .
1456 GeneralUtility
::quoteJSvalue(
1457 (string)$uriBuilder->buildUriFromRoute(
1460 'element' => $this->firstEl
['table'] . ':' . $this->firstEl
['uid'],
1461 'returnUrl' => $this->R_URI
,
1464 ) . '; return false;';
1466 $historyButton = $buttonBar->makeLinkButton()
1468 ->setOnClick($aOnClick)
1469 ->setTitle('Open history of this record')
1470 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1471 'actions-document-history-open',
1474 $buttonBar->addButton($historyButton, ButtonBar
::BUTTON_POSITION_LEFT
, 3);
1476 // If only SOME fields are shown in the form, this will link the user to the FULL form:
1477 if ($this->columnsOnly
) {
1478 $columnsOnlyButton = $buttonBar->makeLinkButton()
1479 ->setHref($this->R_URI
. '&columnsOnly=')
1480 ->setTitle($lang->getLL('editWholeRecord'))
1481 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon(
1485 $buttonBar->addButton($columnsOnlyButton, ButtonBar
::BUTTON_POSITION_LEFT
, 3);
1489 $cshButton = $buttonBar->makeHelpButton()->setModuleName('xMOD_csh_corebe')->setFieldName('TCEforms');
1490 $buttonBar->addButton($cshButton);
1491 $this->shortCutLink();
1492 $this->openInNewWindowLink();
1496 * Put together the various elements (buttons, selectors, form) into a table
1498 * @param string $editForm HTML form.
1499 * @return string Composite HTML
1501 public function compileForm($editForm)
1504 <!-- EDITING FORM -->
1506 action="' . htmlspecialchars($this->R_URI
) . '"
1508 enctype="multipart/form-data"
1510 id="EditDocumentController"
1511 onsubmit="TBE_EDITOR.checkAndDoSubmit(1); return false;">
1514 <input type="hidden" name="returnUrl" value="' . htmlspecialchars($this->retUrl
) . '" />
1515 <input type="hidden" name="viewUrl" value="' . htmlspecialchars($this->viewUrl
) . '" />';
1516 if ($this->returnNewPageId
) {
1517 $formContent .= '<input type="hidden" name="returnNewPageId" value="1" />';
1519 $formContent .= '<input type="hidden" name="popViewId" value="' . htmlspecialchars($this->viewId
) . '" />';
1520 if ($this->viewId_addParams
) {
1521 $formContent .= '<input type="hidden" name="popViewId_addParams" value="' . htmlspecialchars($this->viewId_addParams
) . '" />';
1524 <input type="hidden" name="closeDoc" value="0" />
1525 <input type="hidden" name="doSave" value="0" />
1526 <input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
1527 <input type="hidden" name="_scrollPosition" value="" />';
1528 return $formContent;
1532 * Create shortcut icon
1534 public function shortCutLink()
1536 if ($this->returnUrl
!== $this->getCloseUrl()) {
1537 $shortCutButton = $this->moduleTemplate
->getDocHeaderComponent()->getButtonBar()->makeShortcutButton();
1538 $shortCutButton->setModuleName($this->MCONF
['name'])
1547 $this->moduleTemplate
->getDocHeaderComponent()->getButtonBar()->addButton($shortCutButton);
1552 * Creates open-in-window link
1554 public function openInNewWindowLink()
1556 $closeUrl = $this->getCloseUrl();
1557 if ($this->returnUrl
!== $closeUrl) {
1558 $aOnClick = 'vHWin=window.open(' . GeneralUtility
::quoteJSvalue(GeneralUtility
::linkThisScript(
1559 ['returnUrl' => $closeUrl]
1562 . GeneralUtility
::quoteJSvalue(md5($this->R_URI
))
1563 . ',\'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
1564 $openInNewWindowButton = $this->moduleTemplate
->getDocHeaderComponent()->getButtonBar()
1567 ->setTitle($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.openInNewWindow'))
1568 ->setIcon($this->moduleTemplate
->getIconFactory()->getIcon('actions-window-open', Icon
::SIZE_SMALL
))
1569 ->setOnClick($aOnClick);
1570 $this->moduleTemplate
->getDocHeaderComponent()->getButtonBar()->addButton(
1571 $openInNewWindowButton,
1572 ButtonBar
::BUTTON_POSITION_RIGHT
1578 * Returns if delete for the current table is disabled by configuration.
1579 * For sys_file_metadata in default language delete is always disabled.
1583 protected function getDisableDelete(): bool
1585 $disableDelete = false;
1586 if ($this->firstEl
['table'] === 'sys_file_metadata') {
1587 $row = BackendUtility
::getRecord('sys_file_metadata', $this->firstEl
['uid'], 'sys_language_uid');
1588 $languageUid = $row['sys_language_uid'];
1589 if ($languageUid === 0) {
1590 $disableDelete = true;
1593 $disableDelete = (bool)$this->getNewIconMode($this->firstEl
['table'], 'disableDelete');
1595 return $disableDelete;
1599 * Returns the URL (usually for the "returnUrl") which closes the current window.
1600 * Used when editing a record in a popup.
1604 protected function getCloseUrl(): string
1606 $closeUrl = GeneralUtility
::getFileAbsFileName('EXT:backend/Resources/Public/Html/Close.html');
1607 return PathUtility
::getAbsoluteWebPath($closeUrl);
1610 /***************************
1612 * Localization stuff
1614 ***************************/
1616 * Make selector box for creating new translation for a record or switching to edit the record in an existing
1618 * Displays only languages which are available for the current page.
1620 * @param string $table Table name
1621 * @param int $uid Uid for which to create a new language
1622 * @param int $pid Pid of the record
1624 public function languageSwitch($table, $uid, $pid = null)
1626 $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
1627 $transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
1628 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1629 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
1631 // Table editable and activated for languages?
1632 if ($this->getBackendUser()->check('tables_modify', $table)
1634 && $transOrigPointerField
1636 if (is_null($pid)) {
1637 $row = BackendUtility
::getRecord($table, $uid, 'pid');
1640 // Get all available languages for the page
1641 // If editing a page, the translations of the current UID need to be fetched
1642 if ($table === 'pages') {
1643 $row = BackendUtility
::getRecord($table, $uid, $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']);
1644 // Ensure the check is always done against the default language page
1645 $langRows = $this->getLanguages($row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] ?
: $uid);
1647 $langRows = $this->getLanguages($pid);
1649 // Page available in other languages than default language?
1650 if (is_array($langRows) && count($langRows) > 1) {
1652 $fetchFields = 'uid,' . $languageField . ',' . $transOrigPointerField;
1653 // Get record in current language
1654 $rowCurrent = BackendUtility
::getLiveVersionOfRecord($table, $uid, $fetchFields);
1655 if (!is_array($rowCurrent)) {
1656 $rowCurrent = BackendUtility
::getRecord($table, $uid, $fetchFields);
1658 $currentLanguage = (int)$rowCurrent[$languageField];
1659 // Disabled for records with [all] language!
1660 if ($currentLanguage > -1) {
1661 // Get record in default language if needed
1662 if ($currentLanguage && $rowCurrent[$transOrigPointerField]) {
1663 $rowsByLang[0] = BackendUtility
::getLiveVersionOfRecord(
1665 $rowCurrent[$transOrigPointerField],
1668 if (!is_array($rowsByLang[0])) {
1669 $rowsByLang[0] = BackendUtility
::getRecord(
1671 $rowCurrent[$transOrigPointerField],
1676 $rowsByLang[$rowCurrent[$languageField]] = $rowCurrent;
1678 if ($rowCurrent[$transOrigPointerField] ||
$currentLanguage === 0) {
1679 // Get record in other languages to see what's already available
1681 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
1682 ->getQueryBuilderForTable($table);
1684 $queryBuilder->getRestrictions()
1686 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class))
1687 ->add(GeneralUtility
::makeInstance(BackendWorkspaceRestriction
::class));
1689 $result = $queryBuilder->select(...GeneralUtility
::trimExplode(',', $fetchFields, true))
1692 $queryBuilder->expr()->eq(
1694 $queryBuilder->createNamedParameter($pid, \PDO
::PARAM_INT
)
1696 $queryBuilder->expr()->gt(
1698 $queryBuilder->createNamedParameter(0, \PDO
::PARAM_INT
)
1700 $queryBuilder->expr()->eq(
1701 $transOrigPointerField,
1702 $queryBuilder->createNamedParameter($rowsByLang[0]['uid'], \PDO
::PARAM_INT
)
1707 while ($row = $result->fetch()) {
1708 $rowsByLang[$row[$languageField]] = $row;
1711 $languageMenu = $this->moduleTemplate
->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
1712 $languageMenu->setIdentifier('_langSelector');
1713 foreach ($langRows as $lang) {
1714 if ($this->getBackendUser()->checkLanguageAccess($lang['uid'])) {
1715 $newTranslation = isset($rowsByLang[$lang['uid']]) ?
'' : ' [' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.new')) . ']';
1716 // Create url for creating a localized record
1718 if ($newTranslation) {
1719 $redirectUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', [
1720 'justLocalized' => $table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid'],
1721 'returnUrl' => $this->retUrl
1724 if (array_key_exists(0, $rowsByLang)) {
1725 $href = BackendUtility
::getLinkToDataHandlerAction(
1726 '&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'],
1733 $href = (string)$uriBuilder->buildUriFromRoute('record_edit', [
1734 'edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']' => 'edit',
1735 'returnUrl' => $this->retUrl
1739 $menuItem = $languageMenu->makeMenuItem()
1740 ->setTitle($lang['title'] . $newTranslation)
1742 if ((int)$lang['uid'] === $currentLanguage) {
1743 $menuItem->setActive(true);
1745 $languageMenu->addMenuItem($menuItem);
1749 $this->moduleTemplate
->getDocHeaderComponent()->getMenuRegistry()->addMenu($languageMenu);
1756 * Redirects to FormEngine with new parameters to edit a just created localized record
1758 * @param string $justLocalized String passed by GET &justLocalized=
1760 public function localizationRedirect($justLocalized)
1762 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1763 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
1765 list($table, $origUid, $language) = explode(':', $justLocalized);
1766 if ($GLOBALS['TCA'][$table]
1767 && $GLOBALS['TCA'][$table]['ctrl']['languageField']
1768 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
1770 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
1771 ->getQueryBuilderForTable($table);
1772 $queryBuilder->getRestrictions()
1774 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class))
1775 ->add(GeneralUtility
::makeInstance(BackendWorkspaceRestriction
::class));
1777 $localizedRecord = $queryBuilder->select('uid')
1780 $queryBuilder->expr()->eq(
1781 $GLOBALS['TCA'][$table]['ctrl']['languageField'],
1782 $queryBuilder->createNamedParameter($language, \PDO
::PARAM_INT
)
1784 $queryBuilder->expr()->eq(
1785 $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'],
1786 $queryBuilder->createNamedParameter($origUid, \PDO
::PARAM_INT
)
1792 if (is_array($localizedRecord)) {
1793 // Create parameters and finally run the classic page module for creating a new page translation
1794 $location = (string)$uriBuilder->buildUriFromRoute('record_edit', [
1795 'edit[' . $table . '][' . $localizedRecord['uid'] . ']' => 'edit',
1796 'returnUrl' => GeneralUtility
::sanitizeLocalUrl(GeneralUtility
::_GP('returnUrl'))
1798 HttpUtility
::redirect($location);
1804 * Returns sys_language records available for record translations on given page.
1806 * @param int $id Page id: If zero, the query will select all sys_language records from root level which are NOT
1807 * hidden. If set to another value, the query will select all sys_language records that has a
1808 * translation record on that page (and is not hidden, unless you are admin user)
1809 * @return array Language records including faked record for default language
1811 public function getLanguages($id)
1813 $modSharedTSconfig = BackendUtility
::getModTSconfig($id, 'mod.SHARED');
1814 // Fallback non sprite-configuration
1815 if (preg_match('/\\.gif$/', $modSharedTSconfig['properties']['defaultLanguageFlag'])) {
1816 $modSharedTSconfig['properties']['defaultLanguageFlag'] = str_replace(
1819 $modSharedTSconfig['properties']['defaultLanguageFlag']
1827 'title' => $modSharedTSconfig['properties']['defaultLanguageLabel'] !== ''
1828 ?
$modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage') . ')'
1829 : $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage'),
1830 'flag' => $modSharedTSconfig['properties']['defaultLanguageFlag']
1834 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
1835 ->getQueryBuilderForTable('sys_language');
1837 $queryBuilder->select('s.uid', 's.pid', 's.hidden', 's.title', 's.flag')
1838 ->from('sys_language', 's')
1839 ->groupBy('s.uid', 's.pid', 's.hidden', 's.title', 's.flag', 's.sorting')
1840 ->orderBy('s.sorting');
1843 $queryBuilder->getRestrictions()
1845 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class))
1846 ->add(GeneralUtility
::makeInstance(BackendWorkspaceRestriction
::class));
1848 if (!$this->getBackendUser()->isAdmin()) {
1849 $queryBuilder->getRestrictions()->add(GeneralUtility
::makeInstance(HiddenRestriction
::class));
1852 // Add join with pages translations to only show active languages
1853 $queryBuilder->from('pages', 'o')
1855 $queryBuilder->expr()->eq('o.' . $GLOBALS['TCA']['pages']['ctrl']['languageField'], $queryBuilder->quoteIdentifier('s.uid')),
1856 $queryBuilder->expr()->eq('o.' . $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'], $queryBuilder->createNamedParameter($id, \PDO
::PARAM_INT
))
1860 $result = $queryBuilder->execute();
1861 while ($row = $result->fetch()) {
1862 $languages[$row['uid']] = $row;
1868 /***************************
1872 ***************************/
1874 * Fix $this->editconf if versioning applies to any of the records
1876 * @param array|bool $mapArray Mapping between old and new ids if auto-versioning has been performed.
1878 public function fixWSversioningInEditConf($mapArray = false)
1880 // Traverse the editConf array
1881 if (is_array($this->editconf
)) {
1883 foreach ($this->editconf
as $table => $conf) {
1884 if (is_array($conf) && $GLOBALS['TCA'][$table]) {
1885 // Traverse the keys/comments of each table (keys can be a commalist of uids)
1887 foreach ($conf as $cKey => $cmd) {
1888 if ($cmd === 'edit') {
1889 // Traverse the ids:
1890 $ids = GeneralUtility
::trimExplode(',', $cKey, true);
1891 foreach ($ids as $idKey => $theUid) {
1892 if (is_array($mapArray)) {
1893 if ($mapArray[$table][$theUid]) {
1894 $ids[$idKey] = $mapArray[$table][$theUid];
1897 // Default, look for versions in workspace for record:
1898 $calcPRec = $this->getRecordForEdit($table, $theUid);
1899 if (is_array($calcPRec)) {
1900 // Setting UID again if it had changed, eg. due to workspace versioning.
1901 $ids[$idKey] = $calcPRec['uid'];
1905 // Add the possibly manipulated IDs to the new-build newConf array:
1906 $newConf[implode(',', $ids)] = $cmd;
1908 $newConf[$cKey] = $cmd;
1911 // Store the new conf array:
1912 $this->editconf
[$table] = $newConf;
1919 * Get record for editing.
1921 * @param string $table Table name
1922 * @param int $theUid Record UID
1923 * @return array|false Returns record to edit, FALSE if none
1925 public function getRecordForEdit($table, $theUid)
1927 // Fetch requested record:
1928 $reqRecord = BackendUtility
::getRecord($table, $theUid, 'uid,pid');
1929 if (is_array($reqRecord)) {
1930 // If workspace is OFFLINE:
1931 if ($this->getBackendUser()->workspace
!= 0) {
1932 // Check for versioning support of the table:
1933 if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
1934 // If the record is already a version of "something" pass it by.
1935 if ($reqRecord['pid'] == -1) {
1936 // (If it turns out not to be a version of the current workspace there will be trouble, but
1937 // that is handled inside DataHandler then and in the interface it would clearly be an error of
1938 // links if the user accesses such a scenario)
1941 // The input record was online and an offline version must be found or made:
1942 // Look for version of this workspace:
1943 $versionRec = BackendUtility
::getWorkspaceVersionOfRecord(
1944 $this->getBackendUser()->workspace
,
1949 return is_array($versionRec) ?
$versionRec : $reqRecord;
1951 // This means that editing cannot occur on this record because it was not supporting versioning
1952 // which is required inside an offline workspace.
1955 // In ONLINE workspace, just return the originally requested record:
1958 // Return FALSE because the table/uid was not found anyway.
1963 * Populates the variables $this->storeArray, $this->storeUrl, $this->storeUrlMd5
1967 public function compileStoreDat()
1969 $this->storeArray
= GeneralUtility
::compileSelectedGetVarsFromArray(
1970 'edit,defVals,overrideVals,columnsOnly,noView,workspace',
1971 $this->R_URL_getvars
1973 $this->storeUrl
= GeneralUtility
::implodeArrayForUrl('', $this->storeArray
);
1974 $this->storeUrlMd5
= md5($this->storeUrl
);
1978 * Function used to look for configuration of buttons in the form: Fx. disabling buttons or showing them at various
1981 * @param string $table The table for which the configuration may be specific
1982 * @param string $key The option for look for. Default is checking if the saveDocNew button should be displayed.
1983 * @return string Return value fetched from USER TSconfig
1985 public function getNewIconMode($table, $key = 'saveDocNew')
1987 $TSconfig = $this->getBackendUser()->getTSConfig('options.' . $key);
1988 $output = trim($TSconfig['properties'][$table] ??
$TSconfig['value']);
1993 * Handling the closing of a document
1994 * The argument $mode can be one of this values:
1995 * - 0/1 will redirect to $this->retUrl [self::DOCUMENT_CLOSE_MODE_DEFAULT || self::DOCUMENT_CLOSE_MODE_REDIRECT]
1996 * - 3 will clear the docHandler (thus closing all documents) [self::DOCUMENT_CLOSE_MODE_CLEAR_ALL]
1997 * - 4 will do no redirect [self::DOCUMENT_CLOSE_MODE_NO_REDIRECT]
1998 * - other values will call setDocument with ->retUrl
2000 * @param int $mode the close mode: one of self::DOCUMENT_CLOSE_MODE_*
2002 public function closeDocument($mode = self
::DOCUMENT_CLOSE_MODE_DEFAULT
)
2005 // If current document is found in docHandler,
2006 // then unset it, possibly unset it ALL and finally, write it to the session data
2007 if (isset($this->docHandler
[$this->storeUrlMd5
])) {
2008 // add the closing document to the recent documents
2009 $recentDocs = $this->getBackendUser()->getModuleData('opendocs::recent');
2010 if (!is_array($recentDocs)) {
2013 $closedDoc = $this->docHandler
[$this->storeUrlMd5
];
2014 $recentDocs = array_merge([$this->storeUrlMd5
=> $closedDoc], $recentDocs);
2015 if (count($recentDocs) > 8) {
2016 $recentDocs = array_slice($recentDocs, 0, 8);
2018 // remove it from the list of the open documents
2019 unset($this->docHandler
[$this->storeUrlMd5
]);
2020 if ($mode === self
::DOCUMENT_CLOSE_MODE_CLEAR_ALL
) {
2021 $recentDocs = array_merge($this->docHandler
, $recentDocs);
2022 $this->docHandler
= [];
2024 $this->getBackendUser()->pushModuleData('opendocs::recent', $recentDocs);
2025 $this->getBackendUser()->pushModuleData('FormEngine', [$this->docHandler
, $this->docDat
[1]]);
2026 BackendUtility
::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler
));
2028 if ($mode !== self
::DOCUMENT_CLOSE_MODE_NO_REDIRECT
) {
2029 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
2030 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
2031 // If ->returnEditConf is set, then add the current content of editconf to the ->retUrl variable: (used by
2032 // other scripts, like wizard_add, to know which records was created or so...)
2033 if ($this->returnEditConf
&& $this->retUrl
!= (string)$uriBuilder->buildUriFromRoute('dummy')) {
2034 $this->retUrl
.= '&returnEditConf=' . rawurlencode(json_encode($this->editconf
));
2037 // If mode is NOT set (means 0) OR set to 1, then make a header location redirect to $this->retUrl
2038 if ($mode === self
::DOCUMENT_CLOSE_MODE_DEFAULT ||
$mode === self
::DOCUMENT_CLOSE_MODE_REDIRECT
) {
2039 HttpUtility
::redirect($this->retUrl
);
2041 $this->setDocument('', $this->retUrl
);
2047 * Redirects to the document pointed to by $currentDocFromHandlerMD5 OR $retUrl (depending on some internal
2049 * Most likely you will get a header-location redirect from this function.
2051 * @param string $currentDocFromHandlerMD5 Pointer to the document in the docHandler array
2052 * @param string $retUrl Alternative/Default retUrl
2054 public function setDocument($currentDocFromHandlerMD5 = '', $retUrl = '')
2056 if ($retUrl === '') {
2059 if (!$this->modTSconfig
['properties']['disableDocSelector']
2060 && is_array($this->docHandler
)
2061 && !empty($this->docHandler
)
2063 if (isset($this->docHandler
[$currentDocFromHandlerMD5])) {
2064 $setupArr = $this->docHandler
[$currentDocFromHandlerMD5];
2066 $setupArr = reset($this->docHandler
);
2069 $sParts = parse_url(GeneralUtility
::getIndpEnv('REQUEST_URI'));
2070 $retUrl = $sParts['path'] . '?' . $setupArr[2] . '&returnUrl=' . rawurlencode($retUrl);
2073 HttpUtility
::redirect($retUrl);
2077 * Injects the request object for the current request or subrequest
2079 * @param ServerRequestInterface $request the current request
2080 * @return ResponseInterface the response with the content
2082 public function mainAction(ServerRequestInterface
$request): ResponseInterface
2084 BackendUtility
::lockRecords();
2086 // Preprocessing, storing data if submitted to
2089 // Checks, if a save button has been clicked (or the doSave variable is sent)
2090 if ($this->doProcessData()) {
2091 $this->processData();
2097 return new HtmlResponse($this->moduleTemplate
->renderContent());
2101 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
2103 protected function getBackendUser()
2105 return $GLOBALS['BE_USER'];
2109 * Returns LanguageService
2111 * @return \TYPO3\CMS\Core\Localization\LanguageService
2113 protected function getLanguageService()
2115 return $GLOBALS['LANG'];