19 declare(strict_types=1);
    69         $this->vocab_manager = $services->vocabularies()->manager();
    71             $services->presentation()->elements(),
    72             $services->presentation()->utilities(),
    73             $services->vocabularies()->presentation(),
    74             $services->vocabularies()->slotHandler(),
    75             $services->structure()->structure(),
    76             $services->paths()->navigatorFactory(),
    77             $services->paths()->pathFactory()
    80             $services->paths()->pathFactory(),
    81             $this->vocab_manager->controlledVocabularyCreator(),
    82             $services->vocabularies()->slotHandler()
    85         $this->
ctrl = $DIC->ctrl();
    86         $this->
http = $DIC->http();
    87         $this->temp_files = $DIC->filesystem()->temp();
    88         $this->
lng = $DIC->language();
    89         $this->tpl = $DIC->ui()->mainTemplate();
    90         $this->
toolbar = $DIC->toolbar();
    91         $this->ui_factory = $DIC->ui()->factory();
    92         $this->ui_renderer = $DIC->ui()->renderer();
    97             $this->parent_obj_gui->getRefId(),
   101         $this->
lng->loadLanguageModule(
"meta");
   106         $next_class = $this->
ctrl->getNextClass($this);
   107         $cmd = $this->
ctrl->getCmd();
   110             !$this->access_service->hasCurrentUserVisibleAccess() ||
   111             !$this->access_service->hasCurrentUserReadAccess()
   116         switch ($next_class) {
   117             case strtolower(ilMDVocabularyUploadHandlerGUI::class):
   123                 if (!$cmd || $cmd === 
'view') {
   124                     $cmd = 
'showVocabularies';
   136         if ($this->access_service->hasCurrentUserWriteAccess()) {
   139             $content[] = $import_modal;
   144         $this->tpl->setContent($this->ui_renderer->render($content));
   154             ($action !== 
'show_all' && !$this->access_service->hasCurrentUserWriteAccess())
   156             $this->
ctrl->redirect($this, 
'showVocabularies');
   161                 $this->confirmDeleteVocabulary($vocab_id);
   172             case 'allow_custom_input':
   176             case 'disallow_custom_input':
   181                 $this->showAllValuesModalForVocabulary($vocab_id);
   185                 $this->
ctrl->redirect($this, 
'showVocabularies');
   191         if (!$this->access_service->hasCurrentUserWriteAccess()) {
   192             $this->
ctrl->redirect($this, 
'showVocabularies');
   195         $message_type = 
'failure';
   196         $message_text = $this->
lng->txt(
'md_vocab_import_upload_failed');
   200         $upload_folder = null;
   202             $upload_folder = (string) (
$modal->getData()[
'file'][0] ?? null);
   203             if (!$this->temp_files->hasDir($upload_folder)) {
   204                 $upload_folder = null;
   208         $file_content = null;
   209         if (!is_null($upload_folder)) {
   210             $files = $files = $this->temp_files->listContents($upload_folder);
   211             if (count($files) === 1 && ($files[0] ?? null)?->isFile()) {
   212                 $file_content = $this->temp_files->read($files[0]->getPath());
   214             $this->temp_files->deleteDir($upload_folder);
   217         if (!is_null($file_content)) {
   218             $result = $this->importer->import($file_content);
   220             if ($result->wasSuccessful()) {
   221                 $message_type = 
'success';
   222                 $message_text = $this->
lng->txt(
'md_vocab_import_successful');
   224                 $message_type = 
'failure';
   225                 $message_text = sprintf(
   226                     $this->
lng->txt(
'md_vocab_import_invalid'),
   227                     implode(
"<br/>", $result->getErrors())
   232         $this->tpl->setOnScreenMessage($message_type, $message_text, 
true);
   233         $this->
ctrl->redirect($this, 
'showVocabularies');
   236     #[NoReturn] protected function confirmDeleteVocabulary(string $vocab_id): void   239         $key = $vocabs_id_token->getName();
   241         $vocab = $this->vocab_manager->getVocabulary($vocab_id);
   243         foreach ($this->presentation->makeValuesPresentable(
   245             self::MAX_CONFIRMATION_VALUES
   247             $value_items[] = $this->ui_factory->modal()->interruptiveItem()->standard(
   253         $this->
ctrl->setParameter($this, 
$key, $vocab_id);
   254         $link = $this->
ctrl->getLinkTarget($this, 
'deleteVocabulary');
   255         $this->
ctrl->clearParameters($this);
   257         $modal = $this->ui_factory->modal()->interruptive(
   258             $this->presentation->txt(
'md_vocab_delete_confirmation_title'),
   259             $this->presentation->txtFill(
   260                 'md_vocab_delete_confirmation_text',
   261                 $this->presentation->makeSlotPresentable(
$vocab->slot()),
   266         echo $this->ui_renderer->renderAsync(
$modal);
   273         if ($vocab_id !== 
'') {
   274             $this->vocab_manager->actions()->delete(
   275                 $this->vocab_manager->getVocabulary($vocab_id)
   278         $this->tpl->setOnScreenMessage(
   280             $this->
lng->txt(
'md_vocab_deletion_successful'),
   283         $this->
ctrl->redirect($this, 
'showVocabularies');
   288         $this->vocab_manager->actions()->activate(
   289             $this->vocab_manager->getVocabulary($vocab_id)
   291         $this->tpl->setOnScreenMessage(
   293             $this->
lng->txt(
'md_vocab_update_successful'),
   296         $this->
ctrl->redirect($this, 
'showVocabularies');
   301         $this->vocab_manager->actions()->deactivate(
   302             $this->vocab_manager->getVocabulary($vocab_id)
   304         $this->tpl->setOnScreenMessage(
   306             $this->
lng->txt(
'md_vocab_update_successful'),
   309         $this->
ctrl->redirect($this, 
'showVocabularies');
   314         $this->vocab_manager->actions()->allowCustomInput(
   315             $this->vocab_manager->getVocabulary($vocab_id)
   317         $this->tpl->setOnScreenMessage(
   319             $this->
lng->txt(
'md_vocab_update_successful'),
   322         $this->
ctrl->redirect($this, 
'showVocabularies');
   327         $this->vocab_manager->actions()->disallowCustomInput(
   328             $this->vocab_manager->getVocabulary($vocab_id)
   330         $this->tpl->setOnScreenMessage(
   332             $this->
lng->txt(
'md_vocab_update_successful'),
   335         $this->
ctrl->redirect($this, 
'showVocabularies');
   338     #[NoReturn] protected function showAllValuesModalForVocabulary(string $vocab_id): void   340         $vocab = $this->vocab_manager->getVocabulary($vocab_id);
   341         $values = $this->ui_factory->listing()->unordered(
   342             $this->presentation->makeValuesPresentable(
$vocab)
   344         $modal = $this->ui_factory->modal()->roundtrip(
   345             $this->presentation->txtFill(
   346                 'md_vocab_all_values_title',
   347                 $this->presentation->makeSlotPresentable(
$vocab->slot()),
   352         echo $this->ui_renderer->renderAsync(
$modal);
   358         $column_factory = $this->ui_factory->table()->column();
   360             'element' => $column_factory->text($this->
lng->txt(
'md_vocab_element_column'))->withIsSortable(
false),
   361             'type' => $column_factory->status($this->
lng->txt(
'md_vocab_type_column'))->withIsSortable(
false),
   362             'source' => $column_factory->text($this->
lng->txt(
'md_vocab_source_column'))->withIsSortable(
false),
   363             'preview' => $column_factory->text($this->
lng->txt(
'md_vocab_preview_column'))->withIsSortable(
false),
   364             'active' => $column_factory->statusIcon($this->
lng->txt(
'md_vocab_active_column'))->withIsSortable(
false),
   365             'custom_input' => $column_factory->statusIcon($this->
lng->txt(
'md_vocab_custom_input_column'))->withIsSortable(
false)
   369         $actions_factory = $this->ui_factory->table()->action();
   372         if ($this->access_service->hasCurrentUserWriteAccess()) {
   373             $actions [
'delete'] = $actions_factory->single(
   374                 $this->
lng->txt(
'md_vocab_delete_action'),
   375                 $url_builder->withParameter($action_parameter_token, 
'delete'),
   378             $actions[
'activate'] = $actions_factory->single(
   379                 $this->
lng->txt(
'md_vocab_activate_action'),
   380                 $url_builder->withParameter($action_parameter_token, 
'activate'),
   383             $actions[
'deactivate'] = $actions_factory->single(
   384                 $this->
lng->txt(
'md_vocab_deactivate_action'),
   385                 $url_builder->withParameter($action_parameter_token, 
'deactivate'),
   388             $actions[
'allow_custom_input'] = $actions_factory->single(
   389                 $this->
lng->txt(
'md_vocab_allow_custom_input_action'),
   390                 $url_builder->withParameter($action_parameter_token, 
'allow_custom_input'),
   393             $actions[
'disallow_custom_input'] = $actions_factory->single(
   394                 $this->
lng->txt(
'md_vocab_disallow_custom_input_action'),
   395                 $url_builder->withParameter($action_parameter_token, 
'disallow_custom_input'),
   400         $actions[
'show_all'] = $actions_factory->single(
   401             $this->
lng->txt(
'md_vocab_show_all_action'),
   402             $url_builder->withParameter($action_parameter_token, 
'show_all'),
   406         return $this->ui_factory->table()->data(
   407             $this->
lng->txt(
'md_vocab_table_title'),
   410                 $this->vocab_manager,
   414         )->withActions($actions)->withRequest($this->
http->request());
   419         $file_input = $this->ui_factory->input()->field()->file(
   421             $this->
lng->txt(
'md_import_file_vocab')
   422         )->withAcceptedMimeTypes([MimeType::TEXT__XML])->withMaxFiles(1);
   424         return $this->ui_factory->modal()->roundtrip(
   425             $this->
lng->txt(
'md_import_vocab_modal'),
   427             [
'file' => $file_input],
   428             $this->
ctrl->getLinkTarget($this, 
'importVocabulary')
   434         return $this->ui_factory->button()->standard(
   435             $this->
lng->txt(
'md_import_vocab'),
   443         $key = $action_parameter_token->getName();
   444         if ($this->
http->wrapper()->query()->has(
$key)) {
   445             return $this->
http->wrapper()->query()->retrieve(
   456         $key = $vocabs_id_token->getName();
   457         if ($this->
http->wrapper()->query()->has(
$key)) {
   458             return $this->
http->wrapper()->query()->retrieve(
   469             rtrim(ILIAS_HTTP_PATH, 
'/') . 
'/' . $this->
ctrl->getLinkTarget($this, 
'tableAction')
   471         return $url_builder->acquireParameters(
   472             [
'metadata', 
'vocab'],
 ilMDVocabulariesGUI: ilMDVocabularyUploadHandlerGUI 
 
__construct(ilObjMDSettingsGUI $parent_obj_gui)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
allowCustomInputForVocabulary(string $vocab_id)
 
ilMDSettingsAccessService $access_service
 
deactivateVocabulary(string $vocab_id)
 
const MESSAGE_TYPE_SUCCESS
 
VocabManager $vocab_manager
 
ilGlobalTemplateInterface $tpl
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static http()
Fetches the global http state from ILIAS. 
 
The scope of this class is split ilias-conform URI's into components. 
 
activateVocabulary(string $vocab_id)
 
Presentation $presentation
 
ilObjMDSettingsGUI $parent_obj_gui
 
disallowCustomInputForVocabulary(string $vocab_id)
 
const MAX_CONFIRMATION_VALUES
 
getImportButton(Signal $signal)
 
getTableURLBuilderAndParameters()