Skip to content
Merged
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
7 changes: 6 additions & 1 deletion Classes/Hooks/Datahandler/CommandMapPostProcessingHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ protected function copyToLanguageChildren(int $uid, int $language, string $comma
$containerId = $last;
$pos = $this->containerService->getAfterContainerElementTarget($container);
// move next record after last child
// colPos is required in the update array, otherwise content restriction hooks
// (EXT:content_defender, EXT:container) cast the command value to int and use 1 as page uid
$cmd = ['tt_content' => [$last => [
'move' => [
'target' => $pos,
'action' => 'paste',
'update' => [],
'update' => [
'colPos' => (int)$container->getContainerRecord()['colPos'],
],
],
]]];
$localDataHandler = GeneralUtility::makeInstance(DataHandler::class);
Expand All @@ -82,6 +86,7 @@ protected function copyToLanguageChildren(int $uid, int $language, string $comma
'action' => 'paste',
'update' => [
'tx_container_parent' => $containerId,
'colPos' => (int)$record['colPos'],
],
],
]]];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace B13\Container\Tests\Functional\Datahandler\ContentDefender;

/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/

use B13\Container\Hooks\Datahandler\DatahandlerProcess;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class CopyToLanguageSortingTest extends AbstractContentDefender
{
protected function setUp(): void
{
if ((new Typo3Version())->getMajorVersion() < 14) {
$this->testExtensionsToLoad[] = 'typo3conf/ext/content_defender';
}
parent::setUp();
}

#[Test]
#[Group('content_defender')]
public function localizeWithMultipleNestedElements(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/CopyToLanguageSorting/LocalizeWithMultipleNestedElements.csv');
$cmdmap = [
'tt_content' => [
1 => [
'copyToLanguage' => 4,
],
],
];
$this->dataHandler->start([], $cmdmap, $this->backendUser);
$this->dataHandler->process_cmdmap();
self::assertCSVDataSet(__DIR__ . '/Fixtures/CopyToLanguageSorting/LocalizeWithMultipleNestedElementsResult.csv');
self::assertFalse((GeneralUtility::makeInstance(DatahandlerProcess::class))->areContentElementRestrictionsLooked());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace B13\Container\Tests\Functional\Datahandler\ContentDefender;

/*
* This file is part of TYPO3 CMS-based extension "container" by b13.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*/

use B13\Container\Hooks\Datahandler\DatahandlerProcess;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class CopyToLanguageWithNoPageUid1Test extends AbstractContentDefender
{
protected function setUp(): void
{
if ((new Typo3Version())->getMajorVersion() < 14) {
$this->testExtensionsToLoad[] = 'typo3conf/ext/content_defender';
}
parent::setUp();
}

#[Test]
#[Group('content_defender')]
public function copyToLanguage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/CopyToLanguageWithNoPageUid1.csv');
$cmdmap = [
'tt_content' => [
6 => [
'copyToLanguage' => 4,
],
],
];
$this->dataHandler->start([], $cmdmap, $this->backendUser);
$this->dataHandler->process_cmdmap();
self::assertCSVDataSet(__DIR__ . '/Fixtures/CopyToLanguageWithNoPageUid1Result.csv');
self::assertFalse((GeneralUtility::makeInstance(DatahandlerProcess::class))->areContentElementRestrictionsLooked());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"pages"
,"uid","pid","title"
,"1","0","page-1"
,"4","0","[Translate to de:] page-1"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l10n_source"
,"1","1","b13-2cols-with-header-container","1","256","0","0","0","0"
,"2","1","b13-2cols-with-header-container","2","512","0","201","1","0"
,"3","1","b13-2cols-with-header-container","3","768","0","201","2","0"
,"4","1","b13-2cols-with-header-container","4","1024","0","201","3","0"
,"5","1","b13-2cols-with-header-container","5","1280","0","201","3","0"
,"6","1","b13-2cols-with-header-container","6","1152","0","201","4","0"
,"7","1","header","7","1216","0","200","6","0"

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"pages"
,"uid","pid","title"
,"1","0","page-1"
,"4","0","[Translate to de:] page-1"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l10n_source"
,"1","1","b13-2cols-with-header-container","1","256","0","0","0","0"
,"2","1","b13-2cols-with-header-container","2","512","0","201","1","0"
,"3","1","b13-2cols-with-header-container","3","768","0","201","2","0"
,"4","1","b13-2cols-with-header-container","4","1024","0","201","3","0"
,"5","1","b13-2cols-with-header-container","5","1280","0","201","3","0"
,"6","1","b13-2cols-with-header-container","6","1152","0","201","4","0"
,"7","1","header","7","1216","0","200","6","0"
,"8","1","b13-2cols-with-header-container","[Translate to English-Free:] 1","1536","4","0","0","1"
,"9","1","b13-2cols-with-header-container","[Translate to English-Free:] 2","1792","4","201","8","2"
,"10","1","b13-2cols-with-header-container","[Translate to English-Free:] 3","2048","4","201","9","3"
,"11","1","b13-2cols-with-header-container","[Translate to English-Free:] 4","2176","4","201","10","4"
,"12","1","b13-2cols-with-header-container","[Translate to English-Free:] 6","2240","4","201","11","6"
,"13","1","header","[Translate to English-Free:] 7","2272","4","200","12","7"
,"14","1","b13-2cols-with-header-container","[Translate to English-Free:] 5","2304","4","201","10","5"

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"pages"
,"uid","pid","title"
,"2","0","page-1"
,"4","0","[Translate to de:] page-1"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l10n_source"
,"6","2","b13-2cols-with-header-container","6","1152","0","200","0","0"
,"7","2","header","7","1216","0","200","6","0"

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"pages"
,"uid","pid","title"
,"2","0","page-1"
,"4","0","[Translate to de:] page-1"
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l10n_source"
,"6","2","b13-2cols-with-header-container","6","1152","0","200","0","0"
,"7","2","header","7","1216","0","200","6","0"
,"8","2","b13-2cols-with-header-container","[Translate to English-Free:] 6","1472","4","200","0","6"
,"9","2","header","[Translate to English-Free:] 7","1600","4","200","8","7"

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l10n_source"
,"1","1","b13-2cols-with-header-container","1","256","0","0","0","0"
,"2","1","b13-2cols-with-header-container","2","512","0","200","1","0"
,"2","1","b13-2cols-with-header-container","2","512","0","201","1","0"
,"3","1","b13-2cols-with-header-container","3","768","0","201","2","0"
,"4","1","b13-2cols-with-header-container","4","1024","0","200","3","0"
,"5","1","b13-2cols-with-header-container","5","1280","0","200","3","0"
,"6","1","b13-2cols-with-header-container","6","1152","0","200","4","0"
,"4","1","b13-2cols-with-header-container","4","1024","0","201","3","0"
,"5","1","b13-2cols-with-header-container","5","1280","0","201","3","0"
,"6","1","b13-2cols-with-header-container","6","1152","0","201","4","0"
,"7","1","header","7","1216","0","200","6","0"

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"tt_content"
,"uid","pid","CType","header","sorting","sys_language_uid","colPos","tx_container_parent","l10n_source"
,"1","1","b13-2cols-with-header-container","1","256","0","0","0","0"
,"2","1","b13-2cols-with-header-container","2","512","0","200","1","0"
,"2","1","b13-2cols-with-header-container","2","512","0","201","1","0"
,"3","1","b13-2cols-with-header-container","3","768","0","201","2","0"
,"4","1","b13-2cols-with-header-container","4","1024","0","200","3","0"
,"5","1","b13-2cols-with-header-container","5","1280","0","200","3","0"
,"6","1","b13-2cols-with-header-container","6","1152","0","200","4","0"
,"4","1","b13-2cols-with-header-container","4","1024","0","201","3","0"
,"5","1","b13-2cols-with-header-container","5","1280","0","201","3","0"
,"6","1","b13-2cols-with-header-container","6","1152","0","201","4","0"
,"7","1","header","7","1216","0","200","6","0"
,"8","1","b13-2cols-with-header-container","[Translate to English-Free:] 1","1536","4","0","0","1"
,"9","1","b13-2cols-with-header-container","[Translate to English-Free:] 2","1792","4","200","8","2"
,"9","1","b13-2cols-with-header-container","[Translate to English-Free:] 2","1792","4","201","8","2"
,"10","1","b13-2cols-with-header-container","[Translate to English-Free:] 3","2048","4","201","9","3"
,"11","1","b13-2cols-with-header-container","[Translate to English-Free:] 4","2176","4","200","10","4"
,"12","1","b13-2cols-with-header-container","[Translate to English-Free:] 6","2240","4","200","11","6"
,"11","1","b13-2cols-with-header-container","[Translate to English-Free:] 4","2176","4","201","10","4"
,"12","1","b13-2cols-with-header-container","[Translate to English-Free:] 6","2240","4","201","11","6"
,"13","1","header","[Translate to English-Free:] 7","2272","4","200","12","7"
,"14","1","b13-2cols-with-header-container","[Translate to English-Free:] 5","2304","4","200","10","5"
,"14","1","b13-2cols-with-header-container","[Translate to English-Free:] 5","2304","4","201","10","5"