ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 {
21  protected $ctrl;
22 
26  protected $tpl;
27 
31  protected $tabs;
32 
36  protected $lng;
37 
41  protected $help;
42 
43 
47  public function __construct($a_node_id = 0)
48  {
49  global $DIC;
50 
51  $this->ctrl = $DIC->ctrl();
52  $this->tpl = $DIC["tpl"];
53  $this->tabs = $DIC->tabs();
54  $this->lng = $DIC->language();
55  $this->help = $DIC["ilHelp"];
56  $ilCtrl = $DIC->ctrl();
57 
58  $ilCtrl->saveParameter($this, "obj_id");
59 
60  parent::__construct($a_node_id);
61  }
62 
66  public function getType()
67  {
68  return "scat";
69  }
70 
74  public function executeCommand()
75  {
77  $tpl = $this->tpl;
78  $ilTabs = $this->tabs;
79 
80  //$tpl->getStandardTemplate();
81 
82  $next_class = $ilCtrl->getNextClass($this);
83  $cmd = $ilCtrl->getCmd();
84 
85  switch ($next_class) {
86  default:
87  $ret = $this->$cmd();
88  break;
89  }
90  }
91 
95  public function setTabs($a_tab)
96  {
97  $ilTabs = $this->tabs;
99  $tpl = $this->tpl;
100  $lng = $this->lng;
101  $ilHelp = $this->help;
102 
103  $ilTabs->clearTargets();
104  $ilHelp->setScreenIdComponent("skmg_scat");
105 
106  // content
107  $ilTabs->addTab(
108  "content",
109  $lng->txt("content"),
110  $ilCtrl->getLinkTarget($this, 'listItems')
111  );
112 
113  // properties
114  $ilTabs->addTab(
115  "properties",
116  $lng->txt("settings"),
117  $ilCtrl->getLinkTarget($this, 'editProperties')
118  );
119 
120  // usage
121  $this->addUsageTab($ilTabs);
122 
123  // back link
124  $ilCtrl->setParameterByClass(
125  "ilskillrootgui",
126  "obj_id",
127  $this->node_object->skill_tree->getRootId()
128  );
129  $ilTabs->setBackTarget(
130  $lng->txt("obj_skmg"),
131  $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills")
132  );
133  $ilCtrl->setParameterByClass(
134  "ilskillrootgui",
135  "obj_id",
136  $_GET["obj_id"]
137  );
138 
139 
140  parent::setTitleIcon();
141  $tpl->setTitle(
142  $lng->txt("scat") . ": " . $this->node_object->getTitle()
143  );
144  $this->setSkillNodeDescription();
145 
146  $ilTabs->activateTab($a_tab);
147  }
148 
152  public function editProperties()
153  {
154  $tpl = $this->tpl;
155 
156  $this->setTabs("properties");
157  parent::editProperties();
158  }
159 
163  public function proceedDragDrop()
164  {
166 
167  // $this->slm_object->executeDragDrop($_POST["il_hform_source_id"], $_POST["il_hform_target_id"],
168 // $_POST["il_hform_fc"], $_POST["il_hform_as_subitem"]);
169 // $ilCtrl->redirect($this, "showOrganization");
170  }
171 
175  public function edit()
176  {
177  $tpl = $this->tpl;
178 
179  $this->initForm();
180  $this->getValues();
181  $tpl->setContent($this->form->getHTML());
182  }
183 
189  public function initForm($a_mode = "edit")
190  {
191  $lng = $this->lng;
193 
194  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
195  $this->form = new ilPropertyFormGUI();
196 
197  // title
198  $ti = new ilTextInputGUI($lng->txt("title"), "title");
199  $ti->setMaxLength(200);
200  $ti->setSize(50);
201  $ti->setRequired(true);
202  $this->form->addItem($ti);
203 
204  // status
205  $this->addStatusInput($this->form);
206 
207  // selectable
208  $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "self_eval");
209  $cb->setInfo($lng->txt("skmg_selectable_info"));
210  $this->form->addItem($cb);
211 
212  // save and cancel commands
213  if ($this->checkPermissionBool("write")) {
214  if ($a_mode == "create") {
215  $this->form->addCommandButton("save", $lng->txt("save"));
216  $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
217  $this->form->setTitle($lng->txt("skmg_create_skill_category"));
218  } else {
219  $this->form->addCommandButton("update", $lng->txt("save"));
220  $this->form->setTitle($lng->txt("skmg_edit_scat"));
221  }
222  }
223 
224  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
225  $this->form->setFormAction($ilCtrl->getFormAction($this));
226  }
227 
231  public function saveItem()
232  {
233  if (!$this->checkPermissionBool("write")) {
234  return;
235  }
236  include_once "Services/Skill/classes/class.ilSkillCategory.php";
237 
238  $tree = new ilSkillTree();
239 
240  $it = new ilSkillCategory();
241  $it->setTitle($this->form->getInput("title"));
242  $it->setOrderNr($tree->getMaxOrderNr((int) $_GET["obj_id"]) + 10);
243  $it->setSelfEvaluation($_POST["self_eval"]);
244  $it->setStatus($_POST["status"]);
245  $it->create();
246  ilSkillTreeNode::putInTree($it, (int) $_GET["obj_id"], IL_LAST_NODE);
247  }
248 
252  public function getValues()
253  {
254  $values = array();
255  $values["title"] = $this->node_object->getTitle();
256  $values["self_eval"] = $this->node_object->getSelfEvaluation();
257  $values["status"] = $this->node_object->getStatus();
258  $this->form->setValuesByArray($values);
259  }
260 
264  public function updateItem()
265  {
266  if (!$this->checkPermissionBool("write")) {
267  return;
268  }
269 
270  $this->node_object->setTitle($this->form->getInput("title"));
271  $this->node_object->setSelfEvaluation($_POST["self_eval"]);
272  $this->node_object->setStatus($_POST["status"]);
273  $this->node_object->update();
274  }
275 
279  /* function updateSkillCategory()
280  {
281  global $lng, $ilCtrl, $tpl;
282 
283  $this->initForm("edit");
284  if ($this->form->checkInput())
285  {
286  // perform update
287  $this->node_object->setSelfEvaluation($_POST["self_eval"]);
288  $this->node_object->update();
289 
290  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
291  $ilCtrl->redirect($this, "edit");
292  }
293 
294  $this->form->setValuesByPost();
295  $tpl->setContent($this->form->getHtml());
296  }*/
297 
304  public function listItems()
305  {
306  $tpl = $this->tpl;
307  $lng = $this->lng;
308 
309  if ($this->isInUse()) {
310  ilUtil::sendInfo($lng->txt("skmg_skill_in_use"));
311  }
312 
313  if ($this->checkPermissionBool("write")) {
314  self::addCreationButtons();
315  }
316  $this->setTabs("content");
317 
318  include_once("./Services/Skill/classes/class.ilSkillCatTableGUI.php");
320  $this,
321  "listItems",
322  (int) $_GET["obj_id"],
324  );
325 
326  $tpl->setContent($table->getHTML());
327  }
328 
335  public static function addCreationButtons()
336  {
337  global $DIC;
338 
339  $ilCtrl = $DIC->ctrl();
340  $lng = $DIC->language();
341  $ilToolbar = $DIC->toolbar();
342  $ilUser = $DIC->user();
343 
344  // skill
345  $ilCtrl->setParameterByClass(
346  "ilbasicskillgui",
347  "obj_id",
348  (int) $_GET["obj_id"]
349  );
350  $ilToolbar->addButton(
351  $lng->txt("skmg_create_skll"),
352  $ilCtrl->getLinkTargetByClass("ilbasicskillgui", "create")
353  );
354 
355  // skill category
356  $ilCtrl->setParameterByClass(
357  "ilskillcategorygui",
358  "obj_id",
359  (int) $_GET["obj_id"]
360  );
361  $ilToolbar->addButton(
362  $lng->txt("skmg_create_skill_category"),
363  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "create")
364  );
365 
366  // skill template reference
367  $ilCtrl->setParameterByClass(
368  "ilskilltemplatereferencegui",
369  "obj_id",
370  (int) $_GET["obj_id"]
371  );
372  $ilToolbar->addButton(
373  $lng->txt("skmg_create_skill_template_reference"),
374  $ilCtrl->getLinkTargetByClass("ilskilltemplatereferencegui", "create")
375  );
376 
377  // skills from clipboard
378  $sep = false;
379  if ($ilUser->clipboardHasObjectsOfType("skll")) {
380  $ilToolbar->addSeparator();
381  $sep = true;
382  $ilToolbar->addButton(
383  $lng->txt("skmg_insert_basic_skill_from_clip"),
384  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertBasicSkillClip")
385  );
386  }
387 
388  // skills from clipboard
389  if ($ilUser->clipboardHasObjectsOfType("scat")) {
390  if (!$sep) {
391  $ilToolbar->addSeparator();
392  $sep = true;
393  }
394  $ilToolbar->addButton(
395  $lng->txt("skmg_insert_skill_category_from_clip"),
396  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertSkillCategoryClip")
397  );
398  }
399 
400  // skills from clipboard
401  if ($ilUser->clipboardHasObjectsOfType("sktr")) {
402  if (!$sep) {
403  $ilToolbar->addSeparator();
404  $sep = true;
405  }
406  $ilToolbar->addButton(
407  $lng->txt("skmg_insert_skill_template_reference_from_clip"),
408  $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "insertTemplateReferenceClip")
409  );
410  }
411 
412  // skill template reference
413  $ilToolbar->addButton(
414  $lng->txt("skmg_import_skills"),
415  $ilCtrl->getLinkTargetByClass("ilskillrootgui", "showImportForm")
416  );
417  }
418 
425  public function cancel()
426  {
428 
429  $ilCtrl->redirectByClass("ilobjskillmanagementgui", "editSkills");
430  }
431 
438  public function redirectToParent($a_tmp_mode = false)
439  {
441 
442  $t = ilSkillTreeNode::_lookupType((int) $_GET["obj_id"]);
443 
444  switch ($t) {
445  case "skrt":
446  $ilCtrl->setParameterByClass("ilskillrootgui", "obj_id", (int) $_GET["obj_id"]);
447  $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
448  break;
449  }
450 
451  parent::redirectToParent();
452  }
453 }
addUsageTab($a_tabs)
Add usage tab.
Skill category GUI class.
static addCreationButtons()
Add creation buttons.
This class represents a property form user interface.
setSkillNodeDescription()
Set skill node description.
global $DIC
Definition: saml.php:7
Skill tree.
$_GET["client_id"]
proceedDragDrop()
Perform drag and drop action.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
This class represents a checkbox property in a property form.
static _lookupType($a_obj_id)
Lookup Type.
checkPermissionBool($a_perm)
Check permission pool.
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setTabs($a_tab)
output tabs
executeCommand()
Execute command.
Basic GUI class for skill tree nodes.
__construct($a_node_id=0)
Constructor.
$values
This class represents a text property in a property form.
$ilUser
Definition: imgupload.php:18
setMaxLength($a_maxlength)
Set Max Length.
editProperties()
Edit properties.
const IL_LAST_NODE
Definition: class.ilTree.php:4
$ret
Definition: parser.php:6
getValues()
Get current values for from.
initForm($a_mode="edit")
Init form.
if(empty($password)) $table
Definition: pwgen.php:24
$_POST["username"]
addStatusInput(ilPropertyFormGUI $a_form)
Add status input.
redirectToParent($a_tmp_mode=false)
Redirect to parent (identified by current obj_id)