ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBasicSkillTemplateGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30{
31 protected ilCtrl $ctrl;
32 protected ilLanguage $lng;
33 protected ilTabsGUI $tabs;
35 protected ilHelpGUI $help;
37
38 public function __construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id = 0, int $a_tref_id = 0)
39 {
40 global $DIC;
41
42 $this->ctrl = $DIC->ctrl();
43 $this->lng = $DIC->language();
44 $this->tabs = $DIC->tabs();
45 $this->tpl = $DIC["tpl"];
46 $this->help = $DIC["ilHelp"];
47 $this->toolbar = $DIC->toolbar();
48 $ilCtrl = $DIC->ctrl();
49
50 $this->tref_id = $a_tref_id;
51
52 $ilCtrl->saveParameter($this, array("node_id", "level_id"));
53
54 parent::__construct($node_manager, $a_node_id);
55 }
56
57 public function getType(): string
58 {
59 return "sktp";
60 }
61
62 public function initForm(string $a_mode = "edit"): void
63 {
65 $ilCtrl = $this->ctrl;
66
67 $this->form = new ilPropertyFormGUI();
68
69 // title
70 $ti = new ilTextInputGUI($lng->txt("title"), "title");
71 $ti->setMaxLength(200);
72 $ti->setSize(50);
73 $ti->setRequired(true);
74 $this->form->addItem($ti);
75
76 // description
77 $ta = new ilTextAreaInputGUI($lng->txt("description"), "description");
78 $ta->setRows(5);
79 $this->form->addItem($ta);
80
81 // save and cancel commands
82 if ($this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
83 if ($a_mode == "create") {
84 $this->form->addCommandButton("save", $lng->txt("save"));
85 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
86 $this->form->setTitle($lng->txt("skmg_create_skll"));
87 } else {
88 $this->form->addCommandButton("update", $lng->txt("save"));
89 $this->form->setTitle($lng->txt("skmg_edit_skll"));
90 }
91 } else {
92 foreach ($this->form->getItems() as $item) {
93 $item->setDisabled(true);
94 }
95 }
96
97 $ilCtrl->setParameter($this, "node_id", $this->requested_node_id);
98 $this->form->setFormAction($ilCtrl->getFormAction($this));
99 }
100
101 public function setLevelHead(): void
102 {
103 $ilTabs = $this->tabs;
104 $ilCtrl = $this->ctrl;
107 $ilHelp = $this->help;
108
109 // tabs
110 $ilTabs->clearTargets();
111 $ilHelp->setScreenIdComponent("skmg_lev");
112 $ilTabs->setBackTarget(
113 $lng->txt("skmg_skill_levels"),
114 $ilCtrl->getLinkTarget($this, "edit")
115 );
116
117 if ($this->requested_level_id > 0) {
118 if ($this->tref_id == 0) {
119 $ilTabs->addTab(
120 "level_settings",
121 $lng->txt("settings"),
122 $ilCtrl->getLinkTarget($this, "editLevel")
123 );
124 } else {
125 $ilTabs->addTab(
126 "level_resources",
127 $lng->txt("skmg_resources"),
128 $ilCtrl->getLinkTarget($this, "showLevelResources")
129 );
130 }
131 }
132
133 // title
134 if ($this->requested_level_id > 0) {
135 $tpl->setTitle($lng->txt("skmg_skill_level") . ": " .
136 ilBasicSkill::lookupLevelTitle($this->requested_level_id));
137 } else {
138 $tpl->setTitle($lng->txt("skmg_skill_level"));
139 }
140
141 $desc = $this->skill_tree_node_manager->getWrittenPath($this->node_object->getId());
142 $tpl->setDescription($desc);
143
146 0,
147 "sktp",
148 "",
149 0
150 )
151 );
152 }
153
154 public function setTabs(string $a_tab = "levels"): void
155 {
156 $ilTabs = $this->tabs;
157 $ilCtrl = $this->ctrl;
160 $ilHelp = $this->help;
161
162 $ilTabs->clearTargets();
163 $ilHelp->setScreenIdComponent("skmg_sktp");
164
165 $parent_node_id = $this->tree_repo->getParentNodeIdForNodeId($this->requested_node_id);
166 $parent_title = ilSkillTreeNode::_lookupTitle($parent_node_id);
167 $parent_type = ilSkillTreeNode::_lookupType($parent_node_id);
168
169 if ($this->tref_id == 0) {
170 if ($parent_type === "sctp") {
171 $ilCtrl->setParameterByClass(
172 "ilskilltemplatecategorygui",
173 "node_id",
174 $parent_node_id
175 );
176 $ilTabs->setBackTarget(
177 $parent_title,
178 $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "listItems")
179 );
180 $ilCtrl->setParameterByClass(
181 "ilskilltemplatecategorygui",
182 "node_id",
183 ""
184 );
185 } else {
186 $ilTabs->setBackTarget(
187 $lng->txt("skmg_skill_templates"),
188 $ilCtrl->getLinkTargetByClass("ilobjskilltreegui", "editSkillTemplates")
189 );
190 }
191 }
192
193 if (is_object($this->node_object)) {
194 if ($this->tref_id == 0) {
195 $tpl->setTitle($lng->txt("skmg_skill_template") . ": " .
196 $this->node_object->getTitle());
197 } else {
198 $tpl->setTitle(
199 $this->node_object->getTitle()
200 );
201 }
202
203 // levels
204 $ilTabs->addTab(
205 "levels",
206 $lng->txt("skmg_skill_levels"),
207 $ilCtrl->getLinkTarget($this, 'edit')
208 );
209
210 // properties
211 if ($this->tref_id == 0) {
212 $ilTabs->addTab(
213 "properties",
214 $lng->txt("settings"),
215 $ilCtrl->getLinkTarget($this, 'editProperties')
216 );
217 }
218
219 // if ($this->tref_id > 0)
220 // {
221 // usage
222 $this->addUsageTab($ilTabs);
223 // }
224
225 // assigned objects
226 $this->addObjectsTab($ilTabs);
227
228 $ilTabs->activateTab($a_tab);
229
230 parent::setTitleIcon();
231
233 } else {
234 $tpl->setTitle($lng->txt("skmg_skill"));
235 $tpl->setDescription("");
236 }
237 }
238
239 public function saveItem(): void
240 {
241 if (!$this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
242 return;
243 }
244
245 $it = new ilBasicSkillTemplate();
246 $it->setTitle($this->form->getInput("title"));
247 $it->setDescription($this->form->getInput("description"));
248 $it->create();
249 $this->skill_tree_node_manager->putIntoTree($it, $this->requested_node_id, ilTree::POS_LAST_NODE);
250 $this->node_object = $it;
251 }
252
253 public function afterSave(): void
254 {
255 $ilCtrl = $this->ctrl;
256
257 if (!$this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
258 return;
259 }
260
261 $ilCtrl->setParameterByClass(
262 "ilbasicskilltemplategui",
263 "node_id",
264 $this->node_object->getId()
265 );
266 $ilCtrl->redirectByClass("ilbasicskilltemplategui", "edit");
267 }
268
269 public function edit(): void
270 {
272 $ilToolbar = $this->toolbar;
274 $ilCtrl = $this->ctrl;
275
276 $this->setTabs("levels");
277
278 if ($this->isInUse()) {
279 $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_in_use"));
280 } elseif ($this->tree_access_manager->hasManageCompetenceTemplatesPermission()) {
281 if ($this->tref_id == 0) {
282 $ilToolbar->addButton(
283 $lng->txt("skmg_add_level"),
284 $ilCtrl->getLinkTarget($this, "addLevel")
285 );
286 }
287 }
288
289 $table = new ilSkillLevelTableGUI(
290 $this->requested_node_id,
291 $this,
292 "edit",
293 $this->tref_id,
294 $this->isInUse(),
295 $this->tree_access_manager->hasManageCompetenceTemplatesPermission()
296 );
297 $tpl->setContent($table->getHTML());
298 }
299
300 public function showUsage(): void
301 {
303
304
305 // (a) referenced skill template in main tree
306 if ($this->tref_id > 0) {
307 parent::showUsage();
308 return;
309 }
310
311 // (b) skill template in templates view
312
313 $this->setTabs("usage");
314
315 $usages = $this->usage_manager->getAllUsagesOfTemplate($this->base_skill_id);
316
317 $html = "";
318 foreach ($usages as $k => $usage) {
319 $usages_ui = $this->skill_ui_service->getUsagesUI($k, $usage);
320 $html .= $usages_ui->render() . "<br/><br/>";
321 }
322
323 $tpl->setContent($html);
324 }
325
326 public function showObjects(): void
327 {
329
330 // (a) referenced skill template in main tree
331 if ($this->tref_id > 0) {
332 parent::showObjects();
333 return;
334 }
335
336 // (b) skill template in templates view
337
338 $this->setTabs("objects");
339
340 $objects = $this->usage_manager->getAssignedObjectsForSkillTemplate($this->base_skill_id);
341
342 $table = $this->table_manager->getAssignedObjectsTable(
343 $this,
344 $objects,
345 $this->base_skill_id
346 )->getComponent();
347
348 $tpl->setContent($this->ui_ren->render($table));
349 }
350
351 public function redirectToParent(bool $a_tmp_mode = false): void
352 {
353 $ilCtrl = $this->ctrl;
354
355 $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $this->requested_node_id);
356 $ilCtrl->redirectByClass("ilskillrootgui", "listTemplates");
357 }
358}
Basic skill GUI class.
Basic skill template GUI class.
__construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id=0, int $a_tref_id=0)
redirectToParent(bool $a_tmp_mode=false)
Redirect to parent (identified by current node_id)
static lookupLevelTitle(int $a_id)
Class ilCtrl provides processing control methods.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
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.
addUsageTab(ilTabsGUI $a_tabs)
addObjectsTab(ilTabsGUI $a_tabs)
static getIconPath(int $a_obj_id, string $a_type, string $a_size="", int $a_status=0)
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const POS_LAST_NODE
setDescription(string $a_descr)
Sets description below title in standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setContent(string $a_html)
Sets content for standard template.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
global $DIC
Definition: shib_login.php:26