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\Exception\DatabaseRecordException
;
21 use TYPO3\CMS\Backend\Form\FormDataCompiler
;
22 use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord
;
23 use TYPO3\CMS\Backend\Form\FormResultCompiler
;
24 use TYPO3\CMS\Backend\Form\NodeFactory
;
25 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility
;
26 use TYPO3\CMS\Backend\Template\Components\ButtonBar
;
27 use TYPO3\CMS\Backend\Template\ModuleTemplate
;
28 use TYPO3\CMS\Backend\Utility\BackendUtility
;
29 use TYPO3\CMS\Core\Database\ConnectionPool
;
30 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction
;
31 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
;
32 use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction
;
33 use TYPO3\CMS\Core\DataHandling\DataHandler
;
34 use TYPO3\CMS\Core\Http\HtmlResponse
;
35 use TYPO3\CMS\Core\Imaging\Icon
;
36 use TYPO3\CMS\Core\Messaging\FlashMessage
;
37 use TYPO3\CMS\Core\Messaging\FlashMessageQueue
;
38 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
39 use TYPO3\CMS\Core\Page\PageRenderer
;
40 use TYPO3\CMS\Core\Type\Bitmask\Permission
;
41 use TYPO3\CMS\Core\Utility\GeneralUtility
;
42 use TYPO3\CMS\Core\Utility\HttpUtility
;
43 use TYPO3\CMS\Core\Utility\MathUtility
;
44 use TYPO3\CMS\Core\Utility\PathUtility
;
45 use TYPO3\CMS\Extbase\SignalSlot\Dispatcher
;
46 use TYPO3\CMS\Frontend\Page\CacheHashCalculator
;
47 use TYPO3\CMS\Frontend\Page\PageRepository
;
50 * Script Class: Drawing the editing form for editing records in TYPO3.
51 * Notice: It does NOT use tce_db.php to submit data to, rather it handles submissions itself
53 class EditDocumentController
55 const DOCUMENT_CLOSE_MODE_DEFAULT
= 0;
56 const DOCUMENT_CLOSE_MODE_REDIRECT
= 1; // works like DOCUMENT_CLOSE_MODE_DEFAULT
57 const DOCUMENT_CLOSE_MODE_CLEAR_ALL
= 3;
58 const DOCUMENT_CLOSE_MODE_NO_REDIRECT
= 4;
61 * GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg.
62 * "&edit[pages][123]=edit". See \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick(). Value can be seen
63 * modified internally (converting NEW keyword to id, workspace/versioning etc).
70 * Commalist of fieldnames to edit. The point is IF you specify this list, only those
71 * fields will be rendered in the form. Otherwise all (available) fields in the record
72 * is shown according to the types configuration in $GLOBALS['TCA']
79 * Default values for fields (array with tablenames, fields etc. as keys).
80 * Can be seen modified internally.
87 * Array of values to force being set (as hidden fields). Will be set as $this->defVals
88 * IF defVals does not exist.
95 * If set, this value will be set in $this->retUrl (which is used quite many places
96 * as the return URL). If not set, "dummy.php" will be set in $this->retUrl
103 * Close-document command. Not really sure of all options...
110 * Quite simply, if this variable is set, then the processing of incoming data will be performed
111 * as if a save-button is pressed. Used in the forms as a hidden field which can be set through
112 * JavaScript if the form is somehow submitted by JavaScript).
119 * The data array from which the data comes...
143 * Redirect (not used???)
150 * Boolean: If set, then the GET var "&id=" will be added to the
151 * retUrl string so that the NEW id of something is returned to the script calling the form.
155 public $returnNewPageId;
165 * ID for displaying the page in the frontend (used for SAVE/VIEW operations)
172 * Additional GET vars for the link, eg. "&L=xxx"
176 public $popViewId_addParams;
179 * Alternative URL for viewing the frontend pages.
186 * Alternative title for the document handler.
193 * If set, then no SAVE/VIEW button is printed
202 public $perms_clause;
205 * If set, the $this->editconf array is returned to the calling script
206 * (used by wizard_add.php for instance)
210 public $returnEditConf;
213 * Workspace used for the editing action.
217 protected $workspace;
220 * document template object
222 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
227 * a static HTML template, usually in templates/alt_doc.html
234 * Content accumulation
241 * Return URL script, processed. This contains the script (if any) that we should
242 * RETURN TO from the FormEngine script IF we press the close button. Thus this
243 * variable is normally passed along from the calling script so we can properly return if needed.
250 * Contains the parts of the REQUEST_URI (current url). By parts we mean the result of resolving
251 * REQUEST_URI (current url) by the parse_url() function. The result is an array where eg. "path"
252 * is the script path and "query" is the parameters...
259 * Contains the current GET vars array; More specifically this array is the foundation for creating
260 * the R_URI internal var (which becomes the "url of this script" to which we submit the forms etc.)
264 public $R_URL_getvars;
267 * Set to the URL of this script including variables which is needed to re-display the form. See main()
284 * Is loaded with the "title" of the currently "open document" - this is used in the
285 * Document Selector box. (see makeDocSel())
289 public $storeTitle = '';
292 * Contains an array with key/value pairs of GET parameters needed to reach the
293 * current document displayed - used in the Document Selector box. (see compileStoreDat())
300 * Contains storeArray, but imploded into a GET parameter string (see compileStoreDat())
307 * Hashed value of storeURL (see compileStoreDat())
314 * Module session data
321 * An array of the "open documents" - keys are md5 hashes (see $storeUrlMd5) identifying
322 * the various documents on the GET parameter list needed to open it. The values are
323 * arrays with 0,1,2 keys with information about the document (see compileStoreDat()).
324 * The docHandler variable is stored in the $docDat session data, key "0".
331 * Array of the elements to create edit forms for.
335 public $elementsData;
338 * Pointer to the first element in $elementsData
345 * Counter, used to count the number of errors (when users do not have edit permissions)
352 * Counter, used to count the number of new record forms displayed
359 * Is set to the pid value of the last shown record - thus indicating which page to
360 * show when clicking the SAVE/VIEW button
367 * Is set to additional parameters (like "&L=xxx") if the record supports it.
371 public $viewId_addParams;
374 * Module TSconfig, loaded from main() based on the page id value of viewId
381 * @var FormResultCompiler
383 protected $formResultCompiler;
386 * Used internally to disable the storage of the document reference (eg. new records)
390 public $dontStoreDocumentRef = 0;
393 * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
395 protected $signalSlotDispatcher;
398 * Stores information needed to preview the currently saved record
402 protected $previewData = [];
405 * ModuleTemplate object
407 * @var ModuleTemplate
409 protected $moduleTemplate;
414 public function __construct()
416 $this->moduleTemplate
= GeneralUtility
::makeInstance(ModuleTemplate
::class);
417 $this->moduleTemplate
->setUiBlock(true);
418 $GLOBALS['SOBE'] = $this;
419 $this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf');
423 * Get the SignalSlot dispatcher
425 * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
427 protected function getSignalSlotDispatcher()
429 if (!isset($this->signalSlotDispatcher
)) {
430 $this->signalSlotDispatcher
= GeneralUtility
::makeInstance(Dispatcher
::class);
432 return $this->signalSlotDispatcher
;
436 * Emits a signal after a function was executed
438 * @param string $signalName
440 protected function emitFunctionAfterSignal($signalName)
442 $this->getSignalSlotDispatcher()->dispatch(__CLASS__
, $signalName . 'After', [$this]);
446 * First initialization.
448 public function preInit()
450 if (GeneralUtility
::_GP('justLocalized')) {
451 $this->localizationRedirect(GeneralUtility
::_GP('justLocalized'));
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
= (int)GeneralUtility
::_GP('closeDoc');
460 $this->doSave
= (bool)GeneralUtility
::_GP('doSave');
461 $this->returnEditConf
= GeneralUtility
::_GP('returnEditConf');
462 $this->workspace
= GeneralUtility
::_GP('workspace');
463 $this->uc
= GeneralUtility
::_GP('uc');
464 // Setting override values as default if defVals does not exist.
465 if (!is_array($this->defVals
) && is_array($this->overrideVals
)) {
466 $this->defVals
= $this->overrideVals
;
468 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
469 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
470 // Setting return URL
471 $this->retUrl
= $this->returnUrl ?
: (string)$uriBuilder->buildUriFromRoute('dummy');
472 // Fix $this->editconf if versioning applies to any of the records
473 $this->fixWSversioningInEditConf();
474 // Make R_URL (request url) based on input GETvars:
475 $this->R_URL_parts
= parse_url(GeneralUtility
::getIndpEnv('REQUEST_URI'));
476 $this->R_URL_getvars
= GeneralUtility
::_GET();
477 $this->R_URL_getvars
['edit'] = $this->editconf
;
478 // MAKE url for storing
479 $this->compileStoreDat();
480 // Get session data for the module:
481 $this->docDat
= $this->getBackendUser()->getModuleData('FormEngine', 'ses');
482 $this->docHandler
= $this->docDat
[0];
483 // If a request for closing the document has been sent, act accordingly:
484 if ((int)$this->closeDoc
> self
::DOCUMENT_CLOSE_MODE_DEFAULT
) {
485 $this->closeDocument($this->closeDoc
);
487 // If NO vars are sent to the script, try to read first document:
488 // Added !is_array($this->editconf) because editConf must not be set either.
489 // Anyways I can't figure out when this situation here will apply...
490 if (is_array($this->R_URL_getvars
) && count($this->R_URL_getvars
) < 2 && !is_array($this->editconf
)) {
491 $this->setDocument($this->docDat
[1]);
494 // Sets a temporary workspace, this request is based on
495 if ($this->workspace
!== null) {
496 $this->getBackendUser()->setTemporaryWorkspace($this->workspace
);
499 $this->emitFunctionAfterSignal(__FUNCTION__
);
503 * Detects, if a save command has been triggered.
505 * @return bool TRUE, then save the document (data submitted)
507 public function doProcessData()
510 ||
isset($_POST['_savedok'])
511 ||
isset($_POST['_saveandclosedok'])
512 ||
isset($_POST['_savedokview'])
513 ||
isset($_POST['_savedoknew'])
514 ||
isset($_POST['_duplicatedoc'])
515 ||
isset($_POST['_translation_savedok'])
516 ||
isset($_POST['_translation_savedokclear']);
521 * Do processing of data, submitting it to DataHandler.
523 public function processData()
525 $beUser = $this->getBackendUser();
526 // GPvars specifically for processing:
527 $control = GeneralUtility
::_GP('control');
528 $this->data
= GeneralUtility
::_GP('data');
529 $this->cmd
= GeneralUtility
::_GP('cmd');
530 $this->mirror
= GeneralUtility
::_GP('mirror');
531 $this->cacheCmd
= GeneralUtility
::_GP('cacheCmd');
532 $this->redirect
= GeneralUtility
::_GP('redirect');
533 $this->returnNewPageId
= GeneralUtility
::_GP('returnNewPageId');
534 // See tce_db.php for relevate options here:
535 // Only options related to $this->data submission are included here.
536 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
537 $tce = GeneralUtility
::makeInstance(DataHandler
::class);
539 if (!empty($control)) {
540 $tce->setControl($control);
542 if (isset($_POST['_translation_savedok'])) {
543 $tce->updateModeL10NdiffData
= 'FORCE_FFUPD';
545 if (isset($_POST['_translation_savedokclear'])) {
546 $tce->updateModeL10NdiffData
= 'FORCE_FFUPD';
547 $tce->updateModeL10NdiffDataClear
= true;
549 // Setting default values specific for the user:
550 $TCAdefaultOverride = $beUser->getTSConfigProp('TCAdefaults');
551 if (is_array($TCAdefaultOverride)) {
552 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
554 // Setting internal vars:
555 if ($beUser->uc
['neverHideAtCopy']) {
556 $tce->neverHideAtCopy
= 1;
558 // Loading DataHandler with data:
559 $tce->start($this->data
, $this->cmd
);
560 if (is_array($this->mirror
)) {
561 $tce->setMirror($this->mirror
);
564 // Perform the saving operation with DataHandler:
565 if ($this->doSave
=== true) {
566 $tce->process_uploads($_FILES);
567 $tce->process_datamap();
568 $tce->process_cmdmap();
570 // If pages are being edited, we set an instruction about updating the page tree after this operation.
571 if ($tce->pagetreeNeedsRefresh
572 && (isset($this->data
['pages']) ||
$beUser->workspace
!= 0 && !empty($this->data
))
574 BackendUtility
::setUpdateSignal('updatePageTree');
576 // If there was saved any new items, load them:
577 if (!empty($tce->substNEWwithIDs_table
)) {
578 // save the expanded/collapsed states for new inline records, if any
579 FormEngineUtility
::updateInlineView($this->uc
, $tce);
581 foreach ($this->editconf
as $tableName => $tableCmds) {
582 $keys = array_keys($tce->substNEWwithIDs_table
, $tableName);
584 foreach ($keys as $key) {
585 $editId = $tce->substNEWwithIDs
[$key];
586 // Check if the $editId isn't a child record of an IRRE action
587 if (!(is_array($tce->newRelatedIDs
[$tableName])
588 && in_array($editId, $tce->newRelatedIDs
[$tableName]))
590 // Translate new id to the workspace version:
591 if ($versionRec = BackendUtility
::getWorkspaceVersionOfRecord(
597 $editId = $versionRec['uid'];
599 $newEditConf[$tableName][$editId] = 'edit';
601 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
602 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
603 // Traverse all new records and forge the content of ->editconf so we can continue to EDIT
605 if ($tableName === 'pages'
606 && $this->retUrl
!= (string)$uriBuilder->buildUriFromRoute('dummy')
607 && $this->returnNewPageId
609 $this->retUrl
.= '&id=' . $tce->substNEWwithIDs
[$key];
613 $newEditConf[$tableName] = $tableCmds;
616 // Resetting editconf if newEditConf has values:
617 if (!empty($newEditConf)) {
618 $this->editconf
= $newEditConf;
620 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
621 $this->R_URL_getvars
['edit'] = $this->editconf
;
622 // Unsetting default values since we don't need them anymore.
623 unset($this->R_URL_getvars
['defVals']);
624 // Re-compile the store* values since editconf changed...
625 $this->compileStoreDat();
627 // See if any records was auto-created as new versions?
628 if (!empty($tce->autoVersionIdMap
)) {
629 $this->fixWSversioningInEditConf($tce->autoVersionIdMap
);
631 // If a document is saved and a new one is created right after.
632 if (isset($_POST['_savedoknew']) && is_array($this->editconf
)) {
633 $this->closeDocument(self
::DOCUMENT_CLOSE_MODE_NO_REDIRECT
);
634 // Finding the current table:
635 reset($this->editconf
);
636 $nTable = key($this->editconf
);
637 // Finding the first id, getting the records pid+uid
638 reset($this->editconf
[$nTable]);
639 $nUid = key($this->editconf
[$nTable]);
640 $recordFields = 'pid,uid';
641 if (!empty($GLOBALS['TCA'][$nTable]['ctrl']['versioningWS'])) {
642 $recordFields .= ',t3ver_oid';
644 $nRec = BackendUtility
::getRecord($nTable, $nUid, $recordFields);
645 // Determine insertion mode ('top' is self-explaining,
646 // otherwise new elements are inserted after one using a negative uid)
647 $insertRecordOnTop = ($this->getNewIconMode($nTable) === 'top');
648 // Setting a blank editconf array for a new record:
649 $this->editconf
= [];
650 // Determine related page ID for regular live context
651 if ($nRec['pid'] != -1) {
652 if ($insertRecordOnTop) {
653 $relatedPageId = $nRec['pid'];
655 $relatedPageId = -$nRec['uid'];
658 // Determine related page ID for workspace context
659 if ($insertRecordOnTop) {
660 // Fetch live version of workspace version since the pid value is always -1 in workspaces
661 $liveRecord = BackendUtility
::getRecord($nTable, $nRec['t3ver_oid'], $recordFields);
662 $relatedPageId = $liveRecord['pid'];
664 // Use uid of live version of workspace version
665 $relatedPageId = -$nRec['t3ver_oid'];
668 $this->editconf
[$nTable][$relatedPageId] = 'new';
669 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
670 $this->R_URL_getvars
['edit'] = $this->editconf
;
671 // Re-compile the store* values since editconf changed...
672 $this->compileStoreDat();
674 // If a document should be duplicated.
675 if (isset($_POST['_duplicatedoc']) && is_array($this->editconf
)) {
676 $this->closeDocument(self
::DOCUMENT_CLOSE_MODE_NO_REDIRECT
);
677 // Finding the current table:
678 reset($this->editconf
);
679 $nTable = key($this->editconf
);
680 // Finding the first id, getting the records pid+uid
681 reset($this->editconf
[$nTable]);
682 $nUid = key($this->editconf
[$nTable]);
683 if (!MathUtility
::canBeInterpretedAsInteger($nUid)) {
684 $nUid = $tce->substNEWwithIDs
[$nUid];
687 $recordFields = 'pid,uid';
688 if (!empty($GLOBALS['TCA'][$nTable]['ctrl']['versioningWS'])) {
689 $recordFields .= ',t3ver_oid';
691 $nRec = BackendUtility
::getRecord($nTable, $nUid, $recordFields);
693 // Setting a blank editconf array for a new record:
694 $this->editconf
= [];
696 if ($nRec['pid'] != -1) {
697 $relatedPageId = -$nRec['uid'];
699 $relatedPageId = -$nRec['t3ver_oid'];
702 /** @var $duplicateTce \TYPO3\CMS\Core\DataHandling\DataHandler */
703 $duplicateTce = GeneralUtility
::makeInstance(DataHandler
::class);
708 'copy' => $relatedPageId
713 $duplicateTce->start([], $duplicateCmd);
714 $duplicateTce->process_cmdmap();
716 $duplicateMappingArray = $duplicateTce->copyMappingArray
;
717 $duplicateUid = $duplicateMappingArray[$nTable][$nUid];
719 if ($nTable === 'pages') {
720 BackendUtility
::setUpdateSignal('updatePageTree');
723 $this->editconf
[$nTable][$duplicateUid] = 'edit';
724 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
725 $this->R_URL_getvars
['edit'] = $this->editconf
;
726 // Re-compile the store* values since editconf changed...
727 $this->compileStoreDat();
729 // Inform the user of the duplication
730 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
731 $flashMessage = GeneralUtility
::makeInstance(
733 $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.recordDuplicated'),
737 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
738 $flashMessageService = GeneralUtility
::makeInstance(FlashMessageService
::class);
739 /** @var $defaultFlashMessageQueue FlashMessageQueue */
740 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
741 $defaultFlashMessageQueue->enqueue($flashMessage);
743 // If a preview is requested
744 if (isset($_POST['_savedokview'])) {
745 // Get the first table and id of the data array from DataHandler
746 $table = reset(array_keys($this->data
));
747 $id = reset(array_keys($this->data
[$table]));
748 if (!MathUtility
::canBeInterpretedAsInteger($id)) {
749 $id = $tce->substNEWwithIDs
[$id];
751 // Store this information for later use
752 $this->previewData
['table'] = $table;
753 $this->previewData
['id'] = $id;
755 $tce->printLogErrorMessages();
757 // || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED
758 // because if not, we just get that element re-listed as new. And we don't want that!
759 if ((int)$this->closeDoc
< self
::DOCUMENT_CLOSE_MODE_DEFAULT
760 ||
isset($_POST['_saveandclosedok'])
761 ||
isset($_POST['_translation_savedok'])
763 $this->closeDocument(abs($this->closeDoc
));
768 * Initialize the normal module operation
770 public function init()
772 $beUser = $this->getBackendUser();
773 // Setting more GPvars:
774 $this->popViewId
= GeneralUtility
::_GP('popViewId');
775 $this->popViewId_addParams
= GeneralUtility
::_GP('popViewId_addParams');
776 $this->viewUrl
= GeneralUtility
::_GP('viewUrl');
777 $this->recTitle
= GeneralUtility
::_GP('recTitle');
778 $this->noView
= GeneralUtility
::_GP('noView');
779 $this->perms_clause
= $beUser->getPagePermsClause(Permission
::PAGE_SHOW
);
780 // Set other internal variables:
781 $this->R_URL_getvars
['returnUrl'] = $this->retUrl
;
782 $this->R_URI
= $this->R_URL_parts
['path'] . '?' . ltrim(GeneralUtility
::implodeArrayForUrl(
786 // Setting virtual document name
787 $this->MCONF
['name'] = 'xMOD_alt_doc.php';
789 // Create an instance of the document template object
790 $this->doc
= $GLOBALS['TBE_TEMPLATE'];
791 $pageRenderer = GeneralUtility
::makeInstance(PageRenderer
::class);
792 $pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf');
793 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
794 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
795 // override the default jumpToUrl
796 $this->moduleTemplate
->addJavaScriptCode(
799 function jumpToUrl(URL,formEl) {
800 if (!TBE_EDITOR.isFormChanged()) {
801 window.location.href = URL;
802 } else if (formEl && formEl.type=="checkbox") {
803 formEl.checked = formEl.checked ? 0 : 1;
808 function launchView(table,uid) {
809 console.warn(\'Calling launchView() has been deprecated in v9 and will be removed in v10.0\');
810 var thePreviewWindow = window.open(
811 ' . GeneralUtility
::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('show_item') . '&table=') . ' + encodeURIComponent(table) + "&uid=" + encodeURIComponent(uid),
812 "ShowItem" + Math.random().toString(16).slice(2),
813 "height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0"
815 if (thePreviewWindow && thePreviewWindow.focus) {
816 thePreviewWindow.focus();
819 function deleteRecord(table,id,url) {
820 window.location.href = ' . GeneralUtility
::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1&redirect="+escape(url);
822 ' . (isset($_POST['_savedokview']) && $this->popViewId ?
$this->generatePreviewCode() : '')
824 // Setting up the context sensitive menu:
825 $this->moduleTemplate
->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
827 $this->emitFunctionAfterSignal(__FUNCTION__
);
833 protected function generatePreviewCode()
835 $table = $this->previewData
['table'];
836 $recordId = $this->previewData
['id'];
838 if ($table === 'pages') {
839 $currentPageId = $recordId;
841 $currentPageId = MathUtility
::convertToPositiveInteger($this->popViewId
);
844 $pageTsConfig = BackendUtility
::getPagesTSconfig($currentPageId);
845 $previewConfiguration = $pageTsConfig['TCEMAIN.']['preview.'][$table . '.'] ??
[];
847 $recordArray = BackendUtility
::getRecord($table, $recordId);
849 // find the right preview page id
851 if (isset($previewConfiguration['previewPageId'])) {
852 $previewPageId = $previewConfiguration['previewPageId'];
854 // if no preview page was configured
855 if (!$previewPageId) {
856 $rootPageData = null;
857 $rootLine = BackendUtility
::BEgetRootLine($currentPageId);
858 $currentPage = reset($rootLine);
859 // Allow all doktypes below 200
860 // This makes custom doktype work as well with opening a frontend page.
861 if ((int)$currentPage['doktype'] <= PageRepository
::DOKTYPE_SPACER
) {
862 // try the current page
863 $previewPageId = $currentPageId;
865 // or search for the root page
866 foreach ($rootLine as $page) {
867 if ($page['is_siteroot']) {
868 $rootPageData = $page;
872 $previewPageId = isset($rootPageData)
873 ?
(int)$rootPageData['uid']
878 $linkParameters = [];
881 $languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'] ??
'';
882 if ($languageField && !empty($recordArray[$languageField])) {
883 $l18nPointer = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ??
'';
884 if ($l18nPointer && !empty($recordArray[$l18nPointer])
885 && isset($previewConfiguration['useDefaultLanguageRecord'])
886 && !$previewConfiguration['useDefaultLanguageRecord']
889 $recordId = $recordArray[$l18nPointer];
891 $linkParameters['L'] = $recordArray[$languageField];
894 // map record data to GET parameters
895 if (isset($previewConfiguration['fieldToParameterMap.'])) {
896 foreach ($previewConfiguration['fieldToParameterMap.'] as $field => $parameterName) {
897 $value = $recordArray[$field];
898 if ($field === 'uid') {
901 $linkParameters[$parameterName] = $value;
905 // add/override parameters by configuration
906 if (isset($previewConfiguration['additionalGetParameters.'])) {
907 $additionalGetParameters = [];
908 $this->parseAdditionalGetParameters(
909 $additionalGetParameters,
910 $previewConfiguration['additionalGetParameters.']
912 $linkParameters = array_replace($linkParameters, $additionalGetParameters);
915 if (!empty($previewConfiguration['useCacheHash'])) {
916 /** @var CacheHashCalculator */
917 $cacheHashCalculator = GeneralUtility
::makeInstance(CacheHashCalculator
::class);
918 $fullLinkParameters = GeneralUtility
::implodeArrayForUrl('', array_merge($linkParameters, ['id' => $previewPageId]));
919 $cacheHashParameters = $cacheHashCalculator->getRelevantParameters($fullLinkParameters);
920 $linkParameters['cHash'] = $cacheHashCalculator->calculateCacheHash($cacheHashParameters);
922 $linkParameters['no_cache'] = 1;
925 $this->popViewId
= $previewPageId;
926 $this->popViewId_addParams
= GeneralUtility
::implodeArrayForUrl('', $linkParameters, '', false, true);
927 $anchorSection = $table === 'tt_content' ?
'#c' . $recordId : '';
929 $previewPageRootline = BackendUtility
::BEgetRootLine($this->popViewId
);
933 . BackendUtility
::viewOnClick(
936 $previewPageRootline,
939 $this->popViewId_addParams
,
945 . BackendUtility
::viewOnClick(
948 $previewPageRootline,
951 $this->popViewId_addParams
958 * Migrates a set of (possibly nested) GET parameters in TypoScript syntax to a plain array
960 * This basically removes the trailing dots of sub-array keys in TypoScript.
961 * The result can be used to create a query string with GeneralUtility::implodeArrayForUrl().
963 * @param array $parameters Should be an empty array by default
964 * @param array $typoScript The TypoScript configuration
966 protected function parseAdditionalGetParameters(array &$parameters, array $typoScript)
968 foreach ($typoScript as $key => $value) {
969 if (is_array($value)) {
970 $key = rtrim($key, '.');
971 $parameters[$key] = [];
972 $this->parseAdditionalGetParameters($parameters[$key], $value);
974 $parameters[$key] = $value;
980 * Main module operation
982 public function main()
986 if (is_array($this->editconf
)) {
987 /** @var FormResultCompiler formResultCompiler */
988 $this->formResultCompiler
= GeneralUtility
::makeInstance(FormResultCompiler
::class);
990 // Creating the editing form, wrap it with buttons, document selector etc.
991 $editForm = $this->makeEditForm();
993 $this->firstEl
= reset($this->elementsData
);
994 // Checking if the currently open document is stored in the list of "open documents" - if not, add it:
995 if (($this->docDat
[1] !== $this->storeUrlMd5
996 ||
!isset($this->docHandler
[$this->storeUrlMd5
]))
997 && !$this->dontStoreDocumentRef
999 $this->docHandler
[$this->storeUrlMd5
] = [
1005 $this->getBackendUser()->pushModuleData('FormEngine', [$this->docHandler
, $this->storeUrlMd5
]);
1006 BackendUtility
::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler
));
1008 // Module configuration
1009 $this->modTSconfig
= $this->viewId ? BackendUtility
::getModTSconfig(
1013 $body = $this->formResultCompiler
->addCssFiles();
1014 $body .= $this->compileForm($editForm);
1015 $body .= $this->formResultCompiler
->printNeededJSFunctions();
1020 // The page will show only if there is a valid page and if this page may be viewed by the user
1021 $this->pageinfo
= BackendUtility
::readPageAccess($this->viewId
, $this->perms_clause
);
1022 if ($this->pageinfo
) {
1023 $this->moduleTemplate
->getDocHeaderComponent()->setMetaInformation($this->pageinfo
);
1025 // Setting up the buttons and markers for docheader
1026 $this->getButtons();
1027 $this->languageSwitch($this->firstEl
['table'], $this->firstEl
['uid'], $this->firstEl
['pid']);
1028 $this->moduleTemplate
->setContent($body);
1031 /***************************
1033 * Sub-content functions, rendering specific parts of the module content.
1035 ***************************/
1037 * Creates the editing form with FormEnigne, based on the input from GPvars.
1039 * @return string HTML form elements wrapped in tables
1041 public function makeEditForm()
1043 // Initialize variables:
1044 $this->elementsData
= [];
1049 $beUser = $this->getBackendUser();
1050 // Traverse the GPvar edit array
1052 foreach ($this->editconf
as $table => $conf) {
1053 if (is_array($conf) && $GLOBALS['TCA'][$table] && $beUser->check('tables_modify', $table)) {
1054 // Traverse the keys/comments of each table (keys can be a commalist of uids)
1055 foreach ($conf as $cKey => $command) {
1056 if ($command === 'edit' ||
$command === 'new') {
1058 $ids = GeneralUtility
::trimExplode(',', $cKey, true);
1059 // Traverse the ids:
1060 foreach ($ids as $theUid) {
1061 // Don't save this document title in the document selector if the document is new.
1062 if ($command === 'new') {
1063 $this->dontStoreDocumentRef
= 1;
1067 $formDataGroup = GeneralUtility
::makeInstance(TcaDatabaseRecord
::class);
1068 $formDataCompiler = GeneralUtility
::makeInstance(FormDataCompiler
::class, $formDataGroup);
1069 $nodeFactory = GeneralUtility
::makeInstance(NodeFactory
::class);
1071 // Reset viewId - it should hold data of last entry only
1073 $this->viewId_addParams
= '';
1075 $formDataCompilerInput = [
1076 'tableName' => $table,
1077 'vanillaUid' => (int)$theUid,
1078 'command' => $command,
1079 'returnUrl' => $this->R_URI
,
1081 if (is_array($this->overrideVals
) && is_array($this->overrideVals
[$table])) {
1082 $formDataCompilerInput['overrideValues'] = $this->overrideVals
[$table];
1085 $formData = $formDataCompiler->compile($formDataCompilerInput);
1087 // Set this->viewId if possible
1088 if ($command === 'new'
1089 && $table !== 'pages'
1090 && !empty($formData['parentPageRow']['uid'])
1092 $this->viewId
= $formData['parentPageRow']['uid'];
1094 if ($table === 'pages') {
1095 $this->viewId
= $formData['databaseRow']['uid'];
1096 } elseif (!empty($formData['parentPageRow']['uid'])) {
1097 $this->viewId
= $formData['parentPageRow']['uid'];
1098 // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
1099 if (!empty($formData['processedTca']['ctrl']['languageField'])
1100 && is_array($formData['databaseRow'][$formData['processedTca']['ctrl']['languageField']])
1101 && $formData['databaseRow'][$formData['processedTca']['ctrl']['languageField']][0] > 0
1103 $this->viewId_addParams
= '&L=' . $formData['databaseRow'][$formData['processedTca']['ctrl']['languageField']][0];
1108 // Determine if delete button can be shown
1109 $deleteAccess = false;
1110 if ($command === 'edit') {
1111 $permission = $formData['userPermissionOnPage'];
1112 if ($formData['tableName'] === 'pages') {
1113 $deleteAccess = $permission & Permission
::PAGE_DELETE ?
true : false;
1115 $deleteAccess = $permission & Permission
::CONTENT_EDIT ?
true : false;
1119 // Display "is-locked" message:
1120 if ($command === 'edit') {
1121 $lockInfo = BackendUtility
::isRecordLocked($table, $formData['databaseRow']['uid']);
1123 /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
1124 $flashMessage = GeneralUtility
::makeInstance(
1125 FlashMessage
::class,
1128 FlashMessage
::WARNING
1130 /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
1131 $flashMessageService = GeneralUtility
::makeInstance(FlashMessageService
::class);
1132 /** @var $defaultFlashMessageQueue FlashMessageQueue */
1133 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1134 $defaultFlashMessageQueue->enqueue($flashMessage);
1139 if (!$this->storeTitle
) {
1140 $this->storeTitle
= $this->recTitle
1141 ?
htmlspecialchars($this->recTitle
)
1142 : BackendUtility
::getRecordTitle($table, FormEngineUtility
::databaseRowCompatibility($formData['databaseRow']), true);
1145 $this->elementsData
[] = [
1147 'uid' => $formData['databaseRow']['uid'],
1148 'pid' => $formData['databaseRow']['pid'],
1150 'deleteAccess' => $deleteAccess
1153 if ($command !== 'new') {
1154 BackendUtility
::lockRecords($table, $formData['databaseRow']['uid'], $table === 'tt_content' ?
$formData['databaseRow']['pid'] : 0);
1157 // Set list if only specific fields should be rendered. This will trigger
1158 // ListOfFieldsContainer instead of FullRecordContainer in OuterWrapContainer
1159 if ($this->columnsOnly
) {
1160 if (is_array($this->columnsOnly
)) {
1161 $formData['fieldListToRender'] = $this->columnsOnly
[$table];
1163 $formData['fieldListToRender'] = $this->columnsOnly
;
1167 $formData['renderType'] = 'outerWrapContainer';
1168 $formResult = $nodeFactory->create($formData)->render();
1170 $html = $formResult['html'];
1172 $formResult['html'] = '';
1173 $formResult['doSaveFieldName'] = 'doSave';
1175 // @todo: Put all the stuff into FormEngine as final "compiler" class
1176 // @todo: This is done here for now to not rewrite addCssFiles()
1177 // @todo: and printNeededJSFunctions() now
1178 $this->formResultCompiler
->mergeResult($formResult);
1180 // Seems the pid is set as hidden field (again) at end?!
1181 if ($command === 'new') {
1182 // @todo: looks ugly
1184 . '<input type="hidden"'
1185 . ' name="data[' . htmlspecialchars($table) . '][' . htmlspecialchars($formData['databaseRow']['uid']) . '][pid]"'
1186 . ' value="' . (int)$formData['databaseRow']['pid'] . '" />';
1191 } catch (AccessDeniedException
$e) {
1193 // Try to fetch error message from "recordInternals" be user object
1194 // @todo: This construct should be logged and localized and de-uglified
1195 $message = $beUser->errorMsg
;
1196 if (empty($message)) {
1197 // Create message from exception.
1198 $message = $e->getMessage() . ' ' . $e->getCode();
1200 $editForm .= htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.noEditPermission'))
1201 . '<br /><br />' . htmlspecialchars($message) . '<br /><br />';
1202 } catch (DatabaseRecordException
$e) {
1203 $editForm = '<div class="alert alert-warning">' . htmlspecialchars($e->getMessage()) . '</div>';
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'];