ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilSkillSelectorGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
23 
30 {
31  protected string $select_gui = "";
32  protected string $select_cmd = "";
33  protected string $select_par = "";
35 
36  public function __construct(
37  $a_parent_obj,
38  string $a_parent_cmd,
39  $a_select_gui,
40  string $a_select_cmd,
41  string $a_select_par = "selected_skill",
42  int $a_skill_tree_id = 0
43  ) {
44  global $DIC;
45 
46  $this->ctrl = $DIC->ctrl();
47  $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
48  parent::__construct("skill_sel", $a_parent_obj, $a_parent_cmd, $a_skill_tree_id);
49  $this->select_gui = (is_object($a_select_gui))
50  ? strtolower(get_class($a_select_gui))
51  : $a_select_gui;
52  $this->select_cmd = $a_select_cmd;
53  $this->select_par = $a_select_par;
54  $this->setSkipRootNode(true);
55  }
56 
57  public function setSkillSelected(string $a_id): void
58  {
59  $this->setNodeSelected($this->vtree->getCSkillIdForVTreeId($a_id));
60  }
61 
62  public function getSelectedSkills(): array
63  {
64  $skills = [];
65  $pa = $this->admin_gui_request->getSelectedIds($this->select_postvar);
66  if (!empty($pa)) {
67  foreach ($pa as $p) {
68  $skills[] = $this->vtree->getCSkillIdForVTreeId($p);
69  }
70  }
71  return $skills;
72  }
73 
77  public function getNodeHref($a_node): string
78  {
79  if ($this->select_multi) {
80  return "#";
81  }
82 
83  $ilCtrl = $this->ctrl;
84 
85  // we have a tree id like <skl_tree_id>:<skl_template_tree_id>
86  // and make a "common" skill id in format <skill_id>:<tref_id>
87 
88  $id_parts = explode(":", $a_node["id"]);
89  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
90  // skill in main tree
91  $skill_id = $a_node["id"];
92  } else {
93  // skill in template
94  $skill_id = $id_parts[1] . ":" . $id_parts[0];
95  }
96 
97  $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, $skill_id);
98  $ret = $ilCtrl->getLinkTargetByClass($this->select_gui, $this->select_cmd);
99  $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, "");
100 
101  return $ret;
102  }
103 
107  public function isNodeClickable($a_node): bool
108  {
109  return $this->nodeHasAction($a_node);
110  }
111 
115  protected function isNodeSelectable($a_node): bool
116  {
117  return $this->nodeHasAction($a_node);
118  }
119 
124  private function nodeHasAction($a_node): bool
125  {
126  if (in_array($a_node["type"], array("skll", "sktp"))) {
127  return true;
128  }
129  // references that refer directly to a (basic) skill template
130  if ($a_node["type"] == "sktr" && ilSkillTreeNode::_lookupType((int) $a_node["skill_id"]) == "sktp") {
131  return true;
132  }
133 
134  return false;
135  }
136 }
Request wrapper for guis in skill administration.
static _lookupType(int $a_obj_id)
setNodeSelected($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
global $DIC
Definition: shib_login.php:25
Explorer class that works on tree objects (Services/Tree)
SkillAdminGUIRequest $admin_gui_request
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct( $a_parent_obj, string $a_parent_cmd, $a_select_gui, string $a_select_cmd, string $a_select_par="selected_skill", int $a_skill_tree_id=0)