Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Classes/Hooks/Datahandler/CommandMapPostProcessingHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ protected function copyToLanguageChildren(int $uid, int $language, string $comma
if ($newId === null) {
continue;
}
$this->keepHiddenState($newId, $record, $dataHandler);
$cmd = ['tt_content' => [$newId=> [
'move' => [
'target' => -$last,
Expand Down Expand Up @@ -106,12 +107,29 @@ protected function localizeChildren(int $uid, int $language, string $command, Da
$localDataHandler->enableLogging = $dataHandler->enableLogging;
$localDataHandler->start([], $cmd, $dataHandler->BE_USER);
$localDataHandler->process_cmdmap();
$newId = $localDataHandler->copyMappingArray['tt_content'][$record['uid']] ?? null;
if ($newId !== null) {
$this->keepHiddenState($newId, $record, $dataHandler);
}
}
} catch (Exception $e) {
// nothing todo
}
}

/**
* Localize/copyToLanguage always hide the new record unless the source was already hidden
* (TcaSchemaCapability::HideRecordsAtCopy), losing the original per-child visibility. Restore it explicitly,
* since neither 'localize' nor 'copyToLanguage' cmdmap commands support an 'update' override array.
*/
protected function keepHiddenState(int $newId, array $record, DataHandler $dataHandler): void
{
$hiddenStateDataHandler = GeneralUtility::makeInstance(DataHandler::class);
$hiddenStateDataHandler->enableLogging = $dataHandler->enableLogging;
$hiddenStateDataHandler->start(['tt_content' => [$newId => ['hidden' => (int)$record['hidden']]]], [], $dataHandler->BE_USER);
$hiddenStateDataHandler->process_datamap();
}

protected function copyOrMoveChildren(int $origUid, int $newId, int $containerId, string $command, DataHandler $dataHandler): void
{
try {
Expand Down Expand Up @@ -144,6 +162,8 @@ protected function copyOrMoveChildren(int $origUid, int $newId, int $containerId
'update' => [
'tx_container_parent' => $containerId,
'colPos' => $record['colPos'],
// keep the original hidden state instead of DataHandler's hideAtCopy default
'hidden' => (int)$record['hidden'],
],
],
],
Expand Down
22 changes: 22 additions & 0 deletions Tests/Functional/Datahandler/DefaultLanguage/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,28 @@ public function copyContainerKeepsSortingOfChildren(): void
self::assertCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerKeepsSortingOfChildrenResult.csv');
}

#[Test]
public function copyContainerKeepsHiddenStateOfChildren(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerKeepsHiddenStateOfChildren.csv');
$cmdmap = [
'tt_content' => [
1 => [
'copy' => [
'action' => 'paste',
'target' => 3,
'update' => [
'colPos' => 0,
],
],
],
],
];
$this->dataHandler->start([], $cmdmap, $this->backendUser);
$this->dataHandler->process_cmdmap();
self::assertCSVDataSet(__DIR__ . '/Fixtures/Container/CopyContainerKeepsHiddenStateOfChildrenResult.csv');
}

#[Test]
public function moveContainerOtherPageOnTop(): void
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"pages"
,"uid","pid","title"
,1,0,"page-1"
,3,0,"page-2"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent","hidden"
,1,1,"b13-2cols-with-header-container","container-default",56,0,0,0,0,0
,2,1,"header","header-default",128,0,200,1,0,1
,5,1,"header","second element",256,0,200,1,0,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"pages"
,"uid","pid","title"
,1,0,"page-1"
,3,0,"page-2"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent","hidden"
,1,1,"b13-2cols-with-header-container","container-default",56,0,0,0,0,0
,2,1,"header","header-default",128,0,200,1,0,1
,5,1,"header","second element",256,0,200,1,0,0
,6,3,"b13-2cols-with-header-container","container-default",256,0,0,0,0,1
,7,3,"header","second element",512,0,200,6,0,0
,8,3,"header","header-default",384,0,200,6,0,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"pages"
,"uid","pid","title","slug","sys_language_uid","l10n_parent","l10n_source"
,1,0,"page-1","/",,,
,2,0,"page-1-language-1","/",1,1,1
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","hidden"
,1,1,"b13-2cols-with-header-container","container-language-1",128,0,0,0,0
,2,1,"header","header-language-1",256,0,200,1,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"pages"
,"uid","pid","title"
,1,0,"page-1"
,2,0,"page-1-language-1"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent","l10n_source","hidden"
,1,1,"b13-2cols-with-header-container","container-language-1",128,0,0,0,0,0,0
,2,1,"header","header-language-1",256,0,200,1,0,0,0
,3,1,"b13-2cols-with-header-container","[Translate to german:] container-language-1",512,1,0,0,0,1,1
,4,1,"header","[Translate to german:] header-language-1",640,1,200,3,0,2,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"pages"
,"uid","pid","title","slug","sys_language_uid","l10n_parent","l10n_source"
,1,0,"page-1","/",,,
,2,0,"page-1-language-1","/",1,1,1
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","hidden"
,1,1,"b13-2cols-with-header-container","container-language-1",128,0,0,0,0
,2,1,"header","header-language-1",256,0,200,1,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"pages"
,"uid","pid","title"
,1,0,"page-1"
,2,0,"page-1-language-1"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l18n_parent","l10n_source","hidden"
,1,1,"b13-2cols-with-header-container","container-language-1",128,0,0,0,0,0,0
,2,1,"header","header-language-1",256,0,200,1,0,0,0
,3,1,"b13-2cols-with-header-container","[Translate to german:] container-language-1",192,1,0,0,1,1,1
,4,1,"header","[Translate to german:] header-language-1",512,1,200,1,2,2,0
32 changes: 32 additions & 0 deletions Tests/Functional/Datahandler/Localization/LocalizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@ public function localizeContainerLocalizeChildren(): void
self::assertCSVDataSet(__DIR__ . '/Fixtures/Localize/LocalizeContainerLocalizeChildrenResult.csv');
}

#[Test]
public function localizeContainerKeepsHiddenStateOfChildren(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/Localize/LocalizeContainerKeepsHiddenStateOfChildren.csv');
$cmdmap = [
'tt_content' => [
1 => [
'localize' => 1,
],
],
];
$this->dataHandler->start([], $cmdmap, $this->backendUser);
$this->dataHandler->process_cmdmap();
self::assertCSVDataSet(__DIR__ . '/Fixtures/Localize/LocalizeContainerKeepsHiddenStateOfChildrenResult.csv');
}

#[Test]
public function copyContainerToLanguageKeepsHiddenStateOfChildren(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/Localize/CopyContainerToLanguageKeepsHiddenStateOfChildren.csv');
$cmdmap = [
'tt_content' => [
1 => [
'copyToLanguage' => 1,
],
],
];
$this->dataHandler->start([], $cmdmap, $this->backendUser);
$this->dataHandler->process_cmdmap();
self::assertCSVDataSet(__DIR__ . '/Fixtures/Localize/CopyContainerToLanguageKeepsHiddenStateOfChildrenResult.csv');
}

#[Test]
public function localizeNestedContainerKeepsDefaultLanguageParent(): void
{
Expand Down