@@ -44,730 +44,730 @@ |
||
44 | 44 | */ |
45 | 45 | class ContentController extends ActionController |
46 | 46 | { |
47 | - /** |
|
48 | - * Initialize every action. |
|
49 | - */ |
|
50 | - public function initializeAction() |
|
51 | - { |
|
52 | - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
53 | - $pageRenderer->addInlineLanguageLabelFile('EXT:vidi/Resources/Private/Language/locallang.xlf'); |
|
54 | - |
|
55 | - // Configure property mapping to retrieve the file object. |
|
56 | - if ($this->arguments->hasArgument('columns')) { |
|
57 | - /** @var CsvToArrayConverter $typeConverter */ |
|
58 | - $typeConverter = GeneralUtility::makeInstance(CsvToArrayConverter::class); |
|
59 | - |
|
60 | - $propertyMappingConfiguration = $this->arguments->getArgument('columns')->getPropertyMappingConfiguration(); |
|
61 | - $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
62 | - } |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * List action for this controller. |
|
67 | - * |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public function indexAction(): ResponseInterface |
|
71 | - { |
|
72 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
73 | - $selections = $this->selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
74 | - $this->view->assign('selections', $selections); |
|
75 | - |
|
76 | - $columns = Tca::grid()->getFields(); |
|
77 | - $this->view->assign('columns', $columns); |
|
78 | - $this->view->assign('numberOfColumns', count($columns)); |
|
79 | - return $this->htmlResponse(); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * List Row action for this controller. Output a json list of contents |
|
84 | - * |
|
85 | - * @param array $columns corresponds to columns to be rendered. |
|
86 | - * @param array $matches |
|
87 | - * @Validate("Fab\Vidi\Domain\Validator\ColumnsValidator", param="columns") |
|
88 | - * @Validate("Fab\Vidi\Domain\Validator\MatchesValidator", param="matches") |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - public function listAction(array $columns = [], $matches = []): ResponseInterface |
|
92 | - { |
|
93 | - // Initialize some objects related to the query. |
|
94 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
95 | - $order = OrderObjectFactory::getInstance()->getOrder(); |
|
96 | - $pager = PagerObjectFactory::getInstance()->getPager(); |
|
97 | - |
|
98 | - // Fetch objects via the Content Service. |
|
99 | - $contentService = $this->getContentService()->findBy($matcher, $order, $pager->getLimit(), $pager->getOffset()); |
|
100 | - $pager->setCount($contentService->getNumberOfObjects()); |
|
101 | - |
|
102 | - // Assign values. |
|
103 | - $this->view->assign('columns', $columns); |
|
104 | - $this->view->assign('objects', $contentService->getObjects()); |
|
105 | - $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
106 | - $this->view->assign('pager', $pager); |
|
107 | - |
|
108 | - $this->view->assign('response', $this->responseFactory->createResponse()); |
|
109 | - return $this->htmlResponse(); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Retrieve Content objects first according to matching criteria and then "update" them. |
|
114 | - * Important to notice the field name can contains a path, e.g. metadata.title and therefore must be analysed. |
|
115 | - * |
|
116 | - * Possible values for $matches: |
|
117 | - * ----------------------------- |
|
118 | - * |
|
119 | - * $matches = array(uid => 1), will be taken as $query->equals |
|
120 | - * $matches = array(uid => 1,2,3), will be taken as $query->in |
|
121 | - * $matches = array(field_name1 => bar, field_name2 => bax), will be separated by AND. |
|
122 | - * |
|
123 | - * Possible values for $content: |
|
124 | - * ----------------------------- |
|
125 | - * |
|
126 | - * $content = array(field_name => bar) |
|
127 | - * $content = array(field_name => array(value1, value2)) <-- will be CSV converted by "value1,value2" |
|
128 | - * |
|
129 | - * @param string $fieldNameAndPath |
|
130 | - * @param array $content |
|
131 | - * @param array $matches |
|
132 | - * @param string $savingBehavior |
|
133 | - * @param int $language |
|
134 | - * @param array $columns |
|
135 | - * @throws InvalidKeyInArrayException |
|
136 | - */ |
|
137 | - public function updateAction($fieldNameAndPath, array $content, array $matches = [], $savingBehavior = SavingBehavior::REPLACE, $language = 0, $columns = []) |
|
138 | - { |
|
139 | - // Instantiate the Matcher object according different rules. |
|
140 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
141 | - $order = OrderObjectFactory::getInstance()->getOrder(); |
|
142 | - |
|
143 | - // Fetch objects via the Content Service. |
|
144 | - $contentService = $this->getContentService()->findBy($matcher, $order); |
|
145 | - |
|
146 | - // Get the real field that is going to be updated. |
|
147 | - $updatedFieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
148 | - |
|
149 | - // Get result object for storing data along the processing. |
|
150 | - $result = $this->getJsonResult(); |
|
151 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
152 | - |
|
153 | - foreach ($contentService->getObjects() as $index => $object) { |
|
154 | - $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid', $language); |
|
155 | - |
|
156 | - // It could be the identifier is not found because the translation |
|
157 | - // of the record does not yet exist when mass-editing |
|
158 | - if ((int)$identifier <= 0) { |
|
159 | - continue; |
|
160 | - } |
|
161 | - |
|
162 | - $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
163 | - |
|
164 | - $signalResult = $this->emitProcessContentDataSignal($object, $fieldNameAndPath, $content, $index + 1, $savingBehavior, $language); |
|
165 | - $contentData = $signalResult->getContentData(); |
|
166 | - |
|
167 | - // Add identifier to content data, required by TCEMain. |
|
168 | - $contentData['uid'] = $identifier; |
|
169 | - |
|
170 | - /** @var Content $dataObject */ |
|
171 | - $dataObject = GeneralUtility::makeInstance(Content::class, $dataType, $contentData); |
|
172 | - |
|
173 | - // Properly update object. |
|
174 | - ContentRepositoryFactory::getInstance($dataType)->update($dataObject); |
|
175 | - |
|
176 | - // Get the possible error messages and store them. |
|
177 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
178 | - $result->addErrorMessages($errorMessages); |
|
179 | - |
|
180 | - // We only want to see the detail result if there is one object updated. |
|
181 | - // Required for inline editing + it will display some useful info on the GUI in the flash messages. |
|
182 | - if ($contentService->getNumberOfObjects() === 1) { |
|
183 | - // Fetch the updated object from repository. |
|
184 | - $updatedObject = ContentRepositoryFactory::getInstance()->findByUid($object->getUid()); |
|
185 | - |
|
186 | - // Re-fetch the updated result. |
|
187 | - $updatedResult = $this->getContentObjectResolver()->getValue($updatedObject, $fieldNameAndPath, $updatedFieldName, $language); |
|
188 | - if (is_array($updatedResult)) { |
|
189 | - $_updatedResult = []; // reset result set. |
|
190 | - |
|
191 | - /** @var Content $contentObject */ |
|
192 | - foreach ($updatedResult as $contentObject) { |
|
193 | - $labelField = Tca::table($contentObject)->getLabelField(); |
|
194 | - $values = array( |
|
195 | - 'uid' => $contentObject->getUid(), |
|
196 | - 'name' => $contentObject[$labelField], |
|
197 | - ); |
|
198 | - $_updatedResult[] = $values; |
|
199 | - } |
|
200 | - |
|
201 | - $updatedResult = $_updatedResult; |
|
202 | - } |
|
203 | - |
|
204 | - $labelField = Tca::table($object)->getLabelField(); |
|
205 | - |
|
206 | - $processedObjectData = array( |
|
207 | - 'uid' => $object->getUid(), |
|
208 | - 'name' => $object[$labelField], |
|
209 | - 'updatedField' => $fieldNameAndPath, |
|
210 | - 'updatedValue' => $updatedResult, |
|
211 | - ); |
|
212 | - $result->setProcessedObject($processedObjectData); |
|
213 | - |
|
214 | - if (!empty($columns)) { |
|
215 | - /** @var Row $row */ |
|
216 | - $row = GeneralUtility::makeInstance(Row::class, $columns); |
|
217 | - $result->setRow($row->render($updatedObject)); |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
221 | - |
|
222 | - $response = $this->responseFactory->createResponse() |
|
223 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
224 | - $response->getBody()->write(json_encode($result)); |
|
225 | - return $response; |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Set the sorting of a record giving the previous object. |
|
230 | - * |
|
231 | - * @param array $matches |
|
232 | - * @param int $previousIdentifier |
|
233 | - */ |
|
234 | - public function sortAction(array $matches = [], $previousIdentifier = null) |
|
235 | - { |
|
236 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
237 | - |
|
238 | - // Fetch objects via the Content Service. |
|
239 | - $contentService = $this->getContentService()->findBy($matcher); |
|
240 | - |
|
241 | - // Compute the label field name of the table. |
|
242 | - $tableTitleField = Tca::table()->getLabelField(); |
|
243 | - |
|
244 | - // Get result object for storing data along the processing. |
|
245 | - $result = $this->getJsonResult(); |
|
246 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
247 | - |
|
248 | - foreach ($contentService->getObjects() as $object) { |
|
249 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
250 | - if ($contentService->getNumberOfObjects() === 1) { |
|
251 | - $tableTitleValue = $object[$tableTitleField]; |
|
252 | - $processedObjectData = array( |
|
253 | - 'uid' => $object->getUid(), |
|
254 | - 'name' => $tableTitleValue, |
|
255 | - ); |
|
256 | - $result->setProcessedObject($processedObjectData); |
|
257 | - } |
|
258 | - |
|
259 | - // The $target corresponds to the pid to move the records to. |
|
260 | - // It can also be a negative value in case of sorting. The negative value would be the uid of its predecessor. |
|
261 | - $target = is_null($previousIdentifier) ? $object->getPid() : (-(int)$previousIdentifier); |
|
262 | - |
|
263 | - // Work out the object. |
|
264 | - ContentRepositoryFactory::getInstance()->move($object, $target); |
|
265 | - |
|
266 | - // Get the possible error messages and store them. |
|
267 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
268 | - $result->addErrorMessages($errorMessages); |
|
269 | - } |
|
270 | - |
|
271 | - $response = $this->responseFactory->createResponse() |
|
272 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
273 | - $response->getBody()->write(json_encode($result)); |
|
274 | - return $response; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Returns an editing form for a given field name of a Content object. |
|
279 | - * Argument $fieldNameAndPath corresponds to the field name to be edited. |
|
280 | - * Important to notice it can contains a path, e.g. metadata.title and therefore must be analysed. |
|
281 | - * |
|
282 | - * Possible values for $matches, refer to method "updateAction". |
|
283 | - * |
|
284 | - * @param string $fieldNameAndPath |
|
285 | - * @param array $matches |
|
286 | - * @param bool $hasRecursiveSelection |
|
287 | - * @throws \Exception |
|
288 | - */ |
|
289 | - public function editAction($fieldNameAndPath, array $matches = [], $hasRecursiveSelection = false): ResponseInterface |
|
290 | - { |
|
291 | - // Instantiate the Matcher object according different rules. |
|
292 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
293 | - |
|
294 | - // Fetch objects via the Content Service. |
|
295 | - $contentService = $this->getContentService()->findBy($matcher); |
|
296 | - |
|
297 | - $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
298 | - $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
299 | - |
|
300 | - $fieldType = Tca::table($dataType)->field($fieldName)->getType(); |
|
301 | - $this->view->assign('fieldType', ucfirst($fieldType)); |
|
302 | - $this->view->assign('dataType', $dataType); |
|
303 | - $this->view->assign('fieldName', $fieldName); |
|
304 | - $this->view->assign('matches', $matches); |
|
305 | - $this->view->assign('fieldNameAndPath', $fieldNameAndPath); |
|
306 | - $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
307 | - $this->view->assign('hasRecursiveSelection', $hasRecursiveSelection); |
|
308 | - $this->view->assign('editWholeSelection', empty($matches['uid'])); // necessary?? |
|
309 | - |
|
310 | - // Fetch content and its relations. |
|
311 | - if ($fieldType === FieldType::MULTISELECT) { |
|
312 | - $object = ContentRepositoryFactory::getInstance()->findOneBy($matcher); |
|
313 | - $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
314 | - $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
315 | - |
|
316 | - $content = ContentRepositoryFactory::getInstance($dataType)->findByUid($identifier); |
|
317 | - |
|
318 | - // Makes sure the object was retrieved. Security! |
|
319 | - if (!$content) { |
|
320 | - $message = sprintf('I could not retrieved content object of type "%s" with identifier %s.', $dataType, $identifier); |
|
321 | - throw new \Exception($message, 1402350182); |
|
322 | - } |
|
323 | - |
|
324 | - $relatedDataType = Tca::table($dataType)->field($fieldName)->getForeignTable(); |
|
325 | - |
|
326 | - // Initialize the matcher object. |
|
327 | - /** @var Matcher $matcher */ |
|
328 | - $matcher = GeneralUtility::makeInstance(Matcher::class, [], $relatedDataType); |
|
329 | - |
|
330 | - // Default ordering for related data type. |
|
331 | - $defaultOrderings = Tca::table($relatedDataType)->getDefaultOrderings(); |
|
332 | - /** @var Order $order */ |
|
333 | - $defaultOrder = GeneralUtility::makeInstance(Order::class, $defaultOrderings); |
|
334 | - |
|
335 | - // Fetch related contents |
|
336 | - $relatedContents = ContentRepositoryFactory::getInstance($relatedDataType)->findBy($matcher, $defaultOrder); |
|
337 | - |
|
338 | - if (Tca::table($dataType)->field($fieldName)->isRenderModeTree()) { |
|
339 | - $fieldConfiguration = Tca::table($dataType)->field($fieldName)->getConfiguration(); |
|
340 | - $parentField = $fieldConfiguration['treeConfig']['parentField']; |
|
341 | - |
|
342 | - $flatTree = []; |
|
343 | - foreach ($relatedContents as $node) { |
|
344 | - $flatTree[$node->getUid()] = array( |
|
345 | - 'item' => $node, |
|
346 | - 'parent' => $node[$parentField] ? $node[$parentField]['uid'] : null, |
|
347 | - ); |
|
348 | - } |
|
349 | - |
|
350 | - $tree = []; |
|
351 | - |
|
352 | - // If leaves are selected without its parents selected, those are shown as parent |
|
353 | - foreach ($flatTree as $id => &$flatNode) { |
|
354 | - if (!isset($flatTree[$flatNode['parent']])) { |
|
355 | - $flatNode['parent'] = null; |
|
356 | - } |
|
357 | - } |
|
358 | - |
|
359 | - foreach ($flatTree as $id => &$node) { |
|
360 | - if ($node['parent'] === null) { |
|
361 | - $tree[$id] = &$node; |
|
362 | - } else { |
|
363 | - $flatTree[$node['parent']]['children'][$id] = &$node; |
|
364 | - } |
|
365 | - } |
|
366 | - |
|
367 | - $relatedContents = $tree; |
|
368 | - } |
|
369 | - |
|
370 | - $this->view->assign('content', $content); |
|
371 | - $this->view->assign('relatedContents', $relatedContents); |
|
372 | - $this->view->assign('relatedDataType', $relatedDataType); |
|
373 | - $this->view->assign('relatedContentTitle', Tca::table($relatedDataType)->getTitle()); |
|
374 | - $this->view->assign( |
|
375 | - 'renderMode', |
|
376 | - Tca::table($dataType)->field($fieldName)->isRenderModeTree() ? FieldType::TREE : null |
|
377 | - ); |
|
378 | - } |
|
379 | - return $this->htmlResponse(); |
|
380 | - } |
|
381 | - |
|
382 | - /** |
|
383 | - * Retrieve Content objects first according to matching criteria and then "delete" them. |
|
384 | - * |
|
385 | - * Possible values for $matches, refer to method "updateAction". |
|
386 | - * |
|
387 | - * @param array $matches |
|
388 | - */ |
|
389 | - public function deleteAction(array $matches = []) |
|
390 | - { |
|
391 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
392 | - |
|
393 | - // Fetch objects via the Content Service. |
|
394 | - $contentService = $this->getContentService()->findBy($matcher); |
|
395 | - |
|
396 | - // Compute the label field name of the table. |
|
397 | - $tableTitleField = Tca::table()->getLabelField(); |
|
398 | - |
|
399 | - // Get result object for storing data along the processing. |
|
400 | - $result = $this->getJsonResult(); |
|
401 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
402 | - |
|
403 | - foreach ($contentService->getObjects() as $object) { |
|
404 | - // Store the first object, so that the delete message can be more explicit when deleting only one record. |
|
405 | - if ($contentService->getNumberOfObjects() === 1) { |
|
406 | - $tableTitleValue = $object[$tableTitleField]; |
|
407 | - $processedObjectData = array( |
|
408 | - 'uid' => $object->getUid(), |
|
409 | - 'name' => $tableTitleValue, |
|
410 | - ); |
|
411 | - $result->setProcessedObject($processedObjectData); |
|
412 | - } |
|
413 | - |
|
414 | - // Properly delete object. |
|
415 | - ContentRepositoryFactory::getInstance()->remove($object); |
|
416 | - |
|
417 | - // Get the possible error messages and store them. |
|
418 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
419 | - $result->addErrorMessages($errorMessages); |
|
420 | - } |
|
421 | - |
|
422 | - $response = $this->responseFactory->createResponse() |
|
423 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
424 | - $response->getBody()->write(json_encode($result)); |
|
425 | - return $response; |
|
426 | - } |
|
427 | - |
|
428 | - /** |
|
429 | - * Retrieve Content objects first according to matching criteria and then "copy" them. |
|
430 | - * |
|
431 | - * Possible values for $matches, refer to method "updateAction". |
|
432 | - * |
|
433 | - * @param string $target |
|
434 | - * @param array $matches |
|
435 | - * @throws \Exception |
|
436 | - * @return string |
|
437 | - */ |
|
438 | - public function copyAction($target, array $matches = []) |
|
439 | - { |
|
440 | - // @todo |
|
441 | - throw new \Exception('Not yet implemented', 1410192546); |
|
442 | - } |
|
443 | - |
|
444 | - /** |
|
445 | - * Retrieve Content objects from the Clipboard then "copy" them according to the target. |
|
446 | - * |
|
447 | - * @param string $target |
|
448 | - * @throws \Exception |
|
449 | - */ |
|
450 | - public function copyClipboardAction($target) |
|
451 | - { |
|
452 | - // Retrieve matcher object from clipboard. |
|
453 | - $matcher = $this->getClipboardService()->getMatcher(); |
|
454 | - |
|
455 | - // Fetch objects via the Content Service. |
|
456 | - $contentService = $this->getContentService()->findBy($matcher); |
|
457 | - |
|
458 | - // Compute the label field name of the table. |
|
459 | - $tableTitleField = Tca::table()->getLabelField(); |
|
460 | - |
|
461 | - // Get result object for storing data along the processing. |
|
462 | - $result = $this->getJsonResult(); |
|
463 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
464 | - |
|
465 | - foreach ($contentService->getObjects() as $object) { |
|
466 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
467 | - if ($contentService->getNumberOfObjects() === 1) { |
|
468 | - $tableTitleValue = $object[$tableTitleField]; |
|
469 | - $processedObjectData = array( |
|
470 | - 'uid' => $object->getUid(), |
|
471 | - 'name' => $tableTitleValue, |
|
472 | - ); |
|
473 | - $result->setProcessedObject($processedObjectData); |
|
474 | - } |
|
475 | - |
|
476 | - // Work out the object. |
|
477 | - ContentRepositoryFactory::getInstance()->copy($object, $target); |
|
478 | - |
|
479 | - // Get the possible error messages and store them. |
|
480 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
481 | - $result->addErrorMessages($errorMessages); |
|
482 | - } |
|
483 | - |
|
484 | - // Flush Clipboard if told so. |
|
485 | - if (GeneralUtility::_GP('flushClipboard')) { |
|
486 | - $this->getClipboardService()->flush(); |
|
487 | - } |
|
488 | - |
|
489 | - $response = $this->responseFactory->createResponse() |
|
490 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
491 | - $response->getBody()->write(json_encode($result)); |
|
492 | - return $response; |
|
493 | - } |
|
494 | - |
|
495 | - /** |
|
496 | - * Retrieve Content objects first according to matching criteria and then "move" them. |
|
497 | - * |
|
498 | - * Possible values for $matches, refer to method "updateAction". |
|
499 | - * |
|
500 | - * @param string $target |
|
501 | - * @param array $matches |
|
502 | - */ |
|
503 | - public function moveAction($target, array $matches = []) |
|
504 | - { |
|
505 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
506 | - |
|
507 | - // Fetch objects via the Content Service. |
|
508 | - $contentService = $this->getContentService()->findBy($matcher); |
|
509 | - |
|
510 | - // Compute the label field name of the table. |
|
511 | - $tableTitleField = Tca::table()->getLabelField(); |
|
512 | - |
|
513 | - // Get result object for storing data along the processing. |
|
514 | - $result = $this->getJsonResult(); |
|
515 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
516 | - |
|
517 | - foreach ($contentService->getObjects() as $object) { |
|
518 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
519 | - if ($contentService->getNumberOfObjects() === 1) { |
|
520 | - $tableTitleValue = $object[$tableTitleField]; |
|
521 | - $processedObjectData = array( |
|
522 | - 'uid' => $object->getUid(), |
|
523 | - 'name' => $tableTitleValue, |
|
524 | - ); |
|
525 | - $result->setProcessedObject($processedObjectData); |
|
526 | - } |
|
527 | - |
|
528 | - // Work out the object. |
|
529 | - ContentRepositoryFactory::getInstance()->move($object, $target); |
|
530 | - |
|
531 | - // Get the possible error messages and store them. |
|
532 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
533 | - $result->addErrorMessages($errorMessages); |
|
534 | - } |
|
535 | - |
|
536 | - $response = $this->responseFactory->createResponse() |
|
537 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
538 | - $response->getBody()->write(json_encode($result)); |
|
539 | - return $response; |
|
540 | - } |
|
541 | - |
|
542 | - /** |
|
543 | - * Retrieve Content objects from the Clipboard then "move" them according to the target. |
|
544 | - * |
|
545 | - * @param string $target |
|
546 | - */ |
|
547 | - public function moveClipboardAction($target) |
|
548 | - { |
|
549 | - // Retrieve matcher object from clipboard. |
|
550 | - $matcher = $this->getClipboardService()->getMatcher(); |
|
551 | - |
|
552 | - // Fetch objects via the Content Service. |
|
553 | - $contentService = $this->getContentService()->findBy($matcher); |
|
554 | - |
|
555 | - // Compute the label field name of the table. |
|
556 | - $tableTitleField = Tca::table()->getLabelField(); |
|
557 | - |
|
558 | - // Get result object for storing data along the processing. |
|
559 | - $result = $this->getJsonResult(); |
|
560 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
561 | - |
|
562 | - foreach ($contentService->getObjects() as $object) { |
|
563 | - // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
564 | - if ($contentService->getNumberOfObjects() === 1) { |
|
565 | - $tableTitleValue = $object[$tableTitleField]; |
|
566 | - $processedObjectData = array( |
|
567 | - 'uid' => $object->getUid(), |
|
568 | - 'name' => $tableTitleValue, |
|
569 | - ); |
|
570 | - $result->setProcessedObject($processedObjectData); |
|
571 | - } |
|
572 | - |
|
573 | - // Work out the object. |
|
574 | - ContentRepositoryFactory::getInstance()->move($object, $target); |
|
575 | - |
|
576 | - // Get the possible error messages and store them. |
|
577 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
578 | - $result->addErrorMessages($errorMessages); |
|
579 | - } |
|
580 | - |
|
581 | - // Flush Clipboard if told so. |
|
582 | - if (GeneralUtility::_GP('flushClipboard')) { |
|
583 | - $this->getClipboardService()->flush(); |
|
584 | - } |
|
585 | - |
|
586 | - $response = $this->responseFactory->createResponse() |
|
587 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
588 | - $response->getBody()->write(json_encode($result)); |
|
589 | - return $response; |
|
590 | - } |
|
591 | - |
|
592 | - /** |
|
593 | - * Retrieve Content objects first according to matching criteria and then "localize" them. |
|
594 | - * |
|
595 | - * Possible values for $matches, refer to method "updateAction". |
|
596 | - * |
|
597 | - * @param string $fieldNameAndPath |
|
598 | - * @param array $matches |
|
599 | - * @param int $language |
|
600 | - * @throws \Exception |
|
601 | - */ |
|
602 | - public function localizeAction($fieldNameAndPath, array $matches = [], $language = 0) |
|
603 | - { |
|
604 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
605 | - |
|
606 | - // Fetch objects via the Content Service. |
|
607 | - $contentService = $this->getContentService()->findBy($matcher); |
|
608 | - |
|
609 | - // Get result object for storing data along the processing. |
|
610 | - $result = $this->getJsonResult(); |
|
611 | - $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
612 | - |
|
613 | - foreach ($contentService->getObjects() as $object) { |
|
614 | - $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
615 | - $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
616 | - |
|
617 | - // Fetch the source object to be localized. |
|
618 | - /** @var Content $content */ |
|
619 | - $content = ContentRepositoryFactory::getInstance($dataType)->findByIdentifier($identifier); |
|
620 | - |
|
621 | - // Makes sure the object was retrieved. Security! |
|
622 | - if (!$content) { |
|
623 | - $message = sprintf('Something went wrong when retrieving content "%s" with identifier "%s".', $dataType, $identifier); |
|
624 | - throw new \Exception($message, 1412343097); |
|
625 | - } |
|
626 | - |
|
627 | - // Handover the localization to the Repository. |
|
628 | - ContentRepositoryFactory::getInstance($dataType)->localize($content, $language); |
|
629 | - |
|
630 | - // Get the possible error messages and store them. |
|
631 | - $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
632 | - |
|
633 | - // Redirect to TCEForm so that the BE User can do its job! |
|
634 | - if ($contentService->getNumberOfObjects() === 1) { |
|
635 | - if (!empty($errorMessages)) { |
|
636 | - $message = sprintf( |
|
637 | - 'Something went wrong when localizing content "%s" with identifier "%s". <br/>%s', |
|
638 | - $dataType, |
|
639 | - $identifier, |
|
640 | - implode('<br/>', $errorMessages) |
|
641 | - ); |
|
642 | - throw new \Exception($message, 1412343098); |
|
643 | - } |
|
644 | - |
|
645 | - $localizedContent = $this->getLanguageService()->getLocalizedContent($content, $language); |
|
646 | - if (empty($localizedContent)) { |
|
647 | - $message = sprintf( |
|
648 | - 'Oups! I could not retrieve localized content of type "%s" with identifier "%s"', |
|
649 | - $content->getDataType(), |
|
650 | - $content->getUid() |
|
651 | - ); |
|
652 | - throw new \Exception($message, 1412343099); |
|
653 | - } |
|
654 | - |
|
655 | - /** @var EditUri $uri */ |
|
656 | - $uriRenderer = GeneralUtility::makeInstance(EditUri::class); |
|
657 | - $uri = $uriRenderer->render($localizedContent); |
|
658 | - HttpUtility::redirect($uri); |
|
659 | - break; // no need to further continue |
|
660 | - } |
|
661 | - |
|
662 | - $result->addErrorMessages($errorMessages); |
|
663 | - } |
|
664 | - |
|
665 | - $response = $this->responseFactory->createResponse() |
|
666 | - ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
667 | - $response->getBody()->write(json_encode($result)); |
|
668 | - return $response; |
|
669 | - } |
|
670 | - |
|
671 | - /** |
|
672 | - * Get the Vidi Module Loader. |
|
673 | - * |
|
674 | - * @return ContentService |
|
675 | - */ |
|
676 | - protected function getContentService() |
|
677 | - { |
|
678 | - return GeneralUtility::makeInstance(ContentService::class); |
|
679 | - } |
|
680 | - |
|
681 | - /** |
|
682 | - * @return ContentObjectResolver |
|
683 | - */ |
|
684 | - protected function getContentObjectResolver() |
|
685 | - { |
|
686 | - return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
687 | - } |
|
688 | - |
|
689 | - /** |
|
690 | - * @return FieldPathResolver |
|
691 | - */ |
|
692 | - protected function getFieldPathResolver() |
|
693 | - { |
|
694 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
695 | - } |
|
696 | - |
|
697 | - /** |
|
698 | - * @return JsonResult|object |
|
699 | - */ |
|
700 | - protected function getJsonResult() |
|
701 | - { |
|
702 | - return GeneralUtility::makeInstance(JsonResult::class); |
|
703 | - } |
|
704 | - |
|
705 | - /** |
|
706 | - * Signal that is called for post-processing content data send to the server for update. |
|
707 | - * |
|
708 | - * @param Content $contentObject |
|
709 | - * @param $fieldNameAndPath |
|
710 | - * @param $contentData |
|
711 | - * @param $counter |
|
712 | - * @param $savingBehavior |
|
713 | - * @param $language |
|
714 | - * @return ProcessContentDataSignalArguments |
|
715 | - */ |
|
716 | - protected function emitProcessContentDataSignal(Content $contentObject, $fieldNameAndPath, $contentData, $counter, $savingBehavior, $language) |
|
717 | - { |
|
718 | - /** @var ProcessContentDataSignalArguments $signalArguments */ |
|
719 | - $signalArguments = GeneralUtility::makeInstance(ProcessContentDataSignalArguments::class); |
|
720 | - $signalArguments->setContentObject($contentObject) |
|
721 | - ->setFieldNameAndPath($fieldNameAndPath) |
|
722 | - ->setContentData($contentData) |
|
723 | - ->setCounter($counter) |
|
724 | - ->setSavingBehavior($savingBehavior) |
|
725 | - ->setLanguage($language); |
|
726 | - |
|
727 | - $signalResult = $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\Controller\Backend\ContentController', 'processContentData', array($signalArguments)); |
|
728 | - return $signalResult[0]; |
|
729 | - } |
|
730 | - |
|
731 | - /** |
|
732 | - * Get the SignalSlot dispatcher. |
|
733 | - * |
|
734 | - * @return Dispatcher |
|
735 | - */ |
|
736 | - protected function getSignalSlotDispatcher() |
|
737 | - { |
|
738 | - return GeneralUtility::makeInstance(Dispatcher::class); |
|
739 | - } |
|
740 | - |
|
741 | - /** |
|
742 | - * Get the Clipboard service. |
|
743 | - * |
|
744 | - * @return ClipboardService |
|
745 | - */ |
|
746 | - protected function getClipboardService() |
|
747 | - { |
|
748 | - return GeneralUtility::makeInstance(ClipboardService::class); |
|
749 | - } |
|
750 | - |
|
751 | - /** |
|
752 | - * @return LanguageService |
|
753 | - */ |
|
754 | - protected function getLanguageService() |
|
755 | - { |
|
756 | - return GeneralUtility::makeInstance(LanguageService::class); |
|
757 | - } |
|
758 | - |
|
759 | - /** |
|
760 | - * Get the Vidi Module Loader. |
|
761 | - * |
|
762 | - * @return ModuleLoader |
|
763 | - */ |
|
764 | - protected function getModuleLoader() |
|
765 | - { |
|
766 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
767 | - } |
|
768 | - |
|
769 | - public function injectSelectionRepository(SelectionRepository $selectionRepository): void |
|
770 | - { |
|
771 | - $this->selectionRepository = $selectionRepository; |
|
772 | - } |
|
47 | + /** |
|
48 | + * Initialize every action. |
|
49 | + */ |
|
50 | + public function initializeAction() |
|
51 | + { |
|
52 | + $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); |
|
53 | + $pageRenderer->addInlineLanguageLabelFile('EXT:vidi/Resources/Private/Language/locallang.xlf'); |
|
54 | + |
|
55 | + // Configure property mapping to retrieve the file object. |
|
56 | + if ($this->arguments->hasArgument('columns')) { |
|
57 | + /** @var CsvToArrayConverter $typeConverter */ |
|
58 | + $typeConverter = GeneralUtility::makeInstance(CsvToArrayConverter::class); |
|
59 | + |
|
60 | + $propertyMappingConfiguration = $this->arguments->getArgument('columns')->getPropertyMappingConfiguration(); |
|
61 | + $propertyMappingConfiguration->setTypeConverter($typeConverter); |
|
62 | + } |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * List action for this controller. |
|
67 | + * |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public function indexAction(): ResponseInterface |
|
71 | + { |
|
72 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
73 | + $selections = $this->selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
74 | + $this->view->assign('selections', $selections); |
|
75 | + |
|
76 | + $columns = Tca::grid()->getFields(); |
|
77 | + $this->view->assign('columns', $columns); |
|
78 | + $this->view->assign('numberOfColumns', count($columns)); |
|
79 | + return $this->htmlResponse(); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * List Row action for this controller. Output a json list of contents |
|
84 | + * |
|
85 | + * @param array $columns corresponds to columns to be rendered. |
|
86 | + * @param array $matches |
|
87 | + * @Validate("Fab\Vidi\Domain\Validator\ColumnsValidator", param="columns") |
|
88 | + * @Validate("Fab\Vidi\Domain\Validator\MatchesValidator", param="matches") |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + public function listAction(array $columns = [], $matches = []): ResponseInterface |
|
92 | + { |
|
93 | + // Initialize some objects related to the query. |
|
94 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
95 | + $order = OrderObjectFactory::getInstance()->getOrder(); |
|
96 | + $pager = PagerObjectFactory::getInstance()->getPager(); |
|
97 | + |
|
98 | + // Fetch objects via the Content Service. |
|
99 | + $contentService = $this->getContentService()->findBy($matcher, $order, $pager->getLimit(), $pager->getOffset()); |
|
100 | + $pager->setCount($contentService->getNumberOfObjects()); |
|
101 | + |
|
102 | + // Assign values. |
|
103 | + $this->view->assign('columns', $columns); |
|
104 | + $this->view->assign('objects', $contentService->getObjects()); |
|
105 | + $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
106 | + $this->view->assign('pager', $pager); |
|
107 | + |
|
108 | + $this->view->assign('response', $this->responseFactory->createResponse()); |
|
109 | + return $this->htmlResponse(); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Retrieve Content objects first according to matching criteria and then "update" them. |
|
114 | + * Important to notice the field name can contains a path, e.g. metadata.title and therefore must be analysed. |
|
115 | + * |
|
116 | + * Possible values for $matches: |
|
117 | + * ----------------------------- |
|
118 | + * |
|
119 | + * $matches = array(uid => 1), will be taken as $query->equals |
|
120 | + * $matches = array(uid => 1,2,3), will be taken as $query->in |
|
121 | + * $matches = array(field_name1 => bar, field_name2 => bax), will be separated by AND. |
|
122 | + * |
|
123 | + * Possible values for $content: |
|
124 | + * ----------------------------- |
|
125 | + * |
|
126 | + * $content = array(field_name => bar) |
|
127 | + * $content = array(field_name => array(value1, value2)) <-- will be CSV converted by "value1,value2" |
|
128 | + * |
|
129 | + * @param string $fieldNameAndPath |
|
130 | + * @param array $content |
|
131 | + * @param array $matches |
|
132 | + * @param string $savingBehavior |
|
133 | + * @param int $language |
|
134 | + * @param array $columns |
|
135 | + * @throws InvalidKeyInArrayException |
|
136 | + */ |
|
137 | + public function updateAction($fieldNameAndPath, array $content, array $matches = [], $savingBehavior = SavingBehavior::REPLACE, $language = 0, $columns = []) |
|
138 | + { |
|
139 | + // Instantiate the Matcher object according different rules. |
|
140 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
141 | + $order = OrderObjectFactory::getInstance()->getOrder(); |
|
142 | + |
|
143 | + // Fetch objects via the Content Service. |
|
144 | + $contentService = $this->getContentService()->findBy($matcher, $order); |
|
145 | + |
|
146 | + // Get the real field that is going to be updated. |
|
147 | + $updatedFieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
148 | + |
|
149 | + // Get result object for storing data along the processing. |
|
150 | + $result = $this->getJsonResult(); |
|
151 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
152 | + |
|
153 | + foreach ($contentService->getObjects() as $index => $object) { |
|
154 | + $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid', $language); |
|
155 | + |
|
156 | + // It could be the identifier is not found because the translation |
|
157 | + // of the record does not yet exist when mass-editing |
|
158 | + if ((int)$identifier <= 0) { |
|
159 | + continue; |
|
160 | + } |
|
161 | + |
|
162 | + $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
163 | + |
|
164 | + $signalResult = $this->emitProcessContentDataSignal($object, $fieldNameAndPath, $content, $index + 1, $savingBehavior, $language); |
|
165 | + $contentData = $signalResult->getContentData(); |
|
166 | + |
|
167 | + // Add identifier to content data, required by TCEMain. |
|
168 | + $contentData['uid'] = $identifier; |
|
169 | + |
|
170 | + /** @var Content $dataObject */ |
|
171 | + $dataObject = GeneralUtility::makeInstance(Content::class, $dataType, $contentData); |
|
172 | + |
|
173 | + // Properly update object. |
|
174 | + ContentRepositoryFactory::getInstance($dataType)->update($dataObject); |
|
175 | + |
|
176 | + // Get the possible error messages and store them. |
|
177 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
178 | + $result->addErrorMessages($errorMessages); |
|
179 | + |
|
180 | + // We only want to see the detail result if there is one object updated. |
|
181 | + // Required for inline editing + it will display some useful info on the GUI in the flash messages. |
|
182 | + if ($contentService->getNumberOfObjects() === 1) { |
|
183 | + // Fetch the updated object from repository. |
|
184 | + $updatedObject = ContentRepositoryFactory::getInstance()->findByUid($object->getUid()); |
|
185 | + |
|
186 | + // Re-fetch the updated result. |
|
187 | + $updatedResult = $this->getContentObjectResolver()->getValue($updatedObject, $fieldNameAndPath, $updatedFieldName, $language); |
|
188 | + if (is_array($updatedResult)) { |
|
189 | + $_updatedResult = []; // reset result set. |
|
190 | + |
|
191 | + /** @var Content $contentObject */ |
|
192 | + foreach ($updatedResult as $contentObject) { |
|
193 | + $labelField = Tca::table($contentObject)->getLabelField(); |
|
194 | + $values = array( |
|
195 | + 'uid' => $contentObject->getUid(), |
|
196 | + 'name' => $contentObject[$labelField], |
|
197 | + ); |
|
198 | + $_updatedResult[] = $values; |
|
199 | + } |
|
200 | + |
|
201 | + $updatedResult = $_updatedResult; |
|
202 | + } |
|
203 | + |
|
204 | + $labelField = Tca::table($object)->getLabelField(); |
|
205 | + |
|
206 | + $processedObjectData = array( |
|
207 | + 'uid' => $object->getUid(), |
|
208 | + 'name' => $object[$labelField], |
|
209 | + 'updatedField' => $fieldNameAndPath, |
|
210 | + 'updatedValue' => $updatedResult, |
|
211 | + ); |
|
212 | + $result->setProcessedObject($processedObjectData); |
|
213 | + |
|
214 | + if (!empty($columns)) { |
|
215 | + /** @var Row $row */ |
|
216 | + $row = GeneralUtility::makeInstance(Row::class, $columns); |
|
217 | + $result->setRow($row->render($updatedObject)); |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | + |
|
222 | + $response = $this->responseFactory->createResponse() |
|
223 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
224 | + $response->getBody()->write(json_encode($result)); |
|
225 | + return $response; |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Set the sorting of a record giving the previous object. |
|
230 | + * |
|
231 | + * @param array $matches |
|
232 | + * @param int $previousIdentifier |
|
233 | + */ |
|
234 | + public function sortAction(array $matches = [], $previousIdentifier = null) |
|
235 | + { |
|
236 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
237 | + |
|
238 | + // Fetch objects via the Content Service. |
|
239 | + $contentService = $this->getContentService()->findBy($matcher); |
|
240 | + |
|
241 | + // Compute the label field name of the table. |
|
242 | + $tableTitleField = Tca::table()->getLabelField(); |
|
243 | + |
|
244 | + // Get result object for storing data along the processing. |
|
245 | + $result = $this->getJsonResult(); |
|
246 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
247 | + |
|
248 | + foreach ($contentService->getObjects() as $object) { |
|
249 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
250 | + if ($contentService->getNumberOfObjects() === 1) { |
|
251 | + $tableTitleValue = $object[$tableTitleField]; |
|
252 | + $processedObjectData = array( |
|
253 | + 'uid' => $object->getUid(), |
|
254 | + 'name' => $tableTitleValue, |
|
255 | + ); |
|
256 | + $result->setProcessedObject($processedObjectData); |
|
257 | + } |
|
258 | + |
|
259 | + // The $target corresponds to the pid to move the records to. |
|
260 | + // It can also be a negative value in case of sorting. The negative value would be the uid of its predecessor. |
|
261 | + $target = is_null($previousIdentifier) ? $object->getPid() : (-(int)$previousIdentifier); |
|
262 | + |
|
263 | + // Work out the object. |
|
264 | + ContentRepositoryFactory::getInstance()->move($object, $target); |
|
265 | + |
|
266 | + // Get the possible error messages and store them. |
|
267 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
268 | + $result->addErrorMessages($errorMessages); |
|
269 | + } |
|
270 | + |
|
271 | + $response = $this->responseFactory->createResponse() |
|
272 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
273 | + $response->getBody()->write(json_encode($result)); |
|
274 | + return $response; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Returns an editing form for a given field name of a Content object. |
|
279 | + * Argument $fieldNameAndPath corresponds to the field name to be edited. |
|
280 | + * Important to notice it can contains a path, e.g. metadata.title and therefore must be analysed. |
|
281 | + * |
|
282 | + * Possible values for $matches, refer to method "updateAction". |
|
283 | + * |
|
284 | + * @param string $fieldNameAndPath |
|
285 | + * @param array $matches |
|
286 | + * @param bool $hasRecursiveSelection |
|
287 | + * @throws \Exception |
|
288 | + */ |
|
289 | + public function editAction($fieldNameAndPath, array $matches = [], $hasRecursiveSelection = false): ResponseInterface |
|
290 | + { |
|
291 | + // Instantiate the Matcher object according different rules. |
|
292 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
293 | + |
|
294 | + // Fetch objects via the Content Service. |
|
295 | + $contentService = $this->getContentService()->findBy($matcher); |
|
296 | + |
|
297 | + $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath); |
|
298 | + $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath); |
|
299 | + |
|
300 | + $fieldType = Tca::table($dataType)->field($fieldName)->getType(); |
|
301 | + $this->view->assign('fieldType', ucfirst($fieldType)); |
|
302 | + $this->view->assign('dataType', $dataType); |
|
303 | + $this->view->assign('fieldName', $fieldName); |
|
304 | + $this->view->assign('matches', $matches); |
|
305 | + $this->view->assign('fieldNameAndPath', $fieldNameAndPath); |
|
306 | + $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
307 | + $this->view->assign('hasRecursiveSelection', $hasRecursiveSelection); |
|
308 | + $this->view->assign('editWholeSelection', empty($matches['uid'])); // necessary?? |
|
309 | + |
|
310 | + // Fetch content and its relations. |
|
311 | + if ($fieldType === FieldType::MULTISELECT) { |
|
312 | + $object = ContentRepositoryFactory::getInstance()->findOneBy($matcher); |
|
313 | + $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
314 | + $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
315 | + |
|
316 | + $content = ContentRepositoryFactory::getInstance($dataType)->findByUid($identifier); |
|
317 | + |
|
318 | + // Makes sure the object was retrieved. Security! |
|
319 | + if (!$content) { |
|
320 | + $message = sprintf('I could not retrieved content object of type "%s" with identifier %s.', $dataType, $identifier); |
|
321 | + throw new \Exception($message, 1402350182); |
|
322 | + } |
|
323 | + |
|
324 | + $relatedDataType = Tca::table($dataType)->field($fieldName)->getForeignTable(); |
|
325 | + |
|
326 | + // Initialize the matcher object. |
|
327 | + /** @var Matcher $matcher */ |
|
328 | + $matcher = GeneralUtility::makeInstance(Matcher::class, [], $relatedDataType); |
|
329 | + |
|
330 | + // Default ordering for related data type. |
|
331 | + $defaultOrderings = Tca::table($relatedDataType)->getDefaultOrderings(); |
|
332 | + /** @var Order $order */ |
|
333 | + $defaultOrder = GeneralUtility::makeInstance(Order::class, $defaultOrderings); |
|
334 | + |
|
335 | + // Fetch related contents |
|
336 | + $relatedContents = ContentRepositoryFactory::getInstance($relatedDataType)->findBy($matcher, $defaultOrder); |
|
337 | + |
|
338 | + if (Tca::table($dataType)->field($fieldName)->isRenderModeTree()) { |
|
339 | + $fieldConfiguration = Tca::table($dataType)->field($fieldName)->getConfiguration(); |
|
340 | + $parentField = $fieldConfiguration['treeConfig']['parentField']; |
|
341 | + |
|
342 | + $flatTree = []; |
|
343 | + foreach ($relatedContents as $node) { |
|
344 | + $flatTree[$node->getUid()] = array( |
|
345 | + 'item' => $node, |
|
346 | + 'parent' => $node[$parentField] ? $node[$parentField]['uid'] : null, |
|
347 | + ); |
|
348 | + } |
|
349 | + |
|
350 | + $tree = []; |
|
351 | + |
|
352 | + // If leaves are selected without its parents selected, those are shown as parent |
|
353 | + foreach ($flatTree as $id => &$flatNode) { |
|
354 | + if (!isset($flatTree[$flatNode['parent']])) { |
|
355 | + $flatNode['parent'] = null; |
|
356 | + } |
|
357 | + } |
|
358 | + |
|
359 | + foreach ($flatTree as $id => &$node) { |
|
360 | + if ($node['parent'] === null) { |
|
361 | + $tree[$id] = &$node; |
|
362 | + } else { |
|
363 | + $flatTree[$node['parent']]['children'][$id] = &$node; |
|
364 | + } |
|
365 | + } |
|
366 | + |
|
367 | + $relatedContents = $tree; |
|
368 | + } |
|
369 | + |
|
370 | + $this->view->assign('content', $content); |
|
371 | + $this->view->assign('relatedContents', $relatedContents); |
|
372 | + $this->view->assign('relatedDataType', $relatedDataType); |
|
373 | + $this->view->assign('relatedContentTitle', Tca::table($relatedDataType)->getTitle()); |
|
374 | + $this->view->assign( |
|
375 | + 'renderMode', |
|
376 | + Tca::table($dataType)->field($fieldName)->isRenderModeTree() ? FieldType::TREE : null |
|
377 | + ); |
|
378 | + } |
|
379 | + return $this->htmlResponse(); |
|
380 | + } |
|
381 | + |
|
382 | + /** |
|
383 | + * Retrieve Content objects first according to matching criteria and then "delete" them. |
|
384 | + * |
|
385 | + * Possible values for $matches, refer to method "updateAction". |
|
386 | + * |
|
387 | + * @param array $matches |
|
388 | + */ |
|
389 | + public function deleteAction(array $matches = []) |
|
390 | + { |
|
391 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
392 | + |
|
393 | + // Fetch objects via the Content Service. |
|
394 | + $contentService = $this->getContentService()->findBy($matcher); |
|
395 | + |
|
396 | + // Compute the label field name of the table. |
|
397 | + $tableTitleField = Tca::table()->getLabelField(); |
|
398 | + |
|
399 | + // Get result object for storing data along the processing. |
|
400 | + $result = $this->getJsonResult(); |
|
401 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
402 | + |
|
403 | + foreach ($contentService->getObjects() as $object) { |
|
404 | + // Store the first object, so that the delete message can be more explicit when deleting only one record. |
|
405 | + if ($contentService->getNumberOfObjects() === 1) { |
|
406 | + $tableTitleValue = $object[$tableTitleField]; |
|
407 | + $processedObjectData = array( |
|
408 | + 'uid' => $object->getUid(), |
|
409 | + 'name' => $tableTitleValue, |
|
410 | + ); |
|
411 | + $result->setProcessedObject($processedObjectData); |
|
412 | + } |
|
413 | + |
|
414 | + // Properly delete object. |
|
415 | + ContentRepositoryFactory::getInstance()->remove($object); |
|
416 | + |
|
417 | + // Get the possible error messages and store them. |
|
418 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
419 | + $result->addErrorMessages($errorMessages); |
|
420 | + } |
|
421 | + |
|
422 | + $response = $this->responseFactory->createResponse() |
|
423 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
424 | + $response->getBody()->write(json_encode($result)); |
|
425 | + return $response; |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * Retrieve Content objects first according to matching criteria and then "copy" them. |
|
430 | + * |
|
431 | + * Possible values for $matches, refer to method "updateAction". |
|
432 | + * |
|
433 | + * @param string $target |
|
434 | + * @param array $matches |
|
435 | + * @throws \Exception |
|
436 | + * @return string |
|
437 | + */ |
|
438 | + public function copyAction($target, array $matches = []) |
|
439 | + { |
|
440 | + // @todo |
|
441 | + throw new \Exception('Not yet implemented', 1410192546); |
|
442 | + } |
|
443 | + |
|
444 | + /** |
|
445 | + * Retrieve Content objects from the Clipboard then "copy" them according to the target. |
|
446 | + * |
|
447 | + * @param string $target |
|
448 | + * @throws \Exception |
|
449 | + */ |
|
450 | + public function copyClipboardAction($target) |
|
451 | + { |
|
452 | + // Retrieve matcher object from clipboard. |
|
453 | + $matcher = $this->getClipboardService()->getMatcher(); |
|
454 | + |
|
455 | + // Fetch objects via the Content Service. |
|
456 | + $contentService = $this->getContentService()->findBy($matcher); |
|
457 | + |
|
458 | + // Compute the label field name of the table. |
|
459 | + $tableTitleField = Tca::table()->getLabelField(); |
|
460 | + |
|
461 | + // Get result object for storing data along the processing. |
|
462 | + $result = $this->getJsonResult(); |
|
463 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
464 | + |
|
465 | + foreach ($contentService->getObjects() as $object) { |
|
466 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
467 | + if ($contentService->getNumberOfObjects() === 1) { |
|
468 | + $tableTitleValue = $object[$tableTitleField]; |
|
469 | + $processedObjectData = array( |
|
470 | + 'uid' => $object->getUid(), |
|
471 | + 'name' => $tableTitleValue, |
|
472 | + ); |
|
473 | + $result->setProcessedObject($processedObjectData); |
|
474 | + } |
|
475 | + |
|
476 | + // Work out the object. |
|
477 | + ContentRepositoryFactory::getInstance()->copy($object, $target); |
|
478 | + |
|
479 | + // Get the possible error messages and store them. |
|
480 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
481 | + $result->addErrorMessages($errorMessages); |
|
482 | + } |
|
483 | + |
|
484 | + // Flush Clipboard if told so. |
|
485 | + if (GeneralUtility::_GP('flushClipboard')) { |
|
486 | + $this->getClipboardService()->flush(); |
|
487 | + } |
|
488 | + |
|
489 | + $response = $this->responseFactory->createResponse() |
|
490 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
491 | + $response->getBody()->write(json_encode($result)); |
|
492 | + return $response; |
|
493 | + } |
|
494 | + |
|
495 | + /** |
|
496 | + * Retrieve Content objects first according to matching criteria and then "move" them. |
|
497 | + * |
|
498 | + * Possible values for $matches, refer to method "updateAction". |
|
499 | + * |
|
500 | + * @param string $target |
|
501 | + * @param array $matches |
|
502 | + */ |
|
503 | + public function moveAction($target, array $matches = []) |
|
504 | + { |
|
505 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
506 | + |
|
507 | + // Fetch objects via the Content Service. |
|
508 | + $contentService = $this->getContentService()->findBy($matcher); |
|
509 | + |
|
510 | + // Compute the label field name of the table. |
|
511 | + $tableTitleField = Tca::table()->getLabelField(); |
|
512 | + |
|
513 | + // Get result object for storing data along the processing. |
|
514 | + $result = $this->getJsonResult(); |
|
515 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
516 | + |
|
517 | + foreach ($contentService->getObjects() as $object) { |
|
518 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
519 | + if ($contentService->getNumberOfObjects() === 1) { |
|
520 | + $tableTitleValue = $object[$tableTitleField]; |
|
521 | + $processedObjectData = array( |
|
522 | + 'uid' => $object->getUid(), |
|
523 | + 'name' => $tableTitleValue, |
|
524 | + ); |
|
525 | + $result->setProcessedObject($processedObjectData); |
|
526 | + } |
|
527 | + |
|
528 | + // Work out the object. |
|
529 | + ContentRepositoryFactory::getInstance()->move($object, $target); |
|
530 | + |
|
531 | + // Get the possible error messages and store them. |
|
532 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
533 | + $result->addErrorMessages($errorMessages); |
|
534 | + } |
|
535 | + |
|
536 | + $response = $this->responseFactory->createResponse() |
|
537 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
538 | + $response->getBody()->write(json_encode($result)); |
|
539 | + return $response; |
|
540 | + } |
|
541 | + |
|
542 | + /** |
|
543 | + * Retrieve Content objects from the Clipboard then "move" them according to the target. |
|
544 | + * |
|
545 | + * @param string $target |
|
546 | + */ |
|
547 | + public function moveClipboardAction($target) |
|
548 | + { |
|
549 | + // Retrieve matcher object from clipboard. |
|
550 | + $matcher = $this->getClipboardService()->getMatcher(); |
|
551 | + |
|
552 | + // Fetch objects via the Content Service. |
|
553 | + $contentService = $this->getContentService()->findBy($matcher); |
|
554 | + |
|
555 | + // Compute the label field name of the table. |
|
556 | + $tableTitleField = Tca::table()->getLabelField(); |
|
557 | + |
|
558 | + // Get result object for storing data along the processing. |
|
559 | + $result = $this->getJsonResult(); |
|
560 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
561 | + |
|
562 | + foreach ($contentService->getObjects() as $object) { |
|
563 | + // Store the first object, so that the "action" message can be more explicit when deleting only one record. |
|
564 | + if ($contentService->getNumberOfObjects() === 1) { |
|
565 | + $tableTitleValue = $object[$tableTitleField]; |
|
566 | + $processedObjectData = array( |
|
567 | + 'uid' => $object->getUid(), |
|
568 | + 'name' => $tableTitleValue, |
|
569 | + ); |
|
570 | + $result->setProcessedObject($processedObjectData); |
|
571 | + } |
|
572 | + |
|
573 | + // Work out the object. |
|
574 | + ContentRepositoryFactory::getInstance()->move($object, $target); |
|
575 | + |
|
576 | + // Get the possible error messages and store them. |
|
577 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
578 | + $result->addErrorMessages($errorMessages); |
|
579 | + } |
|
580 | + |
|
581 | + // Flush Clipboard if told so. |
|
582 | + if (GeneralUtility::_GP('flushClipboard')) { |
|
583 | + $this->getClipboardService()->flush(); |
|
584 | + } |
|
585 | + |
|
586 | + $response = $this->responseFactory->createResponse() |
|
587 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
588 | + $response->getBody()->write(json_encode($result)); |
|
589 | + return $response; |
|
590 | + } |
|
591 | + |
|
592 | + /** |
|
593 | + * Retrieve Content objects first according to matching criteria and then "localize" them. |
|
594 | + * |
|
595 | + * Possible values for $matches, refer to method "updateAction". |
|
596 | + * |
|
597 | + * @param string $fieldNameAndPath |
|
598 | + * @param array $matches |
|
599 | + * @param int $language |
|
600 | + * @throws \Exception |
|
601 | + */ |
|
602 | + public function localizeAction($fieldNameAndPath, array $matches = [], $language = 0) |
|
603 | + { |
|
604 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
605 | + |
|
606 | + // Fetch objects via the Content Service. |
|
607 | + $contentService = $this->getContentService()->findBy($matcher); |
|
608 | + |
|
609 | + // Get result object for storing data along the processing. |
|
610 | + $result = $this->getJsonResult(); |
|
611 | + $result->setNumberOfObjects($contentService->getNumberOfObjects()); |
|
612 | + |
|
613 | + foreach ($contentService->getObjects() as $object) { |
|
614 | + $identifier = $this->getContentObjectResolver()->getValue($object, $fieldNameAndPath, 'uid'); |
|
615 | + $dataType = $this->getContentObjectResolver()->getDataType($object, $fieldNameAndPath); |
|
616 | + |
|
617 | + // Fetch the source object to be localized. |
|
618 | + /** @var Content $content */ |
|
619 | + $content = ContentRepositoryFactory::getInstance($dataType)->findByIdentifier($identifier); |
|
620 | + |
|
621 | + // Makes sure the object was retrieved. Security! |
|
622 | + if (!$content) { |
|
623 | + $message = sprintf('Something went wrong when retrieving content "%s" with identifier "%s".', $dataType, $identifier); |
|
624 | + throw new \Exception($message, 1412343097); |
|
625 | + } |
|
626 | + |
|
627 | + // Handover the localization to the Repository. |
|
628 | + ContentRepositoryFactory::getInstance($dataType)->localize($content, $language); |
|
629 | + |
|
630 | + // Get the possible error messages and store them. |
|
631 | + $errorMessages = ContentRepositoryFactory::getInstance()->getErrorMessages(); |
|
632 | + |
|
633 | + // Redirect to TCEForm so that the BE User can do its job! |
|
634 | + if ($contentService->getNumberOfObjects() === 1) { |
|
635 | + if (!empty($errorMessages)) { |
|
636 | + $message = sprintf( |
|
637 | + 'Something went wrong when localizing content "%s" with identifier "%s". <br/>%s', |
|
638 | + $dataType, |
|
639 | + $identifier, |
|
640 | + implode('<br/>', $errorMessages) |
|
641 | + ); |
|
642 | + throw new \Exception($message, 1412343098); |
|
643 | + } |
|
644 | + |
|
645 | + $localizedContent = $this->getLanguageService()->getLocalizedContent($content, $language); |
|
646 | + if (empty($localizedContent)) { |
|
647 | + $message = sprintf( |
|
648 | + 'Oups! I could not retrieve localized content of type "%s" with identifier "%s"', |
|
649 | + $content->getDataType(), |
|
650 | + $content->getUid() |
|
651 | + ); |
|
652 | + throw new \Exception($message, 1412343099); |
|
653 | + } |
|
654 | + |
|
655 | + /** @var EditUri $uri */ |
|
656 | + $uriRenderer = GeneralUtility::makeInstance(EditUri::class); |
|
657 | + $uri = $uriRenderer->render($localizedContent); |
|
658 | + HttpUtility::redirect($uri); |
|
659 | + break; // no need to further continue |
|
660 | + } |
|
661 | + |
|
662 | + $result->addErrorMessages($errorMessages); |
|
663 | + } |
|
664 | + |
|
665 | + $response = $this->responseFactory->createResponse() |
|
666 | + ->withHeader('Content-Type', 'application/json; charset=utf-8'); |
|
667 | + $response->getBody()->write(json_encode($result)); |
|
668 | + return $response; |
|
669 | + } |
|
670 | + |
|
671 | + /** |
|
672 | + * Get the Vidi Module Loader. |
|
673 | + * |
|
674 | + * @return ContentService |
|
675 | + */ |
|
676 | + protected function getContentService() |
|
677 | + { |
|
678 | + return GeneralUtility::makeInstance(ContentService::class); |
|
679 | + } |
|
680 | + |
|
681 | + /** |
|
682 | + * @return ContentObjectResolver |
|
683 | + */ |
|
684 | + protected function getContentObjectResolver() |
|
685 | + { |
|
686 | + return GeneralUtility::makeInstance(ContentObjectResolver::class); |
|
687 | + } |
|
688 | + |
|
689 | + /** |
|
690 | + * @return FieldPathResolver |
|
691 | + */ |
|
692 | + protected function getFieldPathResolver() |
|
693 | + { |
|
694 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
695 | + } |
|
696 | + |
|
697 | + /** |
|
698 | + * @return JsonResult|object |
|
699 | + */ |
|
700 | + protected function getJsonResult() |
|
701 | + { |
|
702 | + return GeneralUtility::makeInstance(JsonResult::class); |
|
703 | + } |
|
704 | + |
|
705 | + /** |
|
706 | + * Signal that is called for post-processing content data send to the server for update. |
|
707 | + * |
|
708 | + * @param Content $contentObject |
|
709 | + * @param $fieldNameAndPath |
|
710 | + * @param $contentData |
|
711 | + * @param $counter |
|
712 | + * @param $savingBehavior |
|
713 | + * @param $language |
|
714 | + * @return ProcessContentDataSignalArguments |
|
715 | + */ |
|
716 | + protected function emitProcessContentDataSignal(Content $contentObject, $fieldNameAndPath, $contentData, $counter, $savingBehavior, $language) |
|
717 | + { |
|
718 | + /** @var ProcessContentDataSignalArguments $signalArguments */ |
|
719 | + $signalArguments = GeneralUtility::makeInstance(ProcessContentDataSignalArguments::class); |
|
720 | + $signalArguments->setContentObject($contentObject) |
|
721 | + ->setFieldNameAndPath($fieldNameAndPath) |
|
722 | + ->setContentData($contentData) |
|
723 | + ->setCounter($counter) |
|
724 | + ->setSavingBehavior($savingBehavior) |
|
725 | + ->setLanguage($language); |
|
726 | + |
|
727 | + $signalResult = $this->getSignalSlotDispatcher()->dispatch('Fab\Vidi\Controller\Backend\ContentController', 'processContentData', array($signalArguments)); |
|
728 | + return $signalResult[0]; |
|
729 | + } |
|
730 | + |
|
731 | + /** |
|
732 | + * Get the SignalSlot dispatcher. |
|
733 | + * |
|
734 | + * @return Dispatcher |
|
735 | + */ |
|
736 | + protected function getSignalSlotDispatcher() |
|
737 | + { |
|
738 | + return GeneralUtility::makeInstance(Dispatcher::class); |
|
739 | + } |
|
740 | + |
|
741 | + /** |
|
742 | + * Get the Clipboard service. |
|
743 | + * |
|
744 | + * @return ClipboardService |
|
745 | + */ |
|
746 | + protected function getClipboardService() |
|
747 | + { |
|
748 | + return GeneralUtility::makeInstance(ClipboardService::class); |
|
749 | + } |
|
750 | + |
|
751 | + /** |
|
752 | + * @return LanguageService |
|
753 | + */ |
|
754 | + protected function getLanguageService() |
|
755 | + { |
|
756 | + return GeneralUtility::makeInstance(LanguageService::class); |
|
757 | + } |
|
758 | + |
|
759 | + /** |
|
760 | + * Get the Vidi Module Loader. |
|
761 | + * |
|
762 | + * @return ModuleLoader |
|
763 | + */ |
|
764 | + protected function getModuleLoader() |
|
765 | + { |
|
766 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
767 | + } |
|
768 | + |
|
769 | + public function injectSelectionRepository(SelectionRepository $selectionRepository): void |
|
770 | + { |
|
771 | + $this->selectionRepository = $selectionRepository; |
|
772 | + } |
|
773 | 773 | } |
@@ -21,68 +21,68 @@ |
||
21 | 21 | */ |
22 | 22 | class UserPreferencesController extends ActionController |
23 | 23 | { |
24 | - /** |
|
25 | - * @param string $key |
|
26 | - * @param string $value |
|
27 | - * @param string $preferenceSignature |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function saveAction($key, $value, $preferenceSignature): ResponseInterface |
|
31 | - { |
|
32 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
24 | + /** |
|
25 | + * @param string $key |
|
26 | + * @param string $value |
|
27 | + * @param string $preferenceSignature |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function saveAction($key, $value, $preferenceSignature): ResponseInterface |
|
31 | + { |
|
32 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
33 | 33 | |
34 | - $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_' . $key; |
|
35 | - $this->getCacheInstance()->set($key, $value, [], 0); |
|
34 | + $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_' . $key; |
|
35 | + $this->getCacheInstance()->set($key, $value, [], 0); |
|
36 | 36 | |
37 | - $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_signature'; |
|
38 | - $this->getCacheInstance()->set($key, $preferenceSignature, [], 0); |
|
37 | + $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_signature'; |
|
38 | + $this->getCacheInstance()->set($key, $preferenceSignature, [], 0); |
|
39 | 39 | |
40 | - return $this->htmlResponse('OK'); |
|
41 | - } |
|
40 | + return $this->htmlResponse('OK'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int |
|
45 | - */ |
|
46 | - protected function getBackendUserIdentifier() |
|
47 | - { |
|
48 | - return $this->getBackendUser()->user['uid']; |
|
49 | - } |
|
43 | + /** |
|
44 | + * @return int |
|
45 | + */ |
|
46 | + protected function getBackendUserIdentifier() |
|
47 | + { |
|
48 | + return $this->getBackendUser()->user['uid']; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Returns an instance of the current Backend User. |
|
53 | - * |
|
54 | - * @return BackendUserAuthentication |
|
55 | - */ |
|
56 | - protected function getBackendUser() |
|
57 | - { |
|
58 | - return $GLOBALS['BE_USER']; |
|
59 | - } |
|
51 | + /** |
|
52 | + * Returns an instance of the current Backend User. |
|
53 | + * |
|
54 | + * @return BackendUserAuthentication |
|
55 | + */ |
|
56 | + protected function getBackendUser() |
|
57 | + { |
|
58 | + return $GLOBALS['BE_USER']; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Get the Vidi Module Loader. |
|
63 | - * |
|
64 | - * @return ModuleLoader |
|
65 | - */ |
|
66 | - protected function getModuleLoader() |
|
67 | - { |
|
68 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
69 | - } |
|
61 | + /** |
|
62 | + * Get the Vidi Module Loader. |
|
63 | + * |
|
64 | + * @return ModuleLoader |
|
65 | + */ |
|
66 | + protected function getModuleLoader() |
|
67 | + { |
|
68 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return AbstractFrontend |
|
73 | - */ |
|
74 | - protected function getCacheInstance() |
|
75 | - { |
|
76 | - return $this->getCacheManager()->getCache('vidi'); |
|
77 | - } |
|
71 | + /** |
|
72 | + * @return AbstractFrontend |
|
73 | + */ |
|
74 | + protected function getCacheInstance() |
|
75 | + { |
|
76 | + return $this->getCacheManager()->getCache('vidi'); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Return the Cache Manager |
|
81 | - * |
|
82 | - * @return CacheManager |
|
83 | - */ |
|
84 | - protected function getCacheManager() |
|
85 | - { |
|
86 | - return GeneralUtility::makeInstance(CacheManager::class); |
|
87 | - } |
|
79 | + /** |
|
80 | + * Return the Cache Manager |
|
81 | + * |
|
82 | + * @return CacheManager |
|
83 | + */ |
|
84 | + protected function getCacheManager() |
|
85 | + { |
|
86 | + return GeneralUtility::makeInstance(CacheManager::class); |
|
87 | + } |
|
88 | 88 | } |
@@ -31,10 +31,10 @@ |
||
31 | 31 | { |
32 | 32 | $dataType = $this->getModuleLoader()->getDataType(); |
33 | 33 | |
34 | - $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_' . $key; |
|
34 | + $key = $dataType.'_'.$this->getBackendUserIdentifier().'_'.$key; |
|
35 | 35 | $this->getCacheInstance()->set($key, $value, [], 0); |
36 | 36 | |
37 | - $key = $dataType . '_' . $this->getBackendUserIdentifier() . '_signature'; |
|
37 | + $key = $dataType.'_'.$this->getBackendUserIdentifier().'_signature'; |
|
38 | 38 | $this->getCacheInstance()->set($key, $preferenceSignature, [], 0); |
39 | 39 | |
40 | 40 | return $this->htmlResponse('OK'); |
@@ -21,47 +21,47 @@ |
||
21 | 21 | */ |
22 | 22 | class FacetController extends ActionController |
23 | 23 | { |
24 | - /** |
|
25 | - * Suggest values according to a facet. |
|
26 | - * Output a json list of key / values. |
|
27 | - * |
|
28 | - * @param string $facet |
|
29 | - * @param string $searchTerm |
|
30 | - * @Validate("Fab\Vidi\Domain\Validator\FacetValidator", param="facet") |
|
31 | - */ |
|
32 | - public function autoSuggestAction($facet, $searchTerm) |
|
33 | - { |
|
34 | - $suggestions = $this->getFacetSuggestionService()->getSuggestions($facet); |
|
24 | + /** |
|
25 | + * Suggest values according to a facet. |
|
26 | + * Output a json list of key / values. |
|
27 | + * |
|
28 | + * @param string $facet |
|
29 | + * @param string $searchTerm |
|
30 | + * @Validate("Fab\Vidi\Domain\Validator\FacetValidator", param="facet") |
|
31 | + */ |
|
32 | + public function autoSuggestAction($facet, $searchTerm) |
|
33 | + { |
|
34 | + $suggestions = $this->getFacetSuggestionService()->getSuggestions($facet); |
|
35 | 35 | |
36 | 36 | |
37 | - return $this->responseFactory->createResponse() |
|
38 | - ->withAddedHeader('Content-Type', 'application/json') |
|
39 | - ->withBody($this->streamFactory->createStream(json_encode($suggestions))); |
|
40 | - } |
|
37 | + return $this->responseFactory->createResponse() |
|
38 | + ->withAddedHeader('Content-Type', 'application/json') |
|
39 | + ->withBody($this->streamFactory->createStream(json_encode($suggestions))); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Suggest values for all configured facets in the Grid. |
|
44 | - * Output a json list of key / values. |
|
45 | - */ |
|
46 | - public function autoSuggestsAction() |
|
47 | - { |
|
48 | - $suggestions = []; |
|
49 | - foreach (Tca::grid()->getFacets() as $facet) { |
|
50 | - /** @var FacetInterface $facet */ |
|
51 | - $name = $facet->getName(); |
|
52 | - $suggestions[$name] = $this->getFacetSuggestionService()->getSuggestions($name); |
|
53 | - } |
|
42 | + /** |
|
43 | + * Suggest values for all configured facets in the Grid. |
|
44 | + * Output a json list of key / values. |
|
45 | + */ |
|
46 | + public function autoSuggestsAction() |
|
47 | + { |
|
48 | + $suggestions = []; |
|
49 | + foreach (Tca::grid()->getFacets() as $facet) { |
|
50 | + /** @var FacetInterface $facet */ |
|
51 | + $name = $facet->getName(); |
|
52 | + $suggestions[$name] = $this->getFacetSuggestionService()->getSuggestions($name); |
|
53 | + } |
|
54 | 54 | |
55 | - return $this->responseFactory->createResponse() |
|
56 | - ->withAddedHeader('Content-Type', 'application/json') |
|
57 | - ->withBody($this->streamFactory->createStream(json_encode($suggestions))); |
|
58 | - } |
|
55 | + return $this->responseFactory->createResponse() |
|
56 | + ->withAddedHeader('Content-Type', 'application/json') |
|
57 | + ->withBody($this->streamFactory->createStream(json_encode($suggestions))); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return FacetSuggestionService|object |
|
62 | - */ |
|
63 | - protected function getFacetSuggestionService() |
|
64 | - { |
|
65 | - return GeneralUtility::makeInstance(FacetSuggestionService::class); |
|
66 | - } |
|
60 | + /** |
|
61 | + * @return FacetSuggestionService|object |
|
62 | + */ |
|
63 | + protected function getFacetSuggestionService() |
|
64 | + { |
|
65 | + return GeneralUtility::makeInstance(FacetSuggestionService::class); |
|
66 | + } |
|
67 | 67 | } |
@@ -22,90 +22,90 @@ |
||
22 | 22 | */ |
23 | 23 | class SelectionController extends ActionController |
24 | 24 | { |
25 | - /** |
|
26 | - * @param Selection $selection |
|
27 | - */ |
|
28 | - public function createAction(Selection $selection = null) |
|
29 | - { |
|
30 | - $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
31 | - $selection->setDataType($this->getModuleLoader()->getDataType()); |
|
25 | + /** |
|
26 | + * @param Selection $selection |
|
27 | + */ |
|
28 | + public function createAction(Selection $selection = null) |
|
29 | + { |
|
30 | + $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
31 | + $selection->setDataType($this->getModuleLoader()->getDataType()); |
|
32 | 32 | |
33 | - $selection->setOwner($this->getBackendUser()->user['uid']); |
|
34 | - $selectionRepository->add($selection); |
|
35 | - $this->redirect('edit', 'Selection', 'vidi', array('dataType' => $selection->getDataType())); |
|
36 | - } |
|
33 | + $selection->setOwner($this->getBackendUser()->user['uid']); |
|
34 | + $selectionRepository->add($selection); |
|
35 | + $this->redirect('edit', 'Selection', 'vidi', array('dataType' => $selection->getDataType())); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param Selection $selection |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function deleteAction(Selection $selection): ResponseInterface |
|
43 | - { |
|
44 | - $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
45 | - $selectionRepository->remove($selection); |
|
46 | - return $this->htmlResponse('ok'); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @param Selection $selection |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function deleteAction(Selection $selection): ResponseInterface |
|
43 | + { |
|
44 | + $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
45 | + $selectionRepository->remove($selection); |
|
46 | + return $this->htmlResponse('ok'); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param Selection $selection |
|
51 | - */ |
|
52 | - public function updateAction(Selection $selection) |
|
53 | - { |
|
54 | - $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
55 | - $selectionRepository->update($selection); |
|
56 | - $this->redirect('show', 'Selection', 'vidi', array('selection' => $selection->getUid())); |
|
57 | - } |
|
49 | + /** |
|
50 | + * @param Selection $selection |
|
51 | + */ |
|
52 | + public function updateAction(Selection $selection) |
|
53 | + { |
|
54 | + $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
55 | + $selectionRepository->update($selection); |
|
56 | + $this->redirect('show', 'Selection', 'vidi', array('selection' => $selection->getUid())); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @param Selection $selection |
|
61 | - */ |
|
62 | - public function showAction(Selection $selection): ResponseInterface |
|
63 | - { |
|
64 | - $this->view->assign('selection', $selection); |
|
65 | - return $this->htmlResponse(); |
|
66 | - } |
|
59 | + /** |
|
60 | + * @param Selection $selection |
|
61 | + */ |
|
62 | + public function showAction(Selection $selection): ResponseInterface |
|
63 | + { |
|
64 | + $this->view->assign('selection', $selection); |
|
65 | + return $this->htmlResponse(); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Returns an editing form for a given data type. |
|
70 | - * |
|
71 | - * @param string $dataType |
|
72 | - */ |
|
73 | - public function editAction($dataType): ResponseInterface |
|
74 | - { |
|
75 | - $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
76 | - $selections = $selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
77 | - $this->view->assign('selections', $selections); |
|
78 | - return $this->htmlResponse(); |
|
79 | - } |
|
68 | + /** |
|
69 | + * Returns an editing form for a given data type. |
|
70 | + * |
|
71 | + * @param string $dataType |
|
72 | + */ |
|
73 | + public function editAction($dataType): ResponseInterface |
|
74 | + { |
|
75 | + $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
76 | + $selections = $selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
77 | + $this->view->assign('selections', $selections); |
|
78 | + return $this->htmlResponse(); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param string $dataType |
|
83 | - */ |
|
84 | - public function listAction($dataType): ResponseInterface |
|
85 | - { |
|
86 | - $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
87 | - $selections = $selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
88 | - $this->view->assign('selections', $selections); |
|
89 | - return $this->htmlResponse(); |
|
90 | - } |
|
81 | + /** |
|
82 | + * @param string $dataType |
|
83 | + */ |
|
84 | + public function listAction($dataType): ResponseInterface |
|
85 | + { |
|
86 | + $selectionRepository = GeneralUtility::makeInstance(SelectionRepository::class); |
|
87 | + $selections = $selectionRepository->findByDataTypeForCurrentBackendUser($dataType); |
|
88 | + $this->view->assign('selections', $selections); |
|
89 | + return $this->htmlResponse(); |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Get the Vidi Module Loader. |
|
94 | - * |
|
95 | - * @return ModuleLoader |
|
96 | - */ |
|
97 | - protected function getModuleLoader() |
|
98 | - { |
|
99 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
100 | - } |
|
92 | + /** |
|
93 | + * Get the Vidi Module Loader. |
|
94 | + * |
|
95 | + * @return ModuleLoader |
|
96 | + */ |
|
97 | + protected function getModuleLoader() |
|
98 | + { |
|
99 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Returns an instance of the current Backend User. |
|
104 | - * |
|
105 | - * @return BackendUserAuthentication |
|
106 | - */ |
|
107 | - protected function getBackendUser() |
|
108 | - { |
|
109 | - return $GLOBALS['BE_USER']; |
|
110 | - } |
|
102 | + /** |
|
103 | + * Returns an instance of the current Backend User. |
|
104 | + * |
|
105 | + * @return BackendUserAuthentication |
|
106 | + */ |
|
107 | + protected function getBackendUser() |
|
108 | + { |
|
109 | + return $GLOBALS['BE_USER']; |
|
110 | + } |
|
111 | 111 | } |
@@ -21,47 +21,47 @@ |
||
21 | 21 | */ |
22 | 22 | class ToolController extends ActionController |
23 | 23 | { |
24 | - /** |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function welcomeAction(): ResponseInterface |
|
28 | - { |
|
29 | - $items = []; |
|
30 | - $tools = ToolRegistry::getInstance()->getTools($this->getModuleLoader()->getDataType()); |
|
24 | + /** |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function welcomeAction(): ResponseInterface |
|
28 | + { |
|
29 | + $items = []; |
|
30 | + $tools = ToolRegistry::getInstance()->getTools($this->getModuleLoader()->getDataType()); |
|
31 | 31 | |
32 | - foreach ($tools as $index => $tool) { |
|
33 | - $item = []; |
|
34 | - $item['title'] = $tool->getTitle(); |
|
35 | - $item['description'] = $tool->getDescription(); |
|
32 | + foreach ($tools as $index => $tool) { |
|
33 | + $item = []; |
|
34 | + $item['title'] = $tool->getTitle(); |
|
35 | + $item['description'] = $tool->getDescription(); |
|
36 | 36 | |
37 | - $items[] = $item; |
|
38 | - } |
|
39 | - $this->view->assign('items', $items); |
|
40 | - return $this->htmlResponse(); |
|
41 | - } |
|
37 | + $items[] = $item; |
|
38 | + } |
|
39 | + $this->view->assign('items', $items); |
|
40 | + return $this->htmlResponse(); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $tool |
|
45 | - * @param array $arguments |
|
46 | - * @return void |
|
47 | - * @Extbase\Validate("Fab\Vidi\Domain\Validator\ToolValidator", param="tool") |
|
48 | - */ |
|
49 | - public function workAction(string $tool, array $arguments = array()): ResponseInterface |
|
50 | - { |
|
51 | - /** @var ToolInterface $tool */ |
|
52 | - $tool = GeneralUtility::makeInstance($tool); |
|
53 | - $workResult = $tool->work($arguments); |
|
54 | - $this->view->assign('result', $workResult); |
|
55 | - return $this->htmlResponse(); |
|
56 | - } |
|
43 | + /** |
|
44 | + * @param string $tool |
|
45 | + * @param array $arguments |
|
46 | + * @return void |
|
47 | + * @Extbase\Validate("Fab\Vidi\Domain\Validator\ToolValidator", param="tool") |
|
48 | + */ |
|
49 | + public function workAction(string $tool, array $arguments = array()): ResponseInterface |
|
50 | + { |
|
51 | + /** @var ToolInterface $tool */ |
|
52 | + $tool = GeneralUtility::makeInstance($tool); |
|
53 | + $workResult = $tool->work($arguments); |
|
54 | + $this->view->assign('result', $workResult); |
|
55 | + return $this->htmlResponse(); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Get the Vidi Module Loader. |
|
60 | - * |
|
61 | - * @return ModuleLoader|object |
|
62 | - */ |
|
63 | - protected function getModuleLoader() |
|
64 | - { |
|
65 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
66 | - } |
|
58 | + /** |
|
59 | + * Get the Vidi Module Loader. |
|
60 | + * |
|
61 | + * @return ModuleLoader|object |
|
62 | + */ |
|
63 | + protected function getModuleLoader() |
|
64 | + { |
|
65 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
66 | + } |
|
67 | 67 | } |
@@ -20,77 +20,77 @@ |
||
20 | 20 | */ |
21 | 21 | class ClipboardController extends ActionController |
22 | 22 | { |
23 | - /** |
|
24 | - * Save data into the clipboard. |
|
25 | - * |
|
26 | - * @param array $matches |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function saveAction(array $matches = array()): ResponseInterface |
|
30 | - { |
|
31 | - $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
32 | - $this->getClipboardService()->save($matcher); |
|
23 | + /** |
|
24 | + * Save data into the clipboard. |
|
25 | + * |
|
26 | + * @param array $matches |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function saveAction(array $matches = array()): ResponseInterface |
|
30 | + { |
|
31 | + $matcher = MatcherObjectFactory::getInstance()->getMatcher($matches); |
|
32 | + $this->getClipboardService()->save($matcher); |
|
33 | 33 | |
34 | - // Fetch objects via the Content Service. |
|
35 | - $contentService = $this->getContentService()->findBy($matcher); |
|
36 | - $numberOfObjects = $contentService->getNumberOfObjects(); |
|
34 | + // Fetch objects via the Content Service. |
|
35 | + $contentService = $this->getContentService()->findBy($matcher); |
|
36 | + $numberOfObjects = $contentService->getNumberOfObjects(); |
|
37 | 37 | |
38 | - if ($numberOfObjects === 0) { |
|
39 | - $this->getClipboardService()->flush(); |
|
40 | - } |
|
38 | + if ($numberOfObjects === 0) { |
|
39 | + $this->getClipboardService()->flush(); |
|
40 | + } |
|
41 | 41 | |
42 | - # Json header is not automatically sent in the BE... |
|
43 | - $this->response->setHeader('Content-Type', 'application/json'); |
|
44 | - $this->response->sendHeaders(); |
|
45 | - return $this->jsonResponse(json_encode($numberOfObjects)); |
|
46 | - } |
|
42 | + # Json header is not automatically sent in the BE... |
|
43 | + $this->response->setHeader('Content-Type', 'application/json'); |
|
44 | + $this->response->sendHeaders(); |
|
45 | + return $this->jsonResponse(json_encode($numberOfObjects)); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Completely flush the clipboard. |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function flushAction(): ResponseInterface |
|
54 | - { |
|
55 | - $this->getClipboardService()->flush(); |
|
48 | + /** |
|
49 | + * Completely flush the clipboard. |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function flushAction(): ResponseInterface |
|
54 | + { |
|
55 | + $this->getClipboardService()->flush(); |
|
56 | 56 | |
57 | - # Json header is not automatically sent in the BE... |
|
58 | - $this->response->setHeader('Content-Type', 'application/json'); |
|
59 | - $this->response->sendHeaders(); |
|
60 | - return $this->jsonResponse(json_encode(true)); |
|
61 | - } |
|
57 | + # Json header is not automatically sent in the BE... |
|
58 | + $this->response->setHeader('Content-Type', 'application/json'); |
|
59 | + $this->response->sendHeaders(); |
|
60 | + return $this->jsonResponse(json_encode(true)); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Show the content of the clipboard. |
|
65 | - */ |
|
66 | - public function showAction(): ResponseInterface |
|
67 | - { |
|
68 | - // Retrieve matcher object from clipboard. |
|
69 | - $matcher = $this->getClipboardService()->getMatcher(); |
|
63 | + /** |
|
64 | + * Show the content of the clipboard. |
|
65 | + */ |
|
66 | + public function showAction(): ResponseInterface |
|
67 | + { |
|
68 | + // Retrieve matcher object from clipboard. |
|
69 | + $matcher = $this->getClipboardService()->getMatcher(); |
|
70 | 70 | |
71 | - // Fetch objects via the Content Service. |
|
72 | - $contentService = $this->getContentService()->findBy($matcher); |
|
71 | + // Fetch objects via the Content Service. |
|
72 | + $contentService = $this->getContentService()->findBy($matcher); |
|
73 | 73 | |
74 | - // count number of items and display it. |
|
75 | - $this->view->assign('target', GeneralUtility::_GP('id')); |
|
76 | - $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
77 | - $this->view->assign('objects', $contentService->getObjects()); |
|
78 | - return $this->htmlResponse(); |
|
79 | - } |
|
74 | + // count number of items and display it. |
|
75 | + $this->view->assign('target', GeneralUtility::_GP('id')); |
|
76 | + $this->view->assign('numberOfObjects', $contentService->getNumberOfObjects()); |
|
77 | + $this->view->assign('objects', $contentService->getObjects()); |
|
78 | + return $this->htmlResponse(); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return ClipboardService|object |
|
83 | - */ |
|
84 | - protected function getClipboardService() |
|
85 | - { |
|
86 | - return GeneralUtility::makeInstance(ClipboardService::class); |
|
87 | - } |
|
81 | + /** |
|
82 | + * @return ClipboardService|object |
|
83 | + */ |
|
84 | + protected function getClipboardService() |
|
85 | + { |
|
86 | + return GeneralUtility::makeInstance(ClipboardService::class); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return ContentService|object |
|
91 | - */ |
|
92 | - protected function getContentService() |
|
93 | - { |
|
94 | - return GeneralUtility::makeInstance(ContentService::class); |
|
95 | - } |
|
89 | + /** |
|
90 | + * @return ContentService|object |
|
91 | + */ |
|
92 | + protected function getContentService() |
|
93 | + { |
|
94 | + return GeneralUtility::makeInstance(ContentService::class); |
|
95 | + } |
|
96 | 96 | } |
@@ -16,9 +16,9 @@ |
||
16 | 16 | */ |
17 | 17 | class SavingBehavior extends Enumeration |
18 | 18 | { |
19 | - public const REMOVE = 'remove'; |
|
19 | + public const REMOVE = 'remove'; |
|
20 | 20 | |
21 | - public const APPEND = 'append'; |
|
21 | + public const APPEND = 'append'; |
|
22 | 22 | |
23 | - public const REPLACE = 'replace'; |
|
23 | + public const REPLACE = 'replace'; |
|
24 | 24 | } |
@@ -14,32 +14,32 @@ |
||
14 | 14 | */ |
15 | 15 | interface ToolInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * Display the title of the tool on the welcome screen. |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function getTitle(); |
|
17 | + /** |
|
18 | + * Display the title of the tool on the welcome screen. |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function getTitle(); |
|
23 | 23 | |
24 | - /** |
|
25 | - * Display the description of the tool on the welcome screen. |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function getDescription(); |
|
24 | + /** |
|
25 | + * Display the description of the tool on the welcome screen. |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function getDescription(); |
|
30 | 30 | |
31 | - /** |
|
32 | - * Do the job. |
|
33 | - * |
|
34 | - * @param array $arguments |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function work(array $arguments = array()); |
|
31 | + /** |
|
32 | + * Do the job. |
|
33 | + * |
|
34 | + * @param array $arguments |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function work(array $arguments = array()); |
|
38 | 38 | |
39 | - /** |
|
40 | - * Tell whether the tools should be displayed. |
|
41 | - * |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function isShown(); |
|
39 | + /** |
|
40 | + * Tell whether the tools should be displayed. |
|
41 | + * |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function isShown(); |
|
45 | 45 | } |
@@ -18,40 +18,40 @@ |
||
18 | 18 | */ |
19 | 19 | abstract class AbstractTool implements ToolInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @param string $templateNameAndPath |
|
23 | - * @return StandaloneView |
|
24 | - * @throws \InvalidArgumentException |
|
25 | - */ |
|
26 | - protected function initializeStandaloneView($templateNameAndPath) |
|
27 | - { |
|
28 | - $templateNameAndPath = GeneralUtility::getFileAbsFileName($templateNameAndPath); |
|
21 | + /** |
|
22 | + * @param string $templateNameAndPath |
|
23 | + * @return StandaloneView |
|
24 | + * @throws \InvalidArgumentException |
|
25 | + */ |
|
26 | + protected function initializeStandaloneView($templateNameAndPath) |
|
27 | + { |
|
28 | + $templateNameAndPath = GeneralUtility::getFileAbsFileName($templateNameAndPath); |
|
29 | 29 | |
30 | - /** @var StandaloneView $view */ |
|
31 | - $view = GeneralUtility::makeInstance(StandaloneView::class); |
|
30 | + /** @var StandaloneView $view */ |
|
31 | + $view = GeneralUtility::makeInstance(StandaloneView::class); |
|
32 | 32 | |
33 | - $view->setTemplatePathAndFilename($templateNameAndPath); |
|
34 | - return $view; |
|
35 | - } |
|
33 | + $view->setTemplatePathAndFilename($templateNameAndPath); |
|
34 | + return $view; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Returns an instance of the current Backend User. |
|
39 | - * |
|
40 | - * @return BackendUserAuthentication |
|
41 | - */ |
|
42 | - protected function getBackendUser() |
|
43 | - { |
|
44 | - return $GLOBALS['BE_USER']; |
|
45 | - } |
|
37 | + /** |
|
38 | + * Returns an instance of the current Backend User. |
|
39 | + * |
|
40 | + * @return BackendUserAuthentication |
|
41 | + */ |
|
42 | + protected function getBackendUser() |
|
43 | + { |
|
44 | + return $GLOBALS['BE_USER']; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get the Vidi Module Loader. |
|
49 | - * |
|
50 | - * @return ModuleLoader |
|
51 | - * @throws \InvalidArgumentException |
|
52 | - */ |
|
53 | - protected function getModuleLoader() |
|
54 | - { |
|
55 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
56 | - } |
|
47 | + /** |
|
48 | + * Get the Vidi Module Loader. |
|
49 | + * |
|
50 | + * @return ModuleLoader |
|
51 | + * @throws \InvalidArgumentException |
|
52 | + */ |
|
53 | + protected function getModuleLoader() |
|
54 | + { |
|
55 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
56 | + } |
|
57 | 57 | } |