Commit d585226c authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[TASK] Use ModuleData API in ReviewController

The ModuleData API, introduced in #96895,
is now used in the ReviewController.

Resolves: #96956
Related: #96895
Releases: main
Change-Id: Ie2e4ac3dab37c246183efb53910bb2cd1a774189
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73591

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: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent fec78269
......@@ -414,7 +414,7 @@ class Backend extends Workspaces {
// Listen for depth changes
this.elements.$depthSelector.on('change', (e: JQueryEventObject): void => {
const depth = (<HTMLSelectElement>e.target).value;
Persistent.set('moduleData.workspaces.settings.depth', depth);
Persistent.set('moduleData.web_WorkspacesWorkspaces.depth', depth);
this.settings.depth = depth;
this.getWorkspaceInfos();
});
......@@ -425,7 +425,7 @@ class Backend extends Workspaces {
// Listen for language changes
this.elements.$languageSelector.on('change', (e: JQueryEventObject): void => {
const $me = $(e.target);
Persistent.set('moduleData.workspaces.settings.language', $me.val());
Persistent.set('moduleData.web_WorkspacesWorkspaces.language', $me.val());
this.settings.language = $me.val();
this.sendRemoteRequest(
this.generateRemotePayload('getWorkspaceInfos', this.settings),
......@@ -438,7 +438,7 @@ class Backend extends Workspaces {
this.elements.$stagesSelector.on('change', (e: JQueryEventObject): void => {
const stage = (<HTMLSelectElement>e.target).value;
Persistent.set('moduleData.workspaces.settings.stage', stage);
Persistent.set('moduleData.web_WorkspacesWorkspaces.stage', stage);
this.settings.stage = stage;
this.getWorkspaceInfos();
});
......
......@@ -58,6 +58,7 @@ class ReviewController
public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$moduleData = $request->getAttribute('moduleData');
$pageUid = (int)($queryParams['id'] ?? 0);
$icons = [
......@@ -106,6 +107,7 @@ class ReviewController
}
$workspaceIsAccessible = $backendUser->workspace !== WorkspaceService::LIVE_WORKSPACE_ID && $pageUid > 0;
$selectedLanguage = (string)$moduleData->get('language');
$view = $this->moduleTemplateFactory->create($request, 'typo3/cms-workspaces');
$view->assignMultiple([
'isAdmin' => $backendUser->isAdmin(),
......@@ -116,13 +118,13 @@ class ReviewController
'pageTitle' => $pageTitle,
'activeWorkspaceUid' => $activeWorkspace,
'activeWorkspaceTitle' => $activeWorkspaceTitle,
'availableLanguages' => $this->getSystemLanguages($pageUid),
'availableLanguages' => $this->getSystemLanguages($pageUid, $selectedLanguage),
'availableStages' => $this->stagesService->getStagesForWSUser(),
'availableSelectStages' => $this->getAvailableSelectStages(),
'stageActions' => $this->getStageActions(),
'selectedLanguage' => $this->getLanguageSelection(),
'selectedDepth' => $this->getDepthSelection($pageUid),
'selectedStage' => $this->getStageSelection(),
'selectedLanguage' => $selectedLanguage,
'selectedDepth' => (int)$moduleData->get('depth', ($pageUid === 0 ? 999 : 1)),
'selectedStage' => (int)$moduleData->get('stage'),
'workspaceSwitched' => $workspaceSwitched,
]);
$view->setTitle(
......@@ -243,24 +245,6 @@ class ReviewController
return (string)$this->uriBuilder->buildUriFromRoute('web_WorkspacesWorkspaces', $parameters);
}
protected function getLanguageSelection(): string
{
$moduleData = $this->getBackendUser()->getModuleData('workspaces') ?? [];
return (string)($moduleData['settings']['language'] ?? 'all');
}
protected function getDepthSelection(int $pageId): int
{
$moduleData = $this->getBackendUser()->getModuleData('workspaces') ?? [];
return (int)($moduleData['settings']['depth'] ?? ($pageId === 0 ? 999 : 1));
}
protected function getStageSelection(): int
{
$moduleData = $this->getBackendUser()->getModuleData('workspaces') ?? [];
return (int)($moduleData['settings']['stage'] ?? -99);
}
/**
* Returns true if at least one custom workspace next to live workspace exists.
*/
......@@ -277,16 +261,15 @@ class ReviewController
/**
* Gets all available system languages.
*/
protected function getSystemLanguages(int $pageId): array
protected function getSystemLanguages(int $pageId, string $selectedLanguage): array
{
$languages = $this->translationConfigurationProvider->getSystemLanguages($pageId);
if (isset($languages[-1])) {
$languages[-1]['uid'] = 'all';
}
$activeLanguage = $this->getLanguageSelection();
foreach ($languages as &$language) {
// needs to be strict type checking as this is not possible in fluid
if ((string)$language['uid'] === $activeLanguage) {
if ((string)$language['uid'] === $selectedLanguage) {
$language['active'] = true;
}
}
......
......@@ -18,5 +18,10 @@ return [
'target' => ReviewController::class . '::handleRequest',
],
],
'moduleData' => [
'language' => 'all',
'depth' => 1,
'stage' => -99,
],
],
];
Supports Markdown
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