ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 function __construct($a_tref_id = 0)
23 {
24 global $ilCtrl;
25
26 $ilCtrl->saveParameter($this, "obj_id");
27 $ilCtrl->saveParameter($this, "tref_id");
28
29 parent::__construct($a_tref_id);
30
31 $this->tref_id = $a_tref_id;
32 if (is_object($this->node_object))
33 {
34 $this->base_skill_id = $this->node_object->getSkillTemplateId();
35 }
36 }
37
41 function getType()
42 {
43 return "sktr";
44 }
45
49 function &executeCommand()
50 {
51 global $ilCtrl, $tpl, $ilTabs;
52
53 $tpl->getStandardTemplate();
54
55 $next_class = $ilCtrl->getNextClass($this);
56 $cmd = $ilCtrl->getCmd();
57
58 switch($next_class)
59 {
60 default:
61 $ret = $this->$cmd();
62 break;
63 }
64 }
65
69 function setTabs($a_tab)
70 {
71 global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
72
73 $ilTabs->clearTargets();
74 $ilHelp->setScreenIdComponent("skmg_sktr");
75
76 if (is_object($this->node_object))
77 {
78 $sk_id = $this->node_object->getSkillTemplateId();
79 $obj_type = ilSkillTreeNode::_lookupType($sk_id);
80
81 if ($obj_type == "sctp")
82 {
83 // content
84 $ilTabs->addTab("content", $lng->txt("content"),
85 $ilCtrl->getLinkTarget($this, 'listItems'));
86 }
87 else
88 {
89 // content
90 $ilTabs->addTab("content", $lng->txt("skmg_skill_levels"),
91 $ilCtrl->getLinkTarget($this, 'listItems'));
92 }
93
94 // properties
95 $ilTabs->addTab("properties", $lng->txt("settings"),
96 $ilCtrl->getLinkTarget($this, 'editProperties'));
97
98 // usage
99 $this->addUsageTab($ilTabs);
100
101 // back link
102/*
103 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
104 $this->node_object->skill_tree->getRootId());
105 $ilTabs->setBackTarget($lng->txt("obj_skmg"),
106 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills"));
107 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
108 $_GET["obj_id"]);*/
109
110 $tid = ilSkillTemplateReference::_lookupTemplateId($this->node_object->getId());
111 $add = " (".ilSkillTreeNode::_lookupTitle($tid).")";
112
113 parent::setTitleIcon();
114 $tpl->setTitle(
115 $lng->txt("skmg_sktr").": ".$this->node_object->getTitle().$add);
117
118 $ilTabs->activateTab($a_tab);
119 }
120 }
121
128 function insert()
129 {
130 global $ilCtrl, $tpl;
131
132 $ilCtrl->saveParameter($this, "parent_id");
133 $ilCtrl->saveParameter($this, "target");
134 $this->initForm("create");
135 $tpl->setContent($this->form->getHTML());
136 }
137
138
142 function editProperties()
143 {
144 global $tpl;
145
146 $this->setTabs("properties");
147
148 $this->initForm();
149 $this->getValues();
150 $tpl->setContent($this->form->getHTML());
151 }
152
158 public function initForm($a_mode = "edit")
159 {
160 global $lng, $ilCtrl;
161
162 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
163 $this->form = new ilPropertyFormGUI();
164
165 // select skill template
166 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
168
169 // title
170 $ti = new ilTextInputGUI($lng->txt("title"), "title");
171 $ti->setRequired(true);
172 $this->form->addItem($ti);
173
174 // order nr
175 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
176 $ni->setMaxLength(6);
177 $ni->setSize(6);
178 $ni->setRequired(true);
179 $this->form->addItem($ni);
180
181 // template
182 $options = array(
183 "" => $lng->txt("please_select"),
184 );
185 foreach ($tmplts as $tmplt)
186 {
187 $options[$tmplt["child"]] = $tmplt["title"];
188 }
189 if ($a_mode != "edit")
190 {
191 $si = new ilSelectInputGUI($lng->txt("skmg_skill_template"), "skill_template_id");
192 $si->setOptions($options);
193 $si->setRequired(true);
194 $this->form->addItem($si);
195 }
196 else
197 {
198 $ne = new ilNonEditableValueGUI($lng->txt("skmg_skill_template"), "");
199 $ne->setValue($options[$this->node_object->getSkillTemplateId()]);
200 $this->form->addItem($ne);
201 }
202
203 // status
204 $this->addStatusInput($this->form);
205
206 // selectable
207 $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "selectable");
208 $cb->setInfo($lng->txt("skmg_selectable_info"));
209 $this->form->addItem($cb);
210
211 if ($a_mode == "create")
212 {
213 $this->form->addCommandButton("save", $lng->txt("save"));
214 $this->form->addCommandButton("cancel", $lng->txt("cancel"));
215 $this->form->setTitle($lng->txt("skmg_new_sktr"));
216 }
217 else
218 {
219 $this->form->addCommandButton("updateSkillTemplateReference", $lng->txt("save"));
220 $this->form->setTitle($lng->txt("skmg_edit_sktr"));
221 }
222
223 $this->form->setFormAction($ilCtrl->getFormAction($this));
224 }
225
229 public function getValues()
230 {
231 $values = array();
232 $values["skill_template_id"] = $this->node_object->getSkillTemplateId();
233 $values["title"] = $this->node_object->getTitle();
234 $values["selectable"] = $this->node_object->getSelfEvaluation();
235 $values["status"] = $this->node_object->getStatus();
236 $values["order_nr"] = $this->node_object->getOrderNr();
237 $this->form->setValuesByArray($values);
238 }
239
243 function saveItem()
244 {
245 $sktr = new ilSkillTemplateReference();
246 $sktr->setTitle($_POST["title"]);
247 $sktr->setSkillTemplateId($_POST["skill_template_id"]);
248 $sktr->setSelfEvaluation($_POST["selectable"]);
249 $sktr->setOrderNr($_POST["order_nr"]);
250 $sktr->setStatus($_POST["status"]);
251 $sktr->create();
252 ilSkillTreeNode::putInTree($sktr, (int) $_GET["obj_id"], IL_LAST_NODE);
253 $this->node_object = $sktr;
254 }
255
259 function afterSave()
260 {
261 global $ilCtrl;
262
263 $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "tref_id",
264 $this->node_object->getId());
265 $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "obj_id",
266 $this->node_object->getSkillTemplateId());
267 $ilCtrl->redirectByClass("ilskilltemplatereferencegui", "listItems");
268 }
269
274 {
275 global $lng, $ilCtrl, $tpl;
276
277 $this->initForm("edit");
278 if ($this->form->checkInput())
279 {
280 // perform update
281// $this->node_object->setSkillTemplateId($_POST["skill_template_id"]);
282 $this->node_object->setTitle($_POST["title"]);
283 $this->node_object->setSelfEvaluation($_POST["selectable"]);
284 $this->node_object->setOrderNr($_POST["order_nr"]);
285 $this->node_object->setStatus($_POST["status"]);
286 $this->node_object->update();
287
288 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
289 $ilCtrl->redirect($this, "editProperties");
290 }
291
292 $this->form->setValuesByPost();
293 $tpl->setContent($this->form->getHtml());
294 }
295
302 function cancel()
303 {
304 global $ilCtrl;
305
306 $ilCtrl->redirectByClass("ilobjskillmanagementgui", "editSkills");
307 }
308
312 function listItems()
313 {
314 global $tpl;
315
316 $this->setTabs("content");
317
318 $sk_id = $this->node_object->getSkillTemplateId();
319 $obj_type = ilSkillTreeNode::_lookupType($sk_id);
320
321 if ($obj_type == "sctp")
322 {
323 include_once("./Services/Skill/classes/class.ilSkillCatTableGUI.php");
324 $table = new ilSkillCatTableGUI($this, "listItems", (int) $sk_id,
325 ilSkillCatTableGUI::MODE_SCTP, $this->node_object->getId());
326 $tpl->setContent($table->getHTML());
327 }
328 else if ($obj_type == "sktp")
329 {
330 include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
331 $table = new ilSkillLevelTableGUI((int) $sk_id, $this, "edit", $this->node_object->getId());
332 $tpl->setContent($table->getHTML());
333 }
334 }
335
336}
337
338?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
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 number property 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.
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 _lookupType($a_obj_id)
Lookup Type.
This class represents a text property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options