ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSkillTree.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4
10class ilSkillTree extends ilTree
11{
12 public function __construct()
13 {
14 parent::__construct(1); // only one skill tree, with ID 1
15 $this->setTreeTablePK("skl_tree_id");
16 $this->setTableNames('skl_tree', 'skl_tree_node');
17 }
18
26 public function getSkillTreePath($a_base_skill_id, $a_tref_id = 0)
27 {
28 if ($a_tref_id > 0) {
29 $path = $this->getPathFull($a_tref_id);
30 $sub_path = $this->getPathFull($a_base_skill_id);
31 if (is_array($path)) {
32 foreach ($path as $k => $v) {
33 if ($v["child"] != $a_tref_id) {
34 $path[$k]["skill_id"] = $v["child"];
35 $path[$k]["tref_id"] = 0;
36 } else {
37 $path[$k]["skill_id"] = ilSkillTemplateReference::_lookupTemplateId($a_tref_id);
38 $path[$k]["tref_id"] = $a_tref_id;
39 }
40 }
41 }
42 $found = false;
43 if (is_array($sub_path)) {
44 foreach ($sub_path as $s) {
45 if ($found) {
46 $s["skill_id"] = $s["child"];
47 $s["tref_id"] = $a_tref_id;
48 $path[] = $s;
49 }
50 if ($s["child"] == ilSkillTemplateReference::_lookupTemplateId($a_tref_id)) {
51 $found = true;
52 }
53 }
54 }
55 } else {
56 $path = $this->getPathFull($a_base_skill_id);
57 if (is_array($path)) {
58 foreach ($path as $k => $v) {
59 $path[$k]["skill_id"] = $v["child"];
60 $path[$k]["tref_id"] = 0;
61 }
62 }
63 }
64
65 if (is_array($path)) {
66 return $path;
67 }
68 return array();
69 }
70
78 public function getSkillTreePathAsString($a_base_skill_id, $a_tref_id = 0)
79 {
80 $path = $this->getSkillTreePath($a_base_skill_id, $a_tref_id);
81 $str = "";
82 $sep = "";
83 foreach ($path as $p) {
84 if ($p["type"] != "skrt" && $p["child"] != $a_base_skill_id) {
85 $str .= $sep . $p["title"];
86 $sep = " > ";
87 }
88 }
89 return $str;
90 }
91
98 public function getTopParentNodeId($a_node_id)
99 {
100 $path = $this->getPathId($a_node_id);
101 return (int) $path[1];
102 }
103
111 public function getMaxOrderNr($a_par_id, $a_templates = false)
112 {
113 if ($a_par_id != $this->readRootId()) {
114 $childs = $this->getChilds($a_par_id);
115 } else {
116 if ($a_templates) {
117 $childs = $this->getChildsByTypeFilter(
118 $a_par_id,
119 array("skrt", "sktp", "sctp")
120 );
121 } else {
122 $childs = $this->getChildsByTypeFilter(
123 $a_par_id,
124 array("skrt", "skll", "scat", "sktr")
125 );
126 }
127 }
128
129 $max = 0;
130 foreach ($childs as $k => $c) {
131 $max = max(array($c["order_nr"], $max));
132 }
133
134 return $max;
135 }
136}
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
$c
Definition: cli.php:37
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc