ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSkillSelectorGUI.php
Go to the documentation of this file.
1 <?php
2 
21 
28 {
29  protected string $select_gui = "";
30  protected string $select_cmd = "";
31  protected string $select_par = "";
33 
34  public function __construct(
35  $a_parent_obj,
36  string $a_parent_cmd,
37  $a_select_gui,
38  string $a_select_cmd,
39  string $a_select_par = "selected_skill",
40  int $a_skill_tree_id = 0
41  ) {
42  global $DIC;
43 
44  $this->ctrl = $DIC->ctrl();
45  $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
46  parent::__construct("skill_sel", $a_parent_obj, $a_parent_cmd, $a_skill_tree_id);
47  $this->select_gui = (is_object($a_select_gui))
48  ? strtolower(get_class($a_select_gui))
49  : $a_select_gui;
50  $this->select_cmd = $a_select_cmd;
51  $this->select_par = $a_select_par;
52  $this->setSkipRootNode(true);
53  }
54 
55  public function setSkillSelected(string $a_id): void
56  {
57  $this->setNodeSelected($this->vtree->getCSkillIdForVTreeId($a_id));
58  }
59 
60  public function getSelectedSkills(): array
61  {
62  $skills = [];
63  $pa = $this->admin_gui_request->getSelectedIds($this->select_postvar);
64  if (!empty($pa)) {
65  foreach ($pa as $p) {
66  $skills[] = $this->vtree->getCSkillIdForVTreeId($p);
67  }
68  }
69  return $skills;
70  }
71 
75  public function getNodeHref($a_node): string
76  {
77  if ($this->select_multi) {
78  return "#";
79  }
80 
81  $ilCtrl = $this->ctrl;
82 
83  // we have a tree id like <skl_tree_id>:<skl_template_tree_id>
84  // and make a "common" skill id in format <skill_id>:<tref_id>
85 
86  $id_parts = explode(":", $a_node["id"]);
87  if (!isset($id_parts[1]) || $id_parts[1] == 0) {
88  // skill in main tree
89  $skill_id = $a_node["id"];
90  } else {
91  // skill in template
92  $skill_id = $id_parts[1] . ":" . $id_parts[0];
93  }
94 
95  $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, $skill_id);
96  $ret = $ilCtrl->getLinkTargetByClass($this->select_gui, $this->select_cmd);
97  $ilCtrl->setParameterByClass($this->select_gui, $this->select_par, "");
98 
99  return $ret;
100  }
101 
105  public function isNodeClickable($a_node): bool
106  {
107  return $this->nodeHasAction($a_node);
108  }
109 
113  protected function isNodeSelectable($a_node): bool
114  {
115  return $this->nodeHasAction($a_node);
116  }
117 
122  private function nodeHasAction($a_node): bool
123  {
124  if (in_array($a_node["type"], array("skll", "sktp"))) {
125  return true;
126  }
127  // references that refer directly to a (basic) skill template
128  if ($a_node["type"] == "sktr" && ilSkillTreeNode::_lookupType($a_node["skill_id"]) == "sktp") {
129  return true;
130  }
131 
132  return false;
133  }
134 }
Request wrapper for guis in skill administration.
static _lookupType(int $a_obj_id)
global $DIC
Definition: feed.php:28
setNodeSelected($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
Explorer class that works on tree objects (Services/Tree)
SkillAdminGUIRequest $admin_gui_request
__construct(Container $dic, ilPlugin $plugin)
__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)