ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilVirtualSkillTree Class Reference

Virtual skill tree. More...

+ Collaboration diagram for ilVirtualSkillTree:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getRootNode ()
 Get root node. More...
 
 setIncludeDrafts ($a_val)
 Set include drafts. More...
 
 getIncludeDrafts ()
 Get include drafts. More...
 
 setIncludeOutdated ($a_val)
 Set include outdated. More...
 
 getIncludeOutdated ()
 Get include outdated. More...
 
 getNode ($a_id)
 Get node. More...
 
 getChildsOfNode ($a_parent_id)
 Get childs of node. More...
 
 getChildsOfNodeForCSkillId ($a_cskill_id)
 Get childs of node for cskill id. More...
 
 getCSkillIdForVTreeId ($a_vtree_id)
 Get common skill id for tree id. More...
 
 getVTreeIdForCSkillId ($a_cskill_id)
 Get tree id for common skill id. More...
 
 getNodeTitle ($a_node)
 Get node content. More...
 
 getSubTreeForCSkillId ($a_cskill_id, $a_only_basic=false)
 Get sub tree. More...
 
 isDraft ($a_node_id)
 Is draft. More...
 
 isOutdated ($a_node_id)
 Is outdated. More...
 

Protected Attributes

 $include_drafts = false
 
 $drafts = array()
 
 $include_outdated = false
 
 $outdated = array()
 

Private Member Functions

 __getSubTreeRec ($id, &$result, $a_only_basic)
 Get subtree, internal. More...
 

Detailed Description

Virtual skill tree.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilVirtualSkillTree.php.

Constructor & Destructor Documentation

◆ __construct()

ilVirtualSkillTree::__construct ( )

Constructor.

Definition at line 23 of file class.ilVirtualSkillTree.php.

24 {
25 include_once("./Services/Skill/classes/class.ilSkillTree.php");
26 $this->tree = new ilSkillTree();
27 }

Member Function Documentation

◆ __getSubTreeRec()

ilVirtualSkillTree::__getSubTreeRec (   $id,
$result,
  $a_only_basic 
)
private

Get subtree, internal.

Parameters
string$idvtree id
array$resultnode array (called by reference)
bool$a_only_basicreturn only basic skills (and basic skill templates)

Definition at line 357 of file class.ilVirtualSkillTree.php.

358 {
359 $childs = $this->getChildsOfNode($id);
360 foreach ($childs as $c)
361 {
362 if (!$a_only_basic || in_array($c["type"], array("skll", "sktp")) ||
363 ($c["type"] == "sktr" && ilSkillTreeNode::_lookupType($c["skill_id"]) == "sktp"))
364 {
365 $result[] = $c;
366 }
367 $this->__getSubTreeRec($c["id"], $result, $a_only_basic);
368 }
369 }
$result
static _lookupType($a_obj_id)
Lookup Type.
__getSubTreeRec($id, &$result, $a_only_basic)
Get subtree, internal.
getChildsOfNode($a_parent_id)
Get childs of node.

References $result, __getSubTreeRec(), ilSkillTreeNode\_lookupType(), and getChildsOfNode().

Referenced by __getSubTreeRec(), and getSubTreeForCSkillId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChildsOfNode()

ilVirtualSkillTree::getChildsOfNode (   $a_parent_id)

Get childs of node.

Parameters
string$a_parent_idparent id
Returns
array childs

Definition at line 133 of file class.ilVirtualSkillTree.php.

134 {
135 $a_parent_id_parts = explode(":", $a_parent_id);
136 $a_parent_skl_tree_id = $a_parent_id_parts[0];
137 $a_parent_skl_template_tree_id = $a_parent_id_parts[1];
138
139 if ($a_parent_skl_template_tree_id == 0)
140 {
141 $childs = $this->tree->getChildsByTypeFilter($a_parent_skl_tree_id, array("scat", "skll", "sktr"), "order_nr");
142 }
143 else
144 {
145 $childs = $this->tree->getChildsByTypeFilter($a_parent_skl_template_tree_id, array("sktp", "sctp"), "order_nr");
146 }
147
148 include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
149 $drafts = array();
150 $outdated = array();
151 foreach ($childs as $k => $c)
152 {
153 if ($a_parent_skl_template_tree_id > 0)
154 {
155 // we are in template tree only
156 $child_id = $a_parent_skl_tree_id.":".$c["child"];
157 }
158 else if (!in_array($c["type"], array("sktr", "sctr")))
159 {
160 // we are in main tree only
161 $child_id = $c["child"].":0";
162 }
163 else
164 {
165 // get template id for references
166 include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
167 $child_id = $c["child"].":".ilSkillTemplateReference::_lookupTemplateId($c["child"]);
168 }
169 unset($childs[$k]["child"]);
170 unset($childs[$k]["skl_tree_id"]);
171 unset($childs[$k]["lft"]);
172 unset($childs[$k]["rgt"]);
173 unset($childs[$k]["depth"]);
174 $childs[$k]["id"] = $child_id;
175//echo "-".$child_id."-";
176 $cid = $this->getCSkillIdForVTreeId($child_id);
177//echo "-".$cid."-";
178 $cid_parts = explode(":", $cid);
179 $childs[$k]["skill_id"] = $cid_parts[0];
180 $childs[$k]["tref_id"] = $cid_parts[1];
181 $childs[$k]["cskill_id"] = $cid;
182 $childs[$k]["parent"] = $a_parent_id;
183
184 $this->parent[$c["id"]] = $a_parent_id;
185
186 // @todo: prepare this for tref id?
188 in_array($a_parent_id, $this->drafts))
189 {
190 $this->drafts[] = $child_id;
191 $drafts[] = $k;
192 }
194 in_array($a_parent_id, $this->outdated))
195 {
196 $this->outdated[] = $child_id;
197 $outdated[] = $k;
198 }
199 }
200 if (!$this->getIncludeDrafts())
201 {
202 foreach ($drafts as $d)
203 {
204 unset($childs[$d]);
205 }
206 }
207 if (!$this->getIncludeOutdated())
208 {
209 foreach ($outdated as $d)
210 {
211 unset($childs[$d]);
212 }
213 }
214
215 return $childs;
216 }
static _lookupTemplateId($a_obj_id)
Lookup template ID.
static _lookupStatus($a_obj_id)
Lookup Status.
getIncludeDrafts()
Get include drafts.
getIncludeOutdated()
Get include outdated.
getCSkillIdForVTreeId($a_vtree_id)
Get common skill id for tree id.

References $d, $drafts, $outdated, ilSkillTreeNode\_lookupStatus(), ilSkillTemplateReference\_lookupTemplateId(), getCSkillIdForVTreeId(), getIncludeDrafts(), getIncludeOutdated(), ilSkillTreeNode\STATUS_DRAFT, and ilSkillTreeNode\STATUS_OUTDATED.

Referenced by __getSubTreeRec(), and getChildsOfNodeForCSkillId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChildsOfNodeForCSkillId()

ilVirtualSkillTree::getChildsOfNodeForCSkillId (   $a_cskill_id)

Get childs of node for cskill id.

Parameters
string$a_cskill_idcommon skill id <skill_id>:<tref_id>
Returns
array array of childs

Definition at line 224 of file class.ilVirtualSkillTree.php.

225 {
226 $id_parts = explode(":", $a_cskill_id);
227 if ($id_parts[1] == 0)
228 {
229 $id = $id_parts[0].":0";
230 }
231 else
232 {
233 $id = $id_parts[1].":".$id_parts[0];
234 }
235 return $this->getChildsOfNode($id);
236 }

References getChildsOfNode().

+ Here is the call graph for this function:

◆ getCSkillIdForVTreeId()

ilVirtualSkillTree::getCSkillIdForVTreeId (   $a_vtree_id)

Get common skill id for tree id.

Parameters
string$a_vtree_idvtree id
Returns
string cskill id

Definition at line 244 of file class.ilVirtualSkillTree.php.

