ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilVirtualSkillTreeExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
24 
31 {
32  protected ilLanguage $lng;
36 
37  protected bool $show_draft_nodes = false;
38  protected bool $show_outdated_nodes = false;
39 
40  public function __construct(string $a_id, $a_parent_obj, string $a_parent_cmd, int $tree_id = 0)
41  {
42  global $DIC;
43 
44  $this->lng = $DIC->language();
45  $this->ctrl = $DIC->ctrl();
46  parent::__construct($a_id, $a_parent_obj, $a_parent_cmd);
47 
48  $this->skill_tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
49  $this->tree_factory = $DIC->skills()->internal()->factory();
50 
51  if ($tree_id == 0) {
52  $this->vtree = $this->tree_factory->tree()->getGlobalVirtualTree();
53  } else {
54  $this->vtree = $this->tree_factory->tree()->getVirtualTreeById($tree_id);
55  }
56 
57  $this->setSkipRootNode(false);
58  $this->setAjax(false);
59  }
60 
61  public function setShowDraftNodes(bool $a_val): void
62  {
63  $this->show_draft_nodes = $a_val;
64  $this->vtree->setIncludeDrafts($a_val);
65  }
66 
67  public function getShowDraftNodes(): bool
68  {
70  }
71 
72  public function setShowOutdatedNodes(bool $a_val): void
73  {
74  $this->show_outdated_nodes = $a_val;
75  $this->vtree->setIncludeOutdated($a_val);
76  }
77 
78  public function getShowOutdatedNodes(): bool
79  {
81  }
82 
86  public function getRootNode(): array
87  {
88  return $this->vtree->getRootNode();
89  }
90 
95  public function getNodeId($a_node): string
96  {
97  return (string) $a_node["id"];
98  }
99 
103  public function getDomNodeIdForNodeId($a_node_id): string
104  {
105  return parent::getDomNodeIdForNodeId(str_replace(":", "_", $a_node_id));
106  }
107 
111  public function getNodeIdForDomNodeId(string $a_dom_node_id): string
112  {
113  $id = parent::getNodeIdForDomNodeId($a_dom_node_id);
114  return str_replace("_", ":", $id);
115  }
116 
121  public function getChildsOfNode($a_parent_node_id): array
122  {
123  return $this->vtree->getChildsOfNode($a_parent_node_id);
124  }
125 
130  public function getNodeContent($a_node): string
131  {
132  $lng = $this->lng;
133 
134  $a_parent_id_parts = explode(":", (string) $a_node["id"]);
135  $a_parent_skl_tree_id = (int) $a_parent_id_parts[0];
136  $a_parent_skl_template_tree_id = isset($a_parent_id_parts[1]) ? (int) $a_parent_id_parts[1] : 0;
137 
138  // title
139  if ((int) $a_node["parent"] == 0) {
140  $tree_obj = $this->skill_tree_manager->getTree($a_node["skl_tree_id"]);
141  $title = $tree_obj->getTitle();
142  } else {
143  $title = $a_node["title"];
144  }
145 
146  // root?
147  if ($a_node["type"] == "skrt") {
148  $lng->txt("skmg_skills");
149  }
150 
151  return $title;
152  }
153 
158  public function getNodeIcon($a_node): string
159  {
160  $a_id_parts = explode(":", (string) $a_node["id"]);
161  $a_skl_template_tree_id = isset($a_id_parts[1]) ? (int) $a_id_parts[1] : 0;
162 
163  // root?
164  if ($a_node["type"] == "skrt") {
165  $icon = ilUtil::getImagePath("standard/icon_scat.svg");
166  } else {
167  $type = $a_node["type"];
168  if ($type == "sktr") {
169  $type = ilSkillTreeNode::_lookupType($a_skl_template_tree_id);
170  }
171  if ($type == "sktp") {
172  $type = "skll";
173  }
174  if ($type == "sctp") {
175  $type = "scat";
176  }
177  $icon = ilUtil::getImagePath("standard/icon_" . $type . ".svg");
178  }
179 
180  return $icon;
181  }
182 
187  public function getNodeHref($a_node): string
188  {
189  $ilCtrl = $this->ctrl;
190 
191  // we have a tree id like <skl_tree_id>:<skl_template_tree_id> here
192  // use this, if you want a "common" skill id in format <skill_id>:<tref_id>
193  $id_parts = explode(":", (string) $a_node["id"]);
194  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
195  // skill in main tree
196  $skill_id = $a_node["id"];
197  } else {
198  // skill in template
199  $skill_id = $id_parts[1] . ":" . $id_parts[0];
200  }
201 
202  return "";
203  }
204 
209  public function isNodeClickable($a_node): bool
210  {
211  return false;
212  }
213 
218  public function getNodeIconAlt($a_node): string
219  {
220  $lng = $this->lng;
221 
222  if ($lng->exists("skmg_" . $a_node["type"])) {
223  return $lng->txt("skmg_" . $a_node["type"]);
224  }
225 
226  return $lng->txt($a_node["type"]);
227  }
228 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
__construct(string $a_id, $a_parent_obj, string $a_parent_cmd, int $tree_id=0)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static _lookupType(int $a_obj_id)
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...