|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
6
|
|
|
* |
|
7
|
|
|
* @license GNU General Public License version 3 or later. |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Kitodo\Dlf\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
15
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
|
|
|
|
|
|
16
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
17
|
|
|
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; |
|
18
|
|
|
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
|
20
|
|
|
use Kitodo\Dlf\Domain\Repository\StructureRepository; |
|
21
|
|
|
use Kitodo\Dlf\Domain\Repository\MetadataRepository; |
|
22
|
|
|
use Kitodo\Dlf\Domain\Repository\SolrCoreRepository; |
|
23
|
|
|
|
|
24
|
|
|
class NewTenantController extends AbstractController |
|
25
|
|
|
{ |
|
26
|
|
|
protected $pid; |
|
27
|
|
|
|
|
28
|
|
|
protected $pageInfo; |
|
29
|
|
|
|
|
30
|
|
|
protected $extKey = 'dlf'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Backend Template Container |
|
34
|
|
|
* |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class; |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
protected $structureRepository; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param StructureRepository $structureRepository |
|
43
|
|
|
*/ |
|
44
|
|
|
public function injectStructureRepository(StructureRepository $structureRepository) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->structureRepository = $structureRepository; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected $metadataRepository; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param MetadataRepository $metadataRepository |
|
53
|
|
|
*/ |
|
54
|
|
|
public function injectMetadataRepository(MetadataRepository $metadataRepository) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->metadataRepository = $metadataRepository; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
protected $solrCoreRepository; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param SolrCoreRepository $solrCoreRepository |
|
63
|
|
|
*/ |
|
64
|
|
|
public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) |
|
65
|
|
|
{ |
|
66
|
|
|
$this->solrCoreRepository = $solrCoreRepository; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
public function addMetadataAction() { |
|
71
|
|
|
// Include metadata definition file. |
|
72
|
|
|
$metadataDefaults = include (ExtensionManagementUtility::extPath($this->extKey) . 'Resources/Private/Data/MetadataDefaults.php'); |
|
73
|
|
|
$i = 0; |
|
74
|
|
|
// Build data array. |
|
75
|
|
|
$this->pid = (int) GeneralUtility::_GP('id'); |
|
76
|
|
|
|
|
77
|
|
|
foreach ($metadataDefaults as $index_name => $values) { |
|
78
|
|
|
$formatIds = []; |
|
79
|
|
|
foreach ($values['format'] as $format) { |
|
80
|
|
|
$formatIds[] = uniqid('NEW'); |
|
81
|
|
|
$data['tx_dlf_metadataformat'][end($formatIds)] = $format; |
|
82
|
|
|
$data['tx_dlf_metadataformat'][end($formatIds)]['pid'] = intval($this->pid); |
|
83
|
|
|
$i++; |
|
84
|
|
|
} |
|
85
|
|
|
$data['tx_dlf_metadata'][uniqid('NEW')] = [ |
|
86
|
|
|
'pid' => intval($this->pid), |
|
87
|
|
|
'label' => $GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/NewTenant.xml:metadata.' . $index_name), |
|
88
|
|
|
'index_name' => $index_name, |
|
89
|
|
|
'format' => implode(',', $formatIds), |
|
90
|
|
|
'default_value' => $values['default_value'], |
|
91
|
|
|
'wrap' => (!empty($values['wrap']) ? $values['wrap'] : $GLOBALS['TCA']['tx_dlf_metadata']['columns']['wrap']['config']['default']), |
|
92
|
|
|
'index_tokenized' => $values['index_tokenized'], |
|
93
|
|
|
'index_stored' => $values['index_stored'], |
|
94
|
|
|
'index_indexed' => $values['index_indexed'], |
|
95
|
|
|
'index_boost' => $values['index_boost'], |
|
96
|
|
|
'is_sortable' => $values['is_sortable'], |
|
97
|
|
|
'is_facet' => $values['is_facet'], |
|
98
|
|
|
'is_listed' => $values['is_listed'], |
|
99
|
|
|
'index_autocomplete' => $values['index_autocomplete'], |
|
100
|
|
|
]; |
|
101
|
|
|
$i++; |
|
102
|
|
|
} |
|
103
|
|
|
$_ids = Helper::processDBasAdmin($data, [], true); |
|
104
|
|
|
// Check for failed inserts. |
|
105
|
|
|
if (count($_ids) == $i) { |
|
106
|
|
|
// Fine. |
|
107
|
|
|
$this->addFlashMessage( |
|
108
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataAddedMsg'), |
|
109
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataAdded'), |
|
110
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK |
|
111
|
|
|
); |
|
112
|
|
|
} else { |
|
113
|
|
|
// Something went wrong. |
|
114
|
|
|
$this->addFlashMessage( |
|
115
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataNotAddedMsg'), |
|
116
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataNotAdded'), |
|
117
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
|
118
|
|
|
); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
$this->forward('index'); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function addSolrCoreAction() { |
|
125
|
|
|
$this->pid = (int) GeneralUtility::_GP('id'); |
|
126
|
|
|
// Build data array. |
|
127
|
|
|
$data['tx_dlf_solrcores'][uniqid('NEW')] = [ |
|
128
|
|
|
'pid' => intval($this->pid), |
|
129
|
|
|
'label' => $GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/NewTenant.xml:solrcore') . ' (PID ' . $this->pid . ')', |
|
130
|
|
|
'index_name' => '', |
|
131
|
|
|
]; |
|
132
|
|
|
$_ids = Helper::processDBasAdmin($data); |
|
133
|
|
|
// Check for failed inserts. |
|
134
|
|
|
if (count($_ids) == 1) { |
|
135
|
|
|
// Fine. |
|
136
|
|
|
$this->addFlashMessage( |
|
137
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreAddedMsg'), |
|
138
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreAdded'), |
|
139
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK |
|
140
|
|
|
); |
|
141
|
|
|
} else { |
|
142
|
|
|
// Something went wrong. |
|
143
|
|
|
$this->addFlashMessage( |
|
144
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreNotAddedMsg'), |
|
145
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreNotAdded'), |
|
146
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
|
147
|
|
|
); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$this->forward('index'); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
public function addStructureAction() { |
|
154
|
|
|
$this->pid = (int) GeneralUtility::_GP('id'); |
|
155
|
|
|
// Include structure definition file. |
|
156
|
|
|
$structureDefaults = include (ExtensionManagementUtility::extPath($this->extKey) . 'Resources/Private/Data/StructureDefaults.php'); |
|
157
|
|
|
// Build data array. |
|
158
|
|
|
foreach ($structureDefaults as $index_name => $values) { |
|
159
|
|
|
$data['tx_dlf_structures'][uniqid('NEW')] = [ |
|
160
|
|
|
'pid' => intval($this->pid), |
|
161
|
|
|
'toplevel' => $values['toplevel'], |
|
162
|
|
|
'label' => $GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/NewTenant.xml:structure.' . $index_name), |
|
163
|
|
|
'index_name' => $index_name, |
|
164
|
|
|
'oai_name' => $values['oai_name'], |
|
165
|
|
|
'thumbnail' => 0, |
|
166
|
|
|
]; |
|
167
|
|
|
} |
|
168
|
|
|
$_ids = Helper::processDBasAdmin($data, [], true); |
|
169
|
|
|
// Check for failed inserts. |
|
170
|
|
|
if (count($_ids) == count($structureDefaults)) { |
|
171
|
|
|
// Fine. |
|
172
|
|
|
$this->addFlashMessage( |
|
173
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureAddedMsg'), |
|
174
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureAdded'), |
|
175
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK |
|
176
|
|
|
); |
|
177
|
|
|
} else { |
|
178
|
|
|
// Something went wrong. |
|
179
|
|
|
$this->addFlashMessage( |
|
180
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureNotAddedMsg'), |
|
181
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureNotAdded'), |
|
182
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
|
183
|
|
|
); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
$this->forward('index'); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* Set up the doc header properly here |
|
191
|
|
|
* |
|
192
|
|
|
* @param ViewInterface $view |
|
193
|
|
|
* @return void |
|
194
|
|
|
*/ |
|
195
|
|
|
protected function initializeView(ViewInterface $view) |
|
196
|
|
|
{ |
|
197
|
|
|
/** @var BackendTemplateView $view */ |
|
198
|
|
|
parent::initializeView($view); |
|
199
|
|
|
if ($this->actionMethodName == 'indexAction' |
|
200
|
|
|
|| $this->actionMethodName == 'onlineAction' |
|
201
|
|
|
|| $this->actionMethodName == 'compareAction') { |
|
202
|
|
|
$this->pid = (int) GeneralUtility::_GP('id'); |
|
203
|
|
|
$this->pageInfo = BackendUtility::readPageAccess($this->pid, $GLOBALS['BE_USER']->getPagePermsClause(1)); |
|
204
|
|
|
$view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); |
|
205
|
|
|
} |
|
206
|
|
|
if ($view instanceof BackendTemplateView) { |
|
|
|
|
|
|
207
|
|
|
$view->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal'); |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Main function of the module |
|
213
|
|
|
* |
|
214
|
|
|
* @access public |
|
215
|
|
|
* |
|
216
|
|
|
*/ |
|
217
|
|
|
public function indexAction() |
|
218
|
|
|
{ |
|
219
|
|
|
$this->pid = (int) GeneralUtility::_GP('id'); |
|
220
|
|
|
if ($this->pageInfo['doktype'] != 254) { |
|
221
|
|
|
$this->addFlashMessage( |
|
222
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.wrongPageTypeMsg'), |
|
223
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.wrongPageType'), |
|
224
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
|
225
|
|
|
); |
|
226
|
|
|
return; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
$structures = $this->structureRepository->findByPid($this->pid); |
|
230
|
|
|
|
|
231
|
|
|
if (count($structures) > 0) { |
|
232
|
|
|
// Fine. |
|
233
|
|
|
$this->addFlashMessage( |
|
234
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureOkayMsg'), |
|
235
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureOkay'), |
|
236
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK |
|
237
|
|
|
); |
|
238
|
|
|
} else { |
|
239
|
|
|
// Configuration missing. |
|
240
|
|
|
$this->addFlashMessage( |
|
241
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureNotOkayMsg'), |
|
242
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.structureNotOkay'), |
|
243
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
|
244
|
|
|
); |
|
245
|
|
|
$this->view->assign('structure', 1); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
$metadata = $this->metadataRepository->findByPid($this->pid); |
|
249
|
|
|
|
|
250
|
|
|
if (count($metadata) > 0) { |
|
251
|
|
|
// Fine. |
|
252
|
|
|
$this->addFlashMessage( |
|
253
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataOkayMsg'), |
|
254
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataOkay'), |
|
255
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK |
|
256
|
|
|
); |
|
257
|
|
|
} else { |
|
258
|
|
|
// Configuration missing. |
|
259
|
|
|
$this->addFlashMessage( |
|
260
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataNotOkayMsg'), |
|
261
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.metadataNotOkay'), |
|
262
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR |
|
263
|
|
|
); |
|
264
|
|
|
$this->view->assign('metadata', 1); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
$solrCore = $this->solrCoreRepository->findByPid($this->pid); |
|
268
|
|
|
$solrCore2 = $this->solrCoreRepository->findByPid(0); |
|
269
|
|
|
|
|
270
|
|
|
if (count($solrCore) > 0 OR count($solrCore2) > 0) { |
|
271
|
|
|
if (count($solrCore) > 0) { |
|
272
|
|
|
// Fine. |
|
273
|
|
|
$this->addFlashMessage( |
|
274
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreOkayMsg'), |
|
275
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreOkay'), |
|
276
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::OK |
|
277
|
|
|
); |
|
278
|
|
|
} else { |
|
279
|
|
|
// Default core available, but this is deprecated. |
|
280
|
|
|
$this->addFlashMessage( |
|
281
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreDeprecatedMsg'), |
|
282
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreDeprecatedOkay'), |
|
283
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE |
|
284
|
|
|
); |
|
285
|
|
|
$this->view->assign('solr', 1); |
|
286
|
|
|
} |
|
287
|
|
|
} else { |
|
288
|
|
|
// Solr core missing. |
|
289
|
|
|
$this->addFlashMessage( |
|
290
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreMissingMsg'), |
|
291
|
|
|
$GLOBALS['LANG']->sL('LLL:EXT:dlf/Resources/Private/Language/FlashMessages.xlf:flash.solrcoreMissing'), |
|
292
|
|
|
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING |
|
293
|
|
|
); |
|
294
|
|
|
$this->view->assign('solr', 1); |
|
295
|
|
|
} |
|
296
|
|
|
} |
|
297
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths