ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 // order nr
194 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
195 $ni->setInfo($lng->txt("skmg_order_nr_info"));
196 $ni->setMaxLength(6);
197 $ni->setSize(6);
198 $ni->setRequired(true);
199 if ($a_mode == "create") {
200 include_once("./Services/Skill/classes/class.ilSkillTree.php");
201 $tree = new ilSkillTree();
202 $max = $tree->getMaxOrderNr((int) $_GET["obj_id"]);
203 $ni->setValue($max + 10);
204 }
205 $this->form->addItem($ni);
206
207 // template
208 $options = array(
209 "" => $lng->txt("please_select"),
210 );
211 foreach ($tmplts as $tmplt) {
212 $options[$tmplt["child"]] = $tmplt["title"];
213 }
214 if ($a_mode != "edit") {
215 $si = new ilSelectInputGUI($lng->txt("skmg_skill_template"), "skill_template_id");
216 $si->setOptions($options);
217 $si->setRequired(true);
218 $this->form->addItem($si);
219 } else {
220 $ne = new ilNonEditableValueGUI($lng->txt("skmg_skill_template"), "");
221 $ne->setValue($options[$this->node_object->getSkillTemplateId()]);
222 $this->form->addItem($ne);
223 }
224
225 // status
226 $this->addStatusInput($this->form);
227
228 // selectable
229 $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "selectable");
230 $cb->setInfo($lng->txt("skmg_selectable_info"));
231 $this->form->addItem($cb);
232
233 if ($this->checkPermissionBool("write")) {
234 if ($a_mode == "create") {
235 $this->form->addCommandButton("save", $lng->txt("save"));
236 $this->form->addCommandButton("cancel", $lng->txt("cancel"));
237 $this->form->setTitle($lng->txt("skmg_new_sktr"));
238 } else {
239 $this->form->addCommandButton("updateSkillTemplateReference", $lng->txt("save"));
240 $this->form->setTitle($lng->txt("skmg_edit_sktr"));
241 }
242 }
243
244 $this->form->setFormAction($ilCtrl->getFormAction($this));
245 }
246
250 public function getValues()
251 {
252 $values = array();
253 $values["skill_template_id"] = $this->node_object->getSkillTemplateId();
254 $values["title"] = $this->node_object->getTitle();
255 $values["selectable"] = $this->node_object->getSelfEvaluation();
256 $values["status"] = $this->node_object->getStatus();
257 $values["order_nr"] = $this->node_object->getOrderNr();
258 $this->form->setValuesByArray($values);
259 }
260
264 public function saveItem()
265 {
266 if (!$this->checkPermissionBool("write")) {
267 return;
268 }
269
270 $sktr = new ilSkillTemplateReference();
271 $sktr->setTitle($_POST["title"]);
272 $sktr->setSkillTemplateId($_POST["skill_template_id"]);
273 $sktr->setSelfEvaluation($_POST["selectable"]);
274 $sktr->setOrderNr($_POST["order_nr"]);
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->setSelfEvaluation($_POST["selectable"]);
320 $this->node_object->setOrderNr($_POST["order_nr"]);
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");
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}
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$_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 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.
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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