ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilBasicSkillTemplateGUI.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.ilBasicSkillTemplate.php");
6include_once("./Services/Skill/classes/class.ilBasicSkillGUI.php");
7
18{
19
23 function __construct($a_node_id = 0, $a_tref_id = 0)
24 {
25 global $ilCtrl;
26
27 $this->tref_id = $a_tref_id;
28
29 $ilCtrl->saveParameter($this, array("obj_id", "level_id"));
30
31 parent::__construct($a_node_id);
32 }
33
37 function getType()
38 {
39 return "sktp";
40 }
41
47 public function initForm($a_mode = "edit")
48 {
49 global $lng, $ilCtrl;
50
51 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
52 $this->form = new ilPropertyFormGUI();
53
54 // title
55 $ti = new ilTextInputGUI($lng->txt("title"), "title");
56 $ti->setMaxLength(200);
57 $ti->setSize(50);
58 $ti->setRequired(true);
59 $this->form->addItem($ti);
60
61 // order nr
62 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
63 $ni->setMaxLength(6);
64 $ni->setSize(6);
65 $ni->setRequired(true);
66 $this->form->addItem($ni);
67
68 // save and cancel commands
69 if ($this->checkPermissionBool("write"))
70 {
71 if ($a_mode == "create")
72 {
73 $this->form->addCommandButton("save", $lng->txt("save"));
74 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
75 $this->form->setTitle($lng->txt("skmg_create_skll"));
76 } else
77 {
78 $this->form->addCommandButton("update", $lng->txt("save"));
79 $this->form->setTitle($lng->txt("skmg_edit_skll"));
80 }
81 }
82
83 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
84 $this->form->setFormAction($ilCtrl->getFormAction($this));
85 }
86
90 function setLevelHead()
91 {
92 global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
93
94 // tabs
95 $ilTabs->clearTargets();
96 $ilHelp->setScreenIdComponent("skmg_lev");
97 $ilTabs->setBackTarget($lng->txt("skmg_skill_levels"),
98 $ilCtrl->getLinkTarget($this, "edit"));
99
100 if ($_GET["level_id"] > 0)
101 {
102 if ($this->tref_id == 0)
103 {
104 $ilTabs->addTab("level_settings",
105 $lng->txt("settings"),
106 $ilCtrl->getLinkTarget($this, "editLevel"));
107 }
108 else
109 {
110 $ilTabs->addTab("level_resources",
111 $lng->txt("skmg_resources"),
112 $ilCtrl->getLinkTarget($this, "showLevelResources"));
113 }
114
115/* $ilTabs->addTab("level_trigger",
116 $lng->txt("skmg_trigger"),
117 $ilCtrl->getLinkTarget($this, "editLevelTrigger"));
118
119 $ilTabs->addTab("level_certificate",
120 $lng->txt("certificate"),
121 $ilCtrl->getLinkTargetByClass("ilcertificategui", "certificateEditor"));*/
122 }
123
124 // title
125 if ($_GET["level_id"] > 0)
126 {
127 $tpl->setTitle($lng->txt("skmg_skill_level").": ".
128 ilBasicSkill::lookupLevelTitle((int) $_GET["level_id"]));
129 }
130 else
131 {
132 $tpl->setTitle($lng->txt("skmg_skill_level"));
133 }
134
135 include_once("./Services/Skill/classes/class.ilSkillTree.php");
136 $tree = new ilSkillTree();
137 $path = $tree->getPathFull($this->node_object->getId());
138 $desc = "";
139 foreach ($path as $p)
140 {
141 if (in_array($p["type"], array("scat", "skll")))
142 {
143 $desc.= $sep.$p["title"];
144 $sep = " > ";
145 }
146 }
147 $tpl->setDescription($desc);
148
149 $tpl->setTitleIcon(
151 0, "sktp", "", false));
152
153 }
154
161 function setTabs($a_tab)
162 {
163 global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
164
165 $ilTabs->clearTargets();
166 $ilHelp->setScreenIdComponent("skmg_sktp");
167
168 if ($this->tref_id == 0)
169 {
170 $ilTabs->setBackTarget($lng->txt("skmg_skill_templates"),
171 $ilCtrl->getLinkTargetByClass("ilobjskillmanagementgui", "editSkillTemplates"));
172 }
173
174 if (is_object($this->node_object))
175 {
176 if ($this->tref_id == 0)
177 {
178 $tpl->setTitle($lng->txt("skmg_skill_template").": ".
179 $this->node_object->getTitle());
180 }
181 else
182 {
183 $tpl->setTitle(
184 $this->node_object->getTitle());
185 }
186
187 // levels
188 $ilTabs->addTab("levels", $lng->txt("skmg_skill_levels"),
189 $ilCtrl->getLinkTarget($this, 'edit'));
190
191 // properties
192 if ($this->tref_id == 0)
193 {
194 $ilTabs->addTab("properties", $lng->txt("settings"),
195 $ilCtrl->getLinkTarget($this, 'editProperties'));
196 }
197
198 // if ($this->tref_id > 0)
199// {
200 // usage
201 $this->addUsageTab($ilTabs);
202// }
203
204 $ilTabs->activateTab($a_tab);
205
206 parent::setTitleIcon();
207
209 }
210 else
211 {
212 $tpl->setTitle($lng->txt("skmg_skill"));
213 $tpl->setDescription("");
214 }
215 }
216
220 function saveItem()
221 {
222 if (!$this->checkPermissionBool("write"))
223 {
224 return;
225 }
226
227 $it = new ilBasicSkillTemplate();
228 $it->setTitle($this->form->getInput("title"));
229 $it->setOrderNr($this->form->getInput("order_nr"));
230 $it->create();
231 ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
232 $this->node_object = $it;
233 }
234
238 function afterSave()
239 {
240 global $ilCtrl;
241
242 $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "obj_id",
243 $this->node_object->getId());
244 $ilCtrl->redirectByClass("ilbasicskilltemplategui", "edit");
245 }
246
253 function edit()
254 {
255 global $tpl, $ilToolbar, $lng, $ilCtrl;
256
257 $this->setTabs("levels");
258
259 if ($this->checkPermissionBool("write"))
260 {
261 if ($this->tref_id == 0)
262 {
263 $ilToolbar->addButton($lng->txt("skmg_add_level"),
264 $ilCtrl->getLinkTarget($this, "addLevel"));
265 }
266 }
267
268 include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
269 $table = new ilSkillLevelTableGUI((int) $_GET["obj_id"], $this, "edit", $this->tref_id);
270 $tpl->setContent($table->getHTML());
271 }
272
276 function showUsage()
277 {
278 global $tpl;
279
280
281 // (a) referenced skill template in main tree
282 if ($this->tref_id > 0)
283 {
284 return parent::showUsage();
285 }
286
287 // (b) skill template in templates view
288
289 $this->setTabs("usage");
290
291 include_once("./Services/Skill/classes/class.ilSkillUsage.php");
292 $usage_info = new ilSkillUsage();
293 $usages = $usage_info->getAllUsagesOfTemplate($this->base_skill_id);
294
295 $html = "";
296 include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
297 foreach ($usages as $k => $usage)
298 {
299 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
300 $html.= $tab->getHTML()."<br/><br/>";
301 }
302
303 $tpl->setContent($html);
304 }
305
306}
307?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
const IL_LAST_NODE
Definition: class.ilTree.php:4
Basic skill GUI class.
Basic skill template GUI class.
setTabs($a_tab)
Set header for skill.
__construct($a_node_id=0, $a_tref_id=0)
Constructor.
initForm($a_mode="edit")
Init form.
static lookupLevelTitle($a_id)
Lookup level title.
This class represents a number property in a property form.
This class represents a property form user interface.
setSkillNodeDescription()
Set skill node description.
addUsageTab($a_tabs)
Add usage tab.
checkPermissionBool($a_perm)
Check permission pool.
static getIconPath($a_obj_id, $a_type, $a_size="", $a_status=0)
Get icon path.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
TableGUI class for skill usages.
This class represents a text property in a property form.
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22