Commit b8dd0cf5 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] Page and info module events/hooks outside form tag

The page module provides ModifyPageLayoutContentEvent
to add content before and/or after the main module content.
Extensions like ext:sys_note can use this to render own
content. Unfortunately, this content is *within* the
default page module form tag, which prevents extension
content to create own POST forms.

The patch changes the page module HTML slightly to
not encapsulate the event content within the form tag.

The same situation appears in info module "page information"
with "drawFooterHook". The situation here is worse, since
the main form tag is rendered by InfoModuleController and
not PageInformationController. This "module function"
construct in info module is still an ugly mess and really
needs an overhaul. For now, the patch adds a hack in
PageInformationController to close the outside form, then
adds the hook content, then opens another form for valid HTML.

Resolves: #96543
Related: #96542
Related: #96526
Releases: main
Change-Id: I9eba97b85284cfbd5c1874bbef8c00a533cb4bff
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73018

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 419e9ed2
......@@ -613,14 +613,7 @@ class PageLayoutController
}
$content .= $this->generateMessagesForCurrentPage();
// Render the primary module content:
$content .= '<form action="' . htmlspecialchars((string)$this->uriBuilder->buildUriFromRoute($this->moduleName, ['id' => $this->id])) . '" id="PageLayoutController" method="post">';
// Page title
$content .= '<h1 class="' . ($this->isPageEditable($this->current_sys_language) ? 't3js-title-inlineedit' : '') . '">' . htmlspecialchars($this->getLocalizedPageTitle()) . '</h1>';
// All other listings
$content .= $this->renderContent($request);
$content .= '</form>';
// Setting up the buttons for the docheader
$this->makeButtons($request);
$this->initializeClipboard($request);
......@@ -679,7 +672,9 @@ class PageLayoutController
$this->pageRenderer->loadRequireJsModule(ImmediateActionElement::MODULE_NAME);
$this->pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
$tableOutput = '';
$title = '<h1 class="' . ($this->isPageEditable($this->current_sys_language) ? 't3js-title-inlineedit' : '') . '">' . htmlspecialchars($this->getLocalizedPageTitle()) . '</h1>';
$tableOutput = '<form action="' . htmlspecialchars((string)$this->uriBuilder->buildUriFromRoute($this->moduleName, ['id' => $this->id])) . '" id="PageLayoutController" method="post">';
$numberOfHiddenElements = 0;
if ($this->context instanceof PageLayoutContext) {
......@@ -714,7 +709,7 @@ class PageLayoutController
->invoke('setLanguageOverlayId', $languageOverlayId);
}
$this->pageRenderer->getJavaScriptRenderer()->addJavaScriptModuleInstruction($pageActionsInstruction);
$tableOutput = GeneralUtility::makeInstance(BackendLayoutRenderer::class, $this->context)->drawContent();
$tableOutput .= GeneralUtility::makeInstance(BackendLayoutRenderer::class, $this->context)->drawContent();
}
if ($this->getBackendUser()->check('tables_select', 'tt_content') && $numberOfHiddenElements > 0) {
......@@ -728,8 +723,10 @@ class PageLayoutController
</div>';
}
$tableOutput .= '</form>';
$event = $this->eventDispatcher->dispatch(new ModifyPageLayoutContentEvent($request, $this->moduleTemplate));
return $event->getHeaderContent() . $tableOutput . $event->getFooterContent();
return $title . $event->getHeaderContent() . $tableOutput . $event->getFooterContent();
}
/***************************
......
......@@ -120,6 +120,9 @@ class PageInformationController
'</div>'
. $this->getTable_pages($this->id, (int)$this->pObj->MOD_SETTINGS['depth'], $request);
// This is a hack to close the default form created by InfoModuleController so the hook below can have own form tags
$theOutput .= '</form>';
// Additional footer content
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'] ?? [] as $hook) {
$params = [
......@@ -127,6 +130,9 @@ class PageInformationController
];
$theOutput .= GeneralUtility::callUserFunction($hook, $params, $this);
}
// Open the form again to have valid HTML
$theOutput .= '<form action="">';
return $theOutput;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment