ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilSkillTreeNodeGUI.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.ilSkillTreeNode.php");
6
16{
18
24 function ilSkillTreeNodeGUI($a_node_id = 0)
25 {
26 $this->node_object = null;
27
28 if ($a_node_id > 0 &&
29 $this->getType() == ilSkillTreeNode::_lookupType($a_node_id))
30 {
31 $this->readNodeObject((int) $a_node_id);
32 }
33 }
34
40 function setParentGUI($a_parentgui)
41 {
42 $this->parentgui = $a_parentgui;
43 }
44
50 function getParentGUI()
51 {
52 return $this->parentgui;
53 }
54
58 function readNodeObject($a_node_id)
59 {
60 include_once("./Services/Skill/classes/class.ilSkillTreeNodeFactory.php");
61 $this->node_object = ilSkillTreeNodeFactory::getInstance($a_node_id);
62 }
63
67 function saveAllTitles()
68 {
69 global $ilCtrl;
70
71 $this->getParentGUI()->saveAllTitles(false);
72 $ilCtrl->redirect($this, "showOrganization");
73 }
74
78 function deleteNodes()
79 {
80 global $ilCtrl;
81
82 $ilCtrl->setParameter($this, "backcmd", $_GET["backcmd"]);
83 $this->getParentGUI()->deleteNodes($this);
84 }
85
89 function cutItems()
90 {
91 global $ilCtrl, $lng;
92
93 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
94
95 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
96 {
97 $this->redirectToParent();
98 }
99
100 $items = ilUtil::stripSlashesArray($_POST["id"]);
101 $todel = array(); // delete IDs < 0 (needed for non-js editing)
102 foreach($items as $k => $item)
103 {
104 if ($item < 0)
105 {
106 $todel[] = $k;
107 }
108 }
109 foreach($todel as $k)
110 {
111 unset($items[$k]);
112 }
113
115 {
116 ilUtil::sendInfo($lng->txt("skmg_insert_please_choose_one_type_only"), true);
117 $this->redirectToParent();
118 }
119
121
122 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
124
125 ilUtil::sendInfo($lng->txt("skmg_selected_items_have_been_cut"), true);
126
127 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
128 $_GET["tmpmode"]);
129
130 $this->redirectToParent();
131 }
132
136 function copyItems()
137 {
138 global $ilCtrl, $lng;
139
140 if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
141 {
142 $this->redirectToParent();
143 }
144
145 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
146
147 $items = ilUtil::stripSlashesArray($_POST["id"]);
148 $todel = array(); // delete IDs < 0 (needed for non-js editing)
149 foreach($items as $k => $item)
150 {
151 if ($item < 0)
152 {
153 $todel[] = $k;
154 }
155 }
156 foreach($todel as $k)
157 {
158 unset($items[$k]);
159 }
161 {
162 ilUtil::sendInfo($lng->txt("skmg_insert_please_choose_one_type_only"), true);
163 $this->redirectToParent();
164 }
166
167 // @todo: move this to a service since it can be used here, too
168 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
170 ilUtil::sendInfo($lng->txt("skmg_selected_items_have_been_copied"), true);
171
172 $this->redirectToParent();
173 }
174
178 function cancelDelete()
179 {
180 global $ilCtrl;
181
182 $this->redirectToParent();
183 }
184
189 {
190 global $ilCtrl;
191
192 $this->getParentGUI()->confirmedDelete(false);
193 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
194 $_GET["tmpmode"]);
195
196 $this->redirectToParent();
197 }
198
202 function setLocator()
203 {
204 global $ilLocator, $tpl, $ilCtrl;
205
206 $ilLocator->addRepositoryItems($_GET["ref_id"]);
207 $this->getParentGUI()->addLocatorItems();
208
209 if ($_GET["obj_id"] > 0)
210 {
211 include_once("./Services/Skill/classes/class.ilSkillTree.php");
212 $tree = new ilSkillTree();
213 $path = $tree->getPathFull($_GET["obj_id"]);
214 for( $i = 1; $i < count($path); $i++)
215 {
216 switch($path[$i]["type"])
217 {
218 case "scat":
219 $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id",
220 $path[$i]["child"]);
221 $ilLocator->addItem($path[$i]["title"],
222 $ilCtrl->getLinkTargetByClass("ilskillmanagementgui",
223 "ilskillcategorygui"), "", 0, $path[$i]["type"],
224 ilUtil::getImagePath("icon_skmg.svg"));
225 break;
226
227 case "skll":
228 $ilCtrl->setParameterByClass("ilbasicskillgui", "obj_id",
229 $path[$i]["child"]);
230 $ilLocator->addItem($path[$i]["title"],
231 $ilCtrl->getLinkTargetByClass("ilskillmanagementgui",
232 "ilbasicskillgui"), "", 0, $path[$i]["type"],
233 ilUtil::getImagePath("icon_skmg.svg"));
234 break;
235
236 }
237 }
238 }
239 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
240
241 $tpl->setLocator();
242 }
243
248 {
249 global $tpl;
250
251 if (is_object($this->node_object))
252 {
253 include_once("./Services/Skill/classes/class.ilSkillTree.php");
254 $tree = new ilSkillTree();
255 $path = $this->node_object->skill_tree->getSkillTreePath($this->node_object->getId(),
256 $this->tref_id);
257 $desc = "";
258 foreach ($path as $p)
259 {
260 if (in_array($p["type"], array("scat", "skll", "sktr")))
261 {
262 $desc.= $sep.$p["title"];
263 $sep = " > ";
264 }
265 }
266 }
267 $tpl->setDescription($desc);
268 }
269
273 function create()
274 {
275 global $tpl;
276
277 $this->initForm("create");
278 $tpl->setContent($this->form->getHTML());
279 }
280
287 {
288 global $lng;
289
290 // status
291 $radg = new ilRadioGroupInputGUI($lng->txt("skmg_status"), "status");
292 foreach (ilSkillTreeNode::getAllStatus() as $k => $op)
293 {
294 $op = new ilRadioOption($op, $k, ilSkillTreeNode::getStatusInfo($k));
295 $radg->addOption($op);
296 }
297 $a_form->addItem($radg);
298 }
299
303 function editProperties()
304 {
305 global $tpl;
306
307 $this->initForm("edit");
308 $this->getPropertyValues();
309 $tpl->setContent($this->form->getHTML());
310 }
311
316 {
317 $values = array();
318
319 $values["title"] = $this->node_object->getTitle();
320 $values["order_nr"] = $this->node_object->getOrderNr();
321 $values["self_eval"] = $this->node_object->getSelfEvaluation();
322 $values["status"] = $this->node_object->getStatus();
323
324 $this->form->setValuesByArray($values);
325 }
326
331 public function save()
332 {
333 global $tpl, $lng, $ilCtrl;
334
335 $this->initForm("create");
336 if ($this->form->checkInput())
337 {
338 $this->saveItem();
339 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
340 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], array(),
341 in_array($this->getType(), array("sktp", "sctp")));
342 $this->afterSave();
343 }
344 else
345 {
346 $this->form->setValuesByPost();
347 $tpl->setContent($this->form->getHtml());
348 }
349 }
350
354 function afterSave()
355 {
356 $this->redirectToParent();
357 }
358
359
364 public function update()
365 {
366 global $tpl, $lng, $ilCtrl;
367
368 $this->initForm("edit");
369 if ($this->form->checkInput())
370 {
371 $this->updateItem();
372 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
373 $this->afterUpdate();
374 }
375 else
376 {
377 $this->form->setValuesByPost();
378 $tpl->setContent($this->form->getHtml());
379 }
380 }
381
385 function afterUpdate()
386 {
387 global $ilCtrl;
388
389 $ilCtrl->redirect($this, "editProperties");
390 }
391
397 public function initForm($a_mode = "edit")
398 {
399 global $lng, $ilCtrl;
400
401 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
402 $this->form = new ilPropertyFormGUI();
403
404 // title
405 $ti = new ilTextInputGUI($lng->txt("title"), "title");
406 $ti->setMaxLength(200);
407 $ti->setSize(50);
408 $ti->setRequired(true);
409 $this->form->addItem($ti);
410
411 // order nr
412 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
413 $ni->setMaxLength(6);
414 $ni->setSize(6);
415 $ni->setRequired(true);
416 $this->form->addItem($ni);
417
418 // save and cancel commands
419 if ($a_mode == "create")
420 {
421 $this->form->addCommandButton("save", $lng->txt("save"));
422 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
423 $this->form->setTitle($lng->txt("skmg_create_".$this->getType()));
424 }
425 else
426 {
427 $this->form->addCommandButton("update", $lng->txt("save"));
428 $this->form->setTitle($lng->txt("skmg_edit_".$this->getType()));
429 }
430
431
432 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
433 $this->form->setFormAction($ilCtrl->getFormAction($this));
434
435 }
436
443 function cancelSave()
444 {
445 $this->redirectToParent();
446 }
447
454 function redirectToParent($a_tmp_mode = false)
455 {
456 global $ilCtrl;
457
458 if ($_GET["tmpmode"])
459 {
460 $a_tmp_mode = true;
461 }
462
463 $t = ilSkillTreeNode::_lookupType((int) $_GET["obj_id"]);
464
465 switch ($t)
466 {
467 case "skrt":
468 $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id", (int) $_GET["obj_id"]);
469 if ($a_tmp_mode)
470 {
471 $ilCtrl->redirectByClass("ilskillrootgui", "listTemplates");
472 }
473 else
474 {
475 $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
476 }
477 break;
478
479 case "sctp":
480 $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "obj_id", (int) $_GET["obj_id"]);
481 $ilCtrl->redirectByClass("ilskilltemplatecategorygui", "listItems");
482 break;
483
484 case "scat":
485 $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id", (int) $_GET["obj_id"]);
486 $ilCtrl->redirectByClass("ilskillcategorygui", "listItems");
487 break;
488 }
489
490 }
491
495 function saveOrder()
496 {
497 global $ilCtrl, $lng;
498
499 ilSkillTreeNode::saveChildsOrder((int) $_GET["obj_id"], $_POST["order"],
500 (int) $_GET["tmpmode"]);
501 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
502 $this->redirectToParent((int) $_GET["tmpmode"]);
503 }
504
509 {
510 global $ilCtrl, $ilUser;
511
512 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
513 $nodes = ilSkillTreeNode::insertItemsFromClip("skll", (int) $_GET["obj_id"]);
514 $this->redirectToParent();
515 }
516
521 {
522 global $ilCtrl, $ilUser;
523
524 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
525 $nodes = ilSkillTreeNode::insertItemsFromClip("scat", (int) $_GET["obj_id"]);
526 $this->redirectToParent();
527 }
528
533 {
534 global $ilCtrl, $ilUser;
535
536 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
537 $nodes = ilSkillTreeNode::insertItemsFromClip("sktr", (int) $_GET["obj_id"]);
538 $this->redirectToParent();
539 }
540
545 {
546 global $ilCtrl, $ilUser;
547
548 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
549 $nodes = ilSkillTreeNode::insertItemsFromClip("sktp", (int) $_GET["obj_id"]);
550 $this->redirectToParent();
551 }
552
557 {
558 global $ilCtrl, $ilUser;
559
560 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
561 $nodes = ilSkillTreeNode::insertItemsFromClip("sctp", (int) $_GET["obj_id"]);
562 $this->redirectToParent();
563 }
564
568 function setTitleIcon()
569 {
570 global $tpl;
571
572 $obj_id = (is_object($this->node_object))
573 ? $this->node_object->getId()
574 :0;
575 $tpl->setTitleIcon(
577 $obj_id, $this->getType(), "",
579 }
580
584
591 function addUsageTab($a_tabs)
592 {
593 global $lng, $ilCtrl;
594
595 $a_tabs->addTab("usage",
596 $lng->txt("skmg_usage"),
597 $ilCtrl->getLinkTarget($this, "showUsage"));
598 }
599
600
604 function showUsage()
605 {
606 global $tpl;
607
608 $this->setTabs("usage");
609
610 include_once("./Services/Skill/classes/class.ilSkillUsage.php");
611 $usage_info = new ilSkillUsage();
612 $base_skill_id = ($this->base_skill_id > 0)
613 ? $this->base_skill_id
614 : $this->node_object->getId();
615 $usages = $usage_info->getAllUsagesInfoOfSubtree($base_skill_id.":".$this->tref_id);
616
617 $html = "";
618 include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
619 foreach ($usages as $k => $usage)
620 {
621 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
622 $html.= $tab->getHTML()."<br/><br/>";
623 }
624
625 $tpl->setContent($html);
626 }
627
628}
629?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
This class represents a number property in a property form.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a property in a property form.
This class represents an option in a radio group.
Basic GUI class for skill tree nodes.
redirectToParent($a_tmp_mode=false)
Redirect to parent (identified by current obj_id)
insertSkillTemplateClip()
Insert skill template from clipboard.
showUsage()
Show skill usage.
save()
Save skill tree node.
insertBasicSkillClip()
Insert basic skills from clipboard.
confirmedDelete()
confirmed delete
deleteNodes()
Delete nodes in the hierarchy.
getPropertyValues()
Get property values for edit form.
setSkillNodeDescription()
Set skill node description.
create()
Create skill tree node.
readNodeObject($a_node_id)
Get node object instance.
getParentGUI()
Get Parent GUI class (ilObjSCORM2004LearningModuleGUI).
setParentGUI($a_parentgui)
Set Parent GUI class.
editProperties()
Edit properties form.
insertTemplateReferenceClip()
Insert skill template references from clipboard.
addUsageTab($a_tabs)
Add usage tab.
ilSkillTreeNodeGUI($a_node_id=0)
constructor
update()
Update skill tree node.
insertTemplateCategoryClip()
Insert skill template category from clipboard.
addStatusInput(ilPropertyFormGUI $a_form)
Add status input.
setLocator()
Set Locator Items.
cutItems()
Copy items to clipboard, then cut them from the current tree.
insertSkillCategoryClip()
Insert skill categories from clipboard.
copyItems()
Copy items to clipboard.
initForm($a_mode="edit")
Init form.
static getIconPath($a_obj_id, $a_type, $a_size="", $a_status=0)
Get icon path.
static uniqueTypesCheck($a_items)
Check for unique types.
static getStatusInfo($a_status)
Get status info.
static _lookupStatus($a_obj_id)
Lookup Status.
static saveChildsOrder($a_par_id, $a_childs_order, $a_templates=false)
Save childs order.
static insertItemsFromClip($a_type, $a_obj_id)
Insert basic skills from clipboard.
static getAllStatus()
Get all status.
static clipboardCopy($a_tree_id, $a_ids)
Copy a set of skills/skill categories into the clipboard.
clipboardCut($a_tree_id, $a_ids)
Cut and copy a set of skills/skill categories into the clipboard.
static _lookupType($a_obj_id)
Lookup Type.
TableGUI class for skill usages.
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.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
global $ilUser
Definition: imgupload.php:15