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