ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
5 include_once("./Services/Skill/classes/class.ilBasicSkillTemplate.php");
6 include_once("./Services/Skill/classes/class.ilBasicSkillGUI.php");
7 
18 {
19 
23  function __construct($a_node_id = 0, $a_tref_id = 0)
24  {
25  global $ilCtrl;
26 
27  $this->tref_id = $a_tref_id;
28 
29  $ilCtrl->saveParameter($this, array("obj_id", "level_id"));
30 
31  parent::__construct($a_node_id);
32  }
33 
37  function getType()
38  {
39  return "sktp";
40  }
41 
47  public function initForm($a_mode = "edit")
48  {
49  global $lng, $ilCtrl;
50 
51  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
52  $this->form = new ilPropertyFormGUI();
53 
54  // title
55  $ti = new ilTextInputGUI($lng->txt("title"), "title");
56  $ti->setMaxLength(200);
57  $ti->setSize(50);
58  $ti->setRequired(true);
59  $this->form->addItem($ti);
60 
61  // order nr
62  $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
63  $ni->setMaxLength(6);
64  $ni->setSize(6);
65  $ni->setRequired(true);
66  $this->form->addItem($ni);
67 
68  // save and cancel commands
69  if ($this->checkPermissionBool("write"))
70  {
71  if ($a_mode == "create")
72  {
73  $this->form->addCommandButton("save", $lng->txt("save"));
74  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
75  $this->form->setTitle($lng->txt("skmg_create_skll"));
76  } else
77  {
78  $this->form->addCommandButton("update", $lng->txt("save"));
79  $this->form->setTitle($lng->txt("skmg_edit_skll"));
80  }
81  }
82 
83  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
84  $this->form->setFormAction($ilCtrl->getFormAction($this));
85  }
86 
90  function setLevelHead()
91  {
92  global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
93 
94  // tabs
95  $ilTabs->clearTargets();
96  $ilHelp->setScreenIdComponent("skmg_lev");
97  $ilTabs->setBackTarget($lng->txt("skmg_skill_levels"),
98  $ilCtrl->getLinkTarget($this, "edit"));
99 
100  if ($_GET["level_id"] > 0)
101  {
102  if ($this->tref_id == 0)
103  {
104  $ilTabs->addTab("level_settings",
105  $lng->txt("settings"),
106  $ilCtrl->getLinkTarget($this, "editLevel"));
107  }
108  else
109  {
110  $ilTabs->addTab("level_resources",
111  $lng->txt("skmg_resources"),
112  $ilCtrl->getLinkTarget($this, "showLevelResources"));
113  }
114 
115 /* $ilTabs->addTab("level_trigger",
116  $lng->txt("skmg_trigger"),
117  $ilCtrl->getLinkTarget($this, "editLevelTrigger"));
118 
119  $ilTabs->addTab("level_certificate",
120  $lng->txt("certificate"),
121  $ilCtrl->getLinkTargetByClass("ilcertificategui", "certificateEditor"));*/
122  }
123 
124  // title
125  if ($_GET["level_id"] > 0)
126  {
127  $tpl->setTitle($lng->txt("skmg_skill_level").": ".
128  ilBasicSkill::lookupLevelTitle((int) $_GET["level_id"]));
129  }
130  else
131  {
132  $tpl->setTitle($lng->txt("skmg_skill_level"));
133  }
134 
135  include_once("./Services/Skill/classes/class.ilSkillTree.php");
136  $tree = new ilSkillTree();
137  $path = $tree->getPathFull($this->node_object->getId());
138  $desc = "";
139  foreach ($path as $p)
140  {
141  if (in_array($p["type"], array("scat", "skll")))
142  {
143  $desc.= $sep.$p["title"];
144  $sep = " > ";
145  }
146  }
147  $tpl->setDescription($desc);
148 
149  $tpl->setTitleIcon(
151  0, "sktp", "", false));
152 
153  }
154 
161  function setTabs($a_tab = "")
162  {
163  global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
164 
165  $ilTabs->clearTargets();
166  $ilHelp->setScreenIdComponent("skmg_sktp");
167 
168  if ($this->tref_id == 0)
169  {
170  $ilTabs->setBackTarget($lng->txt("skmg_skill_templates"),
171  $ilCtrl->getLinkTargetByClass("ilobjskillmanagementgui", "editSkillTemplates"));
172  }
173 
174  if (is_object($this->node_object))
175  {
176  if ($this->tref_id == 0)
177  {
178  $tpl->setTitle($lng->txt("skmg_skill_template").": ".
179  $this->node_object->getTitle());
180  }
181  else
182  {
183  $tpl->setTitle(
184  $this->node_object->getTitle());
185  }
186 
187  // levels
188  $ilTabs->addTab("levels", $lng->txt("skmg_skill_levels"),
189  $ilCtrl->getLinkTarget($this, 'edit'));
190 
191  // properties
192  if ($this->tref_id == 0)
193  {
194  $ilTabs->addTab("properties", $lng->txt("settings"),
195  $ilCtrl->getLinkTarget($this, 'editProperties'));
196  }
197 
198  // if ($this->tref_id > 0)
199 // {
200  // usage
201  $this->addUsageTab($ilTabs);
202 // }
203 
204  $ilTabs->activateTab($a_tab);
205 
206  parent::setTitleIcon();
207 
208  $this->setSkillNodeDescription();
209  }
210  else
211  {
212  $tpl->setTitle($lng->txt("skmg_skill"));
213  $tpl->setDescription("");
214  }
215  }
216 
220  function saveItem()
221  {
222  if (!$this->checkPermissionBool("write"))
223  {
224  return;
225  }
226 
227  $it = new ilBasicSkillTemplate();
228  $it->setTitle($this->form->getInput("title"));
229  $it->setOrderNr($this->form->getInput("order_nr"));
230  $it->create();
231  ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
232  $this->node_object = $it;
233  }
234 
238  function afterSave()
239  {
240  global $ilCtrl;
241 
242  $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "obj_id",
243  $this->node_object->getId());
244  $ilCtrl->redirectByClass("ilbasicskilltemplategui", "edit");
245  }
246 
253  function edit()
254  {
255  global $tpl, $ilToolbar, $lng, $ilCtrl;
256 
257  $this->setTabs("levels");
258 
259  if ($this->isInUse())
260  {
261  ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
262  }
263  else
264  {
265 
266  if ($this->checkPermissionBool("write"))
267  {
268  if ($this->tref_id == 0)
269  {
270  $ilToolbar->addButton($lng->txt("skmg_add_level"),
271  $ilCtrl->getLinkTarget($this, "addLevel"));
272  }
273  }
274  }
275 
276  include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
277  $table = new ilSkillLevelTableGUI((int) $_GET["obj_id"], $this, "edit", $this->tref_id, $this->isInUse());
278  $tpl->setContent($table->getHTML());
279  }
280 
284  function showUsage()
285  {
286  global $tpl;
287 
288 
289  // (a) referenced skill template in main tree
290  if ($this->tref_id > 0)
291  {
292  return parent::showUsage();
293  }
294 
295  // (b) skill template in templates view
296 
297  $this->setTabs("usage");
298 
299  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
300  $usage_info = new ilSkillUsage();
301  $usages = $usage_info->getAllUsagesOfTemplate($this->base_skill_id);
302 
303  $html = "";
304  include_once("./Services/Skill/classes/class.ilSkillUsageTableGUI.php");
305  foreach ($usages as $k => $usage)
306  {
307  $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
308  $html.= $tab->getHTML()."<br/><br/>";
309  }
310 
311  $tpl->setContent($html);
312  }
313 
314 }
315 ?>
$path
Definition: aliased.php:25
addUsageTab($a_tabs)
Add usage tab.
setTabs($a_tab="")
Set header for skill.
This class represents a property form user interface.
setSkillNodeDescription()
Set skill node description.
static lookupLevelTitle($a_id)
Lookup level title.
Skill tree.
$_GET["client_id"]
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.
setLevelHead()
Set header for level.
initForm($a_mode="edit")
Init form.
global $tpl
Definition: ilias.php:8
checkPermissionBool($a_perm)
Check permission pool.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
This class represents a number property in a property form.
This class represents a text property in a property form.
setMaxLength($a_maxlength)
Set Max Length.
__construct($a_node_id=0, $a_tref_id=0)
Constructor.
TableGUI class for skill usages.
Create styles array
The data for the language used.
const IL_LAST_NODE
Definition: class.ilTree.php:4
setMaxLength($a_maxlength)
Set Max Length.
global $lng
Definition: privfeed.php:17
Basic skill GUI class.
Skill usage.
$html
Definition: example_001.php:87
Basic skill template GUI class.