ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSkillCategoryGUI.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.ilSkillTreeNodeGUI.php");
6 
17 {
18 
22  function __construct($a_node_id = 0)
23  {
24  global $ilCtrl;
25 
26  $ilCtrl->saveParameter($this, "obj_id");
27 
28  parent::ilSkillTreeNodeGUI($a_node_id);
29  }
30 
34  function getType()
35  {
36  return "scat";
37  }
38 
42  function &executeCommand()
43  {
44  global $ilCtrl, $tpl, $ilTabs;
45 
46  $tpl->getStandardTemplate();
47 
48  $next_class = $ilCtrl->getNextClass($this);
49  $cmd = $ilCtrl->getCmd();
50 
51  switch($next_class)
52  {
53  default:
54  $ret = $this->$cmd();
55  break;
56  }
57  }
58 
62  function setTabs($a_tab)
63  {
64  global $ilTabs, $ilCtrl, $tpl, $lng;
65 
66  $ilTabs->clearTargets();
67 
68  // content
69  $ilTabs->addTab("content", $lng->txt("content"),
70  $ilCtrl->getLinkTarget($this, 'listItems'));
71 
72  // properties
73  $ilTabs->addTab("properties", $lng->txt("settings"),
74  $ilCtrl->getLinkTarget($this, 'editProperties'));
75 
76  // back link
77  $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
78  $this->node_object->skill_tree->getRootId());
79  $ilTabs->setBackTarget($lng->txt("obj_skmg"),
80  $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills"));
81  $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
82  $_GET["obj_id"]);
83 
84 
86  $tpl->setTitle(
87  $lng->txt("scat").": ".$this->node_object->getTitle());
88  $this->setSkillNodeDescription();
89 
90  $ilTabs->activateTab($a_tab);
91  }
92 
96  function editProperties()
97  {
98  global $tpl;
99 
100  $this->setTabs("properties");
102  }
103 
107  function proceedDragDrop()
108  {
109  global $ilCtrl;
110 
111 // $this->slm_object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
112 // $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
113 // $ilCtrl->redirect($this, "showOrganization");
114  }
115 
119  function edit()
120  {
121  global $tpl;
122 
123  $this->initForm();
124  $this->getValues();
125  $tpl->setContent($this->form->getHTML());
126  }
127 
133  public function initForm($a_mode = "edit")
134  {
135  global $lng, $ilCtrl;
136 
137  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
138  $this->form = new ilPropertyFormGUI();
139 
140  // title
141  $ti = new ilTextInputGUI($lng->txt("title"), "title");
142  $ti->setMaxLength(200);
143  $ti->setSize(50);
144  $ti->setRequired(true);
145  $this->form->addItem($ti);
146 
147  // order nr
148  $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
149  $ni->setMaxLength(6);
150  $ni->setSize(6);
151  $ni->setRequired(true);
152  $this->form->addItem($ni);
153 
154  // draft
155  $cb = new ilCheckboxInputGUI($lng->txt("skmg_draft"), "draft");
156  $cb->setInfo($lng->txt("skmg_draft_info"));
157  $this->form->addItem($cb);
158 
159  // selectable
160  $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "self_eval");
161  $cb->setInfo($lng->txt("skmg_selectable_info"));
162  $this->form->addItem($cb);
163 
164  // save and cancel commands
165  if ($a_mode == "create")
166  {
167  $this->form->addCommandButton("save", $lng->txt("save"));
168  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
169  $this->form->setTitle($lng->txt("skmg_create_skill_category"));
170  }
171  else
172  {
173  $this->form->addCommandButton("update", $lng->txt("save"));
174  $this->form->setTitle($lng->txt("skmg_edit_scat"));
175  }
176 
177  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
178  $this->form->setFormAction($ilCtrl->getFormAction($this));
179  }
180 
184  function saveItem()
185  {
186  include_once "Services/Skill/classes/class.ilSkillCategory.php";
187  $it = new ilSkillCategory();
188  $it->setTitle($this->form->getInput("title"));
189  $it->setOrderNr($this->form->getInput("order_nr"));
190  $it->setSelfEvaluation($_POST["self_eval"]);
191  $it->setDraft($_POST["draft"]);
192  $it->create();
193  ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
194  }
195 
199  public function getValues()
200  {
201  $values = array();
202  $values["title"] = $this->node_object->getTitle();
203  $values["order_nr"] = $this->node_object->getOrderNr();
204  $values["self_eval"] = $this->node_object->getSelfEvaluation();
205  $values["draft"] = $this->node_object->getDraft();
206 echo "-".$this->node_object->getDraft()."-";
207  $this->form->setValuesByArray($values);
208  }
209 
213  function updateItem()
214  {
215  $this->node_object->setTitle($this->form->getInput("title"));
216  $this->node_object->setOrderNr($this->form->getInput("order_nr"));
217  $this->node_object->setSelfEvaluation($_POST["self_eval"]);
218  $this->node_object->setDraft($_POST["draft"]);
219  $this->node_object->update();
220  }
221 
225 /* function updateSkillCategory()
226  {
227  global $lng, $ilCtrl, $tpl;
228 
229  $this->initForm("edit");
230  if ($this->form->checkInput())
231  {
232  // perform update
233  $this->node_object->setSelfEvaluation($_POST["self_eval"]);
234  $this->node_object->update();
235 
236  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
237  $ilCtrl->redirect($this, "edit");
238  }
239 
240  $this->form->setValuesByPost();
241  $tpl->setContent($this->form->getHtml());
242  }*/
243 
250  function listItems()
251  {
252  global $tpl;
253 
255  $this->setTabs("content");
256 
257  include_once("./Services/Skill/classes/class.ilSkillCatTableGUI.php");
258  $table = new ilSkillCatTableGUI($this, "listItems", (int) $_GET["obj_id"],
260 
261  $tpl->setContent($table->getHTML());
262  }
263 
270  static function addCreationButtons()
271  {
272  global $ilCtrl, $lng, $ilToolbar, $ilUser;
273 
274  // skill
275  $ilCtrl->setParameterByClass("ilbasicskillgui",
276  "obj_id", (int) $_GET["obj_id"]);
277  $ilToolbar->addButton($lng->txt("skmg_create_skll"),
278  $ilCtrl->getLinkTargetByClass("ilbasicskillgui", "create"));
279 
280  // skill category
281  $ilCtrl->setParameterByClass("ilskillcategorygui",
282  "obj_id", (int) $_GET["obj_id"]);
283  $ilToolbar->addButton($lng->txt("skmg_create_skill_category"),
284  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "create"));
285 
286  // skill template reference
287  $ilCtrl->setParameterByClass("ilskilltemplatereferencegui",
288  "obj_id", (int) $_GET["obj_id"]);
289  $ilToolbar->addButton($lng->txt("skmg_create_skill_template_reference"),
290  $ilCtrl->getLinkTargetByClass("ilskilltemplatereferencegui", "create"));
291 
292  // skills from clipboard
293  $sep = false;
294  if ($ilUser->clipboardHasObjectsOfType("skll"))
295  {
296  $ilToolbar->addSeparator();
297  $sep = true;
298  $ilToolbar->addButton($lng->txt("skmg_insert_basic_skill_from_clip"),
299  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertBasicSkillClip"));
300  }
301 
302  // skills from clipboard
303  if ($ilUser->clipboardHasObjectsOfType("scat"))
304  {
305  if (!$sep)
306  {
307  $ilToolbar->addSeparator();
308  $sep = true;
309  }
310  $ilToolbar->addButton($lng->txt("skmg_insert_skill_category_from_clip"),
311  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertSkillCategoryClip"));
312  }
313 
314  // skills from clipboard
315  if ($ilUser->clipboardHasObjectsOfType("sktr"))
316  {
317  if (!$sep)
318  {
319  $ilToolbar->addSeparator();
320  $sep = true;
321  }
322  $ilToolbar->addButton($lng->txt("skmg_insert_skill_template_reference_from_clip"),
323  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertTemplateReferenceClip"));
324  }
325 
326  }
327 
334  function cancel()
335  {
336  global $ilCtrl;
337 
338  $ilCtrl->redirectByClass("ilobjskillmanagementgui", "editSkills");
339  }
340 
347  function redirectToParent()
348  {
349  global $ilCtrl;
350 
351  $t = ilSkillTreeNode::_lookupType((int) $_GET["obj_id"]);
352 
353  switch ($t)
354  {
355  case "skrt":
356  $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id", (int) $_GET["obj_id"]);
357  $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
358  break;
359  }
360 
362  }
363 
364 }
365 
366 ?>