Skip to content

Commit

Permalink
Revert "[TASK] Replace localization methods in PageLayoutController"
Browse files Browse the repository at this point in the history
This reverts commit 7e10d6b.

Reason for revert: PageRepository->getPageOverlay() applies
frontend access restrictions, which are wrong in this context,
and which can not be skipped.

Additionally, the WorkspaceRestriction is not applied.

Resolves: #99992
Related: #99613
Releases: main, 11.5
Change-Id: I032f50b6465fbe2c3bf157cd13b9e99e558084db
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77759
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
o-ba committed Feb 21, 2023
1 parent 8f3df86 commit d82f225
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions typo3/sysext/backend/Classes/Controller/PageLayoutController.php
Expand Up @@ -139,8 +139,7 @@ public function mainAction(ServerRequestInterface $request): ResponseInterface
$pageLayoutContext->getDrawingConfiguration()->getLanguageMode()
);

$pageLocalizationRecord = $this->pageRepository->getPageOverlay($this->id, $this->currentSelectedLanguage);
$pageTitle = $this->currentSelectedLanguage <= 0 ? $this->pageinfo['title'] : ($pageLocalizationRecord['title'] ?? '');
$pageLocalizationRecord = $this->getLocalizedPageRecord($this->currentSelectedLanguage);

$view->setTitle($languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_mod.xlf:mlang_tabs_tab'), $this->pageinfo['title']);
$view->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
Expand All @@ -149,7 +148,7 @@ public function mainAction(ServerRequestInterface $request): ResponseInterface
'localizedPageId' => $pageLocalizationRecord['uid'] ?? 0,
'infoBoxes' => $this->generateMessagesForCurrentPage($request),
'isPageEditable' => $this->isPageEditable($this->currentSelectedLanguage),
'localizedPageTitle' => $pageTitle,
'localizedPageTitle' => $this->getLocalizedPageTitle($this->currentSelectedLanguage, $this->pageinfo),
'eventContentHtmlTop' => $event->getHeaderContent(),
'mainContentHtml' => $mainLayoutHtml,
'hiddenElementsShowToggle' => ($this->getBackendUser()->check('tables_select', 'tt_content') && ($numberOfHiddenElements > 0)),
Expand Down Expand Up @@ -264,6 +263,38 @@ protected function getExistingPageTranslations(): array
->fetchAllAssociative();
}

protected function getLocalizedPageRecord(int $languageId): ?array
{
if ($languageId === 0) {
return null;
}
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, $this->getBackendUser()->workspace));
$overlayRecord = $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq(
$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
$queryBuilder->createNamedParameter($this->id, Connection::PARAM_INT)
),
$queryBuilder->expr()->eq(
$GLOBALS['TCA']['pages']['ctrl']['languageField'],
$queryBuilder->createNamedParameter($languageId, Connection::PARAM_INT)
)
)
->setMaxResults(1)
->executeQuery()
->fetchAssociative();
if ($overlayRecord) {
BackendUtility::workspaceOL('pages', $overlayRecord, $this->getBackendUser()->workspace);
}
return is_array($overlayRecord) ? $overlayRecord : null;
}

/**
* This creates the dropdown menu with the different actions this module is able to provide.
* For now, they are Columns and Languages.
Expand Down Expand Up @@ -460,6 +491,18 @@ protected function getPageLinksWhereContentIsAlsoShownOn(int $pageId): string
return implode(', ', $links);
}

protected function getLocalizedPageTitle(int $currentSelectedLanguage, array $pageInfo): string
{
if ($currentSelectedLanguage <= 0) {
return $pageInfo['title'];
}
$pageLocalizationRecord = $this->getLocalizedPageRecord($currentSelectedLanguage);
if (!is_array($pageLocalizationRecord)) {
return $pageInfo['title'];
}
return $pageLocalizationRecord['title'] ?? '';
}

/**
* Initializes the clipboard for generating paste links dynamically via JavaScript after each "+ Content" symbol
*/
Expand Down Expand Up @@ -609,8 +652,8 @@ protected function makeEditButton(ButtonBar $buttonBar, ServerRequestInterface $

$pageUid = $this->id;
if ($this->currentSelectedLanguage > 0) {
$overlayRecord = $this->pageRepository->getPageOverlay($this->id, $this->currentSelectedLanguage);
$pageUid = $overlayRecord['_PAGES_OVERLAY_UID'];
$overlayRecord = $this->getLocalizedPageRecord($this->currentSelectedLanguage);
$pageUid = $overlayRecord['uid'];
}
$params = [
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri(),
Expand Down

0 comments on commit d82f225

Please sign in to comment.