1 | <?php |
||
36 | class AdministrationController extends AbstractController |
||
37 | { |
||
38 | const LANG_FILE = 'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:'; |
||
39 | |||
40 | /** |
||
41 | * Backend Template Container |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class; |
||
46 | |||
47 | /** |
||
48 | * CustomNotificationLogRepository |
||
49 | * |
||
50 | * @var \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository |
||
51 | */ |
||
52 | protected $customNotificationLogRepository; |
||
53 | |||
54 | /** |
||
55 | * ExportService |
||
56 | * |
||
57 | * @var \DERHANSEN\SfEventMgt\Service\ExportService |
||
58 | */ |
||
59 | protected $exportService; |
||
60 | |||
61 | /** |
||
62 | * SettingsService |
||
63 | * |
||
64 | * @var \DERHANSEN\SfEventMgt\Service\SettingsService |
||
65 | */ |
||
66 | protected $settingsService; |
||
67 | |||
68 | /** |
||
69 | * Backend User Session Service |
||
70 | * |
||
71 | * @var \DERHANSEN\SfEventMgt\Service\BeUserSessionService |
||
72 | */ |
||
73 | protected $beUserSessionService; |
||
74 | |||
75 | /** |
||
76 | * @var \DERHANSEN\SfEventMgt\Service\MaintenanceService |
||
77 | */ |
||
78 | protected $maintenanceService; |
||
79 | |||
80 | /** |
||
81 | * The current page uid |
||
82 | * |
||
83 | * @var int |
||
84 | */ |
||
85 | protected $pid = 0; |
||
86 | |||
87 | /** |
||
88 | * BackendTemplateContainer |
||
89 | * |
||
90 | * @var BackendTemplateView |
||
91 | 2 | */ |
|
92 | protected $view; |
||
93 | 2 | ||
94 | 2 | /** |
|
95 | * @var IconFactory |
||
96 | */ |
||
97 | protected $iconFactory; |
||
98 | |||
99 | /** |
||
100 | * DI for $customNotificationLogRepository |
||
101 | 4 | * |
|
102 | * @param \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
||
103 | 4 | */ |
|
104 | 2 | public function injectCustomNotificationLogRepository( |
|
105 | 2 | \DERHANSEN\SfEventMgt\Domain\Repository\CustomNotificationLogRepository $customNotificationLogRepository |
|
106 | 4 | ) { |
|
107 | 4 | $this->customNotificationLogRepository = $customNotificationLogRepository; |
|
108 | 4 | } |
|
109 | 4 | ||
110 | 4 | /** |
|
111 | 4 | * DI for $exportService |
|
112 | 4 | * |
|
113 | 4 | * @param Service\ExportService $exportService |
|
114 | 4 | */ |
|
115 | 4 | public function injectExportService(\DERHANSEN\SfEventMgt\Service\ExportService $exportService) |
|
116 | 4 | { |
|
117 | 4 | $this->exportService = $exportService; |
|
118 | 4 | } |
|
119 | 4 | ||
120 | 4 | /** |
|
121 | * DI for $settingsService |
||
122 | * |
||
123 | * @param Service\SettingsService $settingsService |
||
124 | */ |
||
125 | public function injectSettingsService(\DERHANSEN\SfEventMgt\Service\SettingsService $settingsService) |
||
126 | { |
||
127 | $this->settingsService = $settingsService; |
||
128 | } |
||
129 | |||
130 | 8 | /** |
|
131 | * DI for $beUserSessionService |
||
132 | * |
||
133 | 8 | * @param Service\BeUserSessionService $beUserSessionService |
|
134 | */ |
||
135 | 8 | public function injectBeUserSessionService(\DERHANSEN\SfEventMgt\Service\BeUserSessionService $beUserSessionService) |
|
136 | 6 | { |
|
137 | 6 | $this->beUserSessionService = $beUserSessionService; |
|
138 | 8 | } |
|
139 | |||
140 | 8 | /** |
|
141 | 4 | * DI for $iconFactory |
|
142 | 4 | * |
|
143 | * @param IconFactory $iconFactory |
||
144 | 8 | */ |
|
145 | 2 | public function injectIconFactory(IconFactory $iconFactory) |
|
146 | 2 | { |
|
147 | 2 | $this->iconFactory = $iconFactory; |
|
148 | 2 | } |
|
149 | |||
150 | 8 | /** |
|
151 | 8 | * @param Service\MaintenanceService $maintenanceService |
|
152 | 8 | */ |
|
153 | 8 | public function injectMaintenanceService(\DERHANSEN\SfEventMgt\Service\MaintenanceService $maintenanceService) |
|
154 | { |
||
155 | $this->maintenanceService = $maintenanceService; |
||
156 | } |
||
157 | |||
158 | /** |
||
159 | * Set up the doc header properly here |
||
160 | * |
||
161 | * @param ViewInterface $view |
||
162 | 2 | */ |
|
163 | protected function initializeView(ViewInterface $view) |
||
164 | 2 | { |
|
165 | 2 | /** @var BackendTemplateView $view */ |
|
166 | parent::initializeView($view); |
||
167 | if ($this->actionMethodName === 'listAction' |
||
168 | || $this->actionMethodName === 'indexNotifyAction' |
||
169 | || $this->actionMethodName === 'settingsErrorAction' |
||
170 | ) { |
||
171 | $this->registerDocHeaderButtons(); |
||
172 | |||
173 | 2 | $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer(); |
|
174 | $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DateTimePicker'); |
||
175 | 2 | ||
176 | 2 | $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? |
|
177 | 2 | ['MM-DD-YYYY', 'HH:mm MM-DD-YYYY'] : |
|
178 | ['DD-MM-YYYY', 'HH:mm DD-MM-YYYY']; |
||
179 | $pageRenderer->addInlineSetting('DateTimePicker', 'DateFormat', $dateFormat); |
||
180 | |||
181 | $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); |
||
182 | if ($view instanceof BackendTemplateView) { |
||
183 | $view->getModuleTemplate()->getPageRenderer()->addCssFile( |
||
184 | 'EXT:sf_event_mgt/Resources/Public/Css/administration.css' |
||
185 | ); |
||
186 | 2 | } |
|
187 | } |
||
188 | 2 | } |
|
189 | 2 | ||
190 | 2 | /** |
|
191 | 2 | * Register docHeaderButtons |
|
192 | 2 | */ |
|
193 | 2 | protected function registerDocHeaderButtons() |
|
194 | 2 | { |
|
195 | 2 | $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); |
|
196 | |||
197 | $uriBuilder = $this->objectManager->get(ExtbaseUriBuilder::class); |
||
|
|||
198 | $uriBuilder->setRequest($this->request); |
||
199 | |||
200 | if ($this->request->getControllerActionName() === 'list') { |
||
201 | $buttons = [ |
||
202 | [ |
||
203 | 'label' => 'administration.newEvent', |
||
204 | 'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_event'), |
||
205 | 2 | 'icon' => 'ext-sfeventmgt-event', |
|
206 | 'group' => 1 |
||
207 | 2 | ], |
|
208 | 2 | [ |
|
209 | 2 | 'label' => 'administration.newLocation', |
|
210 | 2 | 'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_location'), |
|
211 | 2 | 'icon' => 'ext-sfeventmgt-location', |
|
212 | 'group' => 1 |
||
213 | 2 | ], |
|
214 | 2 | [ |
|
215 | 2 | 'label' => 'administration.newOrganisator', |
|
216 | 'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_organisator'), |
||
217 | 'icon' => 'ext-sfeventmgt-organisator', |
||
218 | 'group' => 1 |
||
219 | ], |
||
220 | [ |
||
221 | 'label' => 'administration.newSpeaker', |
||
222 | 'link' => $this->getCreateNewRecordUri('tx_sfeventmgt_domain_model_speaker'), |
||
223 | 'icon' => 'ext-sfeventmgt-speaker', |
||
224 | 'group' => 1 |
||
225 | ], |
||
226 | [ |
||
227 | 'label' => 'administration.handleExpiredRegistrations', |
||
228 | 'link' => $uriBuilder->reset()->setRequest($this->request) |
||
229 | ->uriFor('handleExpiredRegistrations', [], 'Administration'), |
||
230 | 'icon' => 'ext-sfeventmgt-action-handle-expired', |
||
231 | 'group' => 2, |
||
232 | ] |
||
233 | ]; |
||
234 | foreach ($buttons as $key => $tableConfiguration) { |
||
235 | $title = $this->getLanguageService()->sL(self::LANG_FILE . $tableConfiguration['label']); |
||
236 | $icon = $this->iconFactory->getIcon($tableConfiguration['icon'], Icon::SIZE_SMALL); |
||
237 | $viewButton = $buttonBar->makeLinkButton() |
||
238 | ->setHref($tableConfiguration['link']) |
||
239 | ->setDataAttributes([ |
||
240 | 'toggle' => 'tooltip', |
||
241 | 'placement' => 'bottom', |
||
242 | 'title' => $title |
||
243 | ]) |
||
244 | ->setTitle($title) |
||
245 | ->setIcon($icon); |
||
246 | $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, $tableConfiguration['group']); |
||
247 | } |
||
248 | } |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * Returns the create new record URL for the given table |
||
253 | * |
||
254 | * @param $table |
||
255 | * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException |
||
256 | * @return string |
||
257 | */ |
||
258 | private function getCreateNewRecordUri($table): string |
||
259 | { |
||
260 | $pid = $this->pid; |
||
261 | $tsConfig = BackendUtility::getPagesTSconfig(0); |
||
262 | if ($pid === 0 && isset($tsConfig['defaultPid.']) |
||
263 | && is_array($tsConfig['defaultPid.']) |
||
264 | && isset($tsConfig['defaultPid.'][$table]) |
||
265 | ) { |
||
266 | $pid = (int)$tsConfig['defaultPid.'][$table]; |
||
267 | } |
||
268 | |||
269 | $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
||
270 | |||
271 | return $uriBuilder->buildUriFromRoute('record_edit', [ |
||
272 | 'edit[' . $table . '][' . $pid . ']' => 'new', |
||
273 | 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') |
||
274 | ]); |
||
275 | } |
||
276 | |||
277 | /** |
||
278 | * Initialize action |
||
279 | */ |
||
280 | public function initializeAction() |
||
284 | |||
285 | /** |
||
286 | * Set date format for fields startDate and endDate |
||
287 | */ |
||
288 | public function initializeListAction() |
||
289 | { |
||
290 | if ($this->settings === null || empty($this->settings)) { |
||
291 | $this->redirect('settingsError'); |
||
292 | } |
||
293 | $this->arguments->getArgument('searchDemand') |
||
308 | |||
309 | /** |
||
310 | * List action for backend module |
||
311 | * |
||
312 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand $searchDemand SearchDemand |
||
313 | * @param array $overwriteDemand OverwriteDemand |
||
314 | */ |
||
315 | public function listAction(SearchDemand $searchDemand = null, array $overwriteDemand = []) |
||
347 | |||
348 | /** |
||
349 | * Export registrations for a given event |
||
350 | * |
||
351 | * @param int $eventUid Event UID |
||
352 | */ |
||
353 | public function exportAction($eventUid) |
||
358 | |||
359 | /** |
||
360 | * Handles expired registrations |
||
361 | */ |
||
362 | public function handleExpiredRegistrationsAction() |
||
375 | |||
376 | /** |
||
377 | * The index notify action |
||
378 | * |
||
379 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
||
380 | */ |
||
381 | public function indexNotifyAction(Event $event) |
||
391 | |||
392 | /** |
||
393 | * Notify action |
||
394 | * |
||
395 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event |
||
396 | * @param string $customNotification CustomNotification |
||
397 | */ |
||
398 | public function notifyAction(Event $event, $customNotification) |
||
414 | |||
415 | /** |
||
416 | * Shows the settings error view |
||
417 | */ |
||
418 | public function settingsErrorAction() |
||
421 | |||
422 | /** |
||
423 | * Suppress default validation messages |
||
424 | * |
||
425 | * @return bool |
||
426 | */ |
||
427 | protected function getErrorFlashMessage() |
||
431 | |||
432 | /** |
||
433 | * Returns the LanguageService |
||
434 | * |
||
435 | * @return LanguageService |
||
436 | */ |
||
437 | protected function getLanguageService(): LanguageService |
||
441 | |||
442 | /** |
||
443 | * Returns an array with possible order directions |
||
444 | * |
||
445 | * @return array |
||
446 | */ |
||
447 | public function getOrderDirections() |
||
454 | |||
455 | /** |
||
456 | * Returns an array with possible orderBy fields |
||
457 | * |
||
458 | * @return array |
||
459 | */ |
||
460 | public function getOrderByFields() |
||
468 | } |
||
469 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.