ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPersonalSkillExplorerGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
30{
31 protected string $select_gui = "";
32 protected string $select_cmd = "";
33 protected string $select_par = "";
34
38 protected array $all_nodes = [];
39
43 protected array $node = [];
44
48 protected array $child_nodes = [];
49
53 protected array $parent = [];
54
58 protected array $selectable = [];
59
63 protected array $selectable_child_nodes = [];
64 protected bool $has_selectable_nodes = false;
65
69
70 public function __construct(
71 $a_parent_obj,
72 string $a_parent_cmd,
73 $a_select_gui,
74 string $a_select_cmd,
75 string $a_select_par = "node_id"
76 ) {
77 global $DIC;
78
79 $this->ctrl = $DIC->ctrl();
80 $this->lng = $DIC->language();
81
82 $this->select_gui = (is_object($a_select_gui))
83 ? strtolower(get_class($a_select_gui))
84 : $a_select_gui;
85 $this->select_cmd = $a_select_cmd;
86 $this->select_par = $a_select_par;
87
88 $this->skill_tree_factory = $DIC->skills()->internal()->factory()->tree();
89 $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
90 $this->skill_tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
91
92 $this->lng->loadLanguageModule("skmg");
93
94 $this->tree = $this->skill_tree_factory->getGlobalTree();
95 $this->root_id = $this->tree->readRootId();
96
97 parent::__construct("pskill_sel", $a_parent_obj, $a_parent_cmd, $this->tree);
98 $this->setSkipRootNode(true);
99
100 $this->all_nodes = [];
101
102 foreach ($this->tree->getChilds(0) as $c) {
103 $node_id = (int) $c["child"];
104 $tree_id = $this->tree_repo->getTreeIdForNodeId($node_id);
105 $tree = $this->skill_tree_factory->getTreeById($tree_id);
107 foreach ($all_nodes as $n) {
108 $this->node[$n["child"]] = $n;
109 $this->child_nodes[$n["parent"]][] = $n;
110 $this->parent[$n["child"]] = $n["parent"];
111 $this->all_nodes[] = $n;
112 }
113 }
114
115
116 // $this->setTypeWhiteList(array("skrt", "skll", "scat", "sktr"));
117 $this->buildSelectableTree(0);
118 }
119
120 protected function getRootId(): int
121 {
122 return 0;
123 }
124
125 protected function setHasSelectableNodes(bool $a_val): void
126 {
127 $this->has_selectable_nodes = $a_val;
128 }
129
130 public function getHasSelectableNodes(): bool
131 {
133 }
134
135 public function buildSelectableTree(int $a_node_id): void
136 {
138 if ($a_node_id != 0 && ilSkillTreeNode::_lookupType($a_node_id) !== "skrt") {
139 return;
140 }
141 }
142
143 $this->selectable[$a_node_id] = false;
145 $this->selectable[$a_node_id] = true;
146 $cid = $a_node_id;
147 //$this->selectable[$this->parent[$a_node_id]] = true;
148 while (isset($this->parent[$cid])) {
149 $this->selectable[$this->parent[$cid]] = true;
150 $cid = $this->parent[$cid];
151 }
152 }
153 foreach ($this->getOriginalChildsOfNode($a_node_id) as $n) {
154 $this->buildSelectableTree((int) $n["child"]);
155 }
156 if ($this->selectable[$a_node_id]) {
157 $this->setHasSelectableNodes(true);
158 if (isset($this->node[$a_node_id])) {
159 $this->selectable_child_nodes[$this->node[$a_node_id]["parent"]][] =
160 $this->node[$a_node_id];
161 }
162 }
163 }
164
170 public function getChildsOfNode($a_parent_node_id): array
171 {
172 if (isset($this->selectable_child_nodes[$a_parent_node_id])
173 && is_array($this->selectable_child_nodes[$a_parent_node_id])) {
174 $childs = $this->selectable_child_nodes[$a_parent_node_id];
175 $childs = ilArrayUtil::sortArray($childs, "order_nr", "asc", true);
176 return $childs;
177 }
178 return [];
179 }
180
184 public function getOriginalChildsOfNode(int $a_parent_id): array
185 {
186 if (isset($this->child_nodes[$a_parent_id]) && is_array($this->child_nodes[$a_parent_id])) {
187 return $this->child_nodes[$a_parent_id];
188 }
189 return [];
190 }
191
196 public function getNodeHref($a_node): string
197 {
198 $ilCtrl = $this->ctrl;
199
200 $skill_id = $a_node["child"];
201
202 $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, $skill_id);
203 $ret = $ilCtrl->getLinkTargetByClass($this->select_gui, $this->select_cmd);
204 $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, "");
205
206 return $ret;
207 }
208
213 public function getNodeContent($a_node): string
214 {
216
217 // title
218 if ((int) $a_node["parent"] == 0) {
219 $tree_obj = $this->skill_tree_manager->getTree((int) $a_node["skl_tree_id"]);
220 $title = $tree_obj->getTitle();
221 } else {
222 $title = $a_node["title"];
223 }
224
225 return $title;
226 }
227
232 public function isNodeClickable($a_node): bool
233 {
234 if (!ilSkillTreeNode::_lookupSelfEvaluation((int) $a_node["child"])) {
235 return false;
236 }
237 return true;
238 }
239
245 public function getNodeIcon($a_node): string
246 {
247 $t = $a_node["type"];
248 if ($t == "sktr") {
249 return ilUtil::getImagePath("standard/icon_skll.svg");
250 }
251 return ilUtil::getImagePath("standard/icon_" . $t . ".svg");
252 }
253
258 public function getNodeIconAlt($a_node): string
259 {
261
262 if ($lng->exists("skmg_" . $a_node["type"])) {
263 return $lng->txt("skmg_" . $a_node["type"]);
264 }
265
266 return $lng->txt($a_node["type"]);
267 }
268}
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 $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: deliver.php:25
Interface ilSkillTreeRepository.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26