ILIAS  release_8 Revision v8.24
class.ilBasicSkillTemplateGUI.php
Go to the documentation of this file.
1<?php
2
21
29{
30 protected ilCtrl $ctrl;
31 protected ilLanguage $lng;
32 protected ilTabsGUI $tabs;
34 protected ilHelpGUI $help;
36
37 public function __construct(Tree\SkillTreeNodeManager $node_manager, int $a_node_id = 0, int $a_tref_id = 0)
38 {
39 global $DIC;
40
41 $this->ctrl = $DIC->ctrl();
42 $this->lng = $DIC->language();
43 $this->tabs = $DIC->tabs();
44 $this->tpl = $DIC["tpl"];
45 $this->help = $DIC["ilHelp"];
46 $this->toolbar = $DIC->toolbar();
47 $ilCtrl = $DIC->ctrl();
48
49 $this->tref_id = $a_tref_id;
50
51 $ilCtrl->saveParameter($this, array("node_id", "level_id"));
52
53 parent::__construct($node_manager, $a_node_id);
54 }
55
56 public function getType(): string
57 {
58 return "sktp";
59 }
60
61 public function initForm(string $a_mode = "edit"): void
62 {
64 $ilCtrl = $this->ctrl;
65
66 $this->form = new ilPropertyFormGUI();
67
68 // title
69 $ti = new ilTextInputGUI($lng->txt("title"), "title");
70 $ti->setMaxLength(200);
71 $ti->setSize(50);
72 $ti->setRequired(true);
73 $this->form->addItem($ti);
74
75 // description
76 $ta = new ilTextAreaInputGUI($lng->txt("description"), "description");
77 $ta->setRows(5);
78 $this->form->addItem($ta);
79
80 // save and cancel commands
81 if ($this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
82 if ($a_mode == "create") {
83 $this->form->addCommandButton("save", $lng->txt("save"));
84 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
85 $this->form->setTitle($lng->txt("skmg_create_skll"));
86 } else {
87 $this->form->addCommandButton("update", $lng->txt("save"));
88 $this->form->setTitle($lng->txt("skmg_edit_skll"));
89 }
90 } else {
91 foreach ($this->form->getItems() as $item) {
92 $item->setDisabled(true);
93 }
94 }
95
96 $ilCtrl->setParameter($this, "node_id", $this->requested_node_id);
97 $this->form->setFormAction($ilCtrl->getFormAction($this));
98 }
99
100 public function setLevelHead(): void
101 {
102 $ilTabs = $this->tabs;
103 $ilCtrl = $this->ctrl;
106 $ilHelp = $this->help;
107
108 // tabs
109 $ilTabs->clearTargets();
110 $ilHelp->setScreenIdComponent("skmg_lev");
111 $ilTabs->setBackTarget(
112 $lng->txt("skmg_skill_levels"),
113 $ilCtrl->getLinkTarget($this, "edit")
114 );
115
116 if ($this->requested_level_id > 0) {
117 if ($this->tref_id == 0) {
118 $ilTabs->addTab(
119 "level_settings",
120 $lng->txt("settings"),
121 $ilCtrl->getLinkTarget($this, "editLevel")
122 );
123 } else {
124 $ilTabs->addTab(
125 "level_resources",
126 $lng->txt("skmg_resources"),
127 $ilCtrl->getLinkTarget($this, "showLevelResources")
128 );
129 }
130 }
131
132 // title
133 if ($this->requested_level_id > 0) {
134 $tpl->setTitle($lng->txt("skmg_skill_level") . ": " .
135 ilBasicSkill::lookupLevelTitle($this->requested_level_id));
136 } else {
137 $tpl->setTitle($lng->txt("skmg_skill_level"));
138 }
139
140 $desc = $this->skill_tree_node_manager->getWrittenPath($this->node_object->getId());
141 $tpl->setDescription($desc);
142
145 0,
146 "sktp",
147 "",
148 false
149 )
150 );
151 }
152
153 public function setTabs(string $a_tab = "levels"): void
154 {
155 $ilTabs = $this->tabs;
156 $ilCtrl = $this->ctrl;
159 $ilHelp = $this->help;
160
161 $ilTabs->clearTargets();
162 $ilHelp->setScreenIdComponent("skmg_sktp");
163
164 $parent_node_id = $this->tree_repo->getParentNodeIdForNodeId($this->requested_node_id);
165 $parent_title = ilSkillTreeNode::_lookupTitle($parent_node_id);
166 $parent_type = ilSkillTreeNode::_lookupType($parent_node_id);
167
168 if ($this->tref_id == 0) {
169 if ($parent_type === "sctp") {
170 $ilCtrl->setParameterByClass(
171 "ilskilltemplatecategorygui",
172 "node_id",
173 $parent_node_id
174 );
175 $ilTabs->setBackTarget(
176 $parent_title,
177 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "listItems")
178 );
179 $ilCtrl->setParameterByClass(
180 "ilskilltemplatecategorygui",
181 "node_id",
182 ""
183 );
184 } else {
185 $ilTabs->setBackTarget(
186 $lng->txt("skmg_skill_templates"),
187 $ilCtrl->getLinkTargetByClass("ilobjskilltreegui", "editSkillTemplates")
188 );
189 }
190 }
191
192 if (is_object($this->node_object)) {
193 if ($this->tref_id == 0) {
194 $tpl->setTitle($lng->txt("skmg_skill_template") . ": " .
195 $this->node_object->getTitle());
196 } else {
197 $tpl->setTitle(
198 $this->node_object->getTitle()
199 );
200 }
201
202 // levels
203 $ilTabs->addTab(
204 "levels",
205 $lng->txt("skmg_skill_levels"),
206 $ilCtrl->getLinkTarget($this, 'edit')
207 );
208
209 // properties
210 if ($this->tref_id == 0) {
211 $ilTabs->addTab(
212 "properties",
213 $lng->txt("settings"),
214 $ilCtrl->getLinkTarget($this, 'editProperties')
215 );
216 }
217
218 // if ($this->tref_id > 0)
219 // {
220 // usage
221 $this->addUsageTab($ilTabs);
222 // }
223
224 // assigned objects
225 $this->addObjectsTab($ilTabs);
226
227 $ilTabs->activateTab($a_tab);
228
229 parent::setTitleIcon();
230
232 } else {
233 $tpl->setTitle($lng->txt("skmg_skill"));
234 $tpl->setDescription("");
235 }
236 }
237
238 public function saveItem(): void
239 {
240 if (!$this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
241 return;
242 }
243
244 $it = new ilBasicSkillTemplate();
245 $it->setTitle($this->form->getInput("title"));
246 $it->setDescription($this->form->getInput("description"));
247 $it->create();
248 $this->skill_tree_node_manager->putIntoTree($it, $this->requested_node_id, ilTree::POS_LAST_NODE);
249 $this->node_object = $it;
250 }
251
252 public function afterSave(): void
253 {
254 $ilCtrl = $this->ctrl;
255
256 if (!$this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
257 return;
258 }
259
260 $ilCtrl->setParameterByClass(
261 "ilbasicskilltemplategui",
262 "node_id",
263 $this->node_object->getId()
264 );
265 $ilCtrl->redirectByClass("ilbasicskilltemplategui", "edit");
266 }
267
268 public function edit(): void
269 {
271 $ilToolbar = $this->toolbar;
273 $ilCtrl = $this->ctrl;
274
275 $this->setTabs("levels");
276
277 if ($this->isInUse()) {
278 $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_in_use"));
279 } elseif ($this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
280 if ($this->tref_id == 0) {
281 $ilToolbar->addButton(
282 $lng->txt("skmg_add_level"),
283 $ilCtrl->getLinkTarget($this, "addLevel")
284 );
285 }
286 }
287
288 $table = new ilSkillLevelTableGUI(
289 $this->requested_node_id,
290 $this,
291 "edit",
292 $this->tref_id,
293 $this->isInUse(),
294 $this->tree_access_manager->hasManageCompetenceTemplatesPermission()
295 );
296 $tpl->setContent($table->getHTML());
297 }
298
299 public function showUsage(): void
300 {
302
303
304 // (a) referenced skill template in main tree
305 if ($this->tref_id > 0) {
306 parent::showUsage();
307 return;
308 }
309
310 // (b) skill template in templates view
311
312 $this->setTabs("usage");
313
314 $usage_info = new ilSkillUsage();
315 $usages = $usage_info->getAllUsagesOfTemplate($this->base_skill_id);
316
317 $html = "";
318 foreach ($usages as $k => $usage) {
319 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
320 $html .= $tab->getHTML() . "<br/><br/>";
321 }
322
323 $tpl->setContent($html);
324 }
325
326 public function showObjects(): void
327 {
329
330 // (a) referenced skill template in main tree
331 if ($this->tref_id > 0) {
332 parent::showObjects();
333 return;
334 }
335
336 // (b) skill template in templates view
337
338 $this->setTabs("objects");
339
340 $usage_info = new ilSkillUsage();
341 $objects = $usage_info->getAssignedObjectsForSkillTemplate($this->base_skill_id);
342
343 $tab = new ilSkillAssignedObjectsTableGUI($this, "showObjects", $objects);
344
345 $tpl->setContent($tab->getHTML());
346 }
347
348 public function redirectToParent(bool $a_tmp_mode = false): void
349 {
350 $ilCtrl = $this->ctrl;
351
352 $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $this->requested_node_id);
353 $ilCtrl->redirectByClass("ilskillrootgui", "listTemplates");
354 }
355}
Basic skill GUI class.
Basic skill template GUI class.
__construct(Tree\SkillTreeNodeManager $node_manager, int $a_node_id=0, int $a_tref_id=0)
redirectToParent(bool $a_tmp_mode=false)
Redirect to parent (identified by current node_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupLevelTitle(int $a_id)
Class ilCtrl provides processing control methods.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
Help GUI class.
setScreenIdComponent(string $a_comp)
language handling
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...
This class represents a property form user interface.
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...
addUsageTab(ilTabsGUI $a_tabs)
addObjectsTab(ilTabsGUI $a_tabs)
static getIconPath(int $a_obj_id, string $a_type, string $a_size="", int $a_status=0)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
static _lookupType(int $a_obj_id)
TableGUI class for skill usages.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const POS_LAST_NODE
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDescription(string $a_descr)
Sets description below title in standard template.
setContent(string $a_html)
Sets content for standard template.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...