ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 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  }
Skill tree.

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 336 of file class.ilVirtualSkillTree.php.

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

Referenced by getSubTreeForCSkillId().

337  {
338  $childs = $this->getChildsOfNode($id);
339  foreach ($childs as $c)
340  {
341  if (!$a_only_basic || in_array($c["type"], array("skll", "sktp")) ||
342  ($c["type"] == "sktr" && ilSkillTreeNode::_lookupType($c["skill_id"]) == "sktp"))
343  {
344  $result[] = $c;
345  }
346  $this->__getSubTreeRec($c["id"], $result, $a_only_basic);
347  }
348  }
$result
getChildsOfNode($a_parent_id)
Get childs of node.
static _lookupType($a_obj_id)
Lookup Type.
__getSubTreeRec($id, &$result, $a_only_basic)
Get subtree, internal.
+ 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.

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

Referenced by __getSubTreeRec(), and getChildsOfNodeForCSkillId().

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.
getIncludeOutdated()
Get include outdated.
getCSkillIdForVTreeId($a_vtree_id)
Get common skill id for tree id.
getIncludeDrafts()
Get include drafts.
static _lookupStatus($a_obj_id)
Lookup Status.
+ 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.

References getChildsOfNode().

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  }
getChildsOfNode($a_parent_id)
Get childs of node.
+ 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.

Referenced by getChildsOfNode(), and getNode().

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  }
+ 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.

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

Referenced by getSubTreeForCSkillId().

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  }
static _lookupTemplateId($a_obj_id)
Lookup template ID.
getCSkillIdForVTreeId($a_vtree_id)
Get common skill id for tree id.
+ 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 269 of file class.ilVirtualSkillTree.php.

References $lng.

270  {
271  global $lng;
272 
273  $a_parent_id_parts = explode(":", $a_node["id"]);
274  $a_parent_skl_tree_id = $a_parent_id_parts[0];
275  $a_parent_skl_template_tree_id = $a_parent_id_parts[1];
276 
277  // title
278  $title = $a_node["title"];
279 
280  // root?
281  if ($a_node["type"] == "skrt")
282  {
283  $lng->txt("skmg_skills");
284  }
285  else
286  {
287  if ($a_node["type"] == "sktr")
288  {
289 // include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
290 // $title.= " (".ilSkillTreeNode::_lookupTitle($a_parent_skl_template_tree_id).")";
291  }
292  }
293 
294  return $title;
295  }
global $lng
Definition: privfeed.php:40

◆ 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 304 of file class.ilVirtualSkillTree.php.

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

305  {
306  $id_parts = explode(":", $a_cskill_id);
307  if ($id_parts[1] == 0)
308  {
309  $id = $id_parts[0].":0";
310  }
311  else
312  {
313  $id = $id_parts[1].":".$id_parts[0];
314  }
315 
316  $result = array();
317 
318  $node = $this->getNode($id);
319  if (!$a_only_basic || in_array($node["type"], array("skll", "sktp")) ||
320  ($node["type"] == "sktr" && ilSkillTreeNode::_lookupType($node["skill_id"]) == "sktp"))
321  {
322  $result[] = $node;
323  }
324  $this->__getSubTreeRec($id, $result, $a_only_basic);
325 
326  return $result;
327  }
$result
static _lookupType($a_obj_id)
Lookup Type.
__getSubTreeRec($id, &$result, $a_only_basic)
Get subtree, internal.
+ Here is the call graph for this function:

◆ isDraft()

ilVirtualSkillTree::isDraft (   $a_node_id)

Is draft.

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

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

357  {
358  return in_array($a_node_id, $this->drafts);
359  }

◆ isOutdated()

ilVirtualSkillTree::isOutdated (   $a_node_id)

Is outdated.

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

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

368  {
369  return in_array($a_node_id, $this->outdated);
370  }

◆ 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: