ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSkillTreeExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 
21 
28 {
29  protected ilLanguage $lng;
31  protected int $requested_skill_node_id = 0;
32  protected int $requested_tref_id = 0;
33 
39  public function __construct($a_parent_obj, string $a_parent_cmd, int $tree_id = 0)
40  {
41  global $DIC;
42 
43  $this->lng = $DIC->language();
44  $this->ctrl = $DIC->ctrl();
45  $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
46  parent::__construct("skill_exp", $a_parent_obj, $a_parent_cmd, $tree_id);
47 
48  $this->requested_skill_node_id = $this->admin_gui_request->getNodeId();
49  $this->requested_tref_id = $this->admin_gui_request->getTrefId();
50 
51  // node should be hidden #26849 (not not hidden, see discussion in #26813 and JF 6 Jan 2020)
52  $this->setSkipRootNode(false);
53  $this->setAjax(false);
54  $this->setShowDraftNodes(true);
55  $this->setShowOutdatedNodes(true);
56  }
57 
61  public function getNodeContent($a_node): string
62  {
63  $lng = $this->lng;
64 
65  $a_parent_id_parts = explode(":", $a_node["id"]);
66  $a_parent_skl_tree_id = (int) $a_parent_id_parts[0];
67  $a_parent_skl_template_tree_id = isset($a_parent_id_parts[1]) ? (int) $a_parent_id_parts[1] : 0;
68 
69  // title
70  $title = $a_node["title"];
71 
72  // root?
73  if ($a_node["type"] == "skrt") {
74  $tree_obj = $this->skill_tree_manager->getTree($a_node["skl_tree_id"]);
75  $title = $tree_obj->getTitle();
76  } else {
77  if ($a_node["type"] == "sktr") {
78  $tid = ilSkillTemplateReference::_lookupTemplateId($a_parent_skl_tree_id);
79  $title .= " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
80  }
81 
82  // @todo: fix this if possible for skill/tref_id combination
83  if (ilSkillTreeNode::_lookupSelfEvaluation($a_parent_skl_tree_id)) {
84  if ($a_parent_skl_template_tree_id == 0 || $a_node["type"] == "sktr") {
85  $title = "<u>" . $title . "</u>";
86  }
87  }
88  }
89 
90  if ($this->vtree->isOutdated($a_node["id"])) {
91  $title = "<span class='light'>" . $title . "</span>";
92  }
93 
94  return $title;
95  }
96 
100  public function getNodeIcon($a_node): string
101  {
102  $a_parent_id_parts = explode(":", $a_node["id"]);
103  $a_parent_skl_tree_id = (int) $a_parent_id_parts[0];
104  $a_parent_skl_template_tree_id = isset($a_parent_id_parts[1]) ? (int) $a_parent_id_parts[1] : 0;
105 
106 
107  // root?
108  if ($a_node["type"] == "skrt") {
109  $icon = ilUtil::getImagePath("icon_scat.svg");
110  } elseif (in_array($a_node["type"], array("skll", "scat", "sctr", "sktr", "sctp", "sktp"))) {
112  $a_parent_skl_tree_id,
113  $a_node["type"],
114  "",
115  ($this->vtree->isDraft($a_node["id"]) || $this->vtree->isOutdated($a_node["id"]))
116  );
117  } else {
118  $icon = ilUtil::getImagePath("icon_" . $a_node["type"] . ".svg");
119  }
120 
121  return $icon;
122  }
123 
127  public function isNodeHighlighted($a_node): bool
128  {
129  $id_parts = explode(":", $a_node["id"]);
130  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
131  // skill in main tree
132  $skill_id = $id_parts[0];
133  $tref_id = 0;
134  } else {
135  // skill in template
136  $tref_id = $id_parts[0];
137  $skill_id = $id_parts[1];
138  }
139 
140  if ($this->requested_skill_node_id == "" && $a_node["type"] == "skrt") {
141  return true;
142  }
143 
144  if ($skill_id == $this->requested_skill_node_id &&
145  ($this->requested_tref_id == $tref_id)) {
146  return true;
147  }
148  return false;
149  }
150 
154  public function getNodeHref($a_node): string
155  {
156  $ilCtrl = $this->ctrl;
157 
158  $id_parts = explode(":", $a_node["id"]);
159  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
160  // skill in main tree
161  $skill_id = $id_parts[0];
162  $tref_id = 0;
163  } else {
164  // skill in template
165  $tref_id = $id_parts[0];
166  $skill_id = $id_parts[1];
167  }
168 
169  $gui_class = array(
170  "skrt" => "ilskillrootgui",
171  "scat" => "ilskillcategorygui",
172  "sktr" => "ilskilltemplatereferencegui",
173  "skll" => "ilbasicskillgui",
174  "sktp" => "ilbasicskilltemplategui",
175  "sctp" => "ilskilltemplatecategorygui"
176  );
177 
178  $cmd = array(
179  "skrt" => "listSkills",
180  "scat" => "listItems",
181  "sktr" => "listItems",
182  "skll" => "edit",
183  "sktp" => "edit",
184  "sctp" => "listItems"
185  );
186 
187  $gui_class = $gui_class[$a_node["type"]];
188  $cmd = $cmd[$a_node["type"]];
189 
190  $ilCtrl->setParameterByClass($gui_class, "tref_id", $tref_id);
191  $ilCtrl->setParameterByClass($gui_class, "node_id", $skill_id);
192  $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI", "ilObjSkillManagementGUI",
193  "ilSkillTreeAdminGUI", "ilObjSkillTreeGUI", $gui_class], $cmd);
194  $ilCtrl->setParameterByClass($gui_class, "node_id", $this->requested_skill_node_id);
195  $ilCtrl->setParameterByClass($gui_class, "tref_id", $this->requested_tref_id);
196 
197  return $ret;
198  }
199 
203  public function isNodeClickable($a_node): bool
204  {
205  return true;
206  }
207 }
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
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)
__construct(Container $dic, ilPlugin $plugin)
Explorer class that works on tree objects (Services/Tree)
static _lookupSelfEvaluation(int $a_obj_id)