ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 ($a_mode == "create")
70  {
71  $this->form->addCommandButton("save", $lng->txt("save"));
72  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
73  $this->form->setTitle($lng->txt("skmg_create_skll"));
74  }
75  else
76  {
77  $this->form->addCommandButton("update", $lng->txt("save"));
78  $this->form->setTitle($lng->txt("skmg_edit_skll"));
79  }
80 
81  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
82  $this->form->setFormAction($ilCtrl->getFormAction($this));
83  }
84 
88  function setLevelHead()
89  {
90  global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
91 
92  // tabs
93  $ilTabs->clearTargets();
94  $ilHelp->setScreenIdComponent("skmg_lev");
95  $ilTabs->setBackTarget($lng->txt("skmg_skill_levels"),
96  $ilCtrl->getLinkTarget($this, "edit"));
97 
98  if ($_GET["level_id"] > 0)
99  {
100  if ($this->tref_id == 0)
101  {
102  $ilTabs->addTab("level_settings",
103  $lng->txt("settings"),
104  $ilCtrl->getLinkTarget($this, "editLevel"));
105  }
106  else
107  {
108  $ilTabs->addTab("level_resources",
109  $lng->txt("skmg_resources"),
110  $ilCtrl->getLinkTarget($this, "showLevelResources"));
111  }
112 
113 /* $ilTabs->addTab("level_trigger",
114  $lng->txt("skmg_trigger"),
115  $ilCtrl->getLinkTarget($this, "editLevelTrigger"));
116 
117  $ilTabs->addTab("level_certificate",
118  $lng->txt("certificate"),
119  $ilCtrl->getLinkTargetByClass("ilcertificategui", "certificateEditor"));*/
120  }
121 
122  // title
123  if ($_GET["level_id"] > 0)
124  {
125  $tpl->setTitle($lng->txt("skmg_skill_level").": ".
126  ilBasicSkill::lookupLevelTitle((int) $_GET["level_id"]));
127  }
128  else
129  {
130  $tpl->setTitle($lng->txt("skmg_skill_level"));
131  }
132 
133  include_once("./Services/Skill/classes/class.ilSkillTree.php");
134  $tree = new ilSkillTree();
135  $path = $tree->getPathFull($this->node_object->getId());
136  $desc = "";
137  foreach ($path as $p)
138  {
139  if (in_array($p["type"], array("scat", "skll")))
140  {
141  $desc.= $sep.$p["title"];
142  $sep = " > ";
143  }
144  }
145  $tpl->setDescription($desc);
146 
147  $tpl->setTitleIcon(
149  0, "sktp", "_b", false));
150 
151  }
152 
159  function setTabs($a_tab)
160  {
161  global $ilTabs, $ilCtrl, $tpl, $lng, $ilHelp;
162 
163  $ilTabs->clearTargets();
164  $ilHelp->setScreenIdComponent("skmg_sktp");
165 
166  if ($this->tref_id == 0)
167  {
168  $ilTabs->setBackTarget($lng->txt("skmg_skill_templates"),
169  $ilCtrl->getLinkTargetByClass("ilobjskillmanagementgui", "editSkillTemplates"));
170  }
171 
172  if (is_object($this->node_object))
173  {
174  if ($this->tref_id == 0)
175  {
176  $tpl->setTitle($lng->txt("skmg_skill_template").": ".
177  $this->node_object->getTitle());
178  }
179  else
180  {
181  $tpl->setTitle(
182  $this->node_object->getTitle());
183  }
184 
185  // levels
186  $ilTabs->addTab("levels", $lng->txt("skmg_skill_levels"),
187  $ilCtrl->getLinkTarget($this, 'edit'));
188 
189  if ($this->tref_id > 0)
190  {
191  // usage
192  $this->addUsageTab($ilTabs);
193  }
194 
195 
196  // properties
197  if ($this->tref_id == 0)
198  {
199  $ilTabs->addTab("properties", $lng->txt("settings"),
200  $ilCtrl->getLinkTarget($this, 'editProperties'));
201  }
202 
203  $ilTabs->activateTab($a_tab);
204 
205  //$tpl->setTitleIcon(ilUtil::getImagePath("icon_sktp_b.png"), $lng->txt("skmg_skill_template"));
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  $it = new ilBasicSkillTemplate();
223  $it->setTitle($this->form->getInput("title"));
224  $it->setOrderNr($this->form->getInput("order_nr"));
225  $it->create();
226  ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
227  $this->node_object = $it;
228  }
229 
233  function afterSave()
234  {
235  global $ilCtrl;
236 
237  $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "obj_id",
238  $this->node_object->getId());
239  $ilCtrl->redirectByClass("ilbasicskilltemplategui", "edit");
240  }
241 
248  function edit()
249  {
250  global $tpl, $ilToolbar, $lng, $ilCtrl;
251 
252  $this->setTabs("levels");
253 
254  if ($this->tref_id == 0)
255  {
256  $ilToolbar->addButton($lng->txt("skmg_add_level"),
257  $ilCtrl->getLinkTarget($this, "addLevel"));
258  }
259 
260  include_once("./Services/Skill/classes/class.ilSkillLevelTableGUI.php");
261  $table = new ilSkillLevelTableGUI((int) $_GET["obj_id"], $this, "edit", $this->tref_id);
262  $tpl->setContent($table->getHTML());
263  }
264 }
265 ?>