ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjMediaObjectsSettingsGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected \ILIAS\MediaObjects\MediaType\MediaTypeManager $media_types;
30 protected ilTabsGUI $tabs;
31
32 public function __construct(
33 $a_data,
34 int $a_id,
35 bool $a_call_by_reference = true,
36 bool $a_prepare_output = true
37 ) {
38 global $DIC;
39 $this->error = $DIC["ilErr"];
40 $this->access = $DIC->access();
41 $this->tabs = $DIC->tabs();
42 $this->tpl = $DIC["tpl"];
43 $this->lng = $DIC->language();
44 $this->ctrl = $DIC->ctrl();
45 $this->type = 'mobs';
46 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
47
48 $this->lng->loadLanguageModule('mob');
49 $this->lng->loadLanguageModule('mep');
50 $this->lng->loadLanguageModule('content');
51 $this->media_types = $DIC->mediaObjects()->internal()->domain()->mediaType();
52 }
53
54 public function executeCommand(): void
55 {
56 $next_class = $this->ctrl->getNextClass($this);
57 $cmd = $this->ctrl->getCmd();
58
59 $this->prepareOutput();
60
61 if (!$this->rbac_system->checkAccess("visible,read", $this->object->getRefId())) {
62 $this->error->raiseError($this->lng->txt('no_permission'), $this->error->WARNING);
63 }
64
65 switch ($next_class) {
66 case 'ilpermissiongui':
67 $this->tabs_gui->setTabActive('perm_settings');
68 $perm_gui = new ilPermissionGUI($this);
69 $this->ctrl->forwardCommand($perm_gui);
70 break;
71
72 default:
73 if (!$cmd || $cmd == 'view') {
74 $cmd = "editSettings";
75 }
76 $this->$cmd();
77 break;
78 }
79 }
80
81 public function getAdminTabs(): void
82 {
83 $ilAccess = $this->access;
84 $ilTabs = $this->tabs;
85
86 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
87 $ilTabs->addTarget(
88 "settings",
89 $this->ctrl->getLinkTarget($this, "editSettings"),
90 array("editSettings", "view")
91 );
92 }
93
94 if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
95 $ilTabs->addTarget(
96 "perm_settings",
97 $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"),
98 array(),
99 'ilpermissiongui'
100 );
101 }
102 }
103
104 public function editSettings(
105 bool $a_omit_init = false
106 ): void {
107 $tpl = $this->tpl;
108
109 if (!$a_omit_init) {
111 $this->getSettingsValues();
112 }
113 $tpl->setContent($this->form->getHTML());
114 }
115
116 public function saveSettings(): void
117 {
119 $ilCtrl = $this->ctrl;
120
121 $this->checkPermission("write");
122
123 $this->initMediaObjectsSettingsForm();
124 if ($this->form->checkInput()) {
125 // perform save
126 $mset = new ilSetting("mobs");
127 $mset->set("mep_activate_pages", $this->form->getInput("activate_pages"));
128 $mset->set("file_manager_always", $this->form->getInput("file_manager_always"));
129 $mset->set("black_list_file_types", $this->form->getInput("black_list_file_types"));
130
131 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
132 $ilCtrl->redirect($this, "editSettings");
133 }
134
135 $this->form->setValuesByPost();
136 $this->editSettings(true);
137 }
138
142 public function initMediaObjectsSettingsForm(): void
143 {
145 $ilCtrl = $this->ctrl;
146 $ilAccess = $this->access;
147
148
149 $this->form = new ilPropertyFormGUI();
150
151 // activate page in media pool
152 $cb = new ilCheckboxInputGUI($lng->txt("mobs_activate_pages"), "activate_pages");
153 $cb->setInfo($lng->txt("mobs_activate_pages_info"));
154 $this->form->addItem($cb);
155
156 // activate page in media pool
157 $cb = new ilCheckboxInputGUI($lng->txt("mobs_always_show_file_manager"), "file_manager_always");
158 $cb->setInfo($lng->txt("mobs_always_show_file_manager_info"));
159 $this->form->addItem($cb);
160
161 // allowed file types
162 /*
163 $ta = new ilTextAreaInputGUI($this->lng->txt("mobs_restrict_file_types"), "restricted_file_types");
164 //$ta->setCols();
165 //$ta->setRows();
166 $ta->setInfo($this->lng->txt("mobs_restrict_file_types_info"));
167 $this->form->addItem($ta);*/
168
169 // black lis file types
170 $ta = new ilTextAreaInputGUI($this->lng->txt("mobs_black_list_file_types"), "black_list_file_types");
171 $ta->setInfo(
172 $this->lng->txt("mobs_black_list_file_types_and_allowed_info") .
173 " " . implode(", ", iterator_to_array($this->media_types->getAllowedMimeTypes()))
174 );
175 $this->form->addItem($ta);
176
177 if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
178 $this->form->addCommandButton("saveSettings", $lng->txt("save"));
179 }
180
181 $this->form->setTitle($lng->txt("settings"));
182 $this->form->setFormAction($ilCtrl->getFormAction($this));
183 }
184
185 public function getSettingsValues(): void
186 {
187 $values = array();
188
189 $mset = new ilSetting("mobs");
190 $values["activate_pages"] = $mset->get("mep_activate_pages");
191 $values["file_manager_always"] = $mset->get("file_manager_always");
192 $values["restricted_file_types"] = $mset->get("restricted_file_types");
193 $values["black_list_file_types"] = $mset->get("black_list_file_types");
194
195 $this->form->setValuesByArray($values);
196 }
197}
error(string $a_errmsg)
This class represents a checkbox property in a property form.
Error Handling & global info handling.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAdminTabs()
administration tabs show only permissions and trash folder
initMediaObjectsSettingsForm()
Init media objects settings form.
__construct( $a_data, int $a_id, bool $a_call_by_reference=true, bool $a_prepare_output=true)
ILIAS MediaObjects MediaType MediaTypeManager $media_types
Class ilObjectGUI Basic methods of all Output classes.
ilAccessHandler $access
ilGlobalTemplateInterface $tpl
prepareOutput(bool $show_sub_objects=true)
This class represents a property form user interface.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTarget(string $a_text, string $a_link, $a_cmd="", $a_cmdClass="", string $a_frame="", bool $a_activate=false, bool $a_dir_text=false)
This class represents a text area property in a property form.
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26