ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSkillTreeExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
23 
30 {
31  protected ilLanguage $lng;
33  protected int $requested_skill_node_id = 0;
34  protected int $requested_tref_id = 0;
35 
41  public function __construct($a_parent_obj, string $a_parent_cmd, int $tree_id = 0)
42  {
43  global $DIC;
44 
45  $this->lng = $DIC->language();
46  $this->ctrl = $DIC->ctrl();
47  $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
48  parent::__construct("skill_exp", $a_parent_obj, $a_parent_cmd, $tree_id);
49 
50  $this->requested_skill_node_id = $this->admin_gui_request->getNodeId();
51  $this->requested_tref_id = $this->admin_gui_request->getTrefId();
52 
53  // node should be hidden #26849 (not not hidden, see discussion in #26813 and JF 6 Jan 2020)
54  $this->setSkipRootNode(false);
55  $this->setAjax(false);
56  $this->setShowDraftNodes(true);
57  $this->setShowOutdatedNodes(true);
58  }
59 
63  public function getNodeContent($a_node): string
64  {
65  $lng = $this->lng;
66 
67  $a_parent_id_parts = explode(":", $a_node["id"]);
68  $a_parent_skl_tree_id = (int) $a_parent_id_parts[0];
69  $a_parent_skl_template_tree_id = isset($a_parent_id_parts[1]) ? (int) $a_parent_id_parts[1] : 0;
70 
71  // title
72  $title = $a_node["title"];
73 
74  // root?
75  if ($a_node["type"] == "skrt") {
76  $tree_obj = $this->skill_tree_manager->getTree($a_node["skl_tree_id"]);
77  $title = $tree_obj->getTitle();
78  } else {
79  if ($a_node["type"] == "sktr") {
80  $tid = ilSkillTemplateReference::_lookupTemplateId($a_parent_skl_tree_id);
81  $title .= " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
82  }
83 
84  // @todo: fix this if possible for skill/tref_id combination
85  if (ilSkillTreeNode::_lookupSelfEvaluation($a_parent_skl_tree_id)) {
86  if ($a_parent_skl_template_tree_id == 0 || $a_node["type"] == "sktr") {
87  $title = "<u>" . $title . "</u>";
88  }
89  }
90  }
91 
92  if ($this->vtree->isOutdated($a_node["id"])) {
93  $title = "<span class='light'>" . $title . "</span>";
94  }
95 
96  return $title;
97  }
98 
102  public function getNodeIcon($a_node): string
103  {
104  $a_parent_id_parts = explode(":", $a_node["id"]);
105  $a_parent_skl_tree_id = (int) $a_parent_id_parts[0];
106  $a_parent_skl_template_tree_id = isset($a_parent_id_parts[1]) ? (int) $a_parent_id_parts[1] : 0;
107 
108 
109  // root?
110  if ($a_node["type"] == "skrt") {
111  $icon = ilUtil::getImagePath("standard/icon_scat.svg");
112  } elseif (in_array($a_node["type"], array("skll", "scat", "sctr", "sktr", "sctp", "sktp"))) {
114  $a_parent_skl_tree_id,
115  $a_node["type"],
116  "",
117  (int) ($this->vtree->isDraft($a_node["id"]) || $this->vtree->isOutdated($a_node["id"]))
118  );
119  } else {
120  $icon = ilUtil::getImagePath("standard/icon_" . $a_node["type"] . ".svg");
121  }
122 
123  return $icon;
124  }
125 
129  public function isNodeHighlighted($a_node): bool
130  {
131  $id_parts = explode(":", $a_node["id"]);
132  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
133  // skill in main tree
134  $skill_id = $id_parts[0];
135  $tref_id = 0;
136  } else {
137  // skill in template
138  $tref_id = $id_parts[0];
139  $skill_id = $id_parts[1];
140  }
141 
142  if ($this->requested_skill_node_id == "" && $a_node["type"] == "skrt") {
143  return true;
144  }
145 
146  if ($skill_id == $this->requested_skill_node_id &&
147  ($this->requested_tref_id == $tref_id)) {
148  return true;
149  }
150  return false;
151  }
152 
156  public function getNodeHref($a_node): string
157  {
158  $ilCtrl = $this->ctrl;
159 
160  $id_parts = explode(":", $a_node["id"]);
161  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
162  // skill in main tree
163  $skill_id = $id_parts[0];
164  $tref_id = 0;
165  } else {
166  // skill in template
167  $tref_id = $id_parts[0];
168  $skill_id = $id_parts[1];
169  }
170 
171  $gui_class = array(
172  "skrt" => "ilskillrootgui",
173  "scat" => "ilskillcategorygui",
174  "sktr" => "ilskilltemplatereferencegui",
175  "skll" => "ilbasicskillgui",
176  "sktp" => "ilbasicskilltemplategui",
177  "sctp" => "ilskilltemplatecategorygui"
178  );
179 
180  $cmd = array(
181  "skrt" => "listSkills",
182  "scat" => "listItems",
183  "sktr" => "listItems",
184  "skll" => "edit",
185  "sktp" => "edit",
186  "sctp" => "listItems"
187  );
188 
189  $gui_class = $gui_class[$a_node["type"]];
190  $cmd = $cmd[$a_node["type"]];
191 
192  $ilCtrl->setParameterByClass($gui_class, "tref_id", $tref_id);
193  $ilCtrl->setParameterByClass($gui_class, "node_id", $skill_id);
194  $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI", "ilObjSkillManagementGUI",
195  "ilSkillTreeAdminGUI", "ilObjSkillTreeGUI", $gui_class], $cmd);
196  $ilCtrl->setParameterByClass($gui_class, "node_id", $this->requested_skill_node_id);
197  $ilCtrl->setParameterByClass($gui_class, "tref_id", $this->requested_tref_id);
198 
199  return $ret;
200  }
201 
205  public function isNodeClickable($a_node): bool
206  {
207  return true;
208  }
209 }
Request wrapper for guis in skill administration.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
SkillAdminGUIRequest $admin_gui_request
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
static getIconPath(int $a_obj_id, string $a_type, string $a_size="", int $a_status=0)
__construct($a_parent_obj, string $a_parent_cmd, int $tree_id=0)
Explorer class that works on tree objects (Services/Tree)
static _lookupSelfEvaluation(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...