ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004OrganizationHFormGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("./Services/Form/classes/class.ilHierarchyFormGUI.php");
25 
34 {
40  function __construct()
41  {
42  global $lng;
43 
45  $this->setCheckboxName("id");
46  $lng->loadLanguageModule("sahs");
47  $this->setExpandVariable("scexpand");
48  }
49 
53  function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs)
54  {
55  global $lng, $ilUser;
56 
57  $cmds = array();
58 
59  if (!$a_first_child) // drop area of node
60  {
61  // page inserts
62  if ($a_node["type"] == "page" || ($a_node["type"] == "sco" && count($a_childs) == 0))
63  {
64  if ($a_node["type"] == "sco")
65  {
66  $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10,
67  "as_subitem" => true);
68  $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10,
69  "as_subitem" => true);
70  if ($ilUser->clipboardHasObjectsOfType("page"))
71  {
72  $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
73  "cmd" => "insertPageClip", "as_subitem" => true);
74  }
75  }
76  else
77  {
78  $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10);
79  $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10);
80 
81  if ($ilUser->clipboardHasObjectsOfType("page"))
82  {
83  $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
84  "cmd" => "insertPageClip");
85  }
86  }
87  }
88 
89  // sco inserts
90  if ($a_node["type"] == "sco" || (($a_node["type"] == "chap" || $a_node["type"] == "seqc") && count($a_childs) == 0))
91  {
92  if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
93  {
94  $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10,
95  "as_subitem" => true);
96  if ($ilUser->clipboardHasObjectsOfType("sco"))
97  {
98  $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
99  "cmd" => "insertScoClip", "as_subitem" => true);
100  }
101  }
102  else
103  {
104  $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
105  if ($ilUser->clipboardHasObjectsOfType("sco"))
106  {
107  $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
108  "cmd" => "insertScoClip");
109  }
110  }
111  }
112  //if ($a_node["type"] == "chap")
113  //{
114  // $cmds[] = array("text" => $lng->txt("sahs_insert_sub_chapter"), "cmd" => "insertSubchapter", "multi" => 10);
115  //}
116 
117  // chapter inserts
118  if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
119  {
120  $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
121  if ($ilUser->clipboardHasObjectsOfType("chap"))
122  {
123  $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
124  "cmd" => "insertChapterClip");
125  }
126 
127  //check if parent chaper has sequencing scenario
128  // $cmds[] = array("text" => $lng->txt("sahs_insert_scenario"), "cmd" => "insertScenarioGUI", "multi" => 0);
129 
130  }
131  }
132  else // drop area before first child of node
133  {
134  if ($a_node["type"] == "" && $a_node["node_id"] == 1) // top node
135  {
136  // chapters
137  $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
138  if ($ilUser->clipboardHasObjectsOfType("chap"))
139  {
140  $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
141  "cmd" => "insertChapterClip");
142  }
143  // $cmds[] = array("text" => $lng->txt("sahs_insert_scenario"), "cmd" => "insertScenarioGUI", "multi" => 0);
144  }
145  if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
146  {
147  $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
148  if ($ilUser->clipboardHasObjectsOfType("sco"))
149  {
150  $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
151  "cmd" => "insertScoClip");
152  }
153  }
154  if ($a_node["type"] == "sco")
155  {
156  $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10);
157  $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10);
158  if ($ilUser->clipboardHasObjectsOfType("page"))
159  {
160  $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
161  "cmd" => "insertPageClip");
162  }
163  }
164 
165 /* if ($a_childs["type"] == "")
166  {
167  $cmds[] = array("text" => "insert Chapter", "cmd" => "insertChapter", "multi" => 10);
168  }*/
169  }
170 
171  return $cmds;
172  }
173 
177  function nodeAllowsChilds($a_node)
178  {
179  if ($a_node["type"] == "pg")
180  {
181  return false;
182  }
183  return true;
184  }
185 
191  function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
192  {
193  global $lng;
194 
195  $this->makeDragContent($a_node["node_id"], "grp_".$a_node["type"]);
196 
197  if (!$a_first_child_drop_area)
198  {
199  // page targets
200  if ($a_node["type"] == "page" || ($a_node["type"] == "sco" && count($a_childs) == 0))
201  {
202  if ($a_node["type"] == "sco")
203  {
204  $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
205  true, "");
206  }
207  else
208  {
209  $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
210  false, "");
211  }
212  }
213 
214  // sco targets
215  if ($a_node["type"] == "sco" || ($a_node["type"] == "chap" && count($a_childs) == 0))
216  {
217  if ($a_node["type"] == "chap")
218  {
219  $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
220  true, "");
221  }
222  else
223  {
224  $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
225  false, "");
226  }
227  }
228 
229  //if ($a_node["type"] != "pg")
230  //{
231  // $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
232  // true, $lng->txt("cont_insert_as_subchapter"));
233  //}
234 
235  // chapter targets
236  if ($a_node["type"] == "chap")
237  {
238  $this->makeDragTarget($a_node["node_id"], "grp_chap", $a_first_child_drop_area,
239  false, $lng->txt("sahs_insert_as_chapter"));
240  }
241  }
242  else
243  {
244  if ($a_node["type"] == "" && $a_node["node_id"] == 1) // top node
245  {
246  $this->makeDragTarget($a_node["node_id"], "grp_chap", $a_first_child_drop_area,
247  true);
248  }
249  if ($a_node["type"] == "chap")
250  {
251  $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
252  true);
253  }
254  if ($a_node["type"] == "sco")
255  {
256  $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
257  true);
258  }
259  }
260  }
261 
268  function getChildCommands($a_item)
269  {
270  global $lng, $ilCtrl;
271 
272  $commands = array();
273 //echo "-".$a_item["type"]."-";
274  switch ($a_item["type"])
275  {
276  case "sco":
277  $ilCtrl->setParameterByClass("ilscorm2004scogui", "obj_id",
278  $a_item["node_id"]);
279  $commands[] = array("text" => $lng->txt("edit"),
280  "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
281  "ilscorm2004scogui"), "showOrganization"));
282  break;
283 
284  case "chap":
285  $ilCtrl->setParameterByClass("ilscorm2004chaptergui", "obj_id",
286  $a_item["node_id"]);
287  $commands[] = array("text" => $lng->txt("edit"),
288  "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
289  "ilscorm2004chaptergui"), "showOrganization"));
290  break;
291 
292  case "seqc":
293  $ilCtrl->setParameterByClass("ilscorm2004seqchaptergui", "obj_id",
294  $a_item["node_id"]);
295  $commands[] = array("text" => $lng->txt("edit"),
296  "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
297  "ilscorm2004seqchaptergui"), "showOrganization"));
298  break;
299 
300  case "page":
301  $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id",
302  $a_item["node_id"]);
303  $commands[] = array("text" => $lng->txt("edit"),
304  "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
305  "ilscorm2004pagenodegui"), "edit"));
306  break;
307  }
308 
309  return $commands;
310  }
311 
312 }