'
. '
'
. $panel
. '
' .
@@ -225,7 +227,8 @@ class FrontendEditPanel
'edit[' . $table . '][' . $editUid . ']' => 'edit',
'columnsOnly' => $fieldList,
'noView' => $noView,
- 'feEdit' => 1
+ 'feEdit' => 1,
+ 'returnUrl' => htmlspecialchars($this->getReturnUrl($editUid)),
]
) . $addUrlParamStr;
$icon = $this->editPanelLinkWrap_doWrap($iconImg, $url, 'content-link');
@@ -264,16 +267,54 @@ class FrontendEditPanel
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
if ($cmd === 'edit') {
$rParts = explode(':', $currentRecord);
- $out = $this->editPanelLinkWrap_doWrap($string, (string)$uriBuilder->buildUriFromRoute('record_edit', ['edit[' . $rParts[0] . '][' . $rParts[1] . ']' => 'edit', 'noView' => $noView, 'feEdit' => 1]), $currentRecord);
+ $out = $this->editPanelLinkWrap_doWrap(
+ $string,
+ (string)$uriBuilder->buildUriFromRoute(
+ 'record_edit',
+ [
+ 'edit[' . $rParts[0] . '][' . $rParts[1] . ']' => 'edit',
+ 'noView' => $noView,
+ 'feEdit' => 1,
+ 'returnUrl' => htmlspecialchars($this->getReturnUrl($rParts[1])),
+ ]
+ ),
+ $currentRecord
+ );
} elseif ($cmd === 'new') {
$rParts = explode(':', $currentRecord);
+ $uidForReturn = null;
+ if (is_numeric($rParts[1])) {
+ $uidForReturn = $rParts[1];
+ }
if ($rParts[0] === 'pages') {
- $out = $this->editPanelLinkWrap_doWrap($string, (string)$uriBuilder->buildUriFromRoute('db_new', ['id' => $rParts[1], 'pagesOnly' => 1]), $currentRecord);
+ $out = $this->editPanelLinkWrap_doWrap(
+ $string,
+ (string)$uriBuilder->buildUriFromRoute(
+ 'db_new',
+ [
+ 'id' => $rParts[1],
+ 'pagesOnly' => 1,
+ 'returnUrl' => htmlspecialchars($this->getReturnUrl($uidForReturn)),
+ ]
+ ),
+ $currentRecord
+ );
} else {
if (!(int)$nPid) {
$nPid = MathUtility::canBeInterpretedAsInteger($rParts[1]) ? -$rParts[1] : $this->frontendController->id;
}
- $out = $this->editPanelLinkWrap_doWrap($string, (string)$uriBuilder->buildUriFromRoute('record_edit', ['edit[' . $rParts[0] . '][' . $nPid . ']' => 'new', 'noView' => $noView]), $currentRecord);
+ $out = $this->editPanelLinkWrap_doWrap(
+ $string,
+ (string)$uriBuilder->buildUriFromRoute(
+ 'record_edit',
+ [
+ 'edit[' . $rParts[0] . '][' . $nPid . ']' => 'new',
+ 'noView' => $noView,
+ 'returnUrl' => htmlspecialchars($this->getReturnUrl($uidForReturn)),
+ ]
+ ),
+ $currentRecord
+ );
}
} else {
if ($confirm && $this->backendUser->jsConfirmation(JsConfirmation::FE_EDIT)) {
@@ -302,7 +343,7 @@ class FrontendEditPanel
$width = MathUtility::forceIntegerInRange($this->backendUser->getTSConfig()['options.']['feedit.']['popupWidth'] ?? 690, 690, 5000, 690);
$height = MathUtility::forceIntegerInRange($this->backendUser->getTSConfig()['options.']['feedit.']['popupHeight'] ?? 500, 500, 5000, 500);
$onclick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url . '&returnUrl=' . rawurlencode(PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Html/Close.html')))) . ',\'FEquickEditWindow\',\'width=' . $width . ',height=' . $height . ',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
- return '
' . $string . '';
+ return '
' . $string . '';
}
/**
@@ -354,6 +395,25 @@ class FrontendEditPanel
return htmlspecialchars($this->getLanguageService()->getLL($key));
}
+ /**
+ * Returns the returnUrl used by TYPO3. Add this as "returnUrl=" to any url that allows the user to go back or close an form.
+ *
+ * @param int $recordUid The record which was edited. Or null if no record was edited. Used to jump back to that record.
+ * @return string The return url.
+ */
+ protected function getReturnUrl(int $recordUid = null): string
+ {
+ $url = GeneralUtility::getIndpEnv('REQUEST_URI');
+
+ if (is_int($recordUid)) {
+ $uri = new Uri($url);
+ $uri = $uri->withFragment('#c' . $recordUid);
+ $url = (string) $uri;
+ }
+
+ return $url;
+ }
+
/**
* @return LanguageService
*/