|
1
|
|
|
<?php |
|
2
|
|
|
namespace DERHANSEN\SfEventMgt\Hooks; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Hooks for DataHandler |
|
21
|
|
|
* |
|
22
|
|
|
* @author Torben Hansen <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class DataHandlerHooks |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Checks if the fields defined in $checkFields are set in the data-array of pi_flexform. |
|
29
|
|
|
* If a field is present and contains an empty value, the field is unset. |
|
30
|
|
|
* |
|
31
|
|
|
* Structure of the checkFields array: |
|
32
|
|
|
* |
|
33
|
|
|
* array('sheet' => array('field1', 'field2')); |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $status |
|
36
|
|
|
* @param string $table |
|
37
|
|
|
* @param string $id |
|
38
|
|
|
* @param array $fieldArray |
|
39
|
|
|
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $reference |
|
40
|
|
|
* |
|
41
|
|
|
* @return void |
|
42
|
|
|
*/ |
|
43
|
|
|
public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$reference) |
|
|
|
|
|
|
44
|
|
|
{ |
|
45
|
|
|
if ($table === 'tt_content' && $status == 'update' && isset($fieldArray['pi_flexform'])) { |
|
46
|
|
|
$checkFields = [ |
|
47
|
|
|
'notification' => [ |
|
48
|
|
|
'settings.notification.senderEmail', |
|
49
|
|
|
'settings.notification.senderName', |
|
50
|
|
|
'settings.notification.adminEmail', |
|
51
|
|
|
'settings.notification.registrationNew.userSubject', |
|
52
|
|
|
'settings.notification.registrationNew.adminSubject', |
|
53
|
|
|
'settings.notification.registrationConfirmed.userSubject', |
|
54
|
|
|
'settings.notification.registrationConfirmed.adminSubject', |
|
55
|
|
|
'settings.notification.registrationCancelled.userSubject', |
|
56
|
|
|
'settings.notification.registrationCancelled.adminSubject', |
|
57
|
|
|
], |
|
58
|
|
|
'sDEF' => [ |
|
59
|
|
|
'settings.templateLayout', |
|
60
|
|
|
'settings.detailPid', |
|
61
|
|
|
'settings.listPid', |
|
62
|
|
|
'settings.registrationPid', |
|
63
|
|
|
'settings.displayMode', |
|
64
|
|
|
'settings.orderField', |
|
65
|
|
|
'settings.orderDirection', |
|
66
|
|
|
'settings.topEventRestriction', |
|
67
|
|
|
'settings.queryLimit', |
|
68
|
|
|
'settings.category', |
|
69
|
|
|
'settings.restrictForeignRecordsToStoragePage', |
|
70
|
|
|
'settings.storagePage', |
|
71
|
|
|
'settings.registration.requiredFields' |
|
72
|
|
|
] |
|
73
|
|
|
]; |
|
74
|
|
|
|
|
75
|
|
|
$flexformData = GeneralUtility::xml2array($fieldArray['pi_flexform']); |
|
76
|
|
|
foreach ($checkFields as $sheet => $fields) { |
|
77
|
|
|
foreach ($fields as $field) { |
|
78
|
|
|
if (isset($flexformData['data'][$sheet]['lDEF'][$field]['vDEF']) && |
|
79
|
|
|
$flexformData['data'][$sheet]['lDEF'][$field]['vDEF'] === '' |
|
80
|
|
|
) { |
|
81
|
|
|
unset($flexformData['data'][$sheet]['lDEF'][$field]); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
// If remaining sheet does not contain fields, then remove the sheet |
|
86
|
|
|
if (isset($flexformData['data'][$sheet]['lDEF']) && $flexformData['data'][$sheet]['lDEF'] === []) { |
|
87
|
|
|
unset($flexformData['data'][$sheet]); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** @var \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools $flexFormTools */ |
|
92
|
|
|
$flexFormTools = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools'); |
|
93
|
|
|
$fieldArray['pi_flexform'] = $flexFormTools->flexArray2Xml($flexformData, true); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.