ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilSkillTree.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/Tree/classes/class.ilTree.php");
6
14class ilSkillTree extends ilTree
15{
16 function __construct()
17 {
18 parent::__construct(1); // only one skill tree, with ID 1
19 $this->setTreeTablePK("skl_tree_id");
20 $this->setTableNames('skl_tree', 'skl_tree_node');
21 }
22
30 function getSkillTreePath($a_base_skill_id, $a_tref_id = 0)
31 {
32 if ($a_tref_id > 0)
33 {
34 include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
35 $path = $this->getPathFull($a_tref_id);
36 $sub_path = $this->getPathFull($a_base_skill_id);
37 foreach ($path as $k => $v)
38 {
39 if ($v["child"] != $a_tref_id)
40 {
41 $path[$k]["skill_id"] = $v["child"];
42 $path[$k]["tref_id"] = 0;
43 }
44 else
45 {
46 $path[$k]["skill_id"] = ilSkillTemplateReference::_lookupTemplateId($a_tref_id);
47 $path[$k]["tref_id"] = $a_tref_id;
48 }
49 }
50 $found = false;
51 foreach ($sub_path as $s)
52 {
53 if ($found)
54 {
55 $s["skill_id"] = $s["child"];
56 $s["tref_id"] = $a_tref_id;
57 $path[] = $s;
58 }
59 if ($s["child"] == ilSkillTemplateReference::_lookupTemplateId($a_tref_id))
60 {
61 $found = true;
62 }
63 }
64
65 }
66 else
67 {
68 $path = $this->getPathFull($a_base_skill_id);
69 if (is_array($path))
70 {
71 foreach ($path as $k => $v)
72 {
73 $path[$k]["skill_id"] = $v["child"];
74 $path[$k]["tref_id"] = 0;
75 }
76 }
77 }
78
79 return $path;
80 }
81
89 function getSkillTreePathAsString($a_base_skill_id, $a_tref_id = 0)
90 {
91 $path = $this->getSkillTreePath($a_base_skill_id, $a_tref_id);
92 $str = "";
93 $sep = "";
94 foreach ($path as $p)
95 {
96 if ($p["type"] != "skrt" && $p["child"] != $a_base_skill_id)
97 {
98 $str.= $sep.$p["title"];
99 $sep = " > ";
100 }
101 }
102 return $str;
103 }
104
111 function getTopParentNodeId($a_node_id)
112 {
113 $path = $this->getPathId($a_node_id);
114 return (int) $path[1];
115 }
116
117
118}
119
120?>
static _lookupTemplateId($a_obj_id)
Lookup template ID.
getSkillTreePathAsString($a_base_skill_id, $a_tref_id=0)
Get skill tree path as string.
getTopParentNodeId($a_node_id)
Get top parent node id for a node.
getSkillTreePath($a_base_skill_id, $a_tref_id=0)
Get skill tree path.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
setTreeTablePK($a_column_name)
set column containing primary key in tree table @access public
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be 'obj_id' You may use...
getPathId($a_endnode_id, $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
getPathFull($a_endnode_id, $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: index.php:22