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