ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilSkillTemplateTreeExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
23 
30 {
32  protected int $requested_skill_node_id = 0;
36  protected array $parent = [];
40  protected array $draft = [];
41 
46  public function __construct($a_parent_obj, string $a_parent_cmd, int $tree_id)
47  {
48  global $DIC;
49 
50  $this->lng = $DIC->language();
51  $this->ctrl = $DIC->ctrl();
52  $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
53  $tree = $DIC->skills()->internal()->factory()->tree()->getTreeById($tree_id);
54  parent::__construct("skill_exp", $a_parent_obj, $a_parent_cmd, $tree);
55 
56  $this->requested_skill_node_id = $this->admin_gui_request->getNodeId();
57 
58  $this->setTypeWhiteList(array("skrt", "sktp", "sctp"));
59 
60  $this->setSkipRootNode(false);
61  $this->setAjax(true);
62  $this->setOrderField("order_nr");
63  }
64 
65  public function getRootNode(): array
66  {
67  $path = $this->getTree()->getPathId($this->requested_skill_node_id);
68  return $this->getTree()->getNodeData($path[1]);
69  }
70 
74  public function getChildsOfNode($a_parent_node_id): array
75  {
76  $childs = parent::getChildsOfNode($a_parent_node_id);
77 
78  foreach ($childs as $c) {
79  $this->parent[$c["child"]] = $c["parent"];
80  if ($this->draft[$c["parent"]]) {
81  $this->draft[$c["child"]] = true;
82  } else {
83  $this->draft[$c["child"]] = (ilSkillTreeNode::_lookupStatus((int) $c["child"]) == ilSkillTreeNode::STATUS_DRAFT);
84  }
85  }
86  return $childs;
87  }
88 
92  public function getNodeContent($a_node): string
93  {
94  $lng = $this->lng;
95 
96  // title
97  $title = $a_node["title"];
98 
99  // root?
100  if ($a_node["type"] == "skrt") {
101  $title = $lng->txt("skmg_skill_templates");
102  } else {
103  if ($a_node["type"] == "sktr") {
104  $tid = ilSkillTemplateReference::_lookupTemplateId((int) $a_node["child"]);
105  $title .= " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
106  }
107  if (ilSkillTreeNode::_lookupSelfEvaluation((int) $a_node["child"])) {
108  $title = "<u>" . $title . "</u>";
109  }
110  }
111 
112  return $title;
113  }
114 
118  public function getNodeIcon($a_node): string
119  {
120  // root?
121  if ($a_node["type"] == "skrt") {
122  $icon = ilUtil::getImagePath("standard/icon_sctp.svg");
123  } elseif (in_array($a_node["type"], array("skll", "scat", "sctr", "sktr"))) {
125  $a_node["child"],
126  $a_node["type"],
127  "",
128  (int) $this->draft[$a_node["child"]]
129  );
130  } else {
131  $icon = ilUtil::getImagePath("standard/icon_" . $a_node["type"] . ".svg");
132  }
133 
134  return $icon;
135  }
136 
140  public function isNodeHighlighted($a_node): bool
141  {
142  if ($a_node["child"] == $this->requested_skill_node_id ||
143  ($this->requested_skill_node_id == "" && $a_node["type"] == "skrt")) {
144  return true;
145  }
146  return false;
147  }
148 
152  public function getNodeHref($a_node): string
153  {
154  $ilCtrl = $this->ctrl;
155 
156  switch ($a_node["type"]) {
157  // root
158  case "skrt":
159  $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $a_node["child"]);
160  $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI",
161  "ilObjSkillManagementGUI",
162  "ilSkillTreeAdminGUI",
163  "ilObjSkillTreeGUI",
164  "ilskillrootgui"
165  ], "listTemplates");
166  $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $this->requested_skill_node_id);
167  return $ret;
168 
169  // template
170  case "sktp":
171  $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "node_id", $a_node["child"]);
172  $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI",
173  "ilObjSkillManagementGUI",
174  "ilSkillTreeAdminGUI",
175  "ilObjSkillTreeGUI",
176  "ilbasicskilltemplategui"
177  ], "edit");
178  $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "node_id", $this->requested_skill_node_id);
179  return $ret;
180 
181  // template category
182  case "sctp":
183  $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "node_id", $a_node["child"]);
184  $ret = $ilCtrl->getLinkTargetByClass(["ilAdministrationGUI",
185  "ilObjSkillManagementGUI",
186  "ilSkillTreeAdminGUI",
187  "ilObjSkillTreeGUI",
188  "ilskilltemplatecategorygui"
189  ], "listItems");
190  $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "node_id", $this->requested_skill_node_id);
191  return $ret;
192 
193  default:
194  return "";
195  }
196  }
197 
201  public function getNodeIconAlt($a_node): string
202  {
203  $lng = $this->lng;
204 
205  if ($lng->exists("skmg_" . $a_node["type"])) {
206  return $lng->txt("skmg_" . $a_node["type"]);
207  }
208 
209  return $lng->txt($a_node["type"]);
210  }
211 }
exists(string $a_topic)
Check if language entry exists.
static _lookupStatus(int $a_obj_id)
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 _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)
$c
Definition: deliver.php:9
$path
Definition: ltiservices.php:30
global $DIC
Definition: shib_login.php:25
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...