ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBasicSkillTemplateGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Skill/classes/class.ilBasicSkillTemplate.php");
6include_once("./Services/Skill/classes/class.ilBasicSkillGUI.php");
7
18{
22 protected $ctrl;
23
27 protected $lng;
28
32 protected $tabs;
33
37 protected $tpl;
38
42 protected $help;
43
47 protected $toolbar;
48
49
53 public function __construct($a_node_id = 0, $a_tref_id = 0)
54 {
55 global $DIC;
56
57 $this->ctrl = $DIC->ctrl();
58 $this->lng = $DIC->language();
59 $this->tabs = $DIC->tabs();
60 $this->tpl = $DIC["tpl"];
61 $this->help = $DIC["ilHelp"];
62 $this->toolbar = $DIC->toolbar();
63 $ilCtrl = $DIC->ctrl();
64
65 $this->tref_id = $a_tref_id;
66
67 $ilCtrl->saveParameter($this, array("obj_id", "level_id"));
68
69 parent::__construct($a_node_id);
70 }
71
75 public function getType()
76 {
77 return "sktp";
78 }
79
85 public function initForm($a_mode = "edit")
86 {
89
90 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
91 $this->form = new ilPropertyFormGUI();
92
93 // title
94 $ti = new ilTextInputGUI($lng->txt("title"), "title");
95 $ti->setMaxLength(200);
96 $ti->setSize(50);
97 $ti->setRequired(true);
98 $this->form->addItem($ti);
99
100 // order nr
101 $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
102 $ni->setInfo($lng->txt("skmg_order_nr_info"));
103 $ni->setMaxLength(6);
104 $ni->setSize(6);
105 $ni->setRequired(true);
106 if ($a_mode == "create") {
107 include_once("./Services/Skill/classes/class.ilSkillTree.php");
108 $tree = new ilSkillTree();
109 $max = $tree->getMaxOrderNr((int) $_GET["obj_id"], true);
110 $ni->setValue($max + 10);
111 }
112 $this->form->addItem($ni);
113
114 // save and cancel commands
115 if ($this->checkPermissionBool("write")) {
116 if ($a_mode == "create") {
117 $this->form->addCommandButton("save", $lng->txt("save"));
118 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
119 $this->form->setTitle($lng->txt("skmg_create_skll"));
120 } else {
121 $this->form->addCommandButton("update", $lng->txt("save"));
122 $this->form->setTitle($lng->txt("skmg_edit_skll"));
123 }
124 }
125
126 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
127 $this->form->setFormAction($ilCtrl->getFormAction($this));
128 }
129
133 public function setLevelHead()
134 {
135 $ilTabs = $this->tabs;
139 $ilHelp = $this->help;
140
141 // tabs
142 $ilTabs->clearTargets();
143 $ilHelp->setScreenIdComponent("skmg_lev");
144 $ilTabs->setBackTarget(
145 $lng->txt("skmg_skill_levels"),
146 $ilCtrl->getLinkTarget($this, "edit")
147 );
148
149 if ($_GET["level_id"] > 0) {
150 if ($this->tref_id == 0) {
151 $ilTabs->addTab(
152 "level_settings",
153 $lng->txt("settings"),
154 $ilCtrl->getLinkTarget($this, "editLevel")
155 );
156 } else {
157 $ilTabs->addTab(
158 "level_resources",
159 $lng->txt("skmg_resources"),
160 $ilCtrl->getLinkTarget($this, "showLevelResources")
161 );
162 }
163
164 /* $ilTabs->addTab("level_trigger",
165 $lng->txt("skmg_trigger"),
166 $ilCtrl->getLinkTarget($this, "editLevelTrigger"));
167
168 $ilTabs->addTab("level_certificate",
169 $lng->txt("certificate"),
170 $ilCtrl->getLinkTargetByClass("ilcertificategui", "certificateEditor"));*/
171 }
172
173 // title
174 if ($_GET["level_id"] > 0) {
175 $tpl->setTitle($lng->txt("skmg_skill_level") . ": " .
176 ilBasicSkill::lookupLevelTitle((int) $_GET["level_id"]));
177 } else {
178 $tpl->setTitle($lng->txt("skmg_skill_level"));
179 }
180
181 include_once("./Services/Skill/classes/class.ilSkillTree.php");
182 $tree = new ilSkillTree();
183 $path = $tree->getPathFull($this->node_object->getId());
184 $desc = "";
185 foreach ($path as $p) {
186 if (in_array($p["type"], array("scat", "skll"))) {
187 $desc .= $sep . $p["title"];
188 $sep = " > ";
189 }
190 }
191 $tpl->setDescription($desc);
192
193 $tpl->setTitleIcon(
195 0,
196 "sktp",
197 "",
198 false
199 )
200 );
201 }
202
209 public function setTabs($a_tab = "")
210 {
211 $ilTabs = $this->tabs;
215 $ilHelp = $this->help;
216
217 $ilTabs->clearTargets();
218 $ilHelp->setScreenIdComponent("skmg_sktp");
219
220 if ($this->tref_id == 0) {
221 $ilTabs->setBackTarget(
222 $lng->txt("skmg_skill_templates"),
223 $ilCtrl->getLinkTargetByClass("ilobjskillmanagementgui", "editSkillTemplates")
224 );
225 }
226
227 if (is_object($this->node_object)) {
228 if ($this->tref_id == 0) {
229 $tpl->setTitle($lng->txt("skmg_skill_template") . ": " .
230 $this->node_object->getTitle());
231 } else {
232 $tpl->setTitle(
233 $this->node_object->getTitle()
234 );
235 }
236
237 // levels
238 $ilTabs->addTab(
239 "levels",
240 $lng->txt("skmg_skill_levels"),
241 $ilCtrl->getLinkTarget($this, 'edit')
242 );
243
244 // properties
245 if ($this->tref_id == 0) {
246 $ilTabs->addTab(
247 "properties",
248 $lng->txt("settings"),
249 $ilCtrl->getLinkTarget($this, 'editProperties')
250 );
251 }
252
253 // if ($this->tref_id > 0)
254 // {
255 // usage
256 $this->addUsageTab($ilTabs);
257 // }
258
259 $ilTabs->activateTab($a_tab);
260
261 parent::setTitleIcon();
262
264 } else {
265 $tpl->setTitle($lng->txt("skmg_skill"));
266 $tpl->setDescription("");
267 }
268 }
269
273 public function saveItem()
274 {
275 if (!$this->checkPermissionBool("write")) {
276 return;
277 }
278
279 $it = new ilBasicSkillTemplate();
280 $it->setTitle($this->form->getInput("title"));
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 {
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;
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 include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
331 $table = new ilSkillLevelTableGUI((int) $_GET["obj_id"], $this, "edit", $this->tref_id, $this->isInUse());
332 $tpl->setContent($table->getHTML());
333 }
334
338 public function showUsage()
339 {
341
342
343 // (a) referenced skill template in main tree
344 if ($this->tref_id > 0) {
345 return parent::showUsage();
346 }
347
348 // (b) skill template in templates view
349
350 $this->setTabs("usage");
351
352 include_once("./Services/Skill/classes/class.ilSkillUsage.php");
353 $usage_info = new ilSkillUsage();
354 $usages = $usage_info->getAllUsagesOfTemplate($this->base_skill_id);
355
356 $html = "";
357 include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
358 foreach ($usages as $k => $usage) {
359 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
360 $html .= $tab->getHTML() . "<br/><br/>";
361 }
362
363 $tpl->setContent($html);
364 }
365}
$path
Definition: aliased.php:25
$_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($a_id)
Lookup level title.
This class represents a number property in a property form.
This class represents a property form user interface.
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 property in a property form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
if(empty($password)) $table
Definition: pwgen.php:24
global $DIC
Definition: saml.php:7