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