ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillCatTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
30{
32 protected int $tref_id = 0;
33 protected int $mode = 0;
36 protected bool $manage_perm = false;
38 protected int $requested_node_id = 0;
39 protected int $requested_tref_id = 0;
40 protected int $requested_ref_id = 0;
41 protected \ILIAS\UI\Factory $ui_fac;
42 protected \ILIAS\UI\Renderer $ui_ren;
43
44 public const MODE_SCAT = 0;
45 public const MODE_SCTP = 1;
46
47 public function __construct(
48 $a_parent_obj,
49 string $a_parent_cmd,
50 int $a_obj_id,
51 int $a_mode = self::MODE_SCAT,
52 int $a_tref_id = 0
53 ) {
54 global $DIC;
55
56 $this->ctrl = $DIC->ctrl();
57 $this->lng = $DIC->language();
58 $this->access = $DIC->access();
59 $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
60 $this->ui_fac = $DIC->ui()->factory();
61 $this->ui_ren = $DIC->ui()->renderer();
62
63 $ilCtrl = $DIC->ctrl();
64 $lng = $DIC->language();
65
66 $this->tref_id = $a_tref_id;
67 $ilCtrl->setParameter($a_parent_obj, "tmpmode", $a_mode);
68
69 $this->requested_node_id = $this->admin_gui_request->getNodeId();
70 $this->requested_tref_id = $this->admin_gui_request->getTrefId();
71 $this->requested_ref_id = $this->admin_gui_request->getRefId();
72
73 $this->mode = $a_mode;
74 $this->skill_tree = $DIC->skills()->internal()->repo()->getTreeRepo()->getTreeForNodeId($a_obj_id);
75 $this->tree_access_manager = $DIC->skills()->internal()->manager()->getTreeAccessManager($this->requested_ref_id);
76
77 parent::__construct($a_parent_obj, $a_parent_cmd);
78
79 if ($this->mode == self::MODE_SCAT) {
80 $this->manage_perm = $this->tree_access_manager->hasManageCompetencesPermission();
81 $childs = $this->skill_tree->getChildsByTypeFilter(
82 $a_obj_id,
83 array("skrt", "skll", "scat", "sktr")
84 );
85 $childs = ilArrayUtil::sortArray($childs, "order_nr", "asc", true);
86 $this->setData($childs);
87 } elseif ($this->mode == self::MODE_SCTP) {
88 $this->manage_perm = $this->tree_access_manager->hasManageCompetenceTemplatesPermission();
89 $childs = $this->skill_tree->getChildsByTypeFilter(
90 $a_obj_id,
91 array("skrt", "sktp", "sctp")
92 );
93 $childs = ilArrayUtil::sortArray($childs, "order_nr", "asc", true);
94 $this->setData($childs);
95 }
96
97 $this->setTitle($lng->txt("skmg_items"));
98
99 if ($this->tref_id == 0 && $this->manage_perm) {
100 $this->addColumn($this->lng->txt(""), "", "1px", true);
101 }
102 $this->addColumn($this->lng->txt("type"), "", "1px");
103 if ($this->tref_id == 0) {
104 $this->addColumn($this->lng->txt("skmg_order"), "", "1px");
105 }
106 $this->addColumn($this->lng->txt("title"));
107
108 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
109 $this->setRowTemplate("tpl.skill_cat_row.html", "components/ILIAS/Skill");
110
111 if ($this->tref_id == 0 && $this->manage_perm) {
112 $this->addMultiCommand("cutItems", $lng->txt("cut"));
113 $this->addMultiCommand("copyItems", $lng->txt("copy"));
114 $this->addMultiCommand("deleteNodes", $lng->txt("delete"));
115 if ($a_mode == self::MODE_SCAT) {
116 $this->addMultiCommand("exportSelectedNodes", $lng->txt("export"));
117 }
118 $this->addCommandButton("saveOrder", $lng->txt("skmg_save_order"));
119 }
120 }
121
122 protected function fillRow(array $a_set): void
123 {
125 $ilCtrl = $this->ctrl;
126
127 $ret = "";
128 switch ($a_set["type"]) {
129 // category
130 case "scat":
131 $ilCtrl->setParameterByClass("ilskillcategorygui", "node_id", $a_set["child"]);
132 $ret = $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "listItems");
133 $ilCtrl->setParameterByClass("ilskillcategorygui", "node_id", $this->requested_node_id);
134 break;
135
136 // skill template reference
137 case "sktr":
138 $tid = ilSkillTemplateReference::_lookupTemplateId((int) $a_set["child"]);
139 $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "tref_id", $a_set["child"]);
140 $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "node_id", $tid);
141 $ret = $ilCtrl->getLinkTargetByClass("ilskilltemplatereferencegui", "listItems");
142 $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "node_id", $this->requested_node_id);
143 $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "tref_id", $this->requested_tref_id);
144 break;
145
146 // skill
147 case "skll":
148 $ilCtrl->setParameterByClass("ilbasicskillgui", "node_id", $a_set["child"]);
149 $ret = $ilCtrl->getLinkTargetByClass("ilbasicskillgui", "edit");
150 $ilCtrl->setParameterByClass("ilbasicskillgui", "node_id", $this->requested_node_id);
151 break;
152
153 // --------
154
155 // template
156 case "sktp":
157 $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "node_id", $a_set["child"]);
158 $ret = $ilCtrl->getLinkTargetByClass("ilbasicskilltemplategui", "edit");
159 $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "node_id", $this->requested_node_id);
160 break;
161
162 // template category
163 case "sctp":
164 $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "node_id", $a_set["child"]);
165 $ret = $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "listItems");
166 $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "node_id", $this->requested_node_id);
167 break;
168 }
169
170 if ($this->tref_id == 0) {
171 if ($this->manage_perm) {
172 $this->tpl->setCurrentBlock("cb");
173 $this->tpl->setVariable("CB_ID", $a_set["child"]);
174 $this->tpl->parseCurrentBlock();
175 }
176
177 $this->tpl->setCurrentBlock("nr");
178 $this->tpl->setVariable("OBJ_ID", $a_set["child"]);
179 $this->tpl->setVariable("ORDER_NR", $a_set["order_nr"]);
180 if (!$this->manage_perm) {
181 $this->tpl->touchBlock("disabled");
182 }
183 $this->tpl->parseCurrentBlock();
184 }
185
186 $this->tpl->setVariable("HREF_TITLE", $ret);
187
188 $this->tpl->setVariable("TITLE", $a_set["title"]);
189 $icon_path = ilSkillTreeNode::getIconPath(
190 (int) $a_set["child"],
191 $a_set["type"],
192 "",
193 ilSkillTreeNode::_lookupStatus((int) $a_set["child"])
194 );
195 $icon = $this->ui_fac->symbol()->icon()->custom(
196 $icon_path,
197 "",
198 "medium"
199 );
200 $this->tpl->setVariable("ICON", $this->ui_ren->render($icon));
201 }
202}
Request wrapper for guis in skill administration.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
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...
__construct( $a_parent_obj, string $a_parent_cmd, int $a_obj_id, int $a_mode=self::MODE_SCAT, int $a_tref_id=0)
SkillTreeAccess $tree_access_manager
SkillAdminGUIRequest $admin_gui_request
fillRow(array $a_set)
Standard Version of Fill Row.
static getIconPath(int $a_obj_id, string $a_type, string $a_size="", int $a_status=0)
static _lookupStatus(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
ilLanguage $lng
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26