1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* Copyright (C) |
6
|
|
|
* Nathan Boiron <[email protected]> |
7
|
|
|
* Romain Canon <[email protected]> |
8
|
|
|
* |
9
|
|
|
* This file is part of the TYPO3 NotiZ project. |
10
|
|
|
* It is free software; you can redistribute it and/or modify it |
11
|
|
|
* under the terms of the GNU General Public License, either |
12
|
|
|
* version 3 of the License, or any later version. |
13
|
|
|
* |
14
|
|
|
* For the full copyright and license information, see: |
15
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\TCA; |
19
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Notification\TCA\EntityTcaWriter; |
21
|
|
|
use CuyZ\Notiz\Core\Notification\TCA\Processor\BodySlotsProcessor; |
22
|
|
|
|
23
|
|
|
class EntityEmailTcaWriter extends EntityTcaWriter |
24
|
|
|
{ |
25
|
|
|
const EMAIL_LLL = 'LLL:EXT:notiz/Resources/Private/Language/Notification/Email/Email.xlf'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var EntityEmailTcaService |
29
|
|
|
*/ |
30
|
|
|
protected $service; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return string |
34
|
|
|
*/ |
35
|
|
|
protected function getNotificationTcaServiceClass(): string |
36
|
|
|
{ |
37
|
|
|
return EntityEmailTcaService::class; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return string |
42
|
|
|
*/ |
43
|
|
|
protected function getChannelLabel(): string |
44
|
|
|
{ |
45
|
|
|
return self::EMAIL_LLL . ':field.mailer'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @inheritdoc |
50
|
|
|
*/ |
51
|
|
|
protected function buildTcaArray(): array |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
'ctrl' => $this->getCtrl(), |
55
|
|
|
|
56
|
|
|
'palettes' => [ |
57
|
|
|
'mail' => [ |
58
|
|
|
'showitem' => 'subject,markers,--linebreak--,body', |
59
|
|
|
'canNotCollapse' => true, |
60
|
|
|
], |
61
|
|
|
'send_to' => [ |
62
|
|
|
'showitem' => 'send_to,--linebreak--,send_to_provided', |
63
|
|
|
'canNotCollapse' => true, |
64
|
|
|
], |
65
|
|
|
'send_cc' => [ |
66
|
|
|
'showitem' => 'send_cc,--linebreak--,send_cc_provided', |
67
|
|
|
'canNotCollapse' => true, |
68
|
|
|
], |
69
|
|
|
'send_bcc' => [ |
70
|
|
|
'showitem' => 'send_bcc,--linebreak--,send_bcc_provided', |
71
|
|
|
'canNotCollapse' => true, |
72
|
|
|
], |
73
|
|
|
], |
74
|
|
|
|
75
|
|
|
'types' => [ |
76
|
|
|
'0' => [ |
77
|
|
|
'showitem' => ' |
78
|
|
|
error_message, |
79
|
|
|
title, description, hidden, |
80
|
|
|
--div--;' . self::LLL . ':tab.event, |
81
|
|
|
event, event_configuration_flex, |
82
|
|
|
--div--;' . self::LLL . ':tab.channel, |
83
|
|
|
channel, |
84
|
|
|
--div--;' . self::EMAIL_LLL . ':tab.mail_configuration, |
85
|
|
|
layout, |
86
|
|
|
--palette--;' . self::EMAIL_LLL . ':palette.mail;mail, |
87
|
|
|
--div--;' . self::EMAIL_LLL . ':tab.mail_recipients, |
88
|
|
|
--palette--;' . self::EMAIL_LLL . ':palette.mail_recipients_to;send_to, |
89
|
|
|
--palette--;' . self::EMAIL_LLL . ':palette.mail_recipients_cc;send_cc, |
90
|
|
|
--palette--;' . self::EMAIL_LLL . ':palette.mail_recipients_bcc;send_bcc, |
91
|
|
|
--div--;' . self::EMAIL_LLL . ':tab.mail_sender, |
92
|
|
|
sender_custom,--linebreak--,sender,sender_default, |
93
|
|
|
', |
94
|
|
|
], |
95
|
|
|
], |
96
|
|
|
|
97
|
|
|
'columns' => [ |
98
|
|
|
|
99
|
|
|
// Mail configuration |
100
|
|
|
|
101
|
|
|
'layout' => [ |
102
|
|
|
'exclude' => 1, |
103
|
|
|
'label' => self::EMAIL_LLL . ':field.layout', |
104
|
|
|
'l10n_mode' => 'exclude', |
105
|
|
|
'l10n_display' => 'defaultAsReadonly', |
106
|
|
|
'config' => [ |
107
|
|
|
'type' => 'select', |
108
|
|
|
'renderType' => 'selectSingle', |
109
|
|
|
'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getLayoutList', |
110
|
|
|
'size' => 1, |
111
|
|
|
'maxitems' => 1, |
112
|
|
|
'eval' => 'required', |
113
|
|
|
], |
114
|
|
|
], |
115
|
|
|
|
116
|
|
|
// Mail content |
117
|
|
|
|
118
|
|
|
'subject' => [ |
119
|
|
|
'exclude' => 1, |
120
|
|
|
'label' => self::EMAIL_LLL . ':field.subject', |
121
|
|
|
'config' => [ |
122
|
|
|
'type' => 'input', |
123
|
|
|
'size' => 40, |
124
|
|
|
'eval' => 'trim,required', |
125
|
|
|
], |
126
|
|
|
], |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* This FlexForm field is fully configured in: |
130
|
|
|
* @see \CuyZ\Notiz\Core\Notification\TCA\Processor\BodySlotsProcessor |
131
|
|
|
*/ |
132
|
|
|
'body' => [ |
133
|
|
|
'exclude' => 1, |
134
|
|
|
'label' => self::EMAIL_LLL . ':field.body', |
135
|
|
|
'config' => [ |
136
|
|
|
'type' => 'flex', |
137
|
|
|
'default' => '', |
138
|
|
|
'ds_pointerField' => 'event', |
139
|
|
|
'behaviour' => [ |
140
|
|
|
'allowLanguageSynchronization' => true, |
141
|
|
|
], |
142
|
|
|
], |
143
|
|
|
], |
144
|
|
|
|
145
|
|
|
// Sender |
146
|
|
|
|
147
|
|
|
'sender_custom' => [ |
148
|
|
|
'exclude' => 1, |
149
|
|
|
'label' => self::EMAIL_LLL . ':field.sender_custom', |
150
|
|
|
'onChange' => 'reload', |
151
|
|
|
'config' => [ |
152
|
|
|
'type' => 'check', |
153
|
|
|
'default' => 0, |
154
|
|
|
], |
155
|
|
|
], |
156
|
|
|
|
157
|
|
|
'sender_default' => [ |
158
|
|
|
'exclude' => 1, |
159
|
|
|
'label' => self::EMAIL_LLL . ':field.sender_default', |
160
|
|
|
'displayCond' => 'FIELD:sender_custom:=:0', |
161
|
|
|
'config' => [ |
162
|
|
|
'type' => 'user', |
163
|
|
|
'userFunc' => $this->getNotificationTcaServiceClass() . '->getDefaultSender', |
164
|
|
|
], |
165
|
|
|
], |
166
|
|
|
|
167
|
|
|
'sender' => [ |
168
|
|
|
'exclude' => 1, |
169
|
|
|
'label' => self::EMAIL_LLL . ':field.sender', |
170
|
|
|
'displayCond' => 'FIELD:sender_custom:=:1', |
171
|
|
|
'config' => [ |
172
|
|
|
'type' => 'input', |
173
|
|
|
'size' => 255, |
174
|
|
|
'eval' => 'email,required', |
175
|
|
|
'default' => '', |
176
|
|
|
'placeholder' => '[email protected]', |
177
|
|
|
], |
178
|
|
|
], |
179
|
|
|
|
180
|
|
|
// Recipients |
181
|
|
|
|
182
|
|
|
'send_to' => [ |
183
|
|
|
'exclude' => 1, |
184
|
|
|
'label' => self::EMAIL_LLL . ':field.send_to', |
185
|
|
|
'config' => [ |
186
|
|
|
'type' => 'input', |
187
|
|
|
'size' => 512, |
188
|
|
|
'eval' => 'trim', |
189
|
|
|
'placeholder' => '[email protected], [email protected]', |
190
|
|
|
], |
191
|
|
|
], |
192
|
|
|
|
193
|
|
|
'send_to_provided' => [ |
194
|
|
|
'exclude' => 1, |
195
|
|
|
'label' => self::EMAIL_LLL . ':field.send_to_provided', |
196
|
|
|
'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->shouldShowProvidedRecipientsSelect', |
197
|
|
|
'config' => [ |
198
|
|
|
'type' => 'select', |
199
|
|
|
'default' => '', |
200
|
|
|
'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getRecipientsList', |
201
|
|
|
'renderType' => 'selectMultipleSideBySide', |
202
|
|
|
'size' => 5, |
203
|
|
|
'maxitems' => 128, |
204
|
|
|
], |
205
|
|
|
], |
206
|
|
|
|
207
|
|
|
'send_cc' => [ |
208
|
|
|
'exclude' => 1, |
209
|
|
|
'label' => self::EMAIL_LLL . ':field.send_cc', |
210
|
|
|
'config' => [ |
211
|
|
|
'type' => 'input', |
212
|
|
|
'size' => 512, |
213
|
|
|
'eval' => 'trim', |
214
|
|
|
'placeholder' => '[email protected], [email protected]', |
215
|
|
|
], |
216
|
|
|
], |
217
|
|
|
|
218
|
|
|
'send_cc_provided' => [ |
219
|
|
|
'exclude' => 1, |
220
|
|
|
'label' => self::EMAIL_LLL . ':field.send_cc_provided', |
221
|
|
|
'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->shouldShowProvidedRecipientsSelect', |
222
|
|
|
'config' => [ |
223
|
|
|
'type' => 'select', |
224
|
|
|
'default' => '', |
225
|
|
|
'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getRecipientsList', |
226
|
|
|
'renderType' => 'selectMultipleSideBySide', |
227
|
|
|
'size' => 5, |
228
|
|
|
'maxitems' => 128, |
229
|
|
|
], |
230
|
|
|
], |
231
|
|
|
|
232
|
|
|
'send_bcc' => [ |
233
|
|
|
'exclude' => 1, |
234
|
|
|
'label' => self::EMAIL_LLL . ':field.send_bcc', |
235
|
|
|
'config' => [ |
236
|
|
|
'type' => 'input', |
237
|
|
|
'size' => 512, |
238
|
|
|
'eval' => 'trim', |
239
|
|
|
'placeholder' => '[email protected], [email protected]', |
240
|
|
|
], |
241
|
|
|
], |
242
|
|
|
|
243
|
|
|
'send_bcc_provided' => [ |
244
|
|
|
'exclude' => 1, |
245
|
|
|
'label' => self::EMAIL_LLL . ':field.send_bcc_provided', |
246
|
|
|
'displayCond' => 'USER:' . $this->getNotificationTcaServiceClass() . '->shouldShowProvidedRecipientsSelect', |
247
|
|
|
'config' => [ |
248
|
|
|
'type' => 'select', |
249
|
|
|
'default' => '', |
250
|
|
|
'itemsProcFunc' => $this->getNotificationTcaServiceClass() . '->getRecipientsList', |
251
|
|
|
'renderType' => 'selectMultipleSideBySide', |
252
|
|
|
'size' => 5, |
253
|
|
|
'maxitems' => 128, |
254
|
|
|
], |
255
|
|
|
], |
256
|
|
|
|
257
|
|
|
], |
258
|
|
|
]; |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @return array |
263
|
|
|
*/ |
264
|
|
|
protected function getCtrl(): array |
265
|
|
|
{ |
266
|
|
|
$ctrl = $this->getDefaultCtrl(); |
267
|
|
|
|
268
|
|
|
$ctrl['searchFields'] .= ',sender,sender_custom,send_to,send_to_provided,send_cc,send_cc_provided,send_bcc,send_bcc_provided,subject,body'; |
269
|
|
|
|
270
|
|
|
$ctrl[self::NOTIFICATION_ENTITY]['processor'][] = BodySlotsProcessor::class; |
271
|
|
|
|
272
|
|
|
return $ctrl; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @return string |
277
|
|
|
*/ |
278
|
|
|
protected function getEntityTitle(): string |
279
|
|
|
{ |
280
|
|
|
return self::EMAIL_LLL . ':title'; |
281
|
|
|
} |
282
|
|
|
} |
283
|
|
|
|