|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Controller; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use EWW\Dpf\Domain\Model\MetadataGroup; |
|
18
|
|
|
use EWW\Dpf\Services\Identifier\Urn; |
|
19
|
|
|
use EWW\Dpf\Services\Transfer\DocumentTransferManager; |
|
20
|
|
|
use EWW\Dpf\Services\Transfer\FedoraRepository; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* DocumentFormController |
|
24
|
|
|
*/ |
|
25
|
|
|
class AjaxDocumentFormController extends \EWW\Dpf\Controller\AbstractController |
|
26
|
|
|
{ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* metadataGroupRepository |
|
30
|
|
|
* |
|
31
|
|
|
* @var \EWW\Dpf\Domain\Repository\MetadataGroupRepository |
|
32
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $metadataGroupRepository = null; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* metadataObjectRepository |
|
38
|
|
|
* |
|
39
|
|
|
* @var \EWW\Dpf\Domain\Repository\MetadataObjectRepository |
|
40
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $metadataObjectRepository = null; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* fisDataService |
|
46
|
|
|
* |
|
47
|
|
|
* @var \EWW\Dpf\Services\FeUser\FisDataService |
|
48
|
|
|
* @TYPO3\CMS\Extbase\Annotation\Inject |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $fisDataService = null; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* |
|
54
|
|
|
* @param integer $pageUid |
|
55
|
|
|
* @param integer $groupUid |
|
56
|
|
|
* @param integer $groupIndex |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
|
|
public function groupAction($pageUid, $groupUid, $groupIndex) |
|
60
|
|
|
{ |
|
61
|
|
|
/** @var MetadataGroup $group */ |
|
62
|
|
|
$group = $this->metadataGroupRepository->findByUid($groupUid); |
|
63
|
|
|
|
|
64
|
|
|
//$groupItem = array(); |
|
65
|
|
|
|
|
66
|
|
|
$groupItem = new \EWW\Dpf\Domain\Model\DocumentFormGroup(); |
|
67
|
|
|
|
|
68
|
|
|
foreach ($group->getMetadataObject() as $object) { |
|
69
|
|
|
|
|
70
|
|
|
$field = new \EWW\Dpf\Domain\Model\DocumentFormField(); |
|
71
|
|
|
|
|
72
|
|
|
$field->setUid($object->getUid()); |
|
73
|
|
|
$field->setDisplayName($object->getDisplayName()); |
|
74
|
|
|
$field->setMandatory($object->getMandatory()); |
|
75
|
|
|
$field->setAccessRestrictionRoles($object->getAccessRestrictionRoles()); |
|
76
|
|
|
$field->setInputField($object->getInputField()); |
|
77
|
|
|
$field->setInputOptions($object->getInputOptionList()); |
|
78
|
|
|
$field->setMaxIteration($object->getMaxIteration()); |
|
79
|
|
|
$field->setFillOutService($object->getFillOutService()); |
|
80
|
|
|
$field->setValidation($object->getValidation()); |
|
81
|
|
|
$field->setDataType($object->getDataType()); |
|
82
|
|
|
$field->setGndFieldUid($object->getGndFieldUid()); |
|
83
|
|
|
$field->setMaxInputLength($object->getMaxInputLength()); |
|
84
|
|
|
$field->setValue("", $object->getDefaultValue()); |
|
85
|
|
|
$field->setObjectType($object->getObjectType()); |
|
86
|
|
|
|
|
87
|
|
|
$groupItem->addItem($field); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
$groupItem->setGroupType($group->getGroupType()); |
|
91
|
|
|
$groupItem->setMandatory($group->getMandatory()); |
|
92
|
|
|
$groupItem->setMaxIteration($group->getMaxIteration()); |
|
93
|
|
|
$groupItem->setEmptyGroup(true); |
|
94
|
|
|
|
|
95
|
|
|
if ($this->security->getFisPersId()) { |
|
96
|
|
|
$this->view->assign('fisPersId', $this->security->getFisPersId()); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
$this->view->assign('formPageUid', $pageUid); |
|
100
|
|
|
$this->view->assign('formGroupUid', $groupUid); |
|
101
|
|
|
$this->view->assign('formGroupDisplayName', $group->getDisplayName()); |
|
102
|
|
|
$this->view->assign('groupIndex', $groupIndex); |
|
103
|
|
|
$this->view->assign('groupItem', $groupItem); |
|
104
|
|
|
|
|
105
|
|
|
if ($this->fisDataService->getPersonData($this->security->getFisPersId())) { |
|
106
|
|
|
$this->view->assign('fisPersId', $this->security->getFisPersId()); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* |
|
112
|
|
|
* @param integer $pageUid |
|
113
|
|
|
* @param integer $groupUid |
|
114
|
|
|
* @param integer $groupIndex |
|
115
|
|
|
* @param integer $fieldUid |
|
116
|
|
|
* @param integer $fieldIndex |
|
117
|
|
|
* @return void |
|
118
|
|
|
*/ |
|
119
|
|
|
public function fieldAction($pageUid, $groupUid, $groupIndex, $fieldUid, $fieldIndex) |
|
120
|
|
|
{ |
|
121
|
|
|
|
|
122
|
|
|
$field = $this->metadataObjectRepository->findByUid($fieldUid); |
|
123
|
|
|
|
|
124
|
|
|
$fieldItem = new \EWW\Dpf\Domain\Model\DocumentFormField(); |
|
125
|
|
|
|
|
126
|
|
|
$fieldItem->setUid($field->getUid()); |
|
127
|
|
|
$fieldItem->setDisplayName($field->getDisplayName()); |
|
128
|
|
|
$fieldItem->setMandatory($field->getMandatory()); |
|
129
|
|
|
$fieldItem->setAccessRestrictionRoles($field->getAccessRestrictionRoles()); |
|
130
|
|
|
$fieldItem->setInputField($field->getInputField()); |
|
131
|
|
|
$fieldItem->setInputOptions($field->getInputOptionList()); |
|
132
|
|
|
$fieldItem->setMaxIteration($field->getMaxIteration()); |
|
133
|
|
|
$fieldItem->setFillOutService($field->getFillOutService()); |
|
134
|
|
|
$fieldItem->setValidation($field->getValidation()); |
|
135
|
|
|
$fieldItem->setDataType($field->getDataType()); |
|
136
|
|
|
$fieldItem->setGndFieldUid($field->getGndFieldUid()); |
|
137
|
|
|
$fieldItem->setMaxInputLength($field->getMaxInputLength()); |
|
138
|
|
|
$fieldItem->setValue("", $field->getDefaultValue()); |
|
139
|
|
|
$fieldItem->setObjectType($field->getObjectType()); |
|
140
|
|
|
|
|
141
|
|
|
$this->view->assign('formPageUid', $pageUid); |
|
142
|
|
|
$this->view->assign('formGroupUid', $groupUid); |
|
143
|
|
|
$this->view->assign('groupIndex', $groupIndex); |
|
144
|
|
|
// $this->view->assign('formField',$formField); |
|
145
|
|
|
$this->view->assign('fieldIndex', $fieldIndex); |
|
146
|
|
|
$this->view->assign('fieldItem', $fieldItem); |
|
147
|
|
|
// $this->view->assign('countries',); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* |
|
152
|
|
|
* @return void |
|
153
|
|
|
*/ |
|
154
|
|
|
public function uploadAction($groupIndex) |
|
|
|
|
|
|
155
|
|
|
{ |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* |
|
160
|
|
|
* @param integer $groupIndex |
|
161
|
|
|
* @return void |
|
162
|
|
|
*/ |
|
163
|
|
|
public function secondaryUploadAction($groupIndex) |
|
164
|
|
|
{ |
|
165
|
|
|
$this->view->assign('groupIndex', $groupIndex); |
|
166
|
|
|
//$this->view->assign('displayName','Sekundärdatei'); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @param int $fileUid |
|
171
|
|
|
* @param int $pageUid |
|
172
|
|
|
* @param int $groupUid |
|
173
|
|
|
* @param int $groupIndex |
|
174
|
|
|
* @param int $fieldUid |
|
175
|
|
|
* @param int $fieldIndex |
|
176
|
|
|
* @param int $isPrimary |
|
177
|
|
|
*/ |
|
178
|
|
|
public function deleteFileAction($fileUid, $pageUid, $groupUid, $groupIndex, $fieldUid, $fieldIndex, $isPrimary = 0) |
|
179
|
|
|
{ |
|
180
|
|
|
$field = $this->metadataObjectRepository->findByUid($fieldUid); |
|
181
|
|
|
|
|
182
|
|
|
$fieldItem = new \EWW\Dpf\Domain\Model\DocumentFormField(); |
|
183
|
|
|
|
|
184
|
|
|
$fieldItem->setUid($field->getUid()); |
|
185
|
|
|
$fieldItem->setDisplayName($field->getDisplayName()); |
|
186
|
|
|
$fieldItem->setMandatory($field->getMandatory()); |
|
187
|
|
|
$fieldItem->setAccessRestrictionRoles($field->getAccessRestrictionRoles()); |
|
188
|
|
|
$fieldItem->setInputField($field->getInputField()); |
|
189
|
|
|
$fieldItem->setInputOptions($field->getInputOptionList()); |
|
190
|
|
|
$fieldItem->setMaxIteration($field->getMaxIteration()); |
|
191
|
|
|
$fieldItem->setFillOutService($field->getFillOutService()); |
|
192
|
|
|
$fieldItem->setValidation($field->getValidation()); |
|
193
|
|
|
$fieldItem->setDataType($field->getDataType()); |
|
194
|
|
|
$fieldItem->setGndFieldUid($field->getGndFieldUid()); |
|
195
|
|
|
$fieldItem->setMaxInputLength($field->getMaxInputLength()); |
|
196
|
|
|
$fieldItem->setValue("", $field->getDefaultValue()); |
|
197
|
|
|
$fieldItem->setObjectType($field->getObjectType()); |
|
198
|
|
|
|
|
199
|
|
|
$this->view->assign('formPageUid', $pageUid); |
|
200
|
|
|
$this->view->assign('formGroupUid', $groupUid); |
|
201
|
|
|
$this->view->assign('groupIndex', $groupIndex); |
|
202
|
|
|
|
|
203
|
|
|
$this->view->assign('fieldIndex', $fieldIndex); |
|
204
|
|
|
$this->view->assign('fieldItem', $fieldItem); |
|
205
|
|
|
|
|
206
|
|
|
$this->view->assign('fileUid', $fileUid); |
|
207
|
|
|
$this->view->assign('isPrimary', $isPrimary); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* |
|
212
|
|
|
* @param string $fedoraPid |
|
213
|
|
|
* @return string |
|
214
|
|
|
*/ |
|
215
|
|
|
public function fillOutAction($fedoraPid) |
|
216
|
|
|
{ |
|
217
|
|
|
try { |
|
218
|
|
|
$urnService = $this->objectManager->get(Urn::class); |
|
219
|
|
|
|
|
220
|
|
|
if (!empty($fedoraPid)) { |
|
221
|
|
|
$urn = $urnService->getUrn($fedoraPid); |
|
222
|
|
|
} else { |
|
223
|
|
|
$documentTransferManager = $this->objectManager->get(DocumentTransferManager::class); |
|
224
|
|
|
$remoteRepository = $this->objectManager->get(FedoraRepository::class); |
|
225
|
|
|
$documentTransferManager->setRemoteRepository($remoteRepository); |
|
226
|
|
|
|
|
227
|
|
|
$fedoraPid = $documentTransferManager->getNextDocumentId(); |
|
228
|
|
|
|
|
229
|
|
|
$urn = $urnService->getUrn($fedoraPid); |
|
230
|
|
|
|
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
return json_encode( |
|
234
|
|
|
array( |
|
235
|
|
|
'error' => false, |
|
236
|
|
|
'fedoraPid' => $fedoraPid, |
|
237
|
|
|
'value' => $urn, |
|
238
|
|
|
) |
|
239
|
|
|
); |
|
240
|
|
|
|
|
241
|
|
|
} catch (\Exception $exception) { |
|
242
|
|
|
return json_encode( |
|
243
|
|
|
array( |
|
244
|
|
|
'error' => true, |
|
245
|
|
|
'fedoraPid' => null, |
|
246
|
|
|
'value' => null, |
|
247
|
|
|
) |
|
248
|
|
|
); |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
} |
|
254
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.