Skip to content

Commit

Permalink
Merge pull request #327 from t3solution/5.2.20
Browse files Browse the repository at this point in the history
Development version - Support of TYPO3 v12 & drop support of v11
  • Loading branch information
t3solution authored May 28, 2023
2 parents 2ea4965 + 414fc2e commit 39a92d9
Show file tree
Hide file tree
Showing 202 changed files with 20,312 additions and 19,733 deletions.
57 changes: 57 additions & 0 deletions Classes/Backend/EventListener/FlexForm/FlexformEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);

namespace T3SBS\T3sbootstrap\Backend\EventListener\FlexForm;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\Environment;

/*
* This file is part of the TYPO3 extension t3sbootstrap.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
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 ) {

$flexForms[$key] = substr($flexForm, 46, -4);
}

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);
}
}
}

$event->setDataStructure($dataStructure);
}
}
}
}
30 changes: 30 additions & 0 deletions Classes/Backend/EventListener/FlexForm/NewsFlexformEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);

namespace T3SBS\T3sbootstrap\Backend\EventListener\FlexForm;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Configuration\Event\AfterFlexFormDataStructureParsedEvent;
use TYPO3\CMS\Core\Utility\ArrayUtility;

class NewsFlexformEvent
{
public function __invoke(AfterFlexFormDataStructureParsedEvent $event): void
{
$dataStructure = $event->getDataStructure();
$identifier = $event->getIdentifier();

if ($identifier['type'] === 'tca' && $identifier['tableName'] === 'tt_content'
&& ($identifier['dataStructureKey'] === '*,news_pi1' || $identifier['dataStructureKey'] === '*,news_newsliststicky')) {

$file = GeneralUtility::getFileAbsFileName('EXT:t3sbootstrap/Resources/Private/Extensions/news/Configuration/FlexForms/News.xml');
$content = @file_get_contents($file);
if ($content) {
$extraDataStructure['sheets']['extraEntry'] = GeneralUtility::xml2array($content);
ArrayUtility::mergeRecursiveWithOverrule($dataStructure, $extraDataStructure);
}
}

$event->setDataStructure($dataStructure);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);

namespace T3SBS\T3sbootstrap\EventListener\TCA;
namespace T3SBS\T3sbootstrap\Backend\EventListener\TCA;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent;
Expand Down
76 changes: 39 additions & 37 deletions Classes/Backend/FormDataProvider/FlexFormManipulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@ class FlexFormManipulation implements FormDataProviderInterface
public function addData(array $result): array
{
$configurationManager =GeneralUtility::makeInstance(BackendConfigurationManager::class);
$configurationManager->getDefaultBackendStoragePid();
$setup = $configurationManager->getTypoScriptSetup();

$flexforms = $setup['plugin.']['tx_t3sbootstrap.']['flexform.'];

# if FlexFormManipulation
if ( !empty($flexforms) ) {

$cType = $result['databaseRow']['CType'];
if ( !empty($flexforms) && !empty($result['databaseRow']['CType']) ) {

switch ($cType) {
switch ($result['databaseRow']['CType']) {
case 't3sbs_card':
$flexformFile = 'cardSetting.';
break;
Expand Down Expand Up @@ -101,23 +97,30 @@ public function addData(array $result): array
$flexformFile = 'bootstrap.';
}

$dataStructure = $result['processedTca']['columns']['tx_t3sbootstrap_flexform']['config']['ds'];
$dataStructure = [];

if (!empty($result['processedTca']['columns']['tx_t3sbootstrap_flexform'])) {

foreach ($flexforms as $file=>$fields) {
if ( $file == $flexformFile ) {
foreach ($fields as $field=>$mod) {
if ( !empty($mod['add']) ) {
foreach (explode(',',$mod['add']) as $add) {
if (!empty($dataStructure['sheets'])) {
foreach ($dataStructure['sheets'] as $sheetName=>$fieldsInSheet) {
foreach ($fieldsInSheet as $fieldArr) {
foreach ($fieldArr as $fieldName) {
if (!empty($fieldName) && is_array($fieldName)) {
foreach ($fieldName as $key=>$name) {
if ($name['config']['type'] == 'select') {
if (substr($field, 0, -1) == $key) {
array_push($dataStructure['sheets'][$sheetName]['ROOT']['el'][$key]['config']['items'],
[trim($add),lcfirst(GeneralUtility::underscoredToUpperCamelCase(trim($add)))]);
$dataStructure = $result['processedTca']['columns']['tx_t3sbootstrap_flexform']['config']['ds'];

$addArr = [];

foreach ($flexforms as $file=>$fields) {
if ( $file == $flexformFile ) {
foreach ($fields as $field=>$mod) {
if ( !empty($mod['add']) ) {
foreach (explode(',',$mod['add']) as $add) {
if (!empty($dataStructure['sheets'])) {
foreach ($dataStructure['sheets'] as $sheetName=>$fieldsInSheet) {
foreach ($fieldsInSheet as $fieldArr) {
foreach ($fieldArr as $fieldName) {
if (!empty($fieldName) && $fieldName !== 'array' && is_array($fieldName)) {
foreach ($fieldName as $key=>$name) {
if (!empty($name['config']['type']) && $name['config']['type'] == 'select') {
if (substr($field, 0, -1) == $key) {
$addArr = ['label' => trim($add), 'value' => lcfirst(GeneralUtility::underscoredToUpperCamelCase(trim($add)))];
array_push($dataStructure['sheets'][$sheetName]['ROOT']['el'][$key]['config']['items'], $addArr);
}
}
}
}
Expand All @@ -127,20 +130,20 @@ public function addData(array $result): array
}
}
}
}
if ($mod['reduce']) {
foreach( explode(',',$mod['reduce']) as $reduce ) {
if (!empty($dataStructure['sheets'])) {
foreach ($dataStructure['sheets'] as $sheetName=>$fieldsInSheet) {
foreach ($fieldsInSheet as $fieldArr) {
foreach ($fieldArr as $fieldName) {
if (!empty($fieldName) && is_array($fieldName)) {
foreach ($fieldName as $key=>$name) {
if ($name['config']['type'] == 'select') {
if (substr($field, 0, -1) == $key) {
foreach ($name['config']['items'] as $k=>$item ) {
if (trim($item[1]) == trim($reduce)) {
unset($dataStructure['sheets'][$sheetName]['ROOT']['el'][$key]['config']['items'][$k]);
if ($mod['reduce']) {
foreach( explode(',',$mod['reduce']) as $reduce ) {
if (!empty($dataStructure['sheets'])) {
foreach ($dataStructure['sheets'] as $sheetName=>$fieldsInSheet) {
foreach ($fieldsInSheet as $fieldArr) {
foreach ($fieldArr as $fieldName) {
if (!empty($fieldName) && $fieldName !== 'array' && is_array($fieldName)) {
foreach ($fieldName as $key=>$name) {
if (!empty($name['config']['type']) && $name['config']['type'] == 'select') {
if (substr($field, 0, -1) == $key) {
foreach ($name['config']['items'] as $k=>$item ) {
if (!empty($item['value']) && trim($item['value']) == trim($reduce)) {
unset($dataStructure['sheets'][$sheetName]['ROOT']['el'][$key]['config']['items'][$k]);
}
}
}
}
Expand All @@ -156,7 +159,6 @@ public function addData(array $result): array
}
}
}

$result['processedTca']['columns']['tx_t3sbootstrap_flexform']['config']['ds'] = $dataStructure;
}

Expand Down
Loading

0 comments on commit 39a92d9

Please sign in to comment.