ILIAS  release_8 Revision v8.24
class.ilSkillCategoryGUI.php
Go to the documentation of this file.
1<?php
2
21
30{
31 protected ilCtrl $ctrl;
33 protected ilTabsGUI $tabs;
34 protected ilLanguage $lng;
35 protected ilHelpGUI $help;
36
37 public function __construct(Tree\SkillTreeNodeManager $node_manager, int $a_node_id = 0)
38 {
39 global $DIC;
40
41 $this->ctrl = $DIC->ctrl();
42 $this->tpl = $DIC["tpl"];
43 $this->tabs = $DIC->tabs();
44 $this->lng = $DIC->language();
45 $this->help = $DIC["ilHelp"];
46 $ilCtrl = $DIC->ctrl();
47
48 $ilCtrl->saveParameter($this, "node_id");
49
50 parent::__construct($node_manager, $a_node_id);
51 }
52
53 public function getType(): string
54 {
55 return "scat";
56 }
57
58 public function executeCommand(): void
59 {
60 $ilCtrl = $this->ctrl;
62 $ilTabs = $this->tabs;
63
64 //$tpl->getStandardTemplate();
65
66 $next_class = $ilCtrl->getNextClass($this);
67 $cmd = $ilCtrl->getCmd();
68
69 switch ($next_class) {
70 default:
71 $ret = $this->$cmd();
72 break;
73 }
74 }
75
76 public function setTabs(string $a_tab): void
77 {
78 $ilTabs = $this->tabs;
79 $ilCtrl = $this->ctrl;
82 $ilHelp = $this->help;
83
84 $ilTabs->clearTargets();
85 $ilHelp->setScreenIdComponent("skmg_scat");
86
87 // content
88 $ilTabs->addTab(
89 "content",
90 $lng->txt("content"),
91 $ilCtrl->getLinkTarget($this, 'listItems')
92 );
93
94 // properties
95 $ilTabs->addTab(
96 "properties",
97 $lng->txt("settings"),
98 $ilCtrl->getLinkTarget($this, 'editProperties')
99 );
100
101 // usage
102 $this->addUsageTab($ilTabs);
103
104 $parent_node_id = $this->tree_repo->getParentNodeIdForNodeId($this->requested_node_id);
105 $parent_title = ilSkillTreeNode::_lookupTitle($parent_node_id);
106 $parent_type = ilSkillTreeNode::_lookupType($parent_node_id);
107
108 // back link
109 if ($parent_type === "scat") {
110 $ilCtrl->setParameter(
111 $this,
112 "node_id",
113 $parent_node_id
114 );
115 $ilTabs->setBackTarget(
116 $parent_title,
117 $ilCtrl->getLinkTarget($this, "listItems")
118 );
119 $ilCtrl->setParameter(
120 $this,
121 "node_id",
122 $this->requested_node_id
123 );
124 } else {
125 $ilCtrl->setParameterByClass(
126 "ilskillrootgui",
127 "node_id",
128 $this->skill_tree_node_manager->getRootId()
129 );
130 $ilTabs->setBackTarget(
131 $lng->txt("skmg_skills"),
132 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills")
133 );
134 $ilCtrl->setParameterByClass(
135 "ilskillrootgui",
136 "node_id",
137 $this->requested_node_id
138 );
139 }
140
141 parent::setTitleIcon();
142 $tpl->setTitle(
143 $lng->txt("scat") . ": " . $this->node_object->getTitle()
144 );
146
147 $ilTabs->activateTab($a_tab);
148 }
149
150 public function editProperties(): void
151 {
153
154 $this->setTabs("properties");
155 parent::editProperties();
156 }
157
158 public function edit(): void
159 {
161
162 $this->initForm();
163 $this->getValues();
164 $tpl->setContent($this->form->getHTML());
165 }
166
167 public function initForm(string $a_mode = "edit"): void
168 {
170 $ilCtrl = $this->ctrl;
171
172 $this->form = new ilPropertyFormGUI();
173
174 // title
175 $ti = new ilTextInputGUI($lng->txt("title"), "title");
176 $ti->setMaxLength(200);
177 $ti->setSize(50);
178 $ti->setRequired(true);
179 $this->form->addItem($ti);
180
181 // description
182 $ta = new ilTextAreaInputGUI($lng->txt("description"), "description");
183 $ta->setRows(5);
184 $this->form->addItem($ta);
185
186 // status
187 $this->addStatusInput($this->form);
188
189 // selectable
190 $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "self_eval");
191 $cb->setInfo($lng->txt("skmg_selectable_info"));
192 $this->form->addItem($cb);
193
194 // save and cancel commands
195 if ($this->tree_access_manager->hasManageCompetencesPermission()) {
196 if ($a_mode == "create") {
197 $this->form->addCommandButton("save", $lng->txt("save"));
198 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
199 $this->form->setTitle($lng->txt("skmg_create_skill_category"));
200 } else {
201 $this->form->addCommandButton("update", $lng->txt("save"));
202 $this->form->setTitle($lng->txt("skmg_edit_scat"));
203 }
204 } else {
205 foreach ($this->form->getItems() as $item) {
206 $item->setDisabled(true);
207 }
208 }
209
210 $ilCtrl->setParameter($this, "node_id", $this->requested_node_id);
211 $this->form->setFormAction($ilCtrl->getFormAction($this));
212 }
213
214 public function saveItem(): void
215 {
216 if (!$this->tree_access_manager->hasManageCompetencesPermission()) {
217 return;
218 }
219
220 $it = new ilSkillCategory();
221 $it->setTitle($this->form->getInput("title"));
222 $it->setDescription($this->form->getInput("description"));
223 $it->setSelfEvaluation((bool) $this->form->getInput("self_eval"));
224 $it->setStatus($this->form->getInput("status"));
225 $it->create();
226 $this->skill_tree_node_manager->putIntoTree($it, $this->requested_node_id, ilTree::POS_LAST_NODE);
227 }
228
232 public function getValues(): void
233 {
234 $values = [];
235 $values["title"] = $this->node_object->getTitle();
236 $values["description"] = $this->node_object->getDescription();
237 $values["self_eval"] = $this->node_object->getSelfEvaluation();
238 $values["status"] = $this->node_object->getStatus();
239 $this->form->setValuesByArray($values);
240 }
241
242 public function updateItem(): void
243 {
244 if (!$this->tree_access_manager->hasManageCompetencesPermission()) {
245 return;
246 }
247
248 $this->node_object->setTitle($this->form->getInput("title"));
249 $this->node_object->setDescription($this->form->getInput("description"));
250 $this->node_object->setSelfEvaluation((bool) $this->form->getInput("self_eval"));
251 $this->node_object->setStatus($this->form->getInput("status"));
252 $this->node_object->update();
253 }
254
255 public function listItems(): void
256 {
259
260 if ($this->isInUse()) {
261 $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_in_use"));
262 }
263
264 if ($this->tree_access_manager->hasManageCompetencesPermission()) {
266 }
267 $this->setTabs("content");
268
269 $table = new ilSkillCatTableGUI(
270 $this,
271 "listItems",
272 $this->requested_node_id,
274 );
275
276 $tpl->setContent($table->getHTML());
277 }
278
279 public static function addCreationButtons(): void
280 {
281 global $DIC;
282
283 $ilCtrl = $DIC->ctrl();
284 $lng = $DIC->language();
285 $ilToolbar = $DIC->toolbar();
286 $ilUser = $DIC->user();
287 $admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
288
290
291 // skill
292 $ilCtrl->setParameterByClass(
293 "ilbasicskillgui",
294 "node_id",
296 );
297 $ilToolbar->addButton(
298 $lng->txt("skmg_create_skll"),
299 $ilCtrl->getLinkTargetByClass("ilbasicskillgui", "create")
300 );
301
302 // skill category
303 $ilCtrl->setParameterByClass(
304 "ilskillcategorygui",
305 "node_id",
307 );
308 $ilToolbar->addButton(
309 $lng->txt("skmg_create_skill_category"),
310 $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "create")
311 );
312
313 // skill template reference
314 $ilCtrl->setParameterByClass(
315 "ilskilltemplatereferencegui",
316 "node_id",
318 );
319 $ilToolbar->addButton(
320 $lng->txt("skmg_create_skill_template_reference"),
321 $ilCtrl->getLinkTargetByClass("ilskilltemplatereferencegui", "create")
322 );
323
324 // skills from clipboard
325 $sep = false;
326 if ($ilUser->clipboardHasObjectsOfType("skll")) {
327 $ilToolbar->addSeparator();
328 $sep = true;
329 $ilToolbar->addButton(
330 $lng->txt("skmg_insert_basic_skill_from_clip"),
331 $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertBasicSkillClip")
332 );
333 }
334
335 // skills from clipboard
336 if ($ilUser->clipboardHasObjectsOfType("scat")) {
337 if (!$sep) {
338 $ilToolbar->addSeparator();
339 $sep = true;
340 }
341 $ilToolbar->addButton(
342 $lng->txt("skmg_insert_skill_category_from_clip"),
343 $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertSkillCategoryClip")
344 );
345 }
346
347 // skills from clipboard
348 if ($ilUser->clipboardHasObjectsOfType("sktr")) {
349 if (!$sep) {
350 $ilToolbar->addSeparator();
351 $sep = true;
352 }
353 $ilToolbar->addButton(
354 $lng->txt("skmg_insert_skill_template_reference_from_clip"),
355 $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertTemplateReferenceClip")
356 );
357 }
358
359 // skill template reference
360 $ilToolbar->addButton(
361 $lng->txt("skmg_import_skills"),
362 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "showImportForm")
363 );
364 }
365
369 public function redirectToParent(bool $a_tmp_mode = false): void
370 {
371 $ilCtrl = $this->ctrl;
372
373 $t = ilSkillTreeNode::_lookupType($this->requested_node_id);
374
375 switch ($t) {
376 case "skrt":
377 $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $this->requested_node_id);
378 $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
379 break;
380 }
381
382 parent::redirectToParent();
383 }
384}
This class represents a checkbox property in a property form.
Class ilCtrl provides processing control methods.
Help GUI class.
setScreenIdComponent(string $a_comp)
language handling
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...
This class represents a property form user interface.
Skill category GUI class.
redirectToParent(bool $a_tmp_mode=false)
Redirect to parent (identified by current node_id)
ilGlobalTemplateInterface $tpl
__construct(Tree\SkillTreeNodeManager $node_manager, int $a_node_id=0)
getValues()
Get current values for from.
initForm(string $a_mode="edit")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Basic GUI class for skill tree nodes.
addUsageTab(ilTabsGUI $a_tabs)
SkillAdminGUIRequest $admin_gui_request
addStatusInput(ilPropertyFormGUI $a_form)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
static _lookupType(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
const POS_LAST_NODE
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...