Commit 9cddf73b authored by Alexander Nitsche's avatar Alexander Nitsche Committed by Anja Leichsenring
Browse files

[TASK] Enable EXT:impexp to include presets in export

Only tables with TCA configurations are available for the export of a
TYPO3 instance. The stored export configurations - so called presets -
were missing the TCA configuration and thus had to be exported and
imported separately in a database client.

This patch adds a TCA configuration for the export configurations and
thus makes them exportable and importable along with the main dump.
The presets are saved on PID=0 and hidden from record lists to
force the user to continue managing them with the export module.

Resolves: #92346
Releases: master, 10.4
Change-Id: Ic5a9babc91a93f8bf1561b697c4fca0ad548f734
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65770


Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Rémy DANIEL's avatarRémy DANIEL <dogawaf@no-log.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent 7877f53a
......@@ -15,6 +15,7 @@
namespace TYPO3\CMS\Impexp\Domain\Repository;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -109,6 +110,8 @@ class PresetRepository
{
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_impexp_presets');
$presetData = GeneralUtility::_GP('preset');
$context = GeneralUtility::makeInstance(Context::class);
$currentTimestamp = $context->getPropertyFromAspect('date', 'timestamp');
$err = false;
$msg = '';
// Save preset
......@@ -126,7 +129,8 @@ class PresetRepository
'public' => $inData['preset']['public'],
'title' => $inData['preset']['title'],
'item_uid' => $inData['pagetree']['id'],
'preset_data' => serialize($inData)
'preset_data' => serialize($inData),
'tstamp' => $currentTimestamp
],
['uid' => (int)$preset['uid']],
['preset_data' => Connection::PARAM_LOB]
......@@ -146,7 +150,9 @@ class PresetRepository
'public' => $inData['preset']['public'],
'title' => $inData['preset']['title'],
'item_uid' => (int)$inData['pagetree']['id'],
'preset_data' => serialize($inData)
'preset_data' => serialize($inData),
'tstamp' => $currentTimestamp,
'crdate' => $currentTimestamp
],
['preset_data' => Connection::PARAM_LOB]
);
......
<?php
return [
'ctrl' => [
'title' => 'LLL:EXT:impexp/Resources/Private/Language/locallang_tca.xlf:tx_impexp_presets',
'label' => 'title',
'default_sortby' => 'title',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'user_uid',
'typeicon_classes' => [
'default' => 'actions-cog'
],
'hideTable' => true,
'rootLevel' => -1,
],
'columns' => [
'title' => [
'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang_tca.xlf:title',
'config' => [
'type' => 'passthrough'
]
],
'public' => [
'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang_tca.xlf:public',
'config' => [
'type' => 'passthrough'
]
],
'user_uid' => [
'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang_tca.xlf:user_uid',
'config' => [
'type' => 'passthrough'
]
],
'item_uid' => [
'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang_tca.xlf:item_uid',
'config' => [
'type' => 'passthrough'
]
],
'preset_data' => [
'label' => 'LLL:EXT:impexp/Resources/Private/Language/locallang_tca.xlf:preset_data',
'config' => [
'type' => 'passthrough'
]
],
],
'types' => [
0 => [
'showitem' => 'title, public, user_uid, item_uid, preset_data',
],
],
];
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1600507075" source-language="en" datatype="plaintext" original="EXT:impexp/Resources/Private/Language/locallang_csh_tx_impexp_presets.xlf" date="2020-09-19T09:17:55Z" product-name="impexp">
<header/>
<body>
<trans-unit id="title.description" resname="title.description" xml:space="preserve">
<source>This title should describe in short what this TYPO3 export configuration is about.</source>
</trans-unit>
<trans-unit id="public.description" resname="public.description" xml:space="preserve">
<source>If this export configuration has public access granted, all backend users can use it. If not public, only the owner can select it.</source>
</trans-unit>
<trans-unit id="user_uid.description" resname="user_uid.description" xml:space="preserve">
<source>The user ID of the configuration owner.</source>
</trans-unit>
<trans-unit id="item_uid.description" resname="item_uid.description" xml:space="preserve">
<source>The root page ID of the page tree that will be exported. Please edit only if you know what you are doing.</source>
</trans-unit>
<trans-unit id="preset_data.description" resname="preset_data.description" xml:space="preserve">
<source>Technical insights of the export configuration. Please edit only if you know what you are doing.</source>
</trans-unit>
</body>
</file>
</xliff>
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1600505616" source-language="en" datatype="plaintext" original="EXT:impexp/Resources/Private/Language/locallang_tca.xlf" date="2020-09-19T08:53:36Z" product-name="impexp">
<header/>
<body>
<trans-unit id="tx_impexp_presets" resname="tx_impexp_presets" xml:space="preserve">
<source>Export Configuration</source>
</trans-unit>
<trans-unit id="title" resname="title" xml:space="preserve">
<source>Title</source>
</trans-unit>
<trans-unit id="public" resname="public" xml:space="preserve">
<source>Public</source>
</trans-unit>
<trans-unit id="user_uid" resname="user_uid" xml:space="preserve">
<source>Owner</source>
</trans-unit>
<trans-unit id="item_uid" resname="item_uid" xml:space="preserve">
<source>Page Root</source>
</trans-unit>
<trans-unit id="preset_data" resname="preset_data" xml:space="preserve">
<source>Configuration</source>
</trans-unit>
</body>
</file>
</xliff>
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* 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.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Impexp\Tests\Functional\Export;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Impexp\Controller\ExportController;
use TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
/**
* Test case
*/
class ExportControllerTest extends AbstractImportExportTestCase
{
/**
* @var ExportController|MockObject|AccessibleObjectInterface
*/
protected $exportControllerMock;
protected function setUp(): void
{
parent::setUp();
$this->exportControllerMock = $this->getAccessibleMock(ExportController::class, ['dummy'], [], '', false);
$this->exportControllerMock->_set('lang', $this->createMock(LanguageService::class));
}
/**
* @test
*/
public function tableSelectOptionsContainPresetsTable()
{
$tables = $this->exportControllerMock->_call('getTableSelectOptions');
self::assertArrayHasKey('tx_impexp_presets', $tables);
}
}
......@@ -3,3 +3,4 @@
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('xMOD_tx_impexp', 'EXT:impexp/Resources/Private/Language/locallang_csh.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_impexp_presets', 'EXT:impexp/Resources/Private/Language/locallang_csh_tx_impexp_presets.xlf');
......@@ -2,13 +2,10 @@
# Table structure for table 'tx_impexp_presets'
#
CREATE TABLE tx_impexp_presets (
uid int(11) NOT NULL auto_increment,
user_uid int(11) DEFAULT '0' NOT NULL,
title varchar(255) DEFAULT '' NOT NULL,
public tinyint(3) DEFAULT '0' NOT NULL,
item_uid int(11) DEFAULT '0' NOT NULL,
preset_data blob,
PRIMARY KEY (uid),
KEY lookup (item_uid)
);
......@@ -31,4 +28,4 @@ CREATE TABLE pages (
#
CREATE TABLE sys_template (
tx_impexp_origuid int(11) DEFAULT '0' NOT NULL
);
\ No newline at end of file
);
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