|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DERHANSEN\SfEventMgt\Hooks; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
use TYPO3\CMS\Backend\Template\DocumentTemplate; |
|
13
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility as BackendUtilityCore; |
|
14
|
|
|
use TYPO3\CMS\Core\Imaging\Icon; |
|
15
|
|
|
use TYPO3\CMS\Core\Imaging\IconFactory; |
|
16
|
|
|
use TYPO3\CMS\Core\Page\PageRenderer; |
|
17
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
|
18
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
19
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Hook to display verbose information about plugin in Web>Page module |
|
23
|
|
|
*/ |
|
24
|
|
|
class PageLayoutView |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Path to the locallang file |
|
28
|
|
|
* |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
const LLPATH = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Data rendered in table of Plugin settings |
|
35
|
|
|
* |
|
36
|
|
|
* @var array |
|
37
|
|
|
*/ |
|
38
|
|
|
public $data = []; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Flexform information |
|
42
|
|
|
* |
|
43
|
|
|
* @var array |
|
44
|
|
|
*/ |
|
45
|
|
|
public $flexformData = []; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var IconFactory |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $iconFactory; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* PageLayoutView constructor |
|
54
|
|
|
*/ |
|
55
|
|
|
public function __construct() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Returns information about this extension's event plugin |
|
62
|
|
|
* |
|
63
|
|
|
* @param array $params Parameters to the hook |
|
64
|
|
|
* @return string Information about plugin |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getEventPluginSummary(array $params) |
|
67
|
|
|
{ |
|
68
|
|
|
$header = htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'plugin.title')); |
|
69
|
|
|
|
|
70
|
|
|
// Add flexform switchable controller actions |
|
71
|
|
|
$this->flexformData = GeneralUtility::xml2array($params['row']['pi_flexform']); |
|
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
// Extend header by flexible controller action |
|
74
|
|
|
$action = htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode')) . ': '; |
|
75
|
|
|
$action .= $this->getSwitchableControllerActionTitle(); |
|
76
|
|
|
|
|
77
|
|
|
$this->getPluginPidConfig('listPid', 'additional'); |
|
78
|
|
|
$this->getPluginPidConfig('detailPid', 'additional'); |
|
79
|
|
|
$this->getPluginPidConfig('registrationPid', 'additional'); |
|
80
|
|
|
$this->getPluginPidConfig('paymentPid', 'additional'); |
|
81
|
|
|
$this->getStoragePage('settings.storagePage'); |
|
82
|
|
|
$this->getOrderSettings('settings.orderField', 'settings.orderDirection'); |
|
83
|
|
|
$this->getOverrideDemandSettings(); |
|
84
|
|
|
|
|
85
|
|
|
if ($this->showFieldsForListViewOnly()) { |
|
86
|
|
|
$this->getCategoryConjuction(); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
$result = $this->renderSettingsAsTable($header, $action, $this->data); |
|
90
|
|
|
return $result; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Returns information about this extension's user registrations plugin |
|
95
|
|
|
* |
|
96
|
|
|
* @param array $params Parameters to the hook |
|
97
|
|
|
* @return string Information about plugin |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getUserRegPluginSummary(array $params) |
|
100
|
|
|
{ |
|
101
|
|
|
$header = htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'plugin_userreg.title')); |
|
102
|
|
|
|
|
103
|
|
|
// Add flexform switchable controller actions |
|
104
|
|
|
$this->flexformData = GeneralUtility::xml2array($params['row']['pi_flexform']); |
|
|
|
|
|
|
105
|
|
|
|
|
106
|
|
|
$this->getPluginPidConfig('registrationPid', 'sDEF'); |
|
107
|
|
|
$this->getStoragePage('settings.userRegistration.storagePage'); |
|
108
|
|
|
$this->getOrderSettings('settings.userRegistration.orderField', 'settings.userRegistration.orderDirection'); |
|
109
|
|
|
|
|
110
|
|
|
$result = $this->renderSettingsAsTable($header, null, $this->data); |
|
111
|
|
|
return $result; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Returns the current title of the switchableControllerAction |
|
116
|
|
|
* |
|
117
|
|
|
* @return string |
|
118
|
|
|
*/ |
|
119
|
|
|
protected function getSwitchableControllerActionTitle() |
|
120
|
|
|
{ |
|
121
|
|
|
$title = ''; |
|
122
|
|
|
$actions = $this->getFieldFromFlexform('switchableControllerActions'); |
|
123
|
|
|
switch ($actions) { |
|
124
|
|
|
case 'Event->list': |
|
125
|
|
|
$title = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode.list'); |
|
126
|
|
|
break; |
|
127
|
|
|
case 'Event->detail;Event->icalDownload': |
|
128
|
|
|
$title = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode.detail'); |
|
129
|
|
|
break; |
|
130
|
|
|
case 'Event->registration;Event->saveRegistration;Event->saveRegistrationResult;Event->confirmRegistration;Event->cancelRegistration': |
|
131
|
|
|
$title = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode.registration'); |
|
132
|
|
|
break; |
|
133
|
|
|
case 'Event->search': |
|
134
|
|
|
$title = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode.search'); |
|
135
|
|
|
break; |
|
136
|
|
|
case 'Event->calendar': |
|
137
|
|
|
$title = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.mode.calendar'); |
|
138
|
|
|
break; |
|
139
|
|
|
default: |
|
140
|
|
|
} |
|
141
|
|
|
return $title; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Returns, if fields, that are only visible for list view, should be shown |
|
146
|
|
|
* |
|
147
|
|
|
* @return bool |
|
148
|
|
|
*/ |
|
149
|
|
|
protected function showFieldsForListViewOnly() |
|
150
|
|
|
{ |
|
151
|
|
|
$actions = $this->getFieldFromFlexform('switchableControllerActions'); |
|
152
|
|
|
switch ($actions) { |
|
153
|
|
|
case 'Event->list': |
|
154
|
|
|
case 'Event->search': |
|
155
|
|
|
case 'Event->calendar': |
|
156
|
|
|
$result = true; |
|
157
|
|
|
break; |
|
158
|
|
|
default: |
|
159
|
|
|
$result = false; |
|
160
|
|
|
} |
|
161
|
|
|
return $result; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Returns the PID config for the given PID |
|
166
|
|
|
* |
|
167
|
|
|
* @param $pidSetting |
|
168
|
|
|
* @param $sheet |
|
169
|
|
|
*/ |
|
170
|
|
|
public function getPluginPidConfig($pidSetting, $sheet = 'sDEF') |
|
171
|
|
|
{ |
|
172
|
|
|
$pid = (int)$this->getFieldFromFlexform('settings.' . $pidSetting, $sheet); |
|
173
|
|
|
if ($pid > 0) { |
|
174
|
|
|
$this->data[] = [ |
|
175
|
|
|
'title' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.' . $pidSetting), |
|
176
|
|
|
'value' => $this->getRecordData($pid) |
|
177
|
|
|
]; |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* |
|
183
|
|
|
* |
|
184
|
|
|
* @param int $id |
|
185
|
|
|
* @param string $table |
|
186
|
|
|
* @return string |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getRecordData($id, $table = 'pages') |
|
189
|
|
|
{ |
|
190
|
|
|
$content = ''; |
|
191
|
|
|
$record = BackendUtilityCore::getRecord($table, $id); |
|
192
|
|
|
|
|
193
|
|
|
if (is_array($record)) { |
|
194
|
|
|
$data = '<span data-toggle="tooltip" data-placement="top" data-title="id=' . $record['uid'] . '">' |
|
195
|
|
|
. $this->iconFactory->getIconForRecord($table, $record, Icon::SIZE_SMALL)->render() |
|
196
|
|
|
. '</span> '; |
|
197
|
|
|
$content = BackendUtilityCore::wrapClickMenuOnIcon($data, $table, $record['uid'], true, '', '+info'); |
|
|
|
|
|
|
198
|
|
|
|
|
199
|
|
|
$linkTitle = htmlspecialchars(BackendUtilityCore::getRecordTitle($table, $record)); |
|
200
|
|
|
$content .= $linkTitle; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
return $content; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Get the storagePage |
|
208
|
|
|
* |
|
209
|
|
|
* @param string $field |
|
210
|
|
|
*/ |
|
211
|
|
|
public function getStoragePage($field) |
|
212
|
|
|
{ |
|
213
|
|
|
$value = $this->getFieldFromFlexform($field); |
|
214
|
|
|
|
|
215
|
|
|
if (!empty($value)) { |
|
216
|
|
|
$pageIds = GeneralUtility::intExplode(',', $value, true); |
|
217
|
|
|
$pagesOut = []; |
|
218
|
|
|
|
|
219
|
|
|
foreach ($pageIds as $id) { |
|
220
|
|
|
$pagesOut[] = $this->getRecordData($id, 'pages'); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
$recursiveLevel = (int)$this->getFieldFromFlexform('settings.recursive'); |
|
224
|
|
|
$recursiveLevelText = ''; |
|
225
|
|
|
if ($recursiveLevel === 250) { |
|
226
|
|
|
$recursiveLevelText = $this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.5'); |
|
227
|
|
|
} elseif ($recursiveLevel > 0) { |
|
228
|
|
|
$recursiveLevelText = $this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:recursive.I.' . $recursiveLevel); |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
if (!empty($recursiveLevelText)) { |
|
232
|
|
|
$recursiveLevelText = '<br />' . |
|
233
|
|
|
htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_general.xlf:LGL.recursive')) . ' ' . |
|
234
|
|
|
$recursiveLevelText; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
$this->data[] = [ |
|
238
|
|
|
'title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_general.xlf:LGL.startingpoint'), |
|
239
|
|
|
'value' => implode(', ', $pagesOut) . $recursiveLevelText |
|
240
|
|
|
]; |
|
241
|
|
|
} |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
/** |
|
245
|
|
|
* Get order settings |
|
246
|
|
|
* |
|
247
|
|
|
* @param string $orderByField |
|
248
|
|
|
* @param string $orderDirectionField |
|
249
|
|
|
*/ |
|
250
|
|
|
public function getOrderSettings($orderByField, $orderDirectionField) |
|
251
|
|
|
{ |
|
252
|
|
|
$orderField = $this->getFieldFromFlexform($orderByField); |
|
253
|
|
|
if (!empty($orderField)) { |
|
254
|
|
|
$text = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.orderField.' . $orderField); |
|
255
|
|
|
|
|
256
|
|
|
// Order direction (asc, desc) |
|
257
|
|
|
$orderDirection = $this->getOrderDirectionSetting($orderDirectionField); |
|
258
|
|
|
if ($orderDirection) { |
|
259
|
|
|
$text .= ', ' . strtolower($orderDirection); |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
$this->data[] = [ |
|
263
|
|
|
'title' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.orderField'), |
|
264
|
|
|
'value' => $text |
|
265
|
|
|
]; |
|
266
|
|
|
} |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
/** |
|
270
|
|
|
* Get order direction |
|
271
|
|
|
* @param string $orderDirectionField |
|
272
|
|
|
* @return string |
|
273
|
|
|
*/ |
|
274
|
|
|
public function getOrderDirectionSetting($orderDirectionField) |
|
275
|
|
|
{ |
|
276
|
|
|
$text = ''; |
|
277
|
|
|
|
|
278
|
|
|
$orderDirection = $this->getFieldFromFlexform($orderDirectionField); |
|
279
|
|
|
if (!empty($orderDirection)) { |
|
280
|
|
|
$text = $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.orderDirection.' . $orderDirection . 'ending'); |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
return $text; |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
|
|
287
|
|
|
/** |
|
288
|
|
|
* Get category conjunction if a category is selected |
|
289
|
|
|
* @return void |
|
290
|
|
|
*/ |
|
291
|
|
|
public function getCategoryConjuction() |
|
292
|
|
|
{ |
|
293
|
|
|
// If not category is selected, we do not need to display the category mode |
|
294
|
|
|
if ($this->getFieldFromFlexform('settings.category') === null) { |
|
295
|
|
|
return; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
$categoryConjunction = $this->getFieldFromFlexform('settings.categoryConjunction'); |
|
299
|
|
|
switch ($categoryConjunction) { |
|
300
|
|
|
case 'or': |
|
301
|
|
|
case 'and': |
|
302
|
|
|
case 'notor': |
|
303
|
|
|
case 'notand': |
|
304
|
|
|
$mode = $categoryConjunction; |
|
305
|
|
|
break; |
|
306
|
|
|
default: |
|
307
|
|
|
$mode = 'ignore'; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
$this->data[] = [ |
|
311
|
|
|
'title' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.categoryConjunction'), |
|
312
|
|
|
'value' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.categoryConjunction.' . $mode) |
|
313
|
|
|
]; |
|
314
|
|
|
} |
|
315
|
|
|
|
|
316
|
|
|
/** |
|
317
|
|
|
* Get information if override demand setting is disabled or not |
|
318
|
|
|
*/ |
|
319
|
|
|
public function getOverrideDemandSettings() |
|
320
|
|
|
{ |
|
321
|
|
|
$field = $this->getFieldFromFlexform('settings.disableOverrideDemand', 'additional'); |
|
322
|
|
|
|
|
323
|
|
|
if ($field == 1) { |
|
324
|
|
|
$this->data[] = [ |
|
325
|
|
|
'title' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.disableOverrideDemand'), |
|
326
|
|
|
'value' => '<i class="fa fa-check"></i>' |
|
327
|
|
|
]; |
|
328
|
|
|
} |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* Render the settings as table for Web>Page module |
|
333
|
|
|
* System settings are displayed in mono font |
|
334
|
|
|
* |
|
335
|
|
|
* @param string $header |
|
336
|
|
|
* @param string $action |
|
337
|
|
|
* @param array $data |
|
338
|
|
|
* @return string |
|
339
|
|
|
*/ |
|
340
|
|
|
protected function renderSettingsAsTable($header, $action, $data) |
|
341
|
|
|
{ |
|
342
|
|
|
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
343
|
|
|
$pageRenderer->loadRequireJsModule('TYPO3/CMS/News/PageLayout'); |
|
344
|
|
|
$pageRenderer->addCssFile( |
|
345
|
|
|
ExtensionManagementUtility::extRelPath('sf_event_mgt') . 'Resources/Public/Css/Backend/PageLayoutView.css' |
|
|
|
|
|
|
346
|
|
|
); |
|
347
|
|
|
|
|
348
|
|
|
$view = GeneralUtility::makeInstance(StandaloneView::class); |
|
349
|
|
|
$view->setTemplatePathAndFilename( |
|
350
|
|
|
GeneralUtility::getFileAbsFileName('EXT:sf_event_mgt/Resources/Private/Backend/PageLayoutView.html') |
|
351
|
|
|
); |
|
352
|
|
|
$view->assignMultiple([ |
|
353
|
|
|
'header' => $header, |
|
354
|
|
|
'action' => $action, |
|
355
|
|
|
'data' => $data |
|
356
|
|
|
]); |
|
357
|
|
|
|
|
358
|
|
|
return $view->render(); |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
/** |
|
362
|
|
|
* Get field value from flexform configuration, |
|
363
|
|
|
* including checks if flexform configuration is available |
|
364
|
|
|
* |
|
365
|
|
|
* @param string $key name of the key |
|
366
|
|
|
* @param string $sheet name of the sheet |
|
367
|
|
|
* @return string|NULL if nothing found, value if found |
|
368
|
|
|
*/ |
|
369
|
|
|
public function getFieldFromFlexform($key, $sheet = 'sDEF') |
|
370
|
|
|
{ |
|
371
|
|
|
$flexform = $this->flexformData; |
|
372
|
|
|
if (isset($flexform['data'])) { |
|
373
|
|
|
$flexform = $flexform['data']; |
|
374
|
|
|
if (is_array($flexform) && is_array($flexform[$sheet]) && is_array($flexform[$sheet]['lDEF']) |
|
375
|
|
|
&& is_array($flexform[$sheet]['lDEF'][$key]) && isset($flexform[$sheet]['lDEF'][$key]['vDEF']) |
|
376
|
|
|
) { |
|
377
|
|
|
return $flexform[$sheet]['lDEF'][$key]['vDEF']; |
|
378
|
|
|
} |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
return null; |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* Return language service instance |
|
386
|
|
|
* |
|
387
|
|
|
* @return \TYPO3\CMS\Lang\LanguageService |
|
388
|
|
|
*/ |
|
389
|
|
|
public function getLanguageService() |
|
390
|
|
|
{ |
|
391
|
|
|
return $GLOBALS['LANG']; |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
/** |
|
395
|
|
|
* Get the DocumentTemplate |
|
396
|
|
|
* |
|
397
|
|
|
* @return DocumentTemplate |
|
398
|
|
|
*/ |
|
399
|
|
|
protected function getDocumentTemplate() |
|
400
|
|
|
{ |
|
401
|
|
|
return $GLOBALS['TBE_TEMPLATE']; |
|
402
|
|
|
} |
|
403
|
|
|
} |
|
404
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..