ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSkillTemplateReferenceGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Skill/classes/class.ilBasicSkillTemplateGUI.php");
6include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
17{
18
22 public function __construct($a_tref_id = 0)
23 {
24 global $DIC;
25
26 $this->ctrl = $DIC->ctrl();
27 $this->tpl = $DIC["tpl"];
28 $this->tabs = $DIC->tabs();
29 $this->lng = $DIC->language();
30 $this->help = $DIC["ilHelp"];
31 $ilCtrl = $DIC->ctrl();
32
33 $ilCtrl->saveParameter($this, "obj_id");
34 $ilCtrl->saveParameter($this, "tref_id");
35
36 parent::__construct($a_tref_id);
37
38 $this->tref_id = $a_tref_id;
39 if (is_object($this->node_object)) {
40 $this->base_skill_id = $this->node_object->getSkillTemplateId();
41 }
42 }
43
47 public function getType()
48 {
49 return "sktr";
50 }
51
55 public function executeCommand()
56 {
59 $ilTabs = $this->tabs;
60
61 //$tpl->getStandardTemplate();
62
63 $next_class = $ilCtrl->getNextClass($this);
64 $cmd = $ilCtrl->getCmd();
65
66 switch ($next_class) {
67 default:
68 $ret = $this->$cmd();
69 break;
70 }
71 }
72
76 public function setTabs($a_tab = "")
77 {
78 $ilTabs = $this->tabs;
82 $ilHelp = $this->help;
83
84 $ilTabs->clearTargets();
85 $ilHelp->setScreenIdComponent("skmg_sktr");
86
87 if (is_object($this->node_object)) {
88 $sk_id = $this->node_object->getSkillTemplateId();
89 $obj_type = ilSkillTreeNode::_lookupType($sk_id);
90
91 if ($obj_type == "sctp") {
92 // content
93 $ilTabs->addTab(
94 "content",
95 $lng->txt("content"),
96 $ilCtrl->getLinkTarget($this, 'listItems')
97 );
98 } else {
99 // content
100 $ilTabs->addTab(
101 "content",
102 $lng->txt("skmg_skill_levels"),
103 $ilCtrl->getLinkTarget($this, 'listItems')
104 );
105 }
106
107 // properties
108 $ilTabs->addTab(
109 "properties",
110 $lng->txt("settings"),
111 $ilCtrl->getLinkTarget($this, 'editProperties')
112 );
113
114 // usage
115 $this->addUsageTab($ilTabs);
116
117 // back link
118 /*
119 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
120 $this->node_object->skill_tree->getRootId());
121 $ilTabs->setBackTarget($lng->txt("obj_skmg"),
122 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills"));
123 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
124 $_GET["obj_id"]);*/
125
126 $tid = ilSkillTemplateReference::_lookupTemplateId($this->node_object->getId());
127 $add = " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
128
129 parent::setTitleIcon();
130 $tpl->setTitle(
131 $lng->txt("skmg_sktr") . ": " . $this->node_object->getTitle() . $add
132 );
134
135 $ilTabs->activateTab($a_tab);
136 }
137 }
138
145 public function insert()
146 {
149
150 $ilCtrl->saveParameter($this, "parent_id");
151 $ilCtrl->saveParameter($this, "target");
152 $this->initForm("create");
153 $tpl->setContent($this->form->getHTML());
154 }
155
156
160 public function editProperties()
161 {
163
164 $this->setTabs("properties");
165
166 $this->initForm();
167 $this->getValues();
168 $tpl->setContent($this->form->getHTML());
169 }
170
176 public function initForm($a_mode = "edit")
177 {
180
181 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
182 $this->form = new ilPropertyFormGUI();
183
184 // select skill template
185 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
187
188 // title
189 $ti = new ilTextInputGUI($lng->txt("title"), "title");
190 $ti->setRequired(true);
191 $this->form->addItem($ti);
192
193 // description
194 if ($a_mode == "edit") {
195 $desc = ilSkillTreeNode::_lookupDescription($this->node_object->getSkillTemplateId());
196 if (!empty($desc)) {
197 $ne = new ilNonEditableValueGUI($lng->txt("description"), "template_description");
198 $ne->setValue($desc);
199 $ne->setInfo($lng->txt("skmg_description_info"));
200 $this->form->addItem($ne);
201 }
202 }
203
204 // template
205 $options = array(
206 "" => $lng->txt("please_select"),
207 );
208 foreach ($tmplts as $tmplt) {
209 $options[$tmplt["child"]] = $tmplt["title"];
210 }
211 if ($a_mode != "edit") {
212 $si = new ilSelectInputGUI($lng->txt("skmg_skill_template"), "skill_template_id");
213 $si->setOptions($options);
214 $si->setRequired(true);
215 $this->form->addItem($si);
216 } else {
217 $ne = new ilNonEditableValueGUI($lng->txt("skmg_skill_template"), "");
218 $ne->setValue($options[$this->node_object->getSkillTemplateId()]);
219 $this->form->addItem($ne);
220 }
221
222 // status
223 $this->addStatusInput($this->form);
224
225 // selectable
226 $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "selectable");
227 $cb->setInfo($lng->txt("skmg_selectable_info"));
228 $this->form->addItem($cb);
229
230 if ($this->checkPermissionBool("write")) {
231 if ($a_mode == "create") {
232 $this->form->addCommandButton("save", $lng->txt("save"));
233 $this->form->addCommandButton("cancel", $lng->txt("cancel"));
234 $this->form->setTitle($lng->txt("skmg_new_sktr"));
235 } else {
236 $this->form->addCommandButton("updateSkillTemplateReference", $lng->txt("save"));
237 $this->form->setTitle($lng->txt("skmg_edit_sktr"));
238 }
239 }
240
241 $this->form->setFormAction($ilCtrl->getFormAction($this));
242 }
243
247 public function getValues()
248 {
249 $values = array();
250 $values["skill_template_id"] = $this->node_object->getSkillTemplateId();
251 $values["title"] = $this->node_object->getTitle();
252 $values["description"] = $this->node_object->getDescription();
253 $values["selectable"] = $this->node_object->getSelfEvaluation();
254 $values["status"] = $this->node_object->getStatus();
255 $this->form->setValuesByArray($values);
256 }
257
261 public function saveItem()
262 {
263 if (!$this->checkPermissionBool("write")) {
264 return;
265 }
266
267 $tree = new ilSkillTree();
268
269 $sktr = new ilSkillTemplateReference();
270 $sktr->setTitle($_POST["title"]);
271 $sktr->setDescription($_POST["description"]);
272 $sktr->setSkillTemplateId($_POST["skill_template_id"]);
273 $sktr->setSelfEvaluation($_POST["selectable"]);
274 $sktr->setOrderNr($tree->getMaxOrderNr((int) $_GET["obj_id"]) + 10);
275 $sktr->setStatus($_POST["status"]);
276 $sktr->create();
277 ilSkillTreeNode::putInTree($sktr, (int) $_GET["obj_id"], IL_LAST_NODE);
278 $this->node_object = $sktr;
279 }
280
284 public function afterSave()
285 {
287
288 $ilCtrl->setParameterByClass(
289 "ilskilltemplatereferencegui",
290 "tref_id",
291 $this->node_object->getId()
292 );
293 $ilCtrl->setParameterByClass(
294 "ilskilltemplatereferencegui",
295 "obj_id",
296 $this->node_object->getSkillTemplateId()
297 );
298 $ilCtrl->redirectByClass("ilskilltemplatereferencegui", "listItems");
299 }
300
305 {
309
310 if (!$this->checkPermissionBool("write")) {
311 return;
312 }
313
314 $this->initForm("edit");
315 if ($this->form->checkInput()) {
316 // perform update
317 // $this->node_object->setSkillTemplateId($_POST["skill_template_id"]);
318 $this->node_object->setTitle($_POST["title"]);
319 $this->node_object->setDescription($_POST["description"]);
320 $this->node_object->setSelfEvaluation($_POST["selectable"]);
321 $this->node_object->setStatus($_POST["status"]);
322 $this->node_object->update();
323
324 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
325 $ilCtrl->redirect($this, "editProperties");
326 }
327
328 $this->form->setValuesByPost();
329 $tpl->setContent($this->form->getHtml());
330 }
331
338 public function cancel()
339 {
341
342 $ilCtrl->redirectByClass("ilobjskillmanagementgui", "editSkills");
343 }
344
348 public function listItems()
349 {
352
353 if ($this->isInUse()) {
354 ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
355 }
356
357 $this->setTabs("content");
358
359 $sk_id = $this->node_object->getSkillTemplateId();
360 $obj_type = ilSkillTreeNode::_lookupType($sk_id);
361
362 if ($obj_type == "sctp") {
363 include_once("./Services/Skill/classes/class.ilSkillCatTableGUI.php");
364 $table = new ilSkillCatTableGUI(
365 $this,
366 "listItems",
367 (int) $sk_id,
369 $this->node_object->getId()
370 );
371 $tpl->setContent($table->getHTML());
372 } elseif ($obj_type == "sktp") {
373 include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
374 $table = new ilSkillLevelTableGUI((int) $sk_id, $this, "edit", $this->node_object->getId());
375 $tpl->setContent($table->getHTML());
376 }
377 }
378}
$_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.
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.
help()
Definition: help.php:2
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46