|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Controller; |
|
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\Extbase\Configuration\BackendConfigurationManager; |
|
18
|
|
|
use EWW\Dpf\Configuration\InputOption\Iso6392b; |
|
19
|
|
|
use EWW\Dpf\\Helper\InputOption\Translator; |
|
|
|
|
|
|
20
|
|
|
use EWW\Dpf\Domain\Model\InputOptionList; |
|
21
|
|
|
/** |
|
22
|
|
|
* ClientController |
|
23
|
|
|
*/ |
|
24
|
|
|
class ClientController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* sysLanguageRepository |
|
29
|
|
|
* |
|
30
|
|
|
* @var \EWW\Dpf\Domain\Repository\SysLanguageRepository |
|
31
|
|
|
* @inject |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $sysLanguageRepository = null; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* clientRepository |
|
37
|
|
|
* |
|
38
|
|
|
* @var \EWW\Dpf\Domain\Repository\ClientRepository |
|
39
|
|
|
* @inject |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $clientRepository = null; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* InputOptionListRepository |
|
45
|
|
|
* |
|
46
|
|
|
* @var \EWW\Dpf\Domain\Repository\InputOptionListRepository |
|
47
|
|
|
* @inject |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $inputOptionListRepository = null; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* persistence manager |
|
53
|
|
|
* |
|
54
|
|
|
* @var \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface |
|
55
|
|
|
* @inject |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $persistenceManager; |
|
58
|
|
|
|
|
59
|
|
|
// TypoScript settings |
|
60
|
|
|
protected $settings = array(); |
|
61
|
|
|
|
|
62
|
|
|
// Id of the selected page in the page tree |
|
63
|
|
|
protected $selectedPageUid; |
|
64
|
|
|
|
|
65
|
|
|
// Page information of selected page |
|
66
|
|
|
protected $pageInfo; |
|
67
|
|
|
|
|
68
|
|
|
protected function initializeAction() |
|
69
|
|
|
{ |
|
70
|
|
|
|
|
71
|
|
|
$this->selectedPageUid = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); |
|
72
|
|
|
|
|
73
|
|
|
$this->pageInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->selectedPageUid, $GLOBALS['BE_USER']->getPagePermsClause(1)); |
|
74
|
|
|
|
|
75
|
|
|
$configManager = $this->objectManager->get(BackendConfigurationManager::class); |
|
76
|
|
|
|
|
77
|
|
|
$this->settings = $configManager->getConfiguration( |
|
78
|
|
|
$this->request->getControllerExtensionName(), |
|
79
|
|
|
$this->request->getPluginName() |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
protected function getPageInfo($pageUid) |
|
84
|
|
|
{ |
|
85
|
|
|
return \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1)); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view) |
|
89
|
|
|
{ |
|
90
|
|
|
parent::initializeView($view); |
|
91
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* start action |
|
96
|
|
|
* |
|
97
|
|
|
* @param \EWW\Dpf\Domain\Model\Client $newClient |
|
98
|
|
|
*/ |
|
99
|
|
|
public function newAction(\EWW\Dpf\Domain\Model\Client $newClient = null) |
|
100
|
|
|
{ |
|
101
|
|
|
if ($this->isValidClientFolder()) { |
|
102
|
|
|
|
|
103
|
|
|
$this->addFlashMessage( |
|
104
|
|
|
"", |
|
105
|
|
|
$messageTitle = 'Der ausgewählte Ordner enthält noch keine Mandanten-Konfiguration!', |
|
106
|
|
|
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING, |
|
107
|
|
|
$storeInSession = true |
|
108
|
|
|
); |
|
109
|
|
|
|
|
110
|
|
|
$this->view->assign('isValidClientFolder', $this->isValidClientFolder()); |
|
111
|
|
|
$this->view->assign('newClient', $newClient); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* initializeClient action |
|
118
|
|
|
* |
|
119
|
|
|
* @param \EWW\Dpf\Domain\Model\Client $newClient |
|
120
|
|
|
*/ |
|
121
|
|
|
public function createAction(\EWW\Dpf\Domain\Model\Client $newClient) |
|
122
|
|
|
{ |
|
123
|
|
|
|
|
124
|
|
|
if ($this->isValidClientFolder()) { |
|
125
|
|
|
$newClient->setPid($this->selectedPageUid); |
|
126
|
|
|
$this->clientRepository->add($newClient); |
|
127
|
|
|
|
|
128
|
|
|
$this->addBaseInputOptionLists($this->selectedPageUid); |
|
129
|
|
|
|
|
130
|
|
|
$this->addFlashMessage( |
|
131
|
|
|
"Mittels des Listen-Moduls können Sie nun die weitere Konfiguration durchführen.", |
|
132
|
|
|
$messageTitle = 'Der QUCOSA-Client wurde erfolgreich angelegt!', |
|
133
|
|
|
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::OK, |
|
134
|
|
|
$storeInSession = true |
|
135
|
|
|
); |
|
136
|
|
|
$this->redirect('default'); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
$this->redirect('new'); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* default action |
|
144
|
|
|
* |
|
145
|
|
|
*/ |
|
146
|
|
|
public function defaultAction() |
|
147
|
|
|
{ |
|
148
|
|
|
|
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
protected function isValidClientFolder() |
|
152
|
|
|
{ |
|
153
|
|
|
|
|
154
|
|
|
if (!$this->selectedPageUid) { |
|
155
|
|
|
$this->addFlashMessage( |
|
156
|
|
|
"Bitte wählen Sie im Seitenbaum einen Systemordner aus, der als QUCOSA-Client initialisiert werden soll.", |
|
157
|
|
|
$messageTitle = 'Bitte wählen Sie einen Zielordner aus!', |
|
158
|
|
|
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::INFO, |
|
159
|
|
|
$storeInSession = true |
|
160
|
|
|
); |
|
161
|
|
|
return false; |
|
162
|
|
|
} else { |
|
163
|
|
|
|
|
164
|
|
|
// check if the selected page already contains a QUCOSA-Client or if it is a subpage of a Client. |
|
165
|
|
|
$client = $this->clientRepository->findAllByPid($this->selectedPageUid)->current(); |
|
166
|
|
|
|
|
167
|
|
|
$pageInfo = $this->getPageInfo($this->selectedPageUid); |
|
168
|
|
|
while ($pageInfo['uid'] != 0 && !$client) { |
|
169
|
|
|
$client = $this->clientRepository->findAllByPid($pageInfo['uid'])->current(); |
|
170
|
|
|
$pageInfo = $this->getPageInfo($pageInfo['pid']); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
if ($client) { |
|
174
|
|
|
$this->addFlashMessage( |
|
175
|
|
|
"Dieser Ordner ist bereits Bestandteil eines initialisierten QUCOSA-Clients.", |
|
176
|
|
|
$messageTitle = 'Eine Initialisierung ist hier leider nicht möglich!', |
|
177
|
|
|
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR, |
|
178
|
|
|
$storeInSession = true |
|
179
|
|
|
); |
|
180
|
|
|
return false; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
if ($this->pageInfo['doktype'] != 254) { |
|
184
|
|
|
$this->addFlashMessage( |
|
185
|
|
|
"Bitte wählen Sie einen Systemordner aus, nur diese können als QUCOSA-Client verwendet werden.", |
|
186
|
|
|
$messageTitle = 'Eine Initialisierung ist hier leider nicht möglich!', |
|
187
|
|
|
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR, |
|
188
|
|
|
$storeInSession = true |
|
189
|
|
|
); |
|
190
|
|
|
return false; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
return true; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* adds all default input options |
|
199
|
|
|
* |
|
200
|
|
|
* @param integer $storagePid |
|
201
|
|
|
*/ |
|
202
|
|
|
protected function addBaseInputOptionLists($storagePid) |
|
203
|
|
|
{ |
|
204
|
|
|
|
|
205
|
|
|
$iso6392b = $this->objectManager->get(Iso6392b::class); |
|
206
|
|
|
|
|
207
|
|
|
$inputOptionTranslator = $this->objectManager->get(Translator::class); |
|
208
|
|
|
$inputOptionTranslator->init(get_class($iso6392b)); |
|
209
|
|
|
|
|
210
|
|
|
// create input option list for the default language |
|
211
|
|
|
$languageOptionList = $this->objectManager->get(InputOptionList::class); |
|
212
|
|
|
$languageOptionList->setName('languageList'); |
|
213
|
|
|
$languageOptionList->setPid($storagePid); |
|
214
|
|
|
$languageOptionList->setSysLanguageUid(0); |
|
215
|
|
|
$this->inputOptionListRepository->add($languageOptionList); |
|
216
|
|
|
|
|
217
|
|
|
$languageOptionList->setValueList($iso6392b->getValuesString()); |
|
218
|
|
|
|
|
219
|
|
|
if ($inputOptionTranslator->hasTranslation($inputOptionTranslator->getDefaultLanguage())) { |
|
220
|
|
|
$valueLabelList = $inputOptionTranslator->translate($iso6392b->getValues()); |
|
221
|
|
|
$displayName = $inputOptionTranslator->translate(array('languageList')); |
|
222
|
|
|
} else { |
|
223
|
|
|
$valueLabelList = $inputOptionTranslator->translate($iso6392b->getValues(), 'en'); |
|
224
|
|
|
$displayName = $inputOptionTranslator->translate(array('languageList'), 'en'); |
|
225
|
|
|
} |
|
226
|
|
|
$languageOptionList->setDisplayName(implode('', $displayName)); |
|
227
|
|
|
$languageOptionList->setValueLabelList(implode('|', $valueLabelList)); |
|
228
|
|
|
|
|
229
|
|
|
$this->persistenceManager->persistAll(); |
|
230
|
|
|
|
|
231
|
|
|
// create input option for all other languages |
|
232
|
|
|
$installedlanguages = $this->sysLanguageRepository->findInstalledLanguages(); |
|
233
|
|
|
if (is_array($installedlanguages)) { |
|
234
|
|
|
foreach ($installedlanguages as $installedLanguage) { |
|
235
|
|
|
$langIsoCode = $installedLanguage->getLangIsocode(); |
|
236
|
|
|
if (!empty($langIsoCode)) { |
|
237
|
|
|
// only when an iso code has been configured, a translation dataset is created |
|
238
|
|
|
if ($inputOptionTranslator->hasTranslation($langIsoCode)) { |
|
239
|
|
|
// only when a translation exists, a translation dataset is created |
|
240
|
|
|
$valueLabelList = $inputOptionTranslator->translate($iso6392b->getValues(), $langIsoCode); |
|
241
|
|
|
$displayName = $inputOptionTranslator->translate(array('languageList'), $langIsoCode); |
|
242
|
|
|
|
|
243
|
|
|
$translatedOptionList = $this->objectManager->get(InputOptionList::class); |
|
244
|
|
|
$translatedOptionList->setDisplayName(implode('', $displayName)); |
|
245
|
|
|
$translatedOptionList->setPid($storagePid); |
|
246
|
|
|
$translatedOptionList->setSysLanguageUid($installedLanguage->getUid()); |
|
247
|
|
|
$translatedOptionList->setL10nParent($languageOptionList->getUid()); |
|
248
|
|
|
$translatedOptionList->setValueLabelList(implode('|', $valueLabelList)); |
|
249
|
|
|
$this->inputOptionListRepository->add($translatedOptionList); |
|
250
|
|
|
|
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
} |
|
254
|
|
|
} |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
} |
|
260
|
|
|
|