ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillTemplateTreeExplorerGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29{
31 protected int $requested_skill_node_id = 0;
35 protected array $parent = [];
39 protected array $draft = [];
40
45 public function __construct($a_parent_obj, string $a_parent_cmd, int $tree_id)
46 {
47 global $DIC;
48
49 $this->lng = $DIC->language();
50 $this->ctrl = $DIC->ctrl();
51 $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
52 $tree = $DIC->skills()->internal()->factory()->tree()->getTreeById($tree_id);
53 parent::__construct("skill_exp", $a_parent_obj, $a_parent_cmd, $tree);
54
55 $this->requested_skill_node_id = $this->admin_gui_request->getNodeId();
56
57 $this->setTypeWhiteList(array("skrt", "sktp", "sctp"));
58
59 $this->setSkipRootNode(false);
60 $this->setAjax(true);
61 $this->setOrderField("order_nr");
62 }
63
64 public function getRootNode(): array
65 {
66 $path = $this->getTree()->getPathId($this->requested_skill_node_id);
67 return $this->getTree()->getNodeData($path[1]);
68 }
69
73 public function getChildsOfNode($a_parent_node_id): array
74 {
75 $childs = parent::getChildsOfNode($a_parent_node_id);
76
77 foreach ($childs as $c) {
78 $this->parent[$c["child"]] = $c["parent"];
79 if ($this->draft[$c["parent"]]) {
80 $this->draft[$c["child"]] = true;
81 } else {
82 $this->draft[$c["child"]] = (ilSkillTreeNode::_lookupStatus((int) $c["child"]) == ilSkillTreeNode::STATUS_DRAFT);
83 }
84 }
85 return $childs;
86 }
87
91 public function getNodeContent($a_node): string
92 {
94
95 // title
96 $title = $a_node["title"];
97
98 // root?
99 if ($a_node["type"] == "skrt") {
100 $title = $lng->txt("skmg_skill_templates");
101 } else {
102 if ($a_node["type"] == "sktr") {
103 $tid = ilSkillTemplateReference::_lookupTemplateId((int) $a_node["child"]);
104 $title .= " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
105 }
106 if (ilSkillTreeNode::_lookupSelfEvaluation((int) $a_node["child"])) {
107 $title = "<u>" . $title . "</u>";
108 }
109 }
110
111 return $title;
112 }
113
117 public function getNodeIcon($a_node): string
118 {
119 // root?
120 if ($a_node["type"] == "skrt") {
121 $icon = ilUtil::getImagePath("standard/icon_sctp.svg");
122 } elseif (in_array($a_node["type"], array("skll", "scat", "sctr", "sktr"))) {
124 $a_node["child"],
125 $a_node["type"],
126 "",
127 (int) $this->draft[$a_node["child"]]
128 );
129 } else {
130 $icon = ilUtil::getImagePath("standard/icon_" . $a_node["type"] . ".svg");
131 }
132
133 return $icon;
134 }
135
139 public function isNodeHighlighted($a_node): bool
140 {
141 if ($a_node["child"] == $this->requested_skill_node_id ||
142 ($this->requested_skill_node_id == "" && $a_node["type"] == "skrt")) {
143 return true;
144 }
145 return false;
146 }
147
151 public function getNodeHref($a_node): string
152 {
153 $ilCtrl = $this->ctrl;
154
155 switch ($a_node["type"]) {
156 // root
157 case "skrt":
158 $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $a_node["child"]);
159 $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI",
160 "ilObjSkillManagementGUI",
161 "ilSkillTreeAdminGUI",
162 "ilObjSkillTreeGUI",
163 "ilskillrootgui"
164 ], "listTemplates");
165 $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $this->requested_skill_node_id);
166 return $ret;
167
168 // template
169 case "sktp":
170 $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "node_id", $a_node["child"]);
171 $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI",
172 "ilObjSkillManagementGUI",
173 "ilSkillTreeAdminGUI",
174 "ilObjSkillTreeGUI",
175 "ilbasicskilltemplategui"
176 ], "edit");
177 $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "node_id", $this->requested_skill_node_id);
178 return $ret;
179
180 // template category
181 case "sctp":
182 $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "node_id", $a_node["child"]);
183 $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI",
184 "ilObjSkillManagementGUI",
185 "ilSkillTreeAdminGUI",
186 "ilObjSkillTreeGUI",
187 "ilskilltemplatecategorygui"
188 ], "listItems");
189 $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "node_id", $this->requested_skill_node_id);
190 return $ret;
191
192 default:
193 return "";
194 }
195 }
196
200 public function getNodeIconAlt($a_node): string
201 {
203
204 if ($lng->exists("skmg_" . $a_node["type"])) {
205 return $lng->txt("skmg_" . $a_node["type"]);
206 }
207
208 return $lng->txt($a_node["type"]);
209 }
210}
Request wrapper for guis in skill administration.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
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...
Explorer class that works on tree objects (Services/Tree)
__construct($a_parent_obj, string $a_parent_cmd, int $tree_id)
isNodeHighlighted($a_node)
Is node highlighted?bool node highlighted true/false
getNodeIcon($a_node)
Get node icon path.string image file path
getNodeIconAlt($a_node)
Get node icon alt attribute.string image alt attribute
getChildsOfNode($a_parent_node_id)
Get childs of node.array childs
getNodeContent($a_node)
Get content of a node.string content of the node
getNodeHref($a_node)
Get href for node.string href attribute
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 _lookupStatus(int $a_obj_id)
Explorer class that works on tree objects (Services/Tree)
setOrderField(string $a_val, bool $a_numeric=false)
setTypeWhiteList(array $a_val)
Set type white list.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: deliver.php:25
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26