ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMDOERSettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected ilCtrl $ctrl;
25 protected ilLanguage $lng;
28
29 protected ?ilMDSettings $md_settings = null;
30
32 {
33 global $DIC;
34
35 $this->ctrl = $DIC->ctrl();
36 $this->lng = $DIC->language();
37 $this->tpl = $DIC->ui()->mainTemplate();
38
39 $this->parent_obj_gui = $parent_obj_gui;
40 $this->access_service = new ilMDSettingsAccessService(
41 $this->parent_obj_gui->getRefId(),
42 $DIC->access()
43 );
44
45 $this->lng->loadLanguageModule("meta");
46 }
47
48 public function executeCommand(): void
49 {
50 $next_class = $this->ctrl->getNextClass($this);
51 $cmd = $this->ctrl->getCmd();
52
53 if (
54 !$this->access_service->hasCurrentUserVisibleAccess() ||
55 !$this->access_service->hasCurrentUserReadAccess()
56 ) {
57 throw new ilPermissionException($this->lng->txt('no_permission'));
58 }
59
60 switch ($next_class) {
61 default:
62 if (!$cmd || $cmd === 'view') {
63 $cmd = 'showOERSettings';
64 }
65
66 $this->$cmd();
67 break;
68 }
69 }
70
71 public function showOERSettings(?ilPropertyFormGUI $form = null): void
72 {
73 if (!$form instanceof ilPropertyFormGUI) {
74 $form = $this->initSettingsForm();
75 }
76 $this->tpl->setContent($form->getHTML());
77 }
78
79 public function saveOERSettings(): void
80 {
81 if (!$this->access_service->hasCurrentUserWriteAccess()) {
82 $this->ctrl->redirect($this, "showOERSettings");
83 }
84 $form = $this->initSettingsForm();
85 if ($form->checkInput()) {
86 $this->MDSettings()->activateCopyrightSelection((bool) $form->getInput('active'));
87 $this->MDSettings()->activateOAIPMH((bool) $form->getInput('oai_active'));
88 $this->MDSettings()->saveOAIRepositoryName((string) $form->getInput('oai_repository_name'));
89 $this->MDSettings()->saveOAIIdentifierPrefix((string) $form->getInput('oai_identifier_prefix'));
90 $this->MDSettings()->saveOAIContactMail((string) $form->getInput('oai_contact_mail'));
91 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
92 $this->ctrl->redirect($this, 'showOERSettings');
93 }
94 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'), true);
95 $form->setValuesByPost();
96 $this->showOERSettings($form);
97 }
98
99 protected function initSettingsForm(): ilPropertyFormGUI
100 {
101 $form = new ilPropertyFormGUI();
102 $form->setFormAction($this->ctrl->getFormAction($this));
103
104 if ($this->access_service->hasCurrentUserWriteAccess()) {
105 $form->addCommandButton('saveOERSettings', $this->lng->txt('save'));
106 }
107
108 $header = new ilFormSectionHeaderGUI();
109 $header->setTitle($this->lng->txt('md_settings_licence'));
110 $form->addItem($header);
111
112 $check = new ilCheckboxInputGUI($this->lng->txt('md_copyright_enabled'), 'active');
113 $check->setChecked($this->MDSettings()->isCopyrightSelectionActive());
114 $check->setValue('1');
115 $check->setInfo($this->lng->txt('md_copyright_enable_info'));
116 $form->addItem($check);
117
118 $header = new ilFormSectionHeaderGUI();
119 $header->setTitle($this->lng->txt('md_settings_harvester'));
120 $form->addItem($header);
121
124 $form,
125 $this->parent_obj_gui
126 );
127
128 $header = new ilFormSectionHeaderGUI();
129 $header->setTitle($this->lng->txt('md_settings_publishing'));
130 $form->addItem($header);
131
132 $oai_check = new ilCheckboxInputGUI($this->lng->txt('md_oai_pmh_enabled'), 'oai_active');
133 $oai_check->setChecked($this->MDSettings()->isOAIPMHActive());
134 $oai_check->setValue('1');
135 $oai_check->setInfo($this->lng->txt('md_oai_pmh_enabled_info'));
136 $form->addItem($oai_check);
137
138 $oai_repo_name = new ilTextInputGUI($this->lng->txt('md_oai_repository_name'), 'oai_repository_name');
139 $oai_repo_name->setValue($this->MDSettings()->getOAIRepositoryName());
140 $oai_repo_name->setInfo($this->lng->txt('md_oai_repository_name_info'));
141 $oai_repo_name->setRequired(true);
142 $oai_check->addSubItem($oai_repo_name);
143
144 $oai_id_prefix = new ilTextInputGUI($this->lng->txt('md_oai_identifier_prefix'), 'oai_identifier_prefix');
145 $oai_id_prefix->setValue($this->MDSettings()->getOAIIdentifierPrefix());
146 $oai_id_prefix->setInfo($this->lng->txt('md_oai_identifier_prefix_info'));
147 $oai_id_prefix->setRequired(true);
148 $oai_check->addSubItem($oai_id_prefix);
149
150 $oai_contact_mail = new ilTextInputGUI($this->lng->txt('md_oai_contact_mail'), 'oai_contact_mail');
151 $oai_contact_mail->setValue($this->MDSettings()->getOAIContactMail());
152 $oai_contact_mail->setRequired(true);
153 $oai_check->addSubItem($oai_contact_mail);
154
155 return $form;
156 }
157
158 protected function MDSettings(): ilMDSettings
159 {
160 if (!isset($this->md_settings)) {
161 $this->md_settings = ilMDSettings::_getInstance();
162 }
163 return $this->md_settings;
164 }
165
166 protected function getAdministrationFormId(): int
167 {
169 }
170}
$check
Definition: buildRTE.php:81
static addFieldsToForm(int $a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
This class represents a checkbox property in a property form.
Class ilCtrl provides processing control methods.
This class represents a section header in a property form.
language handling
__construct(ilObjMDSettingsGUI $parent_obj_gui)
ilObjMDSettingsGUI $parent_obj_gui
ilMDSettingsAccessService $access_service
showOERSettings(?ilPropertyFormGUI $form=null)
ilGlobalTemplateInterface $tpl
This class represents a property form user interface.
This class represents a text property in a property form.
global $DIC
Definition: shib_login.php:26