ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 // template
194 $options = array(
195 "" => $lng->txt("please_select"),
196 );
197 foreach ($tmplts as $tmplt) {
198 $options[$tmplt["child"]] = $tmplt["title"];
199 }
200 if ($a_mode != "edit") {
201 $si = new ilSelectInputGUI($lng->txt("skmg_skill_template"), "skill_template_id");
202 $si->setOptions($options);
203 $si->setRequired(true);
204 $this->form->addItem($si);
205 } else {
206 $ne = new ilNonEditableValueGUI($lng->txt("skmg_skill_template"), "");
207 $ne->setValue($options[$this->node_object->getSkillTemplateId()]);
208 $this->form->addItem($ne);
209 }
210
211 // status
212 $this->addStatusInput($this->form);
213
214 // selectable
215 $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "selectable");
216 $cb->setInfo($lng->txt("skmg_selectable_info"));
217 $this->form->addItem($cb);
218
219 if ($this->checkPermissionBool("write")) {
220 if ($a_mode == "create") {
221 $this->form->addCommandButton("save", $lng->txt("save"));
222 $this->form->addCommandButton("cancel", $lng->txt("cancel"));
223 $this->form->setTitle($lng->txt("skmg_new_sktr"));
224 } else {
225 $this->form->addCommandButton("updateSkillTemplateReference", $lng->txt("save"));
226 $this->form->setTitle($lng->txt("skmg_edit_sktr"));
227 }
228 }
229
230 $this->form->setFormAction($ilCtrl->getFormAction($this));
231 }
232
236 public function getValues()
237 {
238 $values = array();
239 $values["skill_template_id"] = $this->node_object->getSkillTemplateId();
240 $values["title"] = $this->node_object->getTitle();
241 $values["selectable"] = $this->node_object->getSelfEvaluation();
242 $values["status"] = $this->node_object->getStatus();
243 $this->form->setValuesByArray($values);
244 }
245
249 public function saveItem()
250 {
251 if (!$this->checkPermissionBool("write")) {
252 return;
253 }
254
255 $tree = new ilSkillTree();
256
257 $sktr = new ilSkillTemplateReference();
258 $sktr->setTitle($_POST["title"]);
259 $sktr->setSkillTemplateId($_POST["skill_template_id"]);
260 $sktr->setSelfEvaluation($_POST["selectable"]);
261 $sktr->setOrderNr($tree->getMaxOrderNr((int) $_GET["obj_id"]) + 10);
262 $sktr->setStatus($_POST["status"]);
263 $sktr->create();
264 ilSkillTreeNode::putInTree($sktr, (int) $_GET["obj_id"], IL_LAST_NODE);
265 $this->node_object = $sktr;
266 }
267
271 public function afterSave()
272 {
274
275 $ilCtrl->setParameterByClass(
276 "ilskilltemplatereferencegui",
277 "tref_id",
278 $this->node_object->getId()
279 );
280 $ilCtrl->setParameterByClass(
281 "ilskilltemplatereferencegui",
282 "obj_id",
283 $this->node_object->getSkillTemplateId()
284 );
285 $ilCtrl->redirectByClass("ilskilltemplatereferencegui", "listItems");
286 }
287
292 {
296
297 if (!$this->checkPermissionBool("write")) {
298 return;
299 }
300
301 $this->initForm("edit");
302 if ($this->form->checkInput()) {
303 // perform update
304 // $this->node_object->setSkillTemplateId($_POST["skill_template_id"]);
305 $this->node_object->setTitle($_POST["title"]);
306 $this->node_object->setSelfEvaluation($_POST["selectable"]);
307 $this->node_object->setStatus($_POST["status"]);
308 $this->node_object->update();
309
310 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
311 $ilCtrl->redirect($this, "editProperties");
312 }
313
314 $this->form->setValuesByPost();
315 $tpl->setContent($this->form->getHtml());
316 }
317
324 public function cancel()
325 {
327
328 $ilCtrl->redirectByClass("ilobjskillmanagementgui", "editSkills");
329 }
330
334 public function listItems()
335 {
338
339 if ($this->isInUse()) {
340 ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
341 }
342
343 $this->setTabs("content");
344
345 $sk_id = $this->node_object->getSkillTemplateId();
346 $obj_type = ilSkillTreeNode::_lookupType($sk_id);
347
348 if ($obj_type == "sctp") {
349 include_once("./Services/Skill/classes/class.ilSkillCatTableGUI.php");
351 $this,
352 "listItems",
353 (int) $sk_id,
355 $this->node_object->getId()
356 );
357 $tpl->setContent($table->getHTML());
358 } elseif ($obj_type == "sktp") {
359 include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
360 $table = new ilSkillLevelTableGUI((int) $sk_id, $this, "edit", $this->node_object->getId());
361 $tpl->setContent($table->getHTML());
362 }
363 }
364}
$_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 _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 $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
if(empty($password)) $table
Definition: pwgen.php:24
global $DIC
Definition: saml.php:7
$values