ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
133 function getMaxOrderNr($a_par_id, $a_templates = false)
134 {
135 if ($a_par_id != $this->readRootId())
136 {
137 $childs = $this->getChilds($a_par_id);
138 }
139 else
140 {
141 if ($a_templates)
142 {
143 $childs = $this->getChildsByTypeFilter($a_par_id,
144 array("skrt", "sktp", "sctp"));
145 }
146 else
147 {
148 $childs = $this->getChildsByTypeFilter($a_par_id,
149 array("skrt", "skll", "scat", "sktr"));
150 }
151 }
152
153 $max = 0;
154 foreach ($childs as $k => $c)
155 {
156 $max = max(array($c["order_nr"], $max));
157 }
158
159 return $max;
160 }
161
162
163}
164
165?>
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
getMaxOrderNr($a_par_id, $a_templates=false)
Get max order nr.
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...
readRootId()
read root id from database
getChildsByTypeFilter($a_node_id, $a_types, $a_order="", $a_direction="ASC")
get child nodes of given node by object type @access public
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...
getChilds($a_node_id, $a_order="", $a_direction="ASC")
get child nodes of given node @access public