ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilVirtualSkillTreeExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 
22 
29 {
30  protected ilLanguage $lng;
34 
35  protected bool $show_draft_nodes = false;
36  protected bool $show_outdated_nodes = false;
37 
38  public function __construct(string $a_id, $a_parent_obj, string $a_parent_cmd, int $tree_id = 0)
39  {
40  global $DIC;
41 
42  $this->lng = $DIC->language();
43  $this->ctrl = $DIC->ctrl();
44  parent::__construct($a_id, $a_parent_obj, $a_parent_cmd);
45 
46  $this->skill_tree_manager = $DIC->skills()->internal()->manager()->getTreeManager();
47  $this->tree_factory = $DIC->skills()->internal()->factory();
48 
49  if ($tree_id == 0) {
50  $this->vtree = $this->tree_factory->tree()->getGlobalVirtualTree();
51  } else {
52  $this->vtree = $this->tree_factory->tree()->getVirtualTreeById($tree_id);
53  }
54 
55  $this->setSkipRootNode(false);
56  $this->setAjax(false);
57  }
58 
59  public function setShowDraftNodes(bool $a_val): void
60  {
61  $this->show_draft_nodes = $a_val;
62  $this->vtree->setIncludeDrafts($a_val);
63  }
64 
65  public function getShowDraftNodes(): bool
66  {
68  }
69 
70  public function setShowOutdatedNodes(bool $a_val): void
71  {
72  $this->show_outdated_nodes = $a_val;
73  $this->vtree->setIncludeOutdated($a_val);
74  }
75 
76  public function getShowOutdatedNodes(): bool
77  {
79  }
80 
84  public function getRootNode(): array
85  {
86  return $this->vtree->getRootNode();
87  }
88 
93  public function getNodeId($a_node): string
94  {
95  return $a_node["id"];
96  }
97 
101  public function getDomNodeIdForNodeId($a_node_id): string
102  {
103  return parent::getDomNodeIdForNodeId(str_replace(":", "_", $a_node_id));
104  }
105 
109  public function getNodeIdForDomNodeId(string $a_dom_node_id): string
110  {
111  $id = parent::getNodeIdForDomNodeId($a_dom_node_id);
112  return str_replace("_", ":", $id);
113  }
114 
119  public function getChildsOfNode($a_parent_node_id): array
120  {
121  return $this->vtree->getChildsOfNode($a_parent_node_id);
122  }
123 
128  public function getNodeContent($a_node): string
129  {
130  $lng = $this->lng;
131 
132  $a_parent_id_parts = explode(":", (string) $a_node["id"]);
133  $a_parent_skl_tree_id = (int) $a_parent_id_parts[0];
134  $a_parent_skl_template_tree_id = isset($a_parent_id_parts[1]) ? (int) $a_parent_id_parts[1] : 0;
135 
136  // title
137  if ((int) $a_node["parent"] == 0) {
138  $tree_obj = $this->skill_tree_manager->getTree($a_node["skl_tree_id"]);
139  $title = $tree_obj->getTitle();
140  } else {
141  $title = $a_node["title"];
142  }
143 
144  // root?
145  if ($a_node["type"] == "skrt") {
146  $lng->txt("skmg_skills");
147  }
148 
149  return $title;
150  }
151 
156  public function getNodeIcon($a_node): string
157  {
158  $a_id_parts = explode(":", (string) $a_node["id"]);
159  $a_skl_template_tree_id = isset($a_id_parts[1]) ? (int) $a_id_parts[1] : 0;
160 
161  // root?
162  if ($a_node["type"] == "skrt") {
163  $icon = ilUtil::getImagePath("icon_scat.svg");
164  } else {
165  $type = $a_node["type"];
166  if ($type == "sktr") {
167  $type = ilSkillTreeNode::_lookupType($a_skl_template_tree_id);
168  }
169  if ($type == "sktp") {
170  $type = "skll";
171  }
172  if ($type == "sctp") {
173  $type = "scat";
174  }
175  $icon = ilUtil::getImagePath("icon_" . $type . ".svg");
176  }
177 
178  return $icon;
179  }
180 
185  public function getNodeHref($a_node): string
186  {
187  $ilCtrl = $this->ctrl;
188 
189  // we have a tree id like <skl_tree_id>:<skl_template_tree_id> here
190  // use this, if you want a "common" skill id in format <skill_id>:<tref_id>
191  $id_parts = explode(":", (string) $a_node["id"]);
192  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
193  // skill in main tree
194  $skill_id = $a_node["id"];
195  } else {
196  // skill in template
197  $skill_id = $id_parts[1] . ":" . $id_parts[0];
198  }
199 
200  return "";
201  }
202 
207  public function isNodeClickable($a_node): bool
208  {
209  return false;
210  }
211 
216  public function getNodeIconAlt($a_node): string
217  {
218  $lng = $this->lng;
219 
220  if ($lng->exists("skmg_" . $a_node["type"])) {
221  return $lng->txt("skmg_" . $a_node["type"]);
222  }
223 
224  return $lng->txt($a_node["type"]);
225  }
226 }
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...
$type
__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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...