1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
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
|
|
|
namespace DERHANSEN\SfEventMgt\Preview; |
13
|
|
|
|
14
|
|
|
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem; |
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
16
|
|
|
|
17
|
|
|
class PieventPreviewRenderer extends AbstractPluginPreviewRenderer |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Renders the content of the plugin preview. |
21
|
|
|
* |
22
|
|
|
* @param GridColumnItem $item |
23
|
|
|
* @return string |
24
|
|
|
*/ |
25
|
|
|
public function renderPageModulePreviewContent(GridColumnItem $item): string |
26
|
|
|
{ |
27
|
|
|
$data = []; |
28
|
|
|
$record = $item->getRecord(); |
29
|
|
|
$flexFormData = GeneralUtility::xml2array($record['pi_flexform']); |
30
|
|
|
|
31
|
|
|
$pluginName = $this->getPluginName($record); |
32
|
|
|
|
33
|
|
|
$this->setPluginPidConfig($data, $flexFormData, 'listPid', 'additional'); |
34
|
|
|
$this->setPluginPidConfig($data, $flexFormData, 'detailPid', 'additional'); |
35
|
|
|
$this->setPluginPidConfig($data, $flexFormData, 'registrationPid', 'additional'); |
36
|
|
|
$this->setPluginPidConfig($data, $flexFormData, 'paymentPid', 'additional'); |
37
|
|
|
|
38
|
|
|
$this->setStoragePage($data, $flexFormData, 'settings.storagePage'); |
39
|
|
|
|
40
|
|
|
$this->setOrderSettings($data, $flexFormData, 'settings.orderField', 'settings.orderDirection'); |
41
|
|
|
$this->setOverrideDemandSettings($data, $flexFormData); |
42
|
|
|
|
43
|
|
|
$this->setCategoryConjuction($data, $flexFormData); |
44
|
|
|
$this->setCategorySettings($data, $flexFormData); |
45
|
|
|
|
46
|
|
|
return $this->renderAsTable($data, $pluginName); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Sets category conjunction if a category is selected |
52
|
|
|
*/ |
53
|
|
|
protected function setCategoryConjuction(array &$data, array $flexFormData): void |
54
|
|
|
{ |
55
|
|
|
// If not category is selected, we do not need to display the category mode |
56
|
|
|
$categories = $this->getFlexFormFieldValue($flexFormData, 'settings.category'); |
57
|
|
|
if ($categories === null || $categories === '') { |
58
|
|
|
return; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$categoryConjunction = strtolower($this->getFlexFormFieldValue($flexFormData, 'settings.categoryConjunction')); |
|
|
|
|
62
|
|
|
switch ($categoryConjunction) { |
63
|
|
|
case 'or': |
64
|
|
|
case 'and': |
65
|
|
|
case 'notor': |
66
|
|
|
case 'notand': |
67
|
|
|
$text = htmlspecialchars($this->getLanguageService()->sL( |
68
|
|
|
self::LLPATH . 'flexforms_general.categoryConjunction.' . $categoryConjunction |
69
|
|
|
)); |
70
|
|
|
break; |
71
|
|
|
default: |
72
|
|
|
$text = htmlspecialchars($this->getLanguageService()->sL( |
73
|
|
|
self::LLPATH . 'flexforms_general.categoryConjunction.ignore' |
74
|
|
|
)); |
75
|
|
|
$text .= ' <span class="label label-warning">' . htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.possibleMisconfiguration')) . '</span>'; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$data[] = [ |
79
|
|
|
'title' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.categoryConjunction'), |
80
|
|
|
'value' => $text, |
81
|
|
|
]; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get category settings |
86
|
|
|
*/ |
87
|
|
|
protected function setCategorySettings(array &$data, array $flexFormData): void |
88
|
|
|
{ |
89
|
|
|
$categories = GeneralUtility::intExplode(',', $this->getFlexFormFieldValue($flexFormData, 'settings.category'), true); |
90
|
|
|
if (count($categories) > 0) { |
91
|
|
|
$categoriesOut = []; |
92
|
|
|
foreach ($categories as $id) { |
93
|
|
|
$categoriesOut[] = $this->getRecordData($id, 'sys_category'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$data[] = [ |
97
|
|
|
'title' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.category'), |
98
|
|
|
'value' => implode(', ', $categoriesOut), |
99
|
|
|
]; |
100
|
|
|
|
101
|
|
|
$includeSubcategories = $this->getFlexFormFieldValue($flexFormData, 'settings.includeSubcategories'); |
102
|
|
|
if ((int)$includeSubcategories === 1) { |
103
|
|
|
$data[] = [ |
104
|
|
|
'title' => $this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.includeSubcategories'), |
105
|
|
|
'value' => '<i class="fa fa-check"></i>', |
106
|
|
|
]; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|