Skip to content

Commit 0e9a016

Browse files
[BUGFIX] Count elements in clipboard correctly when pasting all
In the record list, the method generating the clipboard paste confirmation along with the "Paste in clipboard content" counted in a wrong fashion since #106032, as the amount of records is not handed in anymore. Since that single method cannot determine what to count without context, a new internal enum `CountMode` is introduced that instructs how elements in the clipboard should get counted. Resolves: #106474 Related: #106032 Releases: main Change-Id: I5538d477884ec71db2fae5971d39ef64cad475bf Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/88881 Tested-by: core-ci <typo3@b13.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Andreas Kienast <akienast@scripting-base.de> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Andreas Kienast <akienast@scripting-base.de> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org>
1 parent 1e5b5bc commit 0e9a016

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

typo3/sysext/backend/Classes/Clipboard/Clipboard.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace TYPO3\CMS\Backend\Clipboard;
1919

2020
use Psr\Http\Message\ServerRequestInterface;
21+
use TYPO3\CMS\Backend\Clipboard\Type\CountMode;
2122
use TYPO3\CMS\Backend\Routing\UriBuilder;
2223
use TYPO3\CMS\Backend\Utility\BackendUtility;
2324
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
@@ -560,12 +561,16 @@ public function confirmMsgText(
560561
string $table,
561562
$reference,
562563
string $type,
564+
CountMode $countMode = CountMode::CURRENT,
563565
): string {
564566
if (!$this->getBackendUser()->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)) {
565567
return '';
566568
}
567569

568-
$selectedElements = $this->elFromTable($table);
570+
$selectedElements = match ($countMode) {
571+
CountMode::CURRENT => $this->elFromTable($table),
572+
CountMode::ALL => $this->elFromTable(),
573+
};
569574

570575
$labelKey = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.'
571576
. ($this->currentMode() === 'copy' ? 'copy' : 'move')
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the TYPO3 CMS project.
7+
*
8+
* It is free software; you can redistribute it and/or modify it under
9+
* the terms of the GNU General Public License, either version 2
10+
* of the License, or any later version.
11+
*
12+
* For the full copyright and license information, please read the
13+
* LICENSE.txt file that was distributed with this source code.
14+
*
15+
* The TYPO3 project - inspiring people to share!
16+
*/
17+
18+
namespace TYPO3\CMS\Backend\Clipboard\Type;
19+
20+
/**
21+
* Count modes for the clipboard
22+
*
23+
* @internal This class is a specific Backend implementation and is not considered part of the Public TYPO3 API.
24+
*/
25+
enum CountMode
26+
{
27+
case CURRENT;
28+
case ALL;
29+
}

typo3/sysext/backend/Classes/Controller/RecordListController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Psr\Http\Message\ServerRequestInterface;
2323
use TYPO3\CMS\Backend\Attribute\AsController;
2424
use TYPO3\CMS\Backend\Clipboard\Clipboard;
25+
use TYPO3\CMS\Backend\Clipboard\Type\CountMode;
2526
use TYPO3\CMS\Backend\Controller\Event\RenderAdditionalContentToRecordListEvent;
2627
use TYPO3\CMS\Backend\Module\ModuleData;
2728
use TYPO3\CMS\Backend\RecordList\DatabaseRecordList;
@@ -342,7 +343,7 @@ protected function getDocHeaderButtons(ModuleTemplate $view, Clipboard $clipboar
342343
if (($this->pagePermissions->createPagePermissionIsGranted() || $this->pagePermissions->editContentPermissionIsGranted()) && $this->editLockPermissions()) {
343344
$elFromTable = $clipboard->elFromTable();
344345
if (!empty($elFromTable)) {
345-
$confirmMessage = $clipboard->confirmMsgText('pages', $this->pageInfo, 'into');
346+
$confirmMessage = $clipboard->confirmMsgText('pages', $this->pageInfo, 'into', CountMode::ALL);
346347
$pasteButton = $buttonBar->makeLinkButton()
347348
->setHref($clipboard->pasteUrl('', $this->id))
348349
->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:clip_paste'))

0 commit comments

Comments
 (0)