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