mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2025-04-27 06:10:51 +02:00

[FEATURE] Move the tea index configuration to FlexForms ()

This is part 1.

(Part 2 is about migrating the storage page for new records
created in the FE editor.)

Part of 
This commit is contained in:
Oliver Klee 2025-04-14 19:28:19 +02:00 committed by GitHub
parent 8a946f0711
commit 2b0d053bd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 163 additions and 29 deletions

View file

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<pagesAndFolders>
<ROOT>
<TCEforms>
<sheetTitle>
LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_index.settings.tab.pagesAndFolders
</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<settings.singleViewPageUid>
<TCEforms>
<label>
LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_index.settings.pagesAndFolders.singleViewPageUid
</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<minitems>1</minitems>
<maxitems>1</maxitems>
<hideSuggest>1</hideSuggest>
</config>
</TCEforms>
</settings.singleViewPageUid>
<persistence.storagePid>
<TCEforms>
<label>
LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_index.settings.pagesAndFolders.storagePid
</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>3</size>
<minitems>1</minitems>
<maxitems>99</maxitems>
<hideSuggest>1</hideSuggest>
</config>
</TCEforms>
</persistence.storagePid>
<persistence.recursive>
<TCEforms>
<label>
LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_index.settings.pagesAndFolders.recursive
</label>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">&amp;nbsp;</numIndex>
<numIndex index="1">0</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">1</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">2</numIndex>
<numIndex index="1">2</numIndex>
</numIndex>
<numIndex index="3" type="array">
<numIndex index="0">3</numIndex>
<numIndex index="1">3</numIndex>
</numIndex>
<numIndex index="4" type="array">
<numIndex index="0">4</numIndex>
<numIndex index="1">4</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</persistence.recursive>
</el>
</ROOT>
</pagesAndFolders>
</sheets>
</T3DataStructure>

View file

@ -1,5 +1,6 @@
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3') || die();
@ -7,7 +8,7 @@ defined('TYPO3') || die();
call_user_func(
static function (): void {
// This makes the plugin selectable in the BE.
ExtensionUtility::registerPlugin(
$indexPluginSignature = ExtensionUtility::registerPlugin(
// extension name, matching the PHP namespaces (but without the vendor)
'Tea',
// arbitrary, but unique plugin name (not visible in the BE)
@ -18,24 +19,31 @@ call_user_func(
'EXT:tea/Resources/Public/Icons/Extension.svg'
);
ExtensionUtility::registerPlugin(
// These two commands add the flexform configuration for the plugin.
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$indexPluginSignature] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
$indexPluginSignature,
'FILE:EXT:tea/Configuration/FlexForms/TeaIndex.xml'
);
$showPluginSignature = ExtensionUtility::registerPlugin(
'Tea',
'TeaShow',
'LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_show',
'EXT:tea/Resources/Public/Icons/Extension.svg'
);
ExtensionUtility::registerPlugin(
$editorPluginSignature = ExtensionUtility::registerPlugin(
'Tea',
'TeaFrontEndEditor',
'LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_frontend_editor',
'EXT:tea/Resources/Public/Icons/Extension.svg'
);
// This removes the default controls from the plugin.
// This removes the default controls from the plugins.
$controlsToRemove = 'recursive,pages';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teaindex'] = $controlsToRemove;
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teashow'] = $controlsToRemove;
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_teafrontendeditor'] = $controlsToRemove;
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$indexPluginSignature] = $controlsToRemove;
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$showPluginSignature] = $controlsToRemove;
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$editorPluginSignature] = $controlsToRemove;
}
);

View file

@ -1,13 +1,10 @@
plugin.tx_tea {
persistence {
# cat=plugin.tx_tea//a; type=string; label=Default storage PID
storagePid =
# cat=plugin.tx_tea//a; type=int; label=UID of the page/folder where all new records will be created
newRecordStoragePid =
}
settings {
# cat=plugin.tx_tea//a; type=int; label=UID of the page with the single view
singleViewPageUid =
}
}

View file

@ -12,12 +12,4 @@ plugin.tx_tea {
0 = EXT:tea/Resources/Private/Layouts/
}
}
persistence {
storagePid = {$plugin.tx_tea.persistence.storagePid}
}
settings {
singleViewPageUid = {$plugin.tx_tea.settings.singleViewPageUid}
}
}

