19declare(strict_types=1);
38use JetBrains\PhpStorm\NoReturn;
70 $this->vocab_manager = $services->vocabularies()->manager();
72 $services->presentation()->elements(),
73 $services->presentation()->utilities(),
74 $services->vocabularies()->presentation(),
75 $services->vocabularies()->slotHandler(),
76 $services->structure()->structure(),
77 $services->paths()->navigatorFactory(),
78 $services->paths()->pathFactory()
81 $services->paths()->pathFactory(),
82 $this->vocab_manager->controlledVocabularyCreator(),
83 $services->vocabularies()->slotHandler()
86 $this->
ctrl = $DIC->ctrl();
87 $this->
http = $DIC->http();
88 $this->temp_files =
$DIC->filesystem()->temp();
89 $this->
lng = $DIC->language();
90 $this->tpl =
$DIC->ui()->mainTemplate();
91 $this->
toolbar = $DIC->toolbar();
92 $this->ui_factory =
$DIC->ui()->factory();
93 $this->ui_renderer =
$DIC->ui()->renderer();
98 $this->parent_obj_gui->getRefId(),
102 $this->
lng->loadLanguageModule(
"meta");
107 $next_class = $this->
ctrl->getNextClass($this);
108 $cmd = $this->
ctrl->getCmd();
110 if (!$this->access_service->hasCurrentUserReadAccess()) {
114 switch ($next_class) {
115 case strtolower(ilMDVocabularyUploadHandlerGUI::class):
121 if (!$cmd || $cmd ===
'view') {
122 $cmd =
'showVocabularies';
134 if ($this->access_service->hasCurrentUserWriteAccess()) {
137 $content[] = $import_modal;
142 $this->tpl->setContent($this->ui_renderer->render($content));
152 ($action !==
'show_all' && !$this->access_service->hasCurrentUserWriteAccess())
154 $this->
ctrl->redirect($this,
'showVocabularies');
159 $this->confirmDeleteVocabulary($vocab_id);
170 case 'allow_custom_input':
174 case 'disallow_custom_input':
179 $this->showAllValuesModalForVocabulary($vocab_id);
183 $this->
ctrl->redirect($this,
'showVocabularies');
189 if (!$this->access_service->hasCurrentUserWriteAccess()) {
190 $this->
ctrl->redirect($this,
'showVocabularies');
193 $message_type =
'failure';
194 $message_text = $this->
lng->txt(
'md_vocab_import_upload_failed');
198 $upload_folder =
null;
200 $upload_folder = (string) (
$modal->getData()[
'file'][0] ??
null);
201 if (!$this->temp_files->hasDir($upload_folder)) {
202 $upload_folder =
null;
206 $file_content =
null;
207 if (!is_null($upload_folder)) {
208 $files = $files = $this->temp_files->listContents($upload_folder);
209 if (count($files) === 1 && ($files[0] ??
null)?->isFile()) {
210 $file_content = $this->temp_files->read($files[0]->getPath());
212 $this->temp_files->deleteDir($upload_folder);
215 if (!is_null($file_content)) {
216 $result = $this->importer->import($file_content);
218 if ($result->wasSuccessful()) {
219 $message_type =
'success';
220 $message_text = $this->
lng->txt(
'md_vocab_import_successful');
222 $message_type =
'failure';
223 $message_text = sprintf(
224 $this->
lng->txt(
'md_vocab_import_invalid'),
225 implode(
"<br/>", $result->getErrors())
230 $this->tpl->setOnScreenMessage($message_type, $message_text,
true);
231 $this->
ctrl->redirect($this,
'showVocabularies');
234 #[NoReturn] protected function confirmDeleteVocabulary(string $vocab_id): void
237 $key = $vocabs_id_token->getName();
239 $vocab = $this->vocab_manager->getVocabulary($vocab_id);
241 foreach ($this->presentation->makeValuesPresentable(
243 self::MAX_CONFIRMATION_VALUES
245 $value_items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
251 $this->
ctrl->setParameter($this,
$key, $vocab_id);
252 $link = $this->
ctrl->getLinkTarget($this,
'deleteVocabulary');
253 $this->
ctrl->clearParameters($this);
255 $modal = $this->ui_factory->modal()->interruptive(
256 $this->presentation->txt(
'md_vocab_delete_confirmation_title'),
257 $this->presentation->txtFill(
258 'md_vocab_delete_confirmation_text',
259 $this->presentation->makeSlotPresentable(
$vocab->slot()),
264 echo $this->ui_renderer->renderAsync(
$modal);
271 if ($vocab_id !==
'') {
272 $this->vocab_manager->actions()->delete(
273 $this->vocab_manager->getVocabulary($vocab_id)
276 $this->tpl->setOnScreenMessage(
277 GlobalTemplate::MESSAGE_TYPE_SUCCESS,
278 $this->
lng->txt(
'md_vocab_deletion_successful'),
281 $this->
ctrl->redirect($this,
'showVocabularies');
286 $this->vocab_manager->actions()->activate(
287 $this->vocab_manager->getVocabulary($vocab_id)
289 $this->tpl->setOnScreenMessage(
290 GlobalTemplate::MESSAGE_TYPE_SUCCESS,
291 $this->
lng->txt(
'md_vocab_update_successful'),
294 $this->
ctrl->redirect($this,
'showVocabularies');
299 $this->vocab_manager->actions()->deactivate(
300 $this->vocab_manager->getVocabulary($vocab_id)
302 $this->tpl->setOnScreenMessage(
303 GlobalTemplate::MESSAGE_TYPE_SUCCESS,
304 $this->
lng->txt(
'md_vocab_update_successful'),
307 $this->
ctrl->redirect($this,
'showVocabularies');
312 $this->vocab_manager->actions()->allowCustomInput(
313 $this->vocab_manager->getVocabulary($vocab_id)
315 $this->tpl->setOnScreenMessage(
316 GlobalTemplate::MESSAGE_TYPE_SUCCESS,
317 $this->
lng->txt(
'md_vocab_update_successful'),
320 $this->
ctrl->redirect($this,
'showVocabularies');
325 $this->vocab_manager->actions()->disallowCustomInput(
326 $this->vocab_manager->getVocabulary($vocab_id)
328 $this->tpl->setOnScreenMessage(
329 GlobalTemplate::MESSAGE_TYPE_SUCCESS,
330 $this->
lng->txt(
'md_vocab_update_successful'),
333 $this->
ctrl->redirect($this,
'showVocabularies');
336 #[NoReturn] protected function showAllValuesModalForVocabulary(string $vocab_id): void
338 $vocab = $this->vocab_manager->getVocabulary($vocab_id);
339 $values = $this->ui_factory->listing()->unordered(
340 $this->presentation->makeValuesPresentable(
$vocab)
342 $modal = $this->ui_factory->modal()->roundtrip(
343 $this->presentation->txtFill(
344 'md_vocab_all_values_title',
345 $this->presentation->makeSlotPresentable(
$vocab->slot()),
350 echo $this->ui_renderer->renderAsync(
$modal);
356 $column_factory = $this->ui_factory->table()->column();
358 'element' => $column_factory->text($this->
lng->txt(
'md_vocab_element_column'))->withIsSortable(
false),
359 'type' => $column_factory->status($this->
lng->txt(
'md_vocab_type_column'))->withIsSortable(
false),
360 'source' => $column_factory->text($this->
lng->txt(
'md_vocab_source_column'))->withIsSortable(
false),
361 'preview' => $column_factory->text($this->
lng->txt(
'md_vocab_preview_column'))->withIsSortable(
false),
362 'active' => $column_factory->statusIcon($this->
lng->txt(
'md_vocab_active_column'))->withIsSortable(
false),
363 'custom_input' => $column_factory->statusIcon($this->
lng->txt(
'md_vocab_custom_input_column'))->withIsSortable(
false)
367 $actions_factory = $this->ui_factory->table()->action();
370 if ($this->access_service->hasCurrentUserWriteAccess()) {
371 $actions [
'delete'] = $actions_factory->single(
372 $this->
lng->txt(
'md_vocab_delete_action'),
373 $url_builder->withParameter($action_parameter_token,
'delete'),
376 $actions[
'activate'] = $actions_factory->single(
377 $this->
lng->txt(
'md_vocab_activate_action'),
378 $url_builder->withParameter($action_parameter_token,
'activate'),
381 $actions[
'deactivate'] = $actions_factory->single(
382 $this->
lng->txt(
'md_vocab_deactivate_action'),
383 $url_builder->withParameter($action_parameter_token,
'deactivate'),
386 $actions[
'allow_custom_input'] = $actions_factory->single(
387 $this->
lng->txt(
'md_vocab_allow_custom_input_action'),
388 $url_builder->withParameter($action_parameter_token,
'allow_custom_input'),
391 $actions[
'disallow_custom_input'] = $actions_factory->single(
392 $this->
lng->txt(
'md_vocab_disallow_custom_input_action'),
393 $url_builder->withParameter($action_parameter_token,
'disallow_custom_input'),
398 $actions[
'show_all'] = $actions_factory->single(
399 $this->
lng->txt(
'md_vocab_show_all_action'),
400 $url_builder->withParameter($action_parameter_token,
'show_all'),
404 return $this->ui_factory->table()->data(
406 $this->vocab_manager,
410 $this->
lng->txt(
'md_vocab_table_title'),
412 )->withActions($actions)->withRequest($this->
http->request());
417 $file_input = $this->ui_factory->input()->field()->file(
419 $this->
lng->txt(
'md_import_file_vocab')
420 )->withAcceptedMimeTypes([MimeType::TEXT__XML])->withMaxFiles(1);
422 return $this->ui_factory->modal()->roundtrip(
423 $this->
lng->txt(
'md_import_vocab_modal'),
425 [
'file' => $file_input],
426 $this->ctrl->getLinkTarget($this,
'importVocabulary')
432 return $this->ui_factory->button()->standard(
433 $this->
lng->txt(
'md_import_vocab'),
441 $key = $action_parameter_token->getName();
442 if ($this->
http->wrapper()->query()->has(
$key)) {
443 return $this->
http->wrapper()->query()->retrieve(
454 $key = $vocabs_id_token->getName();
455 if ($this->
http->wrapper()->query()->has(
$key)) {
456 return $this->
http->wrapper()->query()->retrieve(
458 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
467 rtrim(ILIAS_HTTP_PATH,
'/') .
'/' . $this->
ctrl->getLinkTarget($this,
'tableAction')
469 return $url_builder->acquireParameters(
470 [
'metadata',
'vocab'],
Builds a Color from either hex- or rgb values.
The scope of this class is split ilias-conform URI's into components.
Class ilCtrl provides processing control methods.
@ilCtrl_Calls ilMDVocabulariesGUI: ilMDVocabularyUploadHandlerGUI
disallowCustomInputForVocabulary(string $vocab_id)
ilMDSettingsAccessService $access_service
allowCustomInputForVocabulary(string $vocab_id)
__construct(ilObjMDSettingsGUI $parent_obj_gui)
deactivateVocabulary(string $vocab_id)
VocabManager $vocab_manager
Presentation $presentation
getTableURLBuilderAndParameters()
getImportButton(Signal $signal)
ilGlobalTemplateInterface $tpl
activateVocabulary(string $vocab_id)
ilObjMDSettingsGUI $parent_obj_gui
const int MAX_CONFIRMATION_VALUES
The filesystem interface provides the public interface for the Filesystem service API consumer.
This describes a Data Table.
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.