Skip to content

Commit

Permalink
Merge pull request #371 from t3solution/5.3.3
Browse files Browse the repository at this point in the history
New release v5.3.3
  • Loading branch information
t3solution authored Dec 19, 2023
2 parents 3885e06 + 5abc5dd commit 16f57cd
Show file tree
Hide file tree
Showing 162 changed files with 7,222 additions and 8,427 deletions.
71 changes: 40 additions & 31 deletions Classes/Backend/EventListener/FlexForm/FlexformEvent.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace T3SBS\T3sbootstrap\Backend\EventListener\FlexForm;
Expand All @@ -8,6 +9,8 @@
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

/*
* This file is part of the TYPO3 extension t3sbootstrap.
Expand All @@ -17,41 +20,47 @@
*/
class FlexformEvent
{
public function __invoke(AfterFlexFormDataStructureParsedEvent $event): void
{
$extconf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');

if (array_key_exists('flexformExtend', $extconf) && $extconf['flexformExtend'] === '1') {

$dataStructure = $event->getDataStructure();
$identifier = $event->getIdentifier();

$ffPath = '/fileadmin/T3SB/FlexForms/';

foreach ( $GLOBALS['TCA']['tt_content']['columns']['tx_t3sbootstrap_flexform']['config']['ds'] as $key=>$flexForm ) {
public function __invoke(AfterFlexFormDataStructureParsedEvent $event): void
{
$extconf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');
$configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
$settings = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
't3sbootstrap',
'm1'
);

$flexForms[$key] = substr($flexForm, 46, -4);
}
if (array_key_exists('flexformExtend', $extconf) && $extconf['flexformExtend'] === '1') {
$dataStructure = $event->getDataStructure();
$identifier = $event->getIdentifier();

if ( array_key_exists($identifier['dataStructureKey'],$flexForms) ) {
if (!empty($settings['sitepackage'])) {
$ffPath = 'EXT:t3sb_package/T3SB/FlexForms/';
} else {
$ffPath = '/fileadmin/T3SB/FlexForms/';
}

if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content'
&& $identifier['fieldName'] === 'tx_t3sbootstrap_flexform' && $identifier['dataStructureKey']) {
foreach ($GLOBALS['TCA']['tt_content']['columns']['tx_t3sbootstrap_flexform']['config']['ds'] as $key=>$flexForm) {
$flexForms[$key] = substr($flexForm, 46, -4);
}

$file = Environment::getPublicPath() . $ffPath.$flexForms[$identifier['dataStructureKey']].'.xml';
if (file_exists($file)) {
$content = @file_get_contents($file);
if ($content) {
$dataStructure['sheets']['extraEntry'] = GeneralUtility::xml2array($content);
if (array_key_exists($identifier['dataStructureKey'], $flexForms)) {
if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content'
&& $identifier['fieldName'] === 'tx_t3sbootstrap_flexform' && $identifier['dataStructureKey']) {
$file = Environment::getPublicPath() . $ffPath.$flexForms[$identifier['dataStructureKey']].'.xml';
if (file_exists($file)) {
$content = @file_get_contents($file);
if ($content) {
$dataStructure['sheets']['extraEntry'] = GeneralUtility::xml2array($content);

$extraDataStructure['sheets']['extraEntry'] = GeneralUtility::xml2array($content);
ArrayUtility::mergeRecursiveWithOverrule($dataStructure, $extraDataStructure);
}
}
}
$extraDataStructure['sheets']['extraEntry'] = GeneralUtility::xml2array($content);
ArrayUtility::mergeRecursiveWithOverrule($dataStructure, $extraDataStructure);
}
}
}

$event->setDataStructure($dataStructure);
}
}
}
$event->setDataStructure($dataStructure);
}
}
}
}
Loading

0 comments on commit 16f57cd

Please sign in to comment.