View file

@ -7,6 +7,22 @@
<source>Tea list</source>
<target>Teeliste</target>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.tab.pagesAndFolders" approved="yes">
<source>Pages and folders</source>
<target>Seiten und Ordner</target>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.pagesAndFolders.singleViewPageUid" approved="yes">
<source>Page with the single view</source>
<target>Seite mit der Einzelansicht</target>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.pagesAndFolders.storagePid" approved="yes">
<source>Folders with the tea records</source>
<target>Ordner mit den Teedatensätzen</target>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.pagesAndFolders.recursive" approved="yes">
<source>Recursion into subfolders</source>
<target>Rekursion in Unterordner</target>
</trans-unit>
<trans-unit id="plugin.tea_show" approved="yes">
<source>Tea single view</source>
<target>Tee-Einzelansicht</target>

View file

@ -6,6 +6,18 @@
<trans-unit id="plugin.tea_index">
<source>Tea list</source>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.tab.pagesAndFolders">
<source>Pages and folders</source>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.pagesAndFolders.singleViewPageUid">
<source>Page with the single view</source>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.pagesAndFolders.storagePid">
<source>Folders with the tea records</source>
</trans-unit>
<trans-unit id="plugin.tea_index.settings.pagesAndFolders.recursive">
<source>Recursion into subfolders</source>
</trans-unit>
<trans-unit id="plugin.tea_show">
<source>Tea single view</source>
</trans-unit>

View file

@ -1,4 +1,21 @@
"tt_content"
,"uid","pid","CType","header","list_type"
,1,1,"list","Tea index","tea_teaindex"
,2,3,"list","Tea show","tea_teashow"
,"uid","pid","CType","header","list_type","pi_flexform"
,1,1,"list","Tea index","tea_teaindex","<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
<T3FlexForms>
<data>
<sheet index=""pagesAndFolders"">
<language index=""lDEF"">
<field index=""persistence.storagePid"">
<value index=""vDEF"">2</value>
</field>
<field index=""persistence.recursive"">
<value index=""vDEF"">4</value>
</field>
<field index=""settings.singleViewPage"">
<value index=""vDEF"">3</value>
</field>
</language>
</sheet>
</data>
</T3FlexForms>"
,2,3,"list","Tea show","tea_teashow",""

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -3,3 +3,4 @@
,1,0,"Rootpage","/"
,2,1,"Storage","/storage"
,3,1,"Show","/show"
,4,2,"Storage subfolder","/storage-subfolder"

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -0,0 +1,3 @@
"tx_tea_domain_model_tea"
,"uid","pid","title"
,1,4,"Tea in subfolder"
Can't render this file because it has a wrong number of fields in line 2.

View file

@ -1,5 +0,0 @@
plugin.tx_tea {
persistence {
storagePid = 2
}
}

View file

@ -38,7 +38,6 @@ final class TeaControllerTest extends FunctionalTestCase
'constants' => [
'EXT:fluid_styled_content/Configuration/TypoScript/constants.typoscript',
'EXT:tea/Configuration/TypoScript/constants.typoscript',
'EXT:tea/Tests/Functional/Controller/Fixtures/TypoScript/Constants/PluginConfiguration.typoscript',
],
'setup' => [
'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript',
@ -70,7 +69,7 @@ final class TeaControllerTest extends FunctionalTestCase
}
#[Test]
public function indexActionRendersAllAvailableTeas(): void
public function indexActionRendersAllAvailableTeasOnStoragePage(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/Teas.csv');
@ -82,6 +81,18 @@ final class TeaControllerTest extends FunctionalTestCase
self::assertStringContainsString('Oolong', $html);
}
#[Test]
public function indexActionWithRecursionCanRenderTeaInStoragePageSubfolder(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/TeaInSubfolder.csv');
$request = (new InternalRequest())->withPageId(1);
$html = (string)$this->executeFrontendSubRequest($request)->getBody();
self::assertStringContainsString('Tea in subfolder', $html);
}
#[Test]
public function showActionRendersTheGivenTeas(): void
{