ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSkillTemplateReferenceGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14
18 public function __construct($a_tref_id = 0)
19 {
20 global $DIC;
21
22 $this->ctrl = $DIC->ctrl();
23 $this->tpl = $DIC["tpl"];
24 $this->tabs = $DIC->tabs();
25 $this->lng = $DIC->language();
26 $this->help = $DIC["ilHelp"];
27 $ilCtrl = $DIC->ctrl();
28
29 $ilCtrl->saveParameter($this, "obj_id");
30 $ilCtrl->saveParameter($this, "tref_id");
31
32 parent::__construct($a_tref_id);
33
34 $this->tref_id = $a_tref_id;
35 if (is_object($this->node_object)) {
36 $this->base_skill_id = $this->node_object->getSkillTemplateId();
37 }
38 }
39
43 public function getType()
44 {
45 return "sktr";
46 }
47
51 public function executeCommand()
52 {
53 $ilCtrl = $this->ctrl;
55 $ilTabs = $this->tabs;
56
57 //$tpl->getStandardTemplate();
58
59 $next_class = $ilCtrl->getNextClass($this);
60 $cmd = $ilCtrl->getCmd();
61
62 switch ($next_class) {
63 default:
64 $ret = $this->$cmd();
65 break;
66 }
67 }
68
72 public function setTabs($a_tab = "")
73 {
74 $ilTabs = $this->tabs;
75 $ilCtrl = $this->ctrl;
78 $ilHelp = $this->help;
79
80 $ilTabs->clearTargets();
81 $ilHelp->setScreenIdComponent("skmg_sktr");
82
83 if (is_object($this->node_object)) {
84 $sk_id = $this->node_object->getSkillTemplateId();
85 $obj_type = ilSkillTreeNode::_lookupType($sk_id);
86
87 if ($obj_type == "sctp") {
88 // content
89 $ilTabs->addTab(
90 "content",
91 $lng->txt("content"),
92 $ilCtrl->getLinkTarget($this, 'listItems')
93 );
94 } else {
95 // content
96 $ilTabs->addTab(
97 "content",
98 $lng->txt("skmg_skill_levels"),
99 $ilCtrl->getLinkTarget($this, 'listItems')
100 );
101 }
102
103 // properties
104 $ilTabs->addTab(
105 "properties",
106 $lng->txt("settings"),
107 $ilCtrl->getLinkTarget($this, 'editProperties')
108 );
109
110 // usage
111 $this->addUsageTab($ilTabs);
112
113 // assigned objects
114 if ($obj_type != "sctp") {
115 $this->addObjectsTab($ilTabs);
116 }
117
118 // back link
119 /*
120 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
121 $this->node_object->skill_tree->getRootId());
122 $ilTabs->setBackTarget($lng->txt("obj_skmg"),
123 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills"));
124 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
125 $_GET["obj_id"]);*/
126
127 $tid = ilSkillTemplateReference::_lookupTemplateId($this->node_object->getId());
128 $add = " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
129
130 parent::setTitleIcon();
131 $tpl->setTitle(
132 $lng->txt("skmg_sktr") . ": " . $this->node_object->getTitle() . $add
133 );
135
136 $ilTabs->activateTab($a_tab);
137 }
138 }
139
146 public function insert()
147 {
148 $ilCtrl = $this->ctrl;
150
151 $ilCtrl->saveParameter($this, "parent_id");
152 $ilCtrl->saveParameter($this, "target");
153 $this->initForm("create");
154 $tpl->setContent($this->form->getHTML());
155 }
156
157
161 public function editProperties()
162 {
164
165 $this->setTabs("properties");
166
167 $this->initForm();
168 $this->getValues();
169 $tpl->setContent($this->form->getHTML());
170 }
171
177 public function initForm($a_mode = "edit")
178 {
180 $ilCtrl = $this->ctrl;
181
182 $this->form = new ilPropertyFormGUI();
183
184 // select skill template
186
187 // title
188 $ti = new ilTextInputGUI($lng->txt("title"), "title");
189 $ti->setRequired(true);
190 $this->form->addItem($ti);
191
192 // description
193 if ($a_mode == "edit") {
194 $desc = ilSkillTreeNode::_lookupDescription($this->node_object->getSkillTemplateId());
195 if (!empty($desc)) {
196 $ne = new ilNonEditableValueGUI($lng->txt("description"), "template_description");
197 $ne->setValue($desc);
198 $ne->setInfo($lng->txt("skmg_description_info"));
199 $this->form->addItem($ne);
200 }
201 }
202
203 // template
204 $options = array(
205 "" => $lng->txt("please_select"),
206 );
207 foreach ($tmplts as $tmplt) {
208 $options[$tmplt["child"]] = $tmplt["title"];
209 }
210 if ($a_mode != "edit") {
211 $si = new ilSelectInputGUI($lng->txt("skmg_skill_template"), "skill_template_id");
212 $si->setOptions($options);
213 $si->setRequired(true);
214 $this->form->addItem($si);
215 } else {
216 $ne = new ilNonEditableValueGUI($lng->txt("skmg_skill_template"), "");
217 $ne->setValue($options[$this->node_object->getSkillTemplateId()]);
218 $this->form->addItem($ne);
219 }
220
221 // status
222 $this->addStatusInput($this->form);
223
224 // selectable
225 $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "selectable");
226 $cb->setInfo($lng->txt("skmg_selectable_info"));
227 $this->form->addItem($cb);
228
229 if ($this->checkPermissionBool("write")) {
230 if ($a_mode == "create") {
231 $this->form->addCommandButton("save", $lng->txt("save"));
232 $this->form->addCommandButton("cancel", $lng->txt("cancel"));
233 $this->form->setTitle($lng->txt("skmg_new_sktr"));
234 } else {
235 $this->form->addCommandButton("updateSkillTemplateReference", $lng->txt("save"));
236 $this->form->setTitle($lng->txt("skmg_edit_sktr"));
237 }
238 }
239
240 $this->form->setFormAction($ilCtrl->getFormAction($this));
241 }
242
246 public function getValues()
247 {
248 $values = array();
249 $values["skill_template_id"] = $this->node_object->getSkillTemplateId();
250 $values["title"] = $this->node_object->getTitle();
251 $values["description"] = $this->node_object->getDescription();
252 $values["selectable"] = $this->node_object->getSelfEvaluation();
253 $values["status"] = $this->node_object->getStatus();
254 $this->form->setValuesByArray($values);
255 }
256
260 public function saveItem()
261 {
262 if (!$this->checkPermissionBool("write")) {
263 return;
264 }
265
266 $tree = new ilSkillTree();
267
268 $sktr = new ilSkillTemplateReference();
269 $sktr->setTitle($_POST["title"]);
270 $sktr->setDescription($_POST["description"]);
271 $sktr->setSkillTemplateId($_POST["skill_template_id"]);
272 $sktr->setSelfEvaluation($_POST["selectable"]);
273 $sktr->setOrderNr($tree->getMaxOrderNr((int) $_GET["obj_id"]) + 10);
274 $sktr->setStatus($_POST["status"]);
275 $sktr->create();
276 ilSkillTreeNode::putInTree($sktr, (int) $_GET["obj_id"], IL_LAST_NODE);
277 $this->node_object = $sktr;
278 }
279
283 public function afterSave()
284 {
285 $ilCtrl = $this->ctrl;
286
287 $ilCtrl->setParameterByClass(
288 "ilskilltemplatereferencegui",
289 "tref_id",
290 $this->node_object->getId()
291 );
292 $ilCtrl->setParameterByClass(
293 "ilskilltemplatereferencegui",
294 "obj_id",
295 $this->node_object->getSkillTemplateId()
296 );
297 $ilCtrl->redirectByClass("ilskilltemplatereferencegui", "listItems");
298 }
299
304 {
306 $ilCtrl = $this->ctrl;
308
309 if (!$this->checkPermissionBool("write")) {
310 return;
311 }
312
313 $this->initForm("edit");
314 if ($this->form->checkInput()) {
315 // perform update
316 // $this->node_object->setSkillTemplateId($_POST["skill_template_id"]);
317 $this->node_object->setTitle($_POST["title"]);
318 $this->node_object->setDescription($_POST["description"]);
319 $this->node_object->setSelfEvaluation($_POST["selectable"]);
320 $this->node_object->setStatus($_POST["status"]);
321 $this->node_object->update();
322
323 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
324 $ilCtrl->redirect($this, "editProperties");
325 }
326
327 $this->form->setValuesByPost();
328 $tpl->setContent($this->form->getHtml());
329 }
330
337 public function cancel()
338 {
339 $ilCtrl = $this->ctrl;
340
341 $ilCtrl->redirectByClass("ilobjskillmanagementgui", "editSkills");
342 }
343
347 public function listItems()
348 {
351
352 if ($this->isInUse()) {
353 ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
354 }
355
356 $this->setTabs("content");
357
358 $sk_id = $this->node_object->getSkillTemplateId();
359 $obj_type = ilSkillTreeNode::_lookupType($sk_id);
360
361 if ($obj_type == "sctp") {
362 $table = new ilSkillCatTableGUI(
363 $this,
364 "listItems",
365 (int) $sk_id,
367 $this->node_object->getId()
368 );
369 $tpl->setContent($table->getHTML());
370 } elseif ($obj_type == "sktp") {
371 $table = new ilSkillLevelTableGUI((int) $sk_id, $this, "edit", $this->node_object->getId());
372 $tpl->setContent($table->getHTML());
373 }
374 }
375
379 public function showObjects()
380 {
382
383 $this->setTabs("objects");
384
385 $usage_info = new ilSkillUsage();
386 $objects = $usage_info->getAssignedObjectsForSkill($this->base_skill_id, $this->tref_id);
387
388 $tab = new ilSkillAssignedObjectsTableGUI($this, "showObjects", $objects);
389
390 $tpl->setContent($tab->getHTML());
391 }
392}
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_LAST_NODE
Definition: class.ilTree.php:4
Basic skill template GUI class.
This class represents a checkbox property in a property form.
This class represents a non editable value in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.
TableGUI class for assigned objects of skills.
Skill template reference GUI class.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
setSkillNodeDescription()
Set skill node description.
addUsageTab($a_tabs)
Add usage tab.
addStatusInput(ilPropertyFormGUI $a_form)
Add status input.
checkPermissionBool($a_perm)
Check permission pool.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
static getTopTemplates()
Get top skill templates and template categories.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
static _lookupDescription($a_obj_id)
Lookup Description.
static _lookupType($a_obj_id)
Lookup Type.
This class represents a text property in a property form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6