245 {
246 $id_parts = explode(":", $a_vtree_id);
247 if ($id_parts[1] == 0)
248 {
249 // skill in main tree
250 $skill_id = $id_parts[0];
251 $tref_id = 0;
252 }
253 else
254 {
255 // skill in template
256 $tref_id = $id_parts[0];
257 $skill_id = $id_parts[1];
258 }
259 return $skill_id.":".$tref_id;
260 }

Referenced by getChildsOfNode(), and getNode().

+ Here is the caller graph for this function:

◆ getIncludeDrafts()

ilVirtualSkillTree::getIncludeDrafts ( )

Get include drafts.

Returns
bool include drafts

Definition at line 60 of file class.ilVirtualSkillTree.php.

References $include_drafts.

Referenced by getChildsOfNode().

+ Here is the caller graph for this function:

◆ getIncludeOutdated()

ilVirtualSkillTree::getIncludeOutdated ( )

Get include outdated.

Returns
bool include outdated

Definition at line 80 of file class.ilVirtualSkillTree.php.

References $include_outdated.

Referenced by getChildsOfNode().

+ Here is the caller graph for this function:

◆ getNode()

ilVirtualSkillTree::getNode (   $a_id)

Get node.

Parameters
string$a_idvtree id
Returns
array node array

Definition at line 91 of file class.ilVirtualSkillTree.php.

92 {
93 $id_parts = explode(":", $a_id);
94 $skl_tree_id = $id_parts[0];
95 $skl_template_tree_id = $id_parts[1];
96
97 if ($skl_template_tree_id == 0 || (ilSkillTemplateReference::_lookupTemplateId($skl_tree_id)
98 == $skl_template_tree_id))
99 {
100 $node_data = $this->tree->getNodeData($skl_tree_id);
101 $node_data["parent"] = $node_data["parent"].":0";
102 }
103 else
104 {
105 $node_data = $this->tree->getNodeData($skl_template_tree_id);
106 $node_data["parent"] = $skl_tree_id.":".$node_data["parent"];
107 }
108
109 unset($node_data["child"]);
110 unset($node_data["skl_tree_id"]);
111 unset($node_data["lft"]);
112 unset($node_data["rgt"]);
113 unset($node_data["depth"]);
114
115 $node_data["id"] = $a_id;
116 $cid = $this->getCSkillIdForVTreeId($a_id);
117 $cid_parts = explode(":", $cid);
118 $node_data["skill_id"] = $cid_parts[0];
119 $node_data["tref_id"] = $cid_parts[1];
120 $node_data["cskill_id"] = $cid;
121
122
123 return $node_data;
124 }

References ilSkillTemplateReference\_lookupTemplateId(), and getCSkillIdForVTreeId().

Referenced by getSubTreeForCSkillId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNodeTitle()

ilVirtualSkillTree::getNodeTitle (   $a_node)

Get node content.

Parameters
array$a_nodenode data
Returns
string title

Definition at line 290 of file class.ilVirtualSkillTree.php.

291 {
292 global $lng;
293
294 $a_parent_id_parts = explode(":", $a_node["id"]);
295 $a_parent_skl_tree_id = $a_parent_id_parts[0];
296 $a_parent_skl_template_tree_id = $a_parent_id_parts[1];
297
298 // title
299 $title = $a_node["title"];
300
301 // root?
302 if ($a_node["type"] == "skrt")
303 {
304 $lng->txt("skmg_skills");
305 }
306 else
307 {
308 if ($a_node["type"] == "sktr")
309 {
310// include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
311// $title.= " (".ilSkillTreeNode::_lookupTitle($a_parent_skl_template_tree_id).")";
312 }
313 }
314
315 return $title;
316 }
global $lng
Definition: privfeed.php:40

References $lng.

◆ getRootNode()

ilVirtualSkillTree::getRootNode ( )

Get root node.

Returns
array root node array

Definition at line 34 of file class.ilVirtualSkillTree.php.

35 {
36 $root_id = $this->tree->readRootId();
37 $root_node = $this->tree->getNodeData($root_id);
38 unset($root_node["child"]);
39 $root_node["id"] = $root_id.":0";
40 $root_node["cskill_id"] = $root_id.":0";
41
42 return $root_node;
43 }

◆ getSubTreeForCSkillId()

ilVirtualSkillTree::getSubTreeForCSkillId (   $a_cskill_id,
  $a_only_basic = false 
)

Get sub tree.

Parameters
string$a_cskill_idcskill id
bool$a_only_basicreturn only basic skills (and basic skill templates)
Returns
array node array

Definition at line 325 of file class.ilVirtualSkillTree.php.

326 {
327 $id_parts = explode(":", $a_cskill_id);
328 if ($id_parts[1] == 0)
329 {
330 $id = $id_parts[0].":0";
331 }
332 else
333 {
334 $id = $id_parts[1].":".$id_parts[0];
335 }
336
337 $result = array();
338
339 $node = $this->getNode($id);
340 if (!$a_only_basic || in_array($node["type"], array("skll", "sktp")) ||
341 ($node["type"] == "sktr" && ilSkillTreeNode::_lookupType($node["skill_id"]) == "sktp"))
342 {
343 $result[] = $node;
344 }
345 $this->__getSubTreeRec($id, $result, $a_only_basic);
346
347 return $result;
348 }

References $result, __getSubTreeRec(), ilSkillTreeNode\_lookupType(), and getNode().

+ Here is the call graph for this function:

◆ getVTreeIdForCSkillId()

ilVirtualSkillTree::getVTreeIdForCSkillId (   $a_cskill_id)

Get tree id for common skill id.

Parameters

return

Definition at line 268 of file class.ilVirtualSkillTree.php.

269 {
270 $id_parts = explode(":", $a_cskill_id);
271 if ($id_parts[1] == 0)
272 {
273 $id = $id_parts[0].":0";
274 }
275 else
276 {
277 $id = $id_parts[1].":".$id_parts[0];
278 }
279 return $id;
280 }

◆ isDraft()

ilVirtualSkillTree::isDraft (   $a_node_id)

Is draft.

Parameters
int$a_node_idnode id
Returns
bool is draft true/false

Definition at line 377 of file class.ilVirtualSkillTree.php.

378 {
379 return in_array($a_node_id, $this->drafts);
380 }

◆ isOutdated()

ilVirtualSkillTree::isOutdated (   $a_node_id)

Is outdated.

Parameters
int$a_node_idnode id
Returns
bool is outdated true/false

Definition at line 388 of file class.ilVirtualSkillTree.php.

389 {
390 return in_array($a_node_id, $this->outdated);
391 }

◆ setIncludeDrafts()

ilVirtualSkillTree::setIncludeDrafts (   $a_val)

Set include drafts.

Parameters
bool$a_valinclude drafts

Definition at line 50 of file class.ilVirtualSkillTree.php.

51 {
52 $this->include_drafts = $a_val;
53 }

◆ setIncludeOutdated()

ilVirtualSkillTree::setIncludeOutdated (   $a_val)

Set include outdated.

Parameters
bool$a_valinclude outdated

Definition at line 70 of file class.ilVirtualSkillTree.php.

71 {
72 $this->include_outdated = $a_val;
73 }

Field Documentation

◆ $drafts

ilVirtualSkillTree::$drafts = array()
protected

Definition at line 16 of file class.ilVirtualSkillTree.php.

Referenced by getChildsOfNode().

◆ $include_drafts

ilVirtualSkillTree::$include_drafts = false
protected

Definition at line 15 of file class.ilVirtualSkillTree.php.

Referenced by getIncludeDrafts().

◆ $include_outdated

ilVirtualSkillTree::$include_outdated = false
protected

Definition at line 17 of file class.ilVirtualSkillTree.php.

Referenced by getIncludeOutdated().

◆ $outdated

ilVirtualSkillTree::$outdated = array()
protected

Definition at line 18 of file class.ilVirtualSkillTree.php.

Referenced by getChildsOfNode().


The documentation for this class was generated from the following file: