ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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{
22 protected $ctrl;
23
27 protected $lng;
28
32 protected $tabs;
33
37 protected $tpl;
38
42 protected $help;
43
47 protected $toolbar;
48
49
53 public function __construct($a_node_id = 0, $a_tref_id = 0)
54 {
55 global $DIC;
56
57 $this->ctrl = $DIC->ctrl();
58 $this->lng = $DIC->language();
59 $this->tabs = $DIC->tabs();
60 $this->tpl = $DIC["tpl"];
61 $this->help = $DIC["ilHelp"];
62 $this->toolbar = $DIC->toolbar();
63 $ilCtrl = $DIC->ctrl();
64
65 $this->tref_id = $a_tref_id;
66
67 $ilCtrl->saveParameter($this, array("obj_id", "level_id"));
68
69 parent::__construct($a_node_id);
70 }
71
75 public function getType()
76 {
77 return "sktp";
78 }
79
85 public function initForm($a_mode = "edit")
86 {
89
90 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
91 $this->form = new ilPropertyFormGUI();
92
93 // title
94 $ti = new ilTextInputGUI($lng->txt("title"), "title");
95 $ti->setMaxLength(200);
96 $ti->setSize(50);
97 $ti->setRequired(true);
98 $this->form->addItem($ti);
99
100 // description
101 $ta = new ilTextAreaInputGUI($lng->txt("description"), "description");
102 $ta->setRows(5);
103 $this->form->addItem($ta);
104
105 // order nr
106 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
107 $ni->setInfo($lng->txt("skmg_order_nr_info"));
108 $ni->setMaxLength(6);
109 $ni->setSize(6);
110 $ni->setRequired(true);
111 if ($a_mode == "create") {
112 include_once("./Services/Skill/classes/class.ilSkillTree.php");
113 $tree = new ilSkillTree();
114 $max = $tree->getMaxOrderNr((int) $_GET["obj_id"], true);
115 $ni->setValue($max + 10);
116 }
117 $this->form->addItem($ni);
118
119 // save and cancel commands
120 if ($this->checkPermissionBool("write")) {
121 if ($a_mode == "create") {
122 $this->form->addCommandButton("save", $lng->txt("save"));
123 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
124 $this->form->setTitle($lng->txt("skmg_create_skll"));
125 } else {
126 $this->form->addCommandButton("update", $lng->txt("save"));
127 $this->form->setTitle($lng->txt("skmg_edit_skll"));
128 }
129 }
130
131 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
132 $this->form->setFormAction($ilCtrl->getFormAction($this));
133 }
134
138 public function setLevelHead()
139 {
140 $ilTabs = $this->tabs;
144 $ilHelp = $this->help;
145
146 // tabs
147 $ilTabs->clearTargets();
148 $ilHelp->setScreenIdComponent("skmg_lev");
149 $ilTabs->setBackTarget(
150 $lng->txt("skmg_skill_levels"),
151 $ilCtrl->getLinkTarget($this, "edit")
152 );
153
154 if ($_GET["level_id"] > 0) {
155 if ($this->tref_id == 0) {
156 $ilTabs->addTab(
157 "level_settings",
158 $lng->txt("settings"),
159 $ilCtrl->getLinkTarget($this, "editLevel")
160 );
161 } else {
162 $ilTabs->addTab(
163 "level_resources",
164 $lng->txt("skmg_resources"),
165 $ilCtrl->getLinkTarget($this, "showLevelResources")
166 );
167 }
168
169 /* $ilTabs->addTab("level_trigger",
170 $lng->txt("skmg_trigger"),
171 $ilCtrl->getLinkTarget($this, "editLevelTrigger"));
172
173 $ilTabs->addTab("level_certificate",
174 $lng->txt("certificate"),
175 $ilCtrl->getLinkTargetByClass("ilcertificategui", "certificateEditor"));*/
176 }
177
178 // title
179 if ($_GET["level_id"] > 0) {
180 $tpl->setTitle($lng->txt("skmg_skill_level") . ": " .
181 ilBasicSkill::lookupLevelTitle((int) $_GET["level_id"]));
182 } else {
183 $tpl->setTitle($lng->txt("skmg_skill_level"));
184 }
185
186 include_once("./Services/Skill/classes/class.ilSkillTree.php");
187 $tree = new ilSkillTree();
188 $path = $tree->getPathFull($this->node_object->getId());
189 $desc = "";
190 foreach ($path as $p) {
191 if (in_array($p["type"], array("scat", "skll"))) {
192 $desc .= $sep . $p["title"];
193 $sep = " > ";
194 }
195 }
196 $tpl->setDescription($desc);
197
198 $tpl->setTitleIcon(
200 0,
201 "sktp",
202 "",
203 false
204 )
205 );
206 }
207
214 public function setTabs($a_tab = "")
215 {
216 $ilTabs = $this->tabs;
220 $ilHelp = $this->help;
221
222 $ilTabs->clearTargets();
223 $ilHelp->setScreenIdComponent("skmg_sktp");
224
225 if ($this->tref_id == 0) {
226 $ilTabs->setBackTarget(
227 $lng->txt("skmg_skill_templates"),
228 $ilCtrl->getLinkTargetByClass("ilobjskillmanagementgui", "editSkillTemplates")
229 );
230 }
231
232 if (is_object($this->node_object)) {
233 if ($this->tref_id == 0) {
234 $tpl->setTitle($lng->txt("skmg_skill_template") . ": " .
235 $this->node_object->getTitle());
236 } else {
237 $tpl->setTitle(
238 $this->node_object->getTitle()
239 );
240 }
241
242 // levels
243 $ilTabs->addTab(
244 "levels",
245 $lng->txt("skmg_skill_levels"),
246 $ilCtrl->getLinkTarget($this, 'edit')
247 );
248
249 // properties
250 if ($this->tref_id == 0) {
251 $ilTabs->addTab(
252 "properties",
253 $lng->txt("settings"),
254 $ilCtrl->getLinkTarget($this, 'editProperties')
255 );
256 }
257
258 // if ($this->tref_id > 0)
259 // {
260 // usage
261 $this->addUsageTab($ilTabs);
262 // }
263
264 $ilTabs->activateTab($a_tab);
265
266 parent::setTitleIcon();
267
269 } else {
270 $tpl->setTitle($lng->txt("skmg_skill"));
271 $tpl->setDescription("");
272 }
273 }
274
278 public function saveItem()
279 {
280 if (!$this->checkPermissionBool("write")) {
281 return;
282 }
283
284 $it = new ilBasicSkillTemplate();
285 $it->setTitle($this->form->getInput("title"));
286 $it->setDescription($this->form->getInput("description"));
287 $it->setOrderNr($this->form->getInput("order_nr"));
288 $it->create();
289 ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
290 $this->node_object = $it;
291 }
292
296 public function afterSave()
297 {
299
300 $ilCtrl->setParameterByClass(
301 "ilbasicskilltemplategui",
302 "obj_id",
303 $this->node_object->getId()
304 );
305 $ilCtrl->redirectByClass("ilbasicskilltemplategui", "edit");
306 }
307
314 public function edit()
315 {
317 $ilToolbar = $this->toolbar;
320
321 $this->setTabs("levels");
322
323 if ($this->isInUse()) {
324 ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
325 } else {
326 if ($this->checkPermissionBool("write")) {
327 if ($this->tref_id == 0) {
328 $ilToolbar->addButton(
329 $lng->txt("skmg_add_level"),
330 $ilCtrl->getLinkTarget($this, "addLevel")
331 );
332 }
333 }
334 }
335
336 include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
337 $table = new ilSkillLevelTableGUI((int) $_GET["obj_id"], $this, "edit", $this->tref_id, $this->isInUse());
338 $tpl->setContent($table->getHTML());
339 }
340
344 public function showUsage()
345 {
347
348
349 // (a) referenced skill template in main tree
350 if ($this->tref_id > 0) {
351 return parent::showUsage();
352 }
353
354 // (b) skill template in templates view
355
356 $this->setTabs("usage");
357
358 include_once("./Services/Skill/classes/class.ilSkillUsage.php");
359 $usage_info = new ilSkillUsage();
360 $usages = $usage_info->getAllUsagesOfTemplate($this->base_skill_id);
361
362 $html = "";
363 include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
364 foreach ($usages as $k => $usage) {
365 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
366 $html .= $tab->getHTML() . "<br/><br/>";
367 }
368
369 $tpl->setContent($html);
370 }
371}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_LAST_NODE
Definition: class.ilTree.php:4
Basic skill GUI class.
Basic skill template GUI class.
__construct($a_node_id=0, $a_tref_id=0)
Constructor.
setTabs($a_tab="")
Set header for skill.
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 area property in a property form.
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
$DIC
Definition: xapitoken.php:46