Commit 898cab02 authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[BUGFIX] Properly use TCA option "groupName" across Core TCA config

This change adds the "groupName" property to group
records within the "New Record" wizard into logical
groups, where TYPO3 Core defines
"system", "frontendaccess", "backendaccess" and "content".

Existing extensions with "groupName" continue to work
by shipping their own groups.

Resolves: #95366
Releases: master
Change-Id: I5c218823fa16917fc1d0cb8099899ee26a298cd6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71316

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent b1f77997
......@@ -422,8 +422,18 @@ class NewRecordController
$this->newPagesSelectPosition = !empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageSelectPosition']);
$displayNewPagesIntoLink = $this->newPagesInto && !empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageInside']);
$displayNewPagesAfterLink = $this->newPagesAfter && !empty($pageTS['mod.']['wizards.']['newRecord.']['pages.']['show.']['pageAfter']);
$iconFile = [];
$groupName = '';
$iconFile = [
'backendaccess' => $this->iconFactory->getIcon('status-user-group-backend', Icon::SIZE_SMALL)->render(),
'content' => $this->iconFactory->getIcon('content-panel', Icon::SIZE_SMALL)->render(),
'frontendaccess' => $this->iconFactory->getIcon('status-user-group-frontend', Icon::SIZE_SMALL)->render(),
'system' => $this->iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render(),
];
$groupTitles = [
'backendaccess' => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:recordgroup.backendaccess'),
'content' => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:recordgroup.content'),
'frontendaccess' => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:recordgroup.frontendaccess'),
'system' => $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:system_records'),
];
$groupedLinksOnTop = [];
foreach ($GLOBALS['TCA'] ?? [] as $table => $v) {
switch ($table) {
......@@ -483,47 +493,47 @@ class NewRecordController
break;
}
$nameParts = explode('_', $table);
$thisTitle = '';
$_EXTKEY = '';
if ($nameParts[0] === 'tx' || $nameParts[0] === 'tt') {
$groupName = $v['ctrl']['groupName'] ?? null;
if (!isset($iconFile[$groupName]) || $nameParts[0] === 'tx' || $nameParts[0] === 'tt') {
$groupName = $nameParts[1] ?? null;
// Try to extract extension name
$title = (string)($v['ctrl']['title'] ?? '');
if (strpos($title, 'LLL:EXT:') === 0) {
if ($groupName && strpos($title, 'LLL:EXT:') === 0) {
$_EXTKEY = substr($title, 8);
$_EXTKEY = substr($_EXTKEY, 0, (int)strpos($_EXTKEY, '/'));
if ($_EXTKEY !== '') {
// First try to get localisation of extension title
$temp = explode(':', substr($title, 9 + strlen($_EXTKEY)));
$langFile = $temp[0];
$thisTitle = $lang->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
$langFile = strtok(substr($title, 9 + strlen($_EXTKEY)), ':');
$groupTitle = $lang->sL('LLL:EXT:' . $_EXTKEY . '/' . $langFile . ':extension.title');
// If no localisation available, read title from ext_emconf.php
$extPath = ExtensionManagementUtility::extPath($_EXTKEY);
$extEmConfFile = $extPath . 'ext_emconf.php';
if (!$thisTitle && is_file($extEmConfFile)) {
if (!$groupTitle && is_file($extEmConfFile)) {
$EM_CONF = [];
include $extEmConfFile;
$thisTitle = $EM_CONF[$_EXTKEY]['title'];
$groupTitle = $EM_CONF[$_EXTKEY]['title'];
}
$extensionIcon = ExtensionManagementUtility::getExtensionIcon($extPath);
if (!empty($extensionIcon)) {
$iconFile[$_EXTKEY] = '<img src="' . PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::getExtensionIcon($extPath, true)) . '" width="16" height="16" alt="' . $thisTitle . '" />';
$iconFile[$groupName] = '<img src="' . PathUtility::getAbsoluteWebPath(ExtensionManagementUtility::getExtensionIcon(
$extPath,
true
)) . '" width="16" height="16" alt="' . $groupTitle . '" />';
}
if (!empty($groupTitle)) {
$groupTitles[$groupName] = $groupTitle;
} else {
$groupTitles[$groupName] = ucwords($_EXTKEY);
}
}
}
if (empty($thisTitle)) {
$_EXTKEY = $thisTitle = $nameParts[1];
}
} else {
$_EXTKEY = 'system';
$thisTitle = $lang->getLL('system_records');
$iconFile['system'] = $this->iconFactory->getIcon('apps-pagetree-root', Icon::SIZE_SMALL)->render();
}
if ($groupName === '' || $groupName !== $_EXTKEY) {
$groupName = empty($v['ctrl']['groupName']) ? $_EXTKEY : $v['ctrl']['groupName'];
// Fall back to "system"
if (!$groupName) {
$groupName = 'system';
}
$this->tRows[$groupName]['title'] = $thisTitle;
$this->tRows[$groupName]['icon'] = $iconFile[$groupName] ?? '';
$this->tRows[$groupName]['title'] = $groupTitles[$groupName] ?? $title ?? '';
$this->tRows[$groupName]['icon'] = $iconFile[$groupName] ?? $iconFile['system'] ?? '';
$this->tRows[$groupName]['html'][$table] = $this->renderLink(htmlspecialchars($lang->sL($v['ctrl']['title'])), $table, $this->id);
}
}
......
......@@ -11,6 +11,7 @@ return [
'default_sortby' => 'title',
'prependAtCopy' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.prependAtCopy',
'adminOnly' => true,
'groupName' => 'backendaccess',
'rootLevel' => 1,
'typeicon_classes' => [
'default' => 'status-user-group-backend',
......
......@@ -11,6 +11,7 @@ return [
'delete' => 'deleted',
'adminOnly' => true,
'rootLevel' => 1,
'groupName' => 'backendaccess',
'default_sortby' => 'admin, username',
'enablecolumns' => [
'disabled' => 'disable',
......
......@@ -13,6 +13,7 @@ return [
'default_sortby' => 'title',
'versioningWS' => true,
'rootLevel' => -1,
'groupName' => 'content',
'origUid' => 't3_origuid',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
......
......@@ -9,6 +9,7 @@ return [
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'versioningWS' => true,
'groupName' => 'content',
'origUid' => 't3_origuid',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
......
......@@ -11,6 +11,7 @@ return [
'delete' => 'deleted',
'descriptionColumn' => 'description',
'rootLevel' => 1,
'groupName' => 'system',
'versioningWS_alwaysAllowLiveEdit' => true, // Only have LIVE records of file storages
'enablecolumns' => [],
'typeicon_classes' => [
......@@ -149,7 +150,7 @@ return [
'types' => [
'0' => ['showitem' => '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
name, driver, configuration, is_default, auto_extract_metadata, processingfolder,
name, driver, configuration, is_default, auto_extract_metadata, processingfolder,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:accesscapabilities,
--palette--;Capabilities;capabilities,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
......
......@@ -11,6 +11,7 @@ return [
'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_filemounts',
'adminOnly' => true,
'rootLevel' => 1,
'groupName' => 'backendaccess',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
......
......@@ -8,6 +8,7 @@ return [
'default_sortby' => 'title',
'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_language',
'adminOnly' => true,
'groupName' => 'system',
'rootLevel' => 1,
'enablecolumns' => [
'disabled' => 'hidden',
......
......@@ -9,6 +9,7 @@ return [
'cruser_id' => 'cruser_id',
'adminOnly' => true,
'rootLevel' => 1,
'groupName' => 'backendaccess',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
......
......@@ -246,6 +246,15 @@
<trans-unit id="system_records" resname="system_records">
<source>System Records</source>
</trans-unit>
<trans-unit id="recordgroup.content" resname="recordgroup.content">
<source>Content</source>
</trans-unit>
<trans-unit id="recordgroup.backendaccess" resname="recordgroup.backendaccess">
<source>Backend Access</source>
</trans-unit>
<trans-unit id="recordgroup.frontendaccess" resname="recordgroup.frontendaccess">
<source>Frontend Access</source>
</trans-unit>
<trans-unit id="1_selectType" resname="1_selectType">
<source>First select the type of the new content element</source>
</trans-unit>
......
......@@ -9,6 +9,7 @@ return [
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'versioningWS' => true,
'groupName' => 'system',
'origUid' => 't3_origuid',
'sortby' => 'sorting',
'delete' => 'deleted',
......
......@@ -9,6 +9,7 @@ return [
'cruser_id' => 'cruser_id',
'delete' => 'deleted',
'default_sortby' => 'title',
'groupName' => 'frontendaccess',
'prependAtCopy' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.prependAtCopy',
'enablecolumns' => [
'disabled' => 'hidden',
......
......@@ -8,6 +8,7 @@ return [
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'groupName' => 'frontendaccess',
'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:fe_users',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'prependAtCopy' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.prependAtCopy',
'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:sys_template',
'versioningWS' => true,
'groupName' => 'system',
'origUid' => 't3_origuid',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
......
......@@ -13,6 +13,7 @@ return [
'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:tt_content',
'delete' => 'deleted',
'versioningWS' => true,
'groupName' => 'content',
'origUid' => 't3_origuid',
'type' => 'CType',
'hideAtCopy' => true,
......
......@@ -8,6 +8,7 @@ return [
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'groupName' => 'system',
'type' => 'type',
'default_sortby' => 'crdate',
'enablecolumns' => [
......
......@@ -10,6 +10,7 @@ return [
'cruser_id' => 'createdby',
'tstamp' => 'updatedon',
'versioningWS' => false,
'groupName' => 'system',
'default_sortby' => 'source_host, source_path',
'rootLevel' => -1,
'security' => [
......
......@@ -13,6 +13,7 @@ return [
'default' => 'mimetypes-x-tx_scheduler_task_group',
],
'adminOnly' => true, // Only admin users can edit
'groupName' => 'system',
'rootLevel' => 1,
'enablecolumns' => [
'disabled' => 'hidden',
......
......@@ -8,6 +8,7 @@ return [
'cruser_id' => 'cruser',
'prependAtCopy' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.prependAtCopy',
'delete' => 'deleted',
'groupName' => 'content',
'title' => 'LLL:EXT:sys_note/Resources/Private/Language/locallang_tca.xlf:sys_note',
'typeicon_classes' => [
'default' => 'mimetypes-x-sys_note',
......
......@@ -8,6 +8,7 @@ return [
'descriptionColumn' => 'description',
'adminOnly' => true,
'rootLevel' => 1,
'groupName' => 'system',
'delete' => 'deleted',
'typeicon_classes' => [
'default' => 'mimetypes-x-sys_workspace',
......
Markdown is supported
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