ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSkillTemplateReferenceGUI.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 include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
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 "sktr";
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  if (is_object($this->node_object))
69  {
70  // content
71  $ilTabs->addTab("content", $lng->txt("content"),
72  $ilCtrl->getLinkTarget($this, 'listItems'));
73 
74  // properties
75  $ilTabs->addTab("properties", $lng->txt("settings"),
76  $ilCtrl->getLinkTarget($this, 'editProperties'));
77 
78  // back link
79  $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
80  $this->node_object->skill_tree->getRootId());
81  $ilTabs->setBackTarget($lng->txt("obj_skmg"),
82  $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills"));
83  $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id",
84  $_GET["obj_id"]);
85 
86  $tid = ilSkillTemplateReference::_lookupTemplateId($this->node_object->getId());
87  $add = " (".ilSkillTreeNode::_lookupTitle($tid).")";
88 
90  $tpl->setTitle(
91  $lng->txt("skmg_sktr").": ".$this->node_object->getTitle().$add);
92  $this->setSkillNodeDescription();
93 
94  $ilTabs->activateTab($a_tab);
95  }
96  }
97 
104  function insert()
105  {
106  global $ilCtrl, $tpl;
107 
108  $ilCtrl->saveParameter($this, "parent_id");
109  $ilCtrl->saveParameter($this, "target");
110  $this->initForm("create");
111  $tpl->setContent($this->form->getHTML());
112  }
113 
114 
118  function editProperties()
119  {
120  global $tpl;
121 
122  $this->setTabs("properties");
123 
124  $this->initForm();
125  $this->getValues();
126  $tpl->setContent($this->form->getHTML());
127  }
128 
134  public function initForm($a_mode = "edit")
135  {
136  global $lng, $ilCtrl;
137 
138  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
139  $this->form = new ilPropertyFormGUI();
140 
141  // select skill template
142  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
144 
145  // title
146  $ti = new ilTextInputGUI($lng->txt("title"), "title");
147  $this->form->addItem($ti);
148 
149  // order nr
150  $ni = new ilNumberInputGUI($lng->txt("skmg_order_nr"), "order_nr");
151  $ni->setMaxLength(6);
152  $ni->setSize(6);
153  $ni->setRequired(true);
154  $this->form->addItem($ni);
155 
156  // template
157  $options = array(
158  "" => $lng->txt("please_select"),
159  );
160  foreach ($tmplts as $tmplt)
161  {
162  $options[$tmplt["child"]] = $tmplt["title"];
163  }
164  $si = new ilSelectInputGUI($lng->txt("skmg_skill_template"), "skill_template_id");
165  $si->setOptions($options);
166  $si->setRequired(true);
167  $this->form->addItem($si);
168 
169  // draft
170  $cb = new ilCheckboxInputGUI($lng->txt("skmg_draft"), "draft");
171  $cb->setInfo($lng->txt("skmg_draft_info"));
172  $this->form->addItem($cb);
173 
174  // selectable
175  $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "selectable");
176  $cb->setInfo($lng->txt("skmg_selectable_info"));
177  $this->form->addItem($cb);
178 
179  if ($a_mode == "create")
180  {
181  $this->form->addCommandButton("save", $lng->txt("save"));
182  $this->form->addCommandButton("cancel", $lng->txt("cancel"));
183  $this->form->setTitle($lng->txt("skmg_new_sktr"));
184  }
185  else
186  {
187  $this->form->addCommandButton("updateSkillTemplateReference", $lng->txt("save"));
188  $this->form->setTitle($lng->txt("skmg_edit_sktr"));
189  }
190 
191  $this->form->setFormAction($ilCtrl->getFormAction($this));
192  }
193 
197  public function getValues()
198  {
199  $values = array();
200  $values["skill_template_id"] = $this->node_object->getSkillTemplateId();
201  $values["title"] = $this->node_object->getTitle();
202  $values["selectable"] = $this->node_object->getSelfEvaluation();
203  $values["draft"] = $this->node_object->getDraft();
204  $values["order_nr"] = $this->node_object->getOrderNr();
205  $this->form->setValuesByArray($values);
206  }
207 
211  function saveItem()
212  {
213  $sktr = new ilSkillTemplateReference();
214  $sktr->setTitle($_POST["title"]);
215  $sktr->setSkillTemplateId($_POST["skill_template_id"]);
216  $sktr->setSelfEvaluation($_POST["selectable"]);
217  $sktr->setOrderNr($_POST["order_nr"]);
218  $sktr->setDraft($_POST["draft"]);
219  $sktr->create();
220  ilSkillTreeNode::putInTree($sktr, (int) $_GET["obj_id"], IL_LAST_NODE);
221  }
222 
227  {
228  global $lng, $ilCtrl, $tpl;
229 
230  $this->initForm("edit");
231  if ($this->form->checkInput())
232  {
233  // perform update
234  $this->node_object->setSkillTemplateId($_POST["skill_template_id"]);
235  $this->node_object->setTitle($_POST["title"]);
236  $this->node_object->setSelfEvaluation($_POST["selectable"]);
237  $this->node_object->setOrderNr($_POST["order_nr"]);
238  $this->node_object->setDraft($_POST["draft"]);
239  $this->node_object->update();
240 
241  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
242  $ilCtrl->redirect($this, "editProperties");
243  }
244 
245  $this->form->setValuesByPost();
246  $tpl->setContent($this->form->getHtml());
247  }
248 
255  function cancel()
256  {
257  global $ilCtrl;
258 
259  $ilCtrl->redirectByClass("ilobjskillmanagementgui", "editSkills");
260  }
261 
265  function listItems()
266  {
267  global $tpl;
268 
269  $this->setTabs("content");
270 
271  include_once("./Services/Skill/classes/class.ilSkillTreeNode.php");
272  $bs = ilSkillTreeNode::getSkillTreeNodes((int) $_GET["obj_id"], false);
273  include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
274  $ns = new ilNestedList();
275  $ns->setListClass("il_Explorer");
276  foreach ($bs as $b)
277  {
278  $par = ($b["id"] == (int) $_GET["obj_id"])
279  ? 0
280  : $b["parent"];
281  $ns->addListNode(ilSkillTreeNode::_lookupTitle($b["id"]), $b["id"], $par);
282  }
283 
284  $tpl->setContent($ns->getHTML());
285  }
286 
287 }
288 
289 ?>