|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Render the CMS layout. |
|
5
|
|
|
*/ |
|
6
|
|
|
declare(strict_types=1); |
|
7
|
|
|
|
|
8
|
|
|
namespace HDNET\Calendarize\Hooks; |
|
9
|
|
|
|
|
10
|
|
|
use HDNET\Autoloader\Utility\IconUtility; |
|
11
|
|
|
use HDNET\Calendarize\Service\ContentElementLayoutService; |
|
12
|
|
|
use HDNET\Calendarize\Service\FlexFormService; |
|
13
|
|
|
use HDNET\Calendarize\Utility\HelperUtility; |
|
14
|
|
|
use HDNET\Calendarize\Utility\TranslateUtility; |
|
15
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
|
16
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
17
|
|
|
use TYPO3\CMS\Core\Utility\PathUtility; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Render the CMS layout. |
|
21
|
|
|
* |
|
22
|
|
|
* @see News extension (Thanks Georg) |
|
23
|
|
|
*/ |
|
24
|
|
|
class CmsLayout extends AbstractHook |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Flex form service. |
|
28
|
|
|
* |
|
29
|
|
|
* @var FlexFormService |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $flexFormService; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Content element data. |
|
35
|
|
|
* |
|
36
|
|
|
* @var ContentElementLayoutService |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $layoutService; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Returns information about this extension plugin. |
|
42
|
|
|
* |
|
43
|
|
|
* @param array $params Parameters to the hook |
|
44
|
|
|
* |
|
45
|
|
|
* @return string Information about pi1 plugin |
|
46
|
|
|
* @hook TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|list_type_Info|calendarize_calendar |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getExtensionSummary(array $params) |
|
49
|
|
|
{ |
|
50
|
|
|
if ('calendarize_calendar' !== $params['row']['list_type']) { |
|
51
|
|
|
return ''; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$this->flexFormService = GeneralUtility::makeInstance(FlexFormService::class); |
|
55
|
|
|
$this->flexFormService->load($params['row']['pi_flexform']); |
|
56
|
|
|
if (!$this->flexFormService->isValid()) { |
|
57
|
|
|
return ''; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$extensionIcon = IconUtility::getByExtensionKey('calendarize', true); |
|
61
|
|
|
$extensionIconUsage = PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName($extensionIcon)); |
|
62
|
|
|
$this->layoutService = GeneralUtility::makeInstance(ContentElementLayoutService::class); |
|
63
|
|
|
$this->layoutService->setTitle('<img src="' . $extensionIconUsage . '" width="32" height="32" /> Calendarize'); |
|
64
|
|
|
|
|
65
|
|
|
$actions = $this->flexFormService->get('switchableControllerActions', 'main'); |
|
66
|
|
|
$parts = GeneralUtility::trimExplode(';', $actions, true); |
|
67
|
|
|
$parts = \array_map(function ($element) { |
|
68
|
|
|
$split = \explode('->', $element); |
|
69
|
|
|
|
|
70
|
|
|
return \ucfirst($split[1]); |
|
71
|
|
|
}, $parts); |
|
72
|
|
|
$actionKey = \lcfirst(\implode('', $parts)); |
|
73
|
|
|
|
|
74
|
|
|
$this->layoutService->addRow(TranslateUtility::get('mode'), TranslateUtility::get('mode.' . $actionKey)); |
|
75
|
|
|
|
|
76
|
|
|
$pluginConfiguration = (int) $this->flexFormService->get('settings.pluginConfiguration', 'main'); |
|
77
|
|
|
if ($pluginConfiguration) { |
|
78
|
|
|
$table = 'tx_calendarize_domain_model_pluginconfiguration'; |
|
79
|
|
|
|
|
80
|
|
|
$row = HelperUtility::getDatabaseConnection($table)->select( |
|
81
|
|
|
['*'], |
|
82
|
|
|
$table, |
|
83
|
|
|
['uid' => $pluginConfiguration] |
|
84
|
|
|
)->fetch(); |
|
85
|
|
|
$this->layoutService->addRow( |
|
86
|
|
|
TranslateUtility::get('tx_calendarize_domain_model_pluginconfiguration'), |
|
87
|
|
|
BackendUtility::getRecordTitle($table, $row) |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
if ('' !== \trim((string) $this->flexFormService->get('settings.configuration', 'general'))) { |
|
92
|
|
|
$this->layoutService->addRow( |
|
93
|
|
|
TranslateUtility::get('configuration'), |
|
94
|
|
|
$this->flexFormService->get('settings.configuration', 'general') |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) { |
|
99
|
|
|
$this->layoutService->addRow(TranslateUtility::get('hide.pagination.teaser'), '!!!'); |
|
100
|
|
|
} |
|
101
|
|
|
$useRelativeDate = (bool) $this->flexFormService->get('settings.useRelativeDate', 'main'); |
|
102
|
|
|
if ($useRelativeDate) { |
|
103
|
|
|
$overrideStartRelative = $this->flexFormService->get('settings.overrideStartRelative', 'main'); |
|
104
|
|
|
if ($overrideStartRelative) { |
|
105
|
|
|
$this->layoutService->addRow(TranslateUtility::get('override.startrelative'), $overrideStartRelative); |
|
106
|
|
|
} |
|
107
|
|
|
$overrideEndRelative = $this->flexFormService->get('settings.overrideEndRelative', 'main'); |
|
108
|
|
|
if ($overrideEndRelative) { |
|
109
|
|
|
$this->layoutService->addRow(TranslateUtility::get('override.endrelative'), $overrideEndRelative); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
} else { |
|
113
|
|
|
$overrideStartDate = (int) $this->flexFormService->get('settings.overrideStartdate', 'main'); |
|
114
|
|
|
if ($overrideStartDate) { |
|
115
|
|
|
$this->layoutService->addRow(TranslateUtility::get('override.startdate'), \date('d.m.y H:i', $overrideStartDate)); |
|
116
|
|
|
} |
|
117
|
|
|
$overrideEndDate = (int) $this->flexFormService->get('settings.overrideEnddate', 'main'); |
|
118
|
|
|
if ($overrideEndDate) { |
|
119
|
|
|
$this->layoutService->addRow(TranslateUtility::get('override.enddate'), \date('d.m.y H:i', $overrideEndDate)); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
$this->addPageIdsToTable(); |
|
124
|
|
|
|
|
125
|
|
|
return $this->layoutService->render(); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Add page IDs to the preview of the element. |
|
130
|
|
|
*/ |
|
131
|
|
|
protected function addPageIdsToTable() |
|
132
|
|
|
{ |
|
133
|
|
|
$pageIdsNames = [ |
|
134
|
|
|
'detailPid', |
|
135
|
|
|
'listPid', |
|
136
|
|
|
'yearPid', |
|
137
|
|
|
'monthPid', |
|
138
|
|
|
'weekPid', |
|
139
|
|
|
'dayPid', |
|
140
|
|
|
'bookingPid', |
|
141
|
|
|
]; |
|
142
|
|
|
foreach ($pageIdsNames as $pageIdName) { |
|
143
|
|
|
$pageId = (int) $this->flexFormService->get('settings.' . $pageIdName, 'pages'); |
|
144
|
|
|
$pageRow = BackendUtility::getRecord('pages', $pageId); |
|
145
|
|
|
if ($pageRow) { |
|
146
|
|
|
$this->layoutService->addRow( |
|
147
|
|
|
TranslateUtility::get($pageIdName), |
|
148
|
|
|
$pageRow['title'] . ' (' . $pageId . ')' |
|
149
|
|
|
); |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
|
|