ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 if (is_array($path))
38 {
39 foreach ($path as $k => $v)
40 {
41 if ($v["child"] != $a_tref_id)
42 {
43 $path[$k]["skill_id"] = $v["child"];
44 $path[$k]["tref_id"] = 0;
45 }
46 else
47 {
48 $path[$k]["skill_id"] = ilSkillTemplateReference::_lookupTemplateId($a_tref_id);
49 $path[$k]["tref_id"] = $a_tref_id;
50 }
51 }
52 }
53 $found = false;
54 if (is_array($sub_path))
55 {
56 foreach ($sub_path as $s)
57 {
58 if ($found)
59 {
60 $s["skill_id"] = $s["child"];
61 $s["tref_id"] = $a_tref_id;
62 $path[] = $s;
63 }
64 if ($s["child"] == ilSkillTemplateReference::_lookupTemplateId($a_tref_id))
65 {
66 $found = true;
67 }
68 }
69 }
70 }
71 else
72 {
73 $path = $this->getPathFull($a_base_skill_id);
74 if (is_array($path))
75 {
76 foreach ($path as $k => $v)
77 {
78 $path[$k]["skill_id"] = $v["child"];
79 $path[$k]["tref_id"] = 0;
80 }
81 }
82 }
83
84 if (is_array($path))
85 {
86 return $path;
87 }
88 return array();
89 }
90
98 function getSkillTreePathAsString($a_base_skill_id, $a_tref_id = 0)
99 {
100 $path = $this->getSkillTreePath($a_base_skill_id, $a_tref_id);
101 $str = "";
102 $sep = "";
103 foreach ($path as $p)
104 {
105 if ($p["type"] != "skrt" && $p["child"] != $a_base_skill_id)
106 {
107 $str.= $sep.$p["title"];
108 $sep = " > ";
109 }
110 }
111 return $str;
112 }
113
120 function getTopParentNodeId($a_node_id)
121 {
122 $path = $this->getPathId($a_node_id);
123 return (int) $path[1];
124 }
125
126
127}
128
129?>
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