ILIAS  release_8 Revision v8.24
class.ilObjItemGroupGUI.php
Go to the documentation of this file.
1<?php
2
20
29{
30 protected \ILIAS\ItemGroup\InternalGUIService $gui;
32 protected ilTabsGUI $tabs;
33 protected ilHelpGUI $help;
34
35 public function __construct(
36 int $a_id = 0,
37 int $a_id_type = self::REPOSITORY_NODE_ID,
38 int $a_parent_node_id = 0
39 ) {
40 global $DIC;
41 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
42
43 $this->lng = $DIC->language();
44 $this->tabs = $DIC->tabs();
45 $this->access = $DIC->access();
46 $this->tpl = $DIC["tpl"];
47 $this->ctrl = $DIC->ctrl();
48 $this->locator = $DIC["ilLocator"];
49 $this->tree = $DIC->repositoryTree();
50 $this->help = $DIC["ilHelp"];
51 $this->gui = $DIC->itemGroup()->internal()->gui();
52 $this->ig_request = $this->gui
53 ->standardRequest();
54 }
55
56 protected function afterConstructor(): void
57 {
59
60 $lng->loadLanguageModule("itgr");
61 $this->ctrl->saveParameter($this, array("ref_id"));
62 }
63
64 final public function getType(): string
65 {
66 return "itgr";
67 }
68
69 public function executeCommand(): void
70 {
71 $ilTabs = $this->tabs;
72 $next_class = $this->ctrl->getNextClass($this);
73
74 switch ($next_class) {
75 case 'ilpermissiongui':
76 $this->prepareOutput();
77 $ilTabs->activateTab("perm_settings");
78 $this->addHeaderAction();
79 $perm_gui = new ilPermissionGUI($this);
80 $this->ctrl->forwardCommand($perm_gui);
81 break;
82
83 case "ilcommonactiondispatchergui":
85 $this->ctrl->forwardCommand($gui);
86 break;
87
88 case 'ilobjecttranslationgui':
89 $this->checkPermissionBool("write");
90 $this->prepareOutput();
91 $this->setSettingsSubTabs("settings_trans");
92 $transgui = new ilObjectTranslationGUI($this);
93 $transgui->setEnableFallbackLanguage(false);
94 $transgui->supportContentTranslation(false);
95 $transgui->hideDescription(true);
96 $this->ctrl->forwardCommand($transgui);
97 break;
98
99 default:
100 $cmd = $this->ctrl->getCmd("listMaterials");
101 $this->prepareOutput();
102 $this->addHeaderAction();
103 $this->$cmd();
104 break;
105 }
106 }
107
108 public function addLocatorItems(): void
109 {
110 $ilLocator = $this->locator;
111 $ilAccess = $this->access;
112
113 if (is_object($this->object) && $ilAccess->checkAccess("write", "", $this->object->getRefId())) {
114 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "listMaterials"), "", $this->requested_ref_id);
115 }
116 }
117
118 protected function initCreationForms(string $new_type): array
119 {
120 $forms = array(self::CFORM_NEW => $this->initCreateForm($new_type));
121
122 return $forms;
123 }
124
125 protected function initEditCustomForm(ilPropertyFormGUI $form): void
126 {
127 $form->removeItemByPostVar("desc");
128
129 // presentation
130 $pres = new ilFormSectionHeaderGUI();
131 $pres->setTitle($this->lng->txt('obj_presentation'));
132 $form->addItem($pres);
133
134 // show title
135 $cb = new ilCheckboxInputGUI($this->lng->txt("itgr_show_title"), "show_title");
136 $cb->setInfo($this->lng->txt("itgr_show_title_info"));
137 $form->addItem($cb);
138
139 // behaviour
140 $options = ilItemGroupBehaviour::getAll();
141 $si = new ilSelectInputGUI($this->lng->txt("itgr_behaviour"), "behaviour");
142 $si->setInfo($this->lng->txt("itgr_behaviour_info"));
143 $si->setOptions($options);
144 $cb->addSubItem($si);
145
146 // tile/list
147 $lpres = new ilRadioGroupInputGUI($this->lng->txt('itgr_list_presentation'), "list_presentation");
148
149 $std_list = new ilRadioOption($this->lng->txt('itgr_list_default'), "");
150 $std_list->setInfo($this->lng->txt('itgr_list_default_info'));
151 $lpres->addOption($std_list);
152
153 $item_list = new ilRadioOption($this->lng->txt('itgr_list'), "list");
154 $lpres->addOption($item_list);
155
156 $tile_view = new ilRadioOption($this->lng->txt('itgr_tile'), "tile");
157 $lpres->addOption($tile_view);
158
159 // tile size
160 $si = new ilRadioGroupInputGUI($this->lng->txt("itgr_tile_size"), "tile_size");
161 $dummy_container = new ilContainer();
162 $this->lng->loadLanguageModule("cont");
163 foreach ($dummy_container->getTileSizes() as $key => $txt) {
164 $op = new ilRadioOption($txt, $key);
165 $si->addOption($op);
166 }
167 $tile_view->addSubItem($si);
168 $si->setValue($this->object->getTileSize());
169
170 $lpres->setValue($this->object->getListPresentation());
171 $form->addItem($lpres);
172 }
173
174 protected function afterSave(ilObject $new_object): void
175 {
176 $ilCtrl = $this->ctrl;
177
178 $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
179 $ilCtrl->redirect($this, "listMaterials");
180 }
181
182 public function edit(): void
183 {
184 parent::edit();
185 $this->setSettingsSubTabs("general");
186 }
187
188 public function listMaterials(): void
189 {
191 $ilTabs = $this->tabs;
193
194 $this->checkPermission("write");
195
196 $ilTabs->activateTab("materials");
197
198 $parent_ref_id = $tree->getParentId($this->object->getRefId());
199
200 $gui = new ilObjectAddNewItemGUI($parent_ref_id);
201 $gui->setDisabledObjectTypes(array("itgr", "sess"));
202 $gui->setAfterCreationCallback($this->object->getRefId());
203 $gui->render();
204
205 $tab = new ilItemGroupItemsTableGUI($this->gui, $this, "listMaterials");
206 $tpl->setContent($tab->getHTML());
207 }
208
209 public function saveItemAssignment(): void
210 {
211 $ilCtrl = $this->ctrl;
212
213 $this->checkPermission("write");
214
215 $item_group_items = new ilItemGroupItems($this->object->getRefId());
216 $items = $this->ig_request->getItems();
217 $item_group_items->setItems($items);
218 $item_group_items->update();
219
220 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
221 $ilCtrl->redirect($this, "listMaterials");
222 }
223
224 public function getTemplate(): void
225 {
226 $this->tpl->loadStandardTemplate();
227 }
228
229 protected function setTabs(): void
230 {
231 $ilAccess = $this->access;
232 $ilTabs = $this->tabs;
233 $ilHelp = $this->help;
236
237 $ilHelp->setScreenIdComponent("itgr");
238
239 $parent_ref_id = $tree->getParentId($this->object->getRefId());
240 $parent_obj_id = ilObject::_lookupObjId($parent_ref_id);
241 $parent_type = ilObject::_lookupType($parent_obj_id);
242
243 $ilTabs->setBackTarget(
244 $lng->txt('obj_' . $parent_type),
245 ilLink::_getLink($parent_ref_id),
246 "_top"
247 );
248
249 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
250 $ilTabs->addTab(
251 'materials',
252 $lng->txt('itgr_materials'),
253 $this->ctrl->getLinkTarget($this, 'listMaterials')
254 );
255
256 $ilTabs->addTab(
257 'settings',
258 $lng->txt('settings'),
259 $this->ctrl->getLinkTarget($this, 'edit')
260 );
261 }
262
263 if ($ilAccess->checkAccess("edit_permission", "", $this->object->getRefId())) {
264 $ilTabs->addTab(
265 "perm_settings",
266 $lng->txt('perm_settings'),
267 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
268 );
269 }
270 }
271
272 protected function setSettingsSubTabs(string $active_tab = "general"): void
273 {
274 $this->tabs_gui->addSubTab(
275 "general",
276 $this->lng->txt("settings"),
277 $this->ctrl->getLinkTarget($this, "edit")
278 );
279
280 $this->tabs_gui->addSubTab(
281 "settings_trans",
282 $this->lng->txt("obj_multilinguality"),
283 $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
284 );
285 $this->tabs_gui->activateTab("settings");
286 $this->tabs_gui->activateSubTab($active_tab);
287 }
288
289 public static function _goto(string $a_target): void
290 {
291 global $DIC;
292 $main_tpl = $DIC->ui()->mainTemplate();
293
294 $ilAccess = $DIC->access();
295 $lng = $DIC->language();
296 $tree = $DIC->repositoryTree();
297
298 $targets = explode('_', $a_target);
299 $ref_id = $targets[0];
300 $par_id = $tree->getParentId($ref_id);
301
302 if ($ilAccess->checkAccess("read", "", $par_id)) {
304 exit;
305 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
306 $main_tpl->setOnScreenMessage('failure', sprintf(
307 $lng->txt("msg_no_perm_read_item"),
309 ), true);
311 }
312
313 throw new ilPermissionException($lng->txt("msg_no_perm_read"));
314 }
315
316 public function gotoParent(): void
317 {
318 $ilAccess = $this->access;
320
321 $ref_id = $this->object->getRefId();
322 $par_id = $tree->getParentId($ref_id);
323
324 if ($ilAccess->checkAccess("read", "", $par_id)) {
326 exit;
327 }
328 }
329
333 public function afterSaveCallback(ilObject $a_obj): void
334 {
335 // add new object to materials
336 $items = new ilItemGroupItems($this->object->getRefId());
337 $items->addItem($a_obj->getRefId());
338 $items->update();
339 }
340
344 protected function getEditFormCustomValues(array &$a_values): void
345 {
346 $a_values["show_title"] = !$this->object->getHideTitle();
347 $a_values["behaviour"] = $this->object->getBehaviour();
348 $a_values["list_presentation"] = $this->object->getListPresentation();
349 $a_values["tile_size"] = $this->object->getTileSize();
350 }
351
352 protected function updateCustom(ilPropertyFormGUI $form): void
353 {
354 $this->object->setHideTitle(!$form->getInput("show_title"));
355 $behaviour = ($form->getInput("show_title"))
356 ? $form->getInput("behaviour")
358 $this->object->setBehaviour($behaviour);
359 $this->object->setListPresentation($form->getInput("list_presentation"));
360 $this->object->setTileSize($form->getInput("tile_size"));
361 }
362
363 protected function initCreateForm(string $new_type): ilPropertyFormGUI
364 {
365 $form = parent::initCreateForm($new_type);
366 $form->removeItemByPostVar("desc");
367 return $form;
368 }
369}
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Help GUI class.
static getAll()
Get all behaviours.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
User Interface class for item groups.
getType()
Functions that must be overwritten.
afterConstructor()
Do anything that should be done after constructor in here.
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
addLocatorItems()
Functions to be overwritten.
ILIAS ItemGroup InternalGUIService $gui
setTabs()
create tabs (repository/workspace switch)
StandardGUIRequest $ig_request
getEditFormCustomValues(array &$a_values)
Get edit form values (custom part)
afterSave(ilObject $new_object)
Post (successful) object creation hook.
initEditCustomForm(ilPropertyFormGUI $form)
Add custom fields to update form.
initCreateForm(string $new_type)
executeCommand()
execute command
setSettingsSubTabs(string $active_tab="general")
afterSaveCallback(ilObject $a_obj)
Custom callback after object is created (in parent container)
static _goto(string $a_target)
initCreationForms(string $new_type)
Init creation forms.
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
New implementation of ilObjectGUI.
ilAccessHandler $access
ilGlobalTemplateInterface $tpl
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
ilLocatorGUI $locator
prepareOutput(bool $show_sub_objects=true)
checkPermission(string $perm, string $cmd="", string $type="", int $ref_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
addHeaderAction()
Add header action menu.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
removeItemByPostVar(string $a_post_var, bool $a_remove_unused_headers=false)
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getParentId(int $a_node_id)
get parent id of given node
static redirect(string $a_script)
const ROOT_FOLDER_ID
Definition: constants.php:32
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
setContent(string $a_html)
Sets content for standard template.
exit
Definition: login.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193