ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSkillHFormGUI.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/Form/classes/class.ilHierarchyFormGUI.php");
6 
15 {
19  function __construct()
20  {
21  global $lng;
22 
24  $this->setCheckboxName("id");
25  $lng->loadLanguageModule("skmg");
26  $this->setExpandVariable("skexpand");
27  $this->setTypeWhiteList(array("skrt", "skll", "scat", "sktr"));
28  }
29 
33  function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs)
34  {
35  global $lng, $ilUser;
36 
37  $cmds = array();
38 
39  if (!$a_first_child) // drop area of node
40  {
41  // page inserts
42  if ($a_node["type"] == "skll" || $a_node["type"] == "scat")
43  {
44  $cmds[] = array("text" => $lng->txt("skmg_insert_basic_skill"), "cmd" => "insertBasicSkill", "multi" => 10);
45  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_template_reference"), "cmd" => "insertSkillTemplateReference");
46  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_category"), "cmd" => "insertSkillCategory", "multi" => 10);
47  if ($ilUser->clipboardHasObjectsOfType("skll"))
48  {
49  $cmds[] = array("text" => $lng->txt("skmg_insert_basic_skill_from_clip"),
50  "cmd" => "insertBasicSkillClip", "as_subitem" => false);
51  }
52  if ($ilUser->clipboardHasObjectsOfType("sktr"))
53  {
54  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_template_reference_from_clip"),
55  "cmd" => "insertSkillTemplateReferenceClip", "as_subitem" => false);
56  }
57  if ($ilUser->clipboardHasObjectsOfType("scat"))
58  {
59  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_category_from_clip"),
60  "cmd" => "insertSkillCategoryClip", "as_subitem" => false);
61  }
62  }
63 
64  if ($a_node["type"] == "scat" || $a_node["type"] == "skrt")
65  {
66  $cmds[] = array("text" => $lng->txt("skmg_insert_basic_skill_child"), "cmd" => "insertBasicSkill", "multi" => 10,
67  "as_subitem" => true);
68  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_template_reference_child"), "cmd" => "insertSkillTemplateReference",
69  "as_subitem" => true);
70  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_category_child"), "cmd" => "insertSkillCategory", "multi" => 10,
71  "as_subitem" => true);
72  if ($ilUser->clipboardHasObjectsOfType("skll"))
73  {
74  $cmds[] = array("text" => $lng->txt("skmg_insert_basic_skill_from_clip_child"),
75  "cmd" => "insertBasicSkillClip", "as_subitem" => true);
76  }
77  if ($ilUser->clipboardHasObjectsOfType("sktr"))
78  {
79  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_template_reference_from_clip_child"),
80  "cmd" => "insertSkillTemplateReferenceClip", "as_subitem" => true);
81  }
82  if ($ilUser->clipboardHasObjectsOfType("scat"))
83  {
84  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_category_from_clip_child"),
85  "cmd" => "insertSkillCategoryClip", "as_subitem" => true);
86  }
87  }
88  }
89  else // drop area before first child of node
90  {
91  if (($a_node["type"] == "skrt" && $a_node["node_id"] == 1)
92  || $a_node["type"] == "scat")
93  {
94  $cmds[] = array("text" => $lng->txt("skmg_insert_basic_skill"), "cmd" => "insertBasicSkill", "multi" => 10);
95  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_template_reference"), "cmd" => "insertSkillTemplateReference");
96  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_category"), "cmd" => "insertSkillCategory", "multi" => 10);
97  if ($ilUser->clipboardHasObjectsOfType("skll"))
98  {
99  $cmds[] = array("text" => $lng->txt("skmg_insert_basic_skill_from_clip"),
100  "cmd" => "insertBasicSkillClip", "as_subitem" => false);
101  }
102  if ($ilUser->clipboardHasObjectsOfType("sktr"))
103  {
104  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_template_reference_from_clip"),
105  "cmd" => "insertSkillTemplateReferenceClip", "as_subitem" => false);
106  }
107  if ($ilUser->clipboardHasObjectsOfType("scat"))
108  {
109  $cmds[] = array("text" => $lng->txt("skmg_insert_skill_category_from_clip"),
110  "cmd" => "insertSkillCategoryClip", "as_subitem" => false);
111  }
112  }
113  }
114 
115  return $cmds;
116  }
117 
121  function nodeAllowsChilds($a_node)
122  {
123  if ($a_node["type"] == "skll")
124  {
125  return false;
126  }
127  return true;
128  }
129 
135  function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
136  {
137  global $lng;
138 
139  $this->makeDragContent($a_node["node_id"], "grp_".$a_node["type"]);
140 
141  if (!$a_first_child_drop_area)
142  {
143  if ($a_node["type"] == "skll" || $a_node["type"] == "scat")
144  {
145  $this->makeDragTarget($a_node["node_id"], "grp_skll", $a_first_child_drop_area,
146  false, $lng->txt("skmg_insert_on_same_level"));
147  $this->makeDragTarget($a_node["node_id"], "grp_scat", $a_first_child_drop_area,
148  false, $lng->txt("skmg_insert_on_same_level"));
149  }
150  if ($a_node["type"] == "scat" || $a_node["type"] == "skrt")
151  {
152  $this->makeDragTarget($a_node["node_id"], "grp_skll", $a_first_child_drop_area,
153  true, $lng->txt("skmg_insert_as_subitem"));
154  $this->makeDragTarget($a_node["node_id"], "grp_scat", $a_first_child_drop_area,
155  true, $lng->txt("skmg_insert_as_subitem"));
156  }
157  }
158  else
159  {
160  if (($a_node["type"] == "skrt" && $a_node["node_id"] == 1)
161  || $a_node["type"] == "scat")
162  {
163  $this->makeDragTarget($a_node["node_id"], "grp_skll", $a_first_child_drop_area,
164  true, "");
165  $this->makeDragTarget($a_node["node_id"], "grp_scat", $a_first_child_drop_area,
166  true, "");
167  }
168  }
169  }
170 
177  function getChildCommands($a_item)
178  {
179  global $lng, $ilCtrl;
180 
181  $commands = array();
182 //echo "-".$a_item["type"]."-";
183  switch ($a_item["type"])
184  {
185  case "scat":
186  $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id",
187  $a_item["node_id"]);
188  $commands[] = array("text" => $lng->txt("edit"),
189  "link" => $ilCtrl->getLinkTargetByClass(array("ilobjskillmanagementgui",
190  "ilskillcategorygui"), "edit"));
191  break;
192 
193  case "skll":
194  $ilCtrl->setParameterByClass("ilbasicskillgui", "obj_id",
195  $a_item["node_id"]);
196  $commands[] = array("text" => $lng->txt("edit"),
197  "link" => $ilCtrl->getLinkTargetByClass(array("ilobjskillmanagementgui",
198  "ilbasicskillgui"), "edit"));
199  break;
200 
201  case "sktr":
202  $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "obj_id",
203  $a_item["node_id"]);
204  $commands[] = array("text" => $lng->txt("edit"),
205  "link" => $ilCtrl->getLinkTargetByClass(array("ilobjskillmanagementgui",
206  "ilskilltemplatereferencegui"), "edit"));
207  break;
208 
209  }
210 
211  return $commands;
212  }
213 
214 }