ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBasicSkillTemplateGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $ctrl;
17
21 protected $lng;
22
26 protected $tabs;
27
31 protected $tpl;
32
36 protected $help;
37
41 protected $toolbar;
42
43
47 public function __construct($a_node_id = 0, $a_tref_id = 0)
48 {
49 global $DIC;
50
51 $this->ctrl = $DIC->ctrl();
52 $this->lng = $DIC->language();
53 $this->tabs = $DIC->tabs();
54 $this->tpl = $DIC["tpl"];
55 $this->help = $DIC["ilHelp"];
56 $this->toolbar = $DIC->toolbar();
57 $ilCtrl = $DIC->ctrl();
58
59 $this->tref_id = $a_tref_id;
60
61 $ilCtrl->saveParameter($this, array("obj_id", "level_id"));
62
63 parent::__construct($a_node_id);
64 }
65
69 public function getType()
70 {
71 return "sktp";
72 }
73
79 public function initForm($a_mode = "edit")
80 {
82 $ilCtrl = $this->ctrl;
83
84 $this->form = new ilPropertyFormGUI();
85
86 // title
87 $ti = new ilTextInputGUI($lng->txt("title"), "title");
88 $ti->setMaxLength(200);
89 $ti->setSize(50);
90 $ti->setRequired(true);
91 $this->form->addItem($ti);
92
93 // description
94 $ta = new ilTextAreaInputGUI($lng->txt("description"), "description");
95 $ta->setRows(5);
96 $this->form->addItem($ta);
97
98 // order nr
99 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
100 $ni->setInfo($lng->txt("skmg_order_nr_info"));
101 $ni->setMaxLength(6);
102 $ni->setSize(6);
103 $ni->setRequired(true);
104 if ($a_mode == "create") {
105 $tree = new ilSkillTree();
106 $max = $tree->getMaxOrderNr((int) $_GET["obj_id"], true);
107 $ni->setValue($max + 10);
108 }
109 $this->form->addItem($ni);
110
111 // save and cancel commands
112 if ($this->checkPermissionBool("write")) {
113 if ($a_mode == "create") {
114 $this->form->addCommandButton("save", $lng->txt("save"));
115 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
116 $this->form->setTitle($lng->txt("skmg_create_skll"));
117 } else {
118 $this->form->addCommandButton("update", $lng->txt("save"));
119 $this->form->setTitle($lng->txt("skmg_edit_skll"));
120 }
121 }
122
123 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
124 $this->form->setFormAction($ilCtrl->getFormAction($this));
125 }
126
130 public function setLevelHead()
131 {
132 $ilTabs = $this->tabs;
133 $ilCtrl = $this->ctrl;
136 $ilHelp = $this->help;
137
138 // tabs
139 $ilTabs->clearTargets();
140 $ilHelp->setScreenIdComponent("skmg_lev");
141 $ilTabs->setBackTarget(
142 $lng->txt("skmg_skill_levels"),
143 $ilCtrl->getLinkTarget($this, "edit")
144 );
145
146 if ($_GET["level_id"] > 0) {
147 if ($this->tref_id == 0) {
148 $ilTabs->addTab(
149 "level_settings",
150 $lng->txt("settings"),
151 $ilCtrl->getLinkTarget($this, "editLevel")
152 );
153 } else {
154 $ilTabs->addTab(
155 "level_resources",
156 $lng->txt("skmg_resources"),
157 $ilCtrl->getLinkTarget($this, "showLevelResources")
158 );
159 }
160
161 /* $ilTabs->addTab("level_trigger",
162 $lng->txt("skmg_trigger"),
163 $ilCtrl->getLinkTarget($this, "editLevelTrigger"));
164
165 $ilTabs->addTab("level_certificate",
166 $lng->txt("certificate"),
167 $ilCtrl->getLinkTargetByClass("ilcertificategui", "certificateEditor"));*/
168 }
169
170 // title
171 if ($_GET["level_id"] > 0) {
172 $tpl->setTitle($lng->txt("skmg_skill_level") . ": " .
173 ilBasicSkill::lookupLevelTitle((int) $_GET["level_id"]));
174 } else {
175 $tpl->setTitle($lng->txt("skmg_skill_level"));
176 }
177
178 $tree = new ilSkillTree();
179 $path = $tree->getPathFull($this->node_object->getId());
180 $desc = "";
181 foreach ($path as $p) {
182 if (in_array($p["type"], array("scat", "skll"))) {
183 $desc .= $sep . $p["title"];
184 $sep = " > ";
185 }
186 }
187 $tpl->setDescription($desc);
188
189 $tpl->setTitleIcon(
191 0,
192 "sktp",
193 "",
194 false
195 )
196 );
197 }
198
205 public function setTabs($a_tab = "")
206 {
207 $ilTabs = $this->tabs;
208 $ilCtrl = $this->ctrl;
211 $ilHelp = $this->help;
212
213 $ilTabs->clearTargets();
214 $ilHelp->setScreenIdComponent("skmg_sktp");
215
216 if ($this->tref_id == 0) {
217 $ilTabs->setBackTarget(
218 $lng->txt("skmg_skill_templates"),
219 $ilCtrl->getLinkTargetByClass("ilobjskillmanagementgui", "editSkillTemplates")
220 );
221 }
222
223 if (is_object($this->node_object)) {
224 if ($this->tref_id == 0) {
225 $tpl->setTitle($lng->txt("skmg_skill_template") . ": " .
226 $this->node_object->getTitle());
227 } else {
228 $tpl->setTitle(
229 $this->node_object->getTitle()
230 );
231 }
232
233 // levels
234 $ilTabs->addTab(
235 "levels",
236 $lng->txt("skmg_skill_levels"),
237 $ilCtrl->getLinkTarget($this, 'edit')
238 );
239
240 // properties
241 if ($this->tref_id == 0) {
242 $ilTabs->addTab(
243 "properties",
244 $lng->txt("settings"),
245 $ilCtrl->getLinkTarget($this, 'editProperties')
246 );
247 }
248
249 // if ($this->tref_id > 0)
250 // {
251 // usage
252 $this->addUsageTab($ilTabs);
253 // }
254
255 // assigned objects
256 $this->addObjectsTab($ilTabs);
257
258 $ilTabs->activateTab($a_tab);
259
260 parent::setTitleIcon();
261
263 } else {
264 $tpl->setTitle($lng->txt("skmg_skill"));
265 $tpl->setDescription("");
266 }
267 }
268
272 public function saveItem()
273 {
274 if (!$this->checkPermissionBool("write")) {
275 return;
276 }
277
278 $it = new ilBasicSkillTemplate();
279 $it->setTitle($this->form->getInput("title"));
280 $it->setDescription($this->form->getInput("description"));
281 $it->setOrderNr($this->form->getInput("order_nr"));
282 $it->create();
283 ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
284 $this->node_object = $it;
285 }
286
290 public function afterSave()
291 {
292 $ilCtrl = $this->ctrl;
293
294 $ilCtrl->setParameterByClass(
295 "ilbasicskilltemplategui",
296 "obj_id",
297 $this->node_object->getId()
298 );
299 $ilCtrl->redirectByClass("ilbasicskilltemplategui", "edit");
300 }
301
308 public function edit()
309 {
311 $ilToolbar = $this->toolbar;
313 $ilCtrl = $this->ctrl;
314
315 $this->setTabs("levels");
316
317 if ($this->isInUse()) {
318 ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
319 } else {
320 if ($this->checkPermissionBool("write")) {
321 if ($this->tref_id == 0) {
322 $ilToolbar->addButton(
323 $lng->txt("skmg_add_level"),
324 $ilCtrl->getLinkTarget($this, "addLevel")
325 );
326 }
327 }
328 }
329
330 $table = new ilSkillLevelTableGUI((int) $_GET["obj_id"], $this, "edit", $this->tref_id, $this->isInUse());
331 $tpl->setContent($table->getHTML());
332 }
333
337 public function showUsage()
338 {
340
341
342 // (a) referenced skill template in main tree
343 if ($this->tref_id > 0) {
344 return parent::showUsage();
345 }
346
347 // (b) skill template in templates view
348
349 $this->setTabs("usage");
350
351 $usage_info = new ilSkillUsage();
352 $usages = $usage_info->getAllUsagesOfTemplate($this->base_skill_id);
353
354 $html = "";
355 foreach ($usages as $k => $usage) {
356 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
357 $html .= $tab->getHTML() . "<br/><br/>";
358 }
359
360 $tpl->setContent($html);
361 }
362
366 public function showObjects()
367 {
369
370 // (a) referenced skill template in main tree
371 if ($this->tref_id > 0) {
372 return parent::showObjects();
373 }
374
375 // (b) skill template in templates view
376
377 $this->setTabs("objects");
378
379 $usage_info = new ilSkillUsage();
380 $objects = $usage_info->getAssignedObjectsForSkillTemplate($this->base_skill_id);
381
382 $tab = new ilSkillAssignedObjectsTableGUI($this, "showObjects", $objects);
383
384 $tpl->setContent($tab->getHTML());
385 }
386}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_LAST_NODE
Definition: class.ilTree.php:4
Basic skill GUI class.
Basic skill template GUI class.
__construct($a_node_id=0, $a_tref_id=0)
Constructor.
setTabs($a_tab="")
Set header for skill.
initForm($a_mode="edit")
Init form.
static lookupLevelTitle(int $a_id)
This class represents a number property in a property form.
This class represents a property form user interface.
TableGUI class for assigned objects of skills.
setSkillNodeDescription()
Set skill node description.
addUsageTab($a_tabs)
Add usage tab.
checkPermissionBool($a_perm)
Check permission pool.
static getIconPath($a_obj_id, $a_type, $a_size="", $a_status=0)
Get icon path.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
TableGUI class for skill usages.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc