Skip to content

Commit 940ceb2

Browse files
committed
[BUGFIX] sorting when copyToLanguage
child element are sorted after default language content element when copyToLanguage
1 parent 375309c commit 940ceb2

14 files changed

+75
-90
lines changed

Classes/Hooks/Datahandler/CommandMapPostProcessingHook.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use B13\Container\Domain\Factory\ContainerFactory;
1616
use B13\Container\Domain\Factory\Exception;
17+
use B13\Container\Domain\Service\ContainerService;
1718
use TYPO3\CMS\Backend\Utility\BackendUtility;
1819
use TYPO3\CMS\Core\DataHandling\DataHandler;
1920
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -50,17 +51,37 @@ protected function localizeOrCopyToLanguage(int $uid, int $language, string $com
5051
{
5152
try {
5253
$container = $this->containerFactory->buildContainer($uid);
54+
$last = $dataHandler->copyMappingArray['tt_content'][$uid] ?? null;
55+
if ($command === 'copyToLanguage') {
56+
$containerId = $last;
57+
} else {
58+
$containerId = $container->getUid();
59+
}
5360
$children = $container->getChildRecords();
54-
$children = array_reverse($children);
55-
$cmd = ['tt_content' => []];
5661
foreach ($children as $colPos => $record) {
57-
$cmd['tt_content'][$record['uid']] = [$command => $language];
58-
}
59-
if (count($cmd['tt_content']) > 0) {
62+
$cmd = ['tt_content' => [$record['uid'] => [$command => $language]]];
63+
$localDataHandler = GeneralUtility::makeInstance(DataHandler::class);
64+
$localDataHandler->enableLogging = $dataHandler->enableLogging;
65+
$localDataHandler->start([], $cmd, $dataHandler->BE_USER);
66+
$localDataHandler->process_cmdmap();
67+
$newId = $localDataHandler->copyMappingArray['tt_content'][$record['uid']] ?? null;
68+
if ($newId === null) {
69+
continue;
70+
}
71+
$cmd = ['tt_content' => [$newId=> [
72+
'move' => [
73+
'target' => -$last,
74+
'action' => 'paste',
75+
'update' => [
76+
'tx_container_parent' => $containerId,
77+
]
78+
]
79+
]]];
6080
$localDataHandler = GeneralUtility::makeInstance(DataHandler::class);
6181
$localDataHandler->enableLogging = $dataHandler->enableLogging;
6282
$localDataHandler->start([], $cmd, $dataHandler->BE_USER);
6383
$localDataHandler->process_cmdmap();
84+
$last = $newId;
6485
}
6586
} catch (Exception $e) {
6687
// nothing todo

Classes/Hooks/Datahandler/DatamapPreProcessFieldArrayHook.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ protected function newElementAfterContainer(array $incomingFieldArray): array
6464
if ((int)$record['uid'] === (int)($incomingFieldArray['tx_container_parent'] ?? 0)) {
6565
return $incomingFieldArray;
6666
}
67-
if (($record['l10n_source'] ?? 0) > 0 && (int)$record['l10n_source'] === (int)($incomingFieldArray['tx_container_parent'] ?? 0)) {
68-
return $incomingFieldArray;
69-
}
7067
if ((int)($incomingFieldArray['tx_container_parent'] ?? 0) > 0 &&
7168
(GeneralUtility::makeInstance(DatahandlerProcess::class))->isContainerInProcess((int)$incomingFieldArray['tx_container_parent'])
7269
) {

Tests/Functional/Datahandler/Localization/Fixtures/CopyToLanguageSorting/LocalizeKeepsSorting-Dataset-1Result.csv

Lines changed: 0 additions & 16 deletions
This file was deleted.

Tests/Functional/Datahandler/Localization/Fixtures/CopyToLanguageSorting/LocalizeKeepsSorting-Dataset2Result.csv

Lines changed: 0 additions & 16 deletions
This file was deleted.

Tests/Functional/Datahandler/Localization/Fixtures/CopyToLanguageSorting/LocalizeKeepsSortingDataset1Result.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
,4,1,"b13-2cols-with-header-container","container-2",1024,0,0,0,0
1111
,5,1,"header","child-2-1",2048,0,200,4,0
1212
,6,1,"b13-2cols-with-header-container","[Translate to german:] container-2",2304,1,0,0,0
13-
,7,1,"header","[Translate to german:] child-2-1",2560,1,200,6,0
13+
,7,1,"header","[Translate to german:] child-2-1",2432,1,200,6,0
1414
,8,1,"b13-2cols-with-header-container","[Translate to german:] container-1",768,1,0,0,0
15-
,9,1,"header","[Translate to german:] child-1-2",896,1,200,8,0
16-
,10,1,"header","[Translate to german:] child-1-1",832,1,200,8,0
15+
,10,1,"header","[Translate to german:] child-1-2",880,1,200,8,0
16+
,9,1,"header","[Translate to german:] child-1-1",832,1,200,8,0

Tests/Functional/Datahandler/Localization/Fixtures/CopyToLanguageSorting/LocalizeKeepsSortingDataset2Result.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
,4,1,"b13-2cols-with-header-container","container-2",1024,0,0,0,0
1111
,5,1,"header","child-2-1",2048,0,200,4,0
1212
,6,1,"b13-2cols-with-header-container","[Translate to german:] container-1",768,1,0,0,0
13-
,7,1,"header","[Translate to german:] child-1-2",896,1,200,6,0
14-
,8,1,"header","[Translate to german:] child-1-1",832,1,200,6,0
15-
,9,1,"b13-2cols-with-header-container","[Translate to german:] container-2",960,1,0,0,0
16-
,10,1,"header","[Translate to german:] child-2-1",992,1,200,9,0
13+
,8,1,"header","[Translate to german:] child-1-2",880,1,200,6,0
14+
,7,1,"header","[Translate to german:] child-1-1",832,1,200,6,0
15+
,9,1,"b13-2cols-with-header-container","[Translate to german:] container-2",952,1,0,0,0
16+
,10,1,"header","[Translate to german:] child-2-1",970,1,200,9,0

Tests/Functional/Datahandler/Localization/Fixtures/CopyToLanguageSorting/LocalizeWithNestedElementsResult.csv

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
,"3","1","header","child-2-1","768","0","201","2","0","0"
66
,"4","1","header","child-2-2","1024","0","201","2","0","0"
77
,"5","1","b13-2cols-with-header-container","[Translate to English-Free:] container-1","1280","4","0","0","0","1"
8-
,"6","1","b13-2cols-with-header-container","[Translate to English-Free:] container-2","1536","4","201","5","0","2"
9-
,"8","1","header","[Translate to English-Free:] child-2-1","1664","4","201","6","0","3"
10-
,"7","1","header","[Translate to English-Free:] child-2-2","1792","4","201","6","0","4"
11-
8+
,"6","1","b13-2cols-with-header-container","[Translate to English-Free:] container-2","1408","4","201","5","0","2"
9+
,"7","1","header","[Translate to English-Free:] child-2-1","1472","4","201","6","0","3"
10+
,"8","1","header","[Translate to English-Free:] child-2-2","1536","4","201","6","0","4"

Tests/Functional/Datahandler/Localization/Fixtures/Localize/CopyContainerToLanguageCopiesChildrenResult.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
,1,1,"b13-2cols-with-header-container","container-language-1",256,0,0,0,0,0
88
,2,1,"header","header-language-1",128,0,200,1,0,0
99
,3,1,"b13-2cols-with-header-container","[Translate to german:] container-language-1",192,1,0,0,0,1
10-
,4,1,"header","[Translate to german:] header-language-1",224,1,200,3,0,2
10+
,4,1,"header","[Translate to german:] header-language-1",208,1,200,3,0,2

Tests/Functional/Datahandler/Localization/Fixtures/Localize/CopyToLanguageContainerFromNonDefaultLanguageLocalizeChildrenResult.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
,21,1,"b13-2cols-with-header-container","container-language-1",768,1,0,0,1,0
1111
,22,1,"header","header-language-1",128,1,200,1,2,0
1212
,23,1,"b13-2cols-with-header-container","[Translate to france:] container-language-1",1024,2,0,0,0,21
13-
,24,1,"header","[Translate to france:] header-language-1",384,2,200,23,0,22
13+
,24,1,"header","[Translate to france:] header-language-1",1280,2,200,23,0,22

Tests/Functional/Datahandler/Localization/Fixtures/Localize/CopyToLanguageContainerFromNonDefaultLanguageLocalizeChildrenWhenCopiedFromFreeModeResult.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
,51,1,"b13-2cols-with-header-container","container-language-1",256,1,0,0,0,0
99
,52,1,"header","header-language-1",257,1,200,51,0,0
1010
,53,1,"b13-2cols-with-header-container","[Translate to france:] container-language-1",513,2,0,0,0,51
11-
,54,1,"header","[Translate to france:] header-language-1",769,2,200,53,0,52
11+
,54,1,"header","[Translate to france:] header-language-1",641,2,200,53,0,52

0 commit comments

Comments
 (0)