From f23c2aa2fbec379e909c72ae2c32fdab8a87f565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanel=20P=C3=B5ld?= Date: Mon, 22 Jul 2024 11:17:43 +0300 Subject: [PATCH] [FEATURE] bidirectional contact records for pages --- Configuration/TCA/Overrides/pages.php | 61 ++++++++++++------- .../TCA/tx_personnel_domain_model_person.php | 33 ++++++++++ ext_tables.sql | 13 ++++ 3 files changed, 85 insertions(+), 22 deletions(-) diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index 5d6cfb3..31b774d 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -4,33 +4,50 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); -$personnelConiguration = $extensionConfiguration->get('personnel'); +$extConf = $extensionConfiguration->get('personnel'); -$tempColumns = array( - 'tx_personnel_authors' => [ - 'exclude' => 1, - 'label' => 'Persons', - 'config' => [ - 'type' => 'select', - 'renderType' => 'selectMultipleSideBySide', - 'foreign_table' => 'tx_personnel_domain_model_person', - 'foreign_table_where' => 'AND tx_personnel_domain_model_person.sys_language_uid IN (-1,0)', - 'size' => '3', - 'behaviour' => [ - 'allowLanguageSynchronization' => true, +if ($extConf['personnelEnableAuthors']) { + $tempColumns = array( + 'tx_personnel' => [ + 'exclude' => 1, + 'label' => 'Persons', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectMultipleSideBySide', + 'foreign_table' => 'tx_personnel_domain_model_person', + 'MM' => 'tx_personnel_mm', + 'MM_opposite_field' => 'pages', + 'MM_match_fields' => [ + 'tablenames' => 'pages', + 'fieldname' => 'tx_personnel', + ], + 'size' => 5, + 'autoSizeMax' => 5, + 'maxitems' => 9999, + 'multiple' => 0, + 'fieldControl' => [ + 'editPopup' => [ + 'disabled' => true, + 'options' => [ + 'windowOpenParameters' => 'height=300,width=500,status=0,menubar=0,scrollbars=1', + ], + ], + 'addRecord' => [ + 'disabled' => true, + ], + 'listModule' => [ + 'disabled' => true, + ], + ], ], - ] - ], -); - -ExtensionManagementUtility::addTCAcolumns('pages', $tempColumns, 1); - -if ($personnelConiguration['personnelEnableAuthors']) { + ], + ); + ExtensionManagementUtility::addTCAcolumns('pages', $tempColumns, 1); ExtensionManagementUtility::addToAllTCAtypes( 'pages', - '--palette--;Personnel;personnelcontact', + '--palette--;Personnel;personnelInPages', '1', 'after:subtitle' ); - $GLOBALS['TCA']['pages']['palettes']['personnelcontact']['showitem'] = 'tx_personnel_authors,'; + $GLOBALS['TCA']['pages']['palettes']['personnelInPages']['showitem'] = 'tx_personnel,'; } diff --git a/Configuration/TCA/tx_personnel_domain_model_person.php b/Configuration/TCA/tx_personnel_domain_model_person.php index a1c67db..16448a7 100644 --- a/Configuration/TCA/tx_personnel_domain_model_person.php +++ b/Configuration/TCA/tx_personnel_domain_model_person.php @@ -46,6 +46,7 @@ --palette--;;paletteLanguage, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories, selected_categories, + --div--;Pages,pages, ' ] ], @@ -563,5 +564,37 @@ ], ] ], + 'pages' => [ + 'exclude' => 1, + 'label' => 'Pages', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectMultipleSideBySide', + 'foreign_table' => 'pages', + 'MM' => 'tx_personnel_mm', + 'MM_match_fields' => [ + 'tablenames' => 'pages', + 'fieldname' => 'tx_personnel', + ], + 'size' => 5, + 'autoSizeMax' => 5, + 'maxitems' => 9999, + 'multiple' => 0, + 'fieldControl' => [ + 'editPopup' => [ + 'disabled' => true, + 'options' => [ + 'windowOpenParameters' => 'height=300,width=500,status=0,menubar=0,scrollbars=1', + ], + ], + 'addRecord' => [ + 'disabled' => true, + ], + 'listModule' => [ + 'disabled' => true, + ], + ], + ], + ], ], ]; diff --git a/ext_tables.sql b/ext_tables.sql index 6fe1ca0..458588a 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -37,4 +37,17 @@ CREATE TABLE tx_personnel_domain_model_person ( CREATE TABLE pages ( tx_personnel_authors tinytext, + tx_personnel INT UNSIGNED DEFAULT 0 NOT NULL, +); + +CREATE TABLE tx_personnel_mm ( + uid_local int(11) DEFAULT '0' NOT NULL, + uid_foreign int(11) DEFAULT '0' NOT NULL, + sorting int(11) DEFAULT '0' NOT NULL, + sorting_foreign int(11) DEFAULT '0' NOT NULL, + tablenames varchar(255) DEFAULT '' NOT NULL, + fieldname varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (uid_local, uid_foreign), + KEY uid_local (uid_local), + KEY uid_foreign (uid_foreign) );