ILIAS  release_8 Revision v8.24
class.ilPersonalSkillExplorerGUI.php
Go to the documentation of this file.
1<?php
2
22
29{
30 protected string $select_gui = "";
31 protected string $select_cmd = "";
32 protected string $select_par = "";
33
37 protected array $all_nodes = [];
38
42 protected array $node = [];
43
47 protected array $child_nodes = [];
48
52 protected array $parent = [];
53
57 protected array $selectable = [];
58
62 protected array $selectable_child_nodes = [];
63 protected bool $has_selectable_nodes = false;
64
68
69 public function __construct(
70 $a_parent_obj,
71 string $a_parent_cmd,
72 $a_select_gui,
73 string $a_select_cmd,
74 string $a_select_par = "node_id"
75 ) {
76 global $DIC;
77
78 $this->ctrl = $DIC->ctrl();
79 $this->lng = $DIC->language();
80
81 $this->select_gui = (is_object($a_select_gui))
82 ? strtolower(get_class($a_select_gui))
83 : $a_select_gui;
84 $this->select_cmd = $a_select_cmd;
85 $this->select_par = $a_select_par;
86
87 $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
88 $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
89 $this->skill_tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
90
91 $this->lng->loadLanguageModule("skmg");
92
93 $this->tree = $this->skill_tree_factory->getGlobalTree();
94 $this->root_id = $this->tree->readRootId();
95
96 parent::__construct("pskill_sel", $a_parent_obj, $a_parent_cmd, $this->tree);
97 $this->setSkipRootNode(true);
98
99 $this->all_nodes = [];
100
101 foreach ($this->tree->getChilds(0) as $c) {
102 $tree_id = $this->tree_repo->getTreeIdForNodeId($c["child"]);
103 $tree = $this->skill_tree_factory->getTreeById($tree_id);
105 foreach ($all_nodes as $n) {
106 $this->node[$n["child"]] = $n;
107 $this->child_nodes[$n["parent"]][] = $n;
108 $this->parent[$n["child"]] = $n["parent"];
109 $this->all_nodes[] = $n;
110 }
111 }
112
113
114 // $this->setTypeWhiteList(array("skrt", "skll", "scat", "sktr"));
115 $this->buildSelectableTree(0);
116 }
117
118 protected function getRootId(): int
119 {
120 return 0;
121 }
122
123 protected function setHasSelectableNodes(bool $a_val): void
124 {
125 $this->has_selectable_nodes = $a_val;
126 }
127
128 public function getHasSelectableNodes(): bool
129 {
131 }
132
133 public function buildSelectableTree(int $a_node_id): void
134 {
136 if ($a_node_id != 0 && ilSkillTreeNode::_lookupType($a_node_id) !== "skrt") {
137 return;
138 }
139 }
140
141 $this->selectable[$a_node_id] = false;
143 $this->selectable[$a_node_id] = true;
144 $cid = $a_node_id;
145 //$this->selectable[$this->parent[$a_node_id]] = true;
146 while (isset($this->parent[$cid])) {
147 $this->selectable[$this->parent[$cid]] = true;
148 $cid = $this->parent[$cid];
149 }
150 }
151 foreach ($this->getOriginalChildsOfNode($a_node_id) as $n) {
152 $this->buildSelectableTree($n["child"]);
153 }
154 if ($this->selectable[$a_node_id]) {
155 $this->setHasSelectableNodes(true);
156 if (isset($this->node[$a_node_id])) {
157 $this->selectable_child_nodes[$this->node[$a_node_id]["parent"]][] =
158 $this->node[$a_node_id];
159 }
160 }
161 }
162
168 public function getChildsOfNode($a_parent_node_id): array
169 {
170 if (isset($this->selectable_child_nodes[$a_parent_node_id])
171 && is_array($this->selectable_child_nodes[$a_parent_node_id])) {
172 $childs = $this->selectable_child_nodes[$a_parent_node_id];
173 $childs = ilArrayUtil::sortArray($childs, "order_nr", "asc", true);
174 return $childs;
175 }
176 return [];
177 }
178
182 public function getOriginalChildsOfNode(int $a_parent_id): array
183 {
184 if (isset($this->child_nodes[$a_parent_id]) && is_array($this->child_nodes[$a_parent_id])) {
185 return $this->child_nodes[$a_parent_id];
186 }
187 return [];
188 }
189
194 public function getNodeHref($a_node): string
195 {
196 $ilCtrl = $this->ctrl;
197
198 $skill_id = $a_node["child"];
199
200 $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, $skill_id);
201 $ret = $ilCtrl->getLinkTargetByClass($this->select_gui, $this->select_cmd);
202 $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, "");
203
204 return $ret;
205 }
206
211 public function getNodeContent($a_node): string
212 {
214
215 // title
216 if ((int) $a_node["parent"] == 0) {
217 $tree_obj = $this->skill_tree_manager->getTree($a_node["skl_tree_id"]);
218 $title = $tree_obj->getTitle();
219 } else {
220 $title = $a_node["title"];
221 }
222
223 return $title;
224 }
225
230 public function isNodeClickable($a_node): bool
231 {
232 if (!ilSkillTreeNode::_lookupSelfEvaluation($a_node["child"])) {
233 return false;
234 }
235 return true;
236 }
237
243 public function getNodeIcon($a_node): string
244 {
245 $t = $a_node["type"];
246 if ($t == "sktr") {
247 return ilUtil::getImagePath("icon_skll.svg");
248 }
249 return ilUtil::getImagePath("icon_" . $t . ".svg");
250 }
251
256 public function getNodeIconAlt($a_node): string
257 {
259
260 if ($lng->exists("skmg_" . $a_node["type"])) {
261 return $lng->txt("skmg_" . $a_node["type"]);
262 }
263
264 return $lng->txt($a_node["type"]);
265 }
266}
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
exists(string $a_topic)
Check if language entry exists.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Explorer for selecting a personal skill.
getNodeIcon($a_node)
get image path (may be overwritten by derived classes)
getChildsOfNode($a_parent_node_id)
Get childs of node (selectable tree)
__construct( $a_parent_obj, string $a_parent_cmd, $a_select_gui, string $a_select_cmd, string $a_select_par="node_id")
getOriginalChildsOfNode(int $a_parent_id)
Get original childs of node (whole tree)
static _lookupSelfEvaluation(int $a_obj_id)
static _lookupType(int $a_obj_id)
static _lookupStatus(int $a_obj_id)
Explorer class that works on tree objects (Services/Tree)
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
Interface ilSkillTreeRepository.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc