ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
5 include_once("./Services/Tree/classes/class.ilTree.php");
6 
14 class 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  foreach ($path as $k => $v)
70  {
71  $path[$k]["skill_id"] = $v["child"];
72  $path[$k]["tref_id"] = 0;
73  }
74  }
75 
76  return $path;
77  }
78 
86  function getSkillTreePathAsString($a_base_skill_id, $a_tref_id = 0)
87  {
88  $path = $this->getSkillTreePath($a_base_skill_id, $a_tref_id);
89  $str = "";
90  $sep = "";
91  foreach ($path as $p)
92  {
93  if ($p["type"] != "skrt" && $p["child"] != $a_base_skill_id)
94  {
95  $str.= $sep.$p["title"];
96  $sep = " > ";
97  }
98  }
99  return $str;
100  }
101 
108  function getTopParentNodeId($a_node_id)
109  {
110  $path = $this->getPathId($a_node_id);
111  return (int) $path[1];
112  }
113 
114 
115 }
116 
117 ?>
Skill tree.
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...
getSkillTreePath($a_base_skill_id, $a_tref_id=0)
Get skill tree path.
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...
getTopParentNodeId($a_node_id)
Get top parent node id for a node.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
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 &#39;obj_id&#39; You may use...
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 public
$path
Definition: index.php:22
getSkillTreePathAsString($a_base_skill_id, $a_tref_id=0)
Get skill tree path as string.