ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSCORM2004OrganizationHFormGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Form/classes/class.ilHierarchyFormGUI.php");
5
14{
20 function __construct()
21 {
22 global $lng;
23
24 parent::__construct();
25 $this->setCheckboxName("id");
26 $lng->loadLanguageModule("sahs");
27 $this->setExpandVariable("scexpand");
28 }
29
33 function getMenuItems($a_node, $a_depth, $a_first_child = false, $a_next_sibling = null, $a_childs = null)
34 {
35 global $lng, $ilUser;
36
37 // @todo: move this to a service since it can be used here, too
38 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
39
40 include_once("./Services/Style/classes/class.ilPageLayout.php");
41 $page_layouts = (count(ilPageLayout::activeLayouts()) > 0);
42 $special_pages = (count(ilPageLayout::activeLayouts(true)) > 0);
43
44 $cmds = array();
45//echo "+".$a_depth."-";
46 if (!$a_first_child) // drop area of node
47 {
48 // page inserts
49 if ($a_node["type"] == "page" || ($a_node["type"] == "sco" && count($a_childs) == 0) ||
50 ($a_node["type"] == "ass" && count($a_childs) == 0))
51 {
52 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
53 {
54 $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10,
55 "as_subitem" => true);
56 if ($page_layouts > 0)
57 {
58 $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10,
59 "as_subitem" => true);
60 }
61 if ($special_pages > 0)
62 {
63 $cmds[] = array("text" => $lng->txt("sahs_insert_special_page"), "cmd" => "insertSpecialPage", "multi" => 10,
64 "as_subitem" => true);
65 }
66 if ($ilUser->clipboardHasObjectsOfType("page"))
67 {
68 $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
69 "cmd" => "insertPageClip", "as_subitem" => true);
70 }
71 if (($ilUser->clipboardHasObjectsOfType("pg") && ilEditClipboard::getAction() == "copy"))
72 {
73 $cmds[] = array("text" => $lng->txt("sahs_insert_pg_from_clip"),
74 "cmd" => "insertPageClip", "as_subitem" => true);
75 }
76 }
77 else
78 {
79 $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10);
80 if ($page_layouts > 0)
81 {
82 $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10);
83 }
84 if ($special_pages > 0)
85 {
86 $cmds[] = array("text" => $lng->txt("sahs_insert_special_page"), "cmd" => "insertSpecialPage", "multi" => 10);
87 }
88
89 if ($ilUser->clipboardHasObjectsOfType("page"))
90 {
91 $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
92 "cmd" => "insertPageClip");
93 }
94 if (($ilUser->clipboardHasObjectsOfType("pg") && ilEditClipboard::getAction() == "copy"))
95 {
96 $cmds[] = array("text" => $lng->txt("sahs_insert_pg_from_clip"),
97 "cmd" => "insertPageClip");
98 }
99 }
100 }
101
102 // sco/asset inserts... in/after chapters
103 if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
104 {
105 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
106 if (count($a_childs) == 0)
107 {
108 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_inside_chap"), "cmd" => "insertAsset", "multi" => 10,
109 "as_subitem" => true);
110 }
111 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
112 if (count($a_childs) == 0)
113 {
114 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_inside_chap"), "cmd" => "insertSco", "multi" => 10,
115 "as_subitem" => true);
116 }
117 if ($ilUser->clipboardHasObjectsOfType("sco"))
118 {
119 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
120 "cmd" => "insertScoClip", "as_subitem" => false);
121 if (count($a_childs) == 0)
122 {
123 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip_inside_chap"),
124 "cmd" => "insertScoClip", "as_subitem" => true);
125 }
126 }
127 if ($ilUser->clipboardHasObjectsOfType("ass"))
128 {
129 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
130 "cmd" => "insertAssetClip", "as_subitem" => false);
131 if (count($a_childs) == 0)
132 {
133 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip_inside_chap"),
134 "cmd" => "insertAssetClip", "as_subitem" => true);
135 }
136 }
137
138 // insert chapter from learning module
139 if ($ilUser->clipboardHasObjectsOfType("st") && ilEditClipboard::getAction() == "copy")
140 {
141 $cmds[] = array("text" => $lng->txt("sahs_insert_st_from_clip"),
142 "cmd" => "insertLMChapterClip", "as_subitem" => false);
143 if (count($a_childs) == 0)
144 {
145 $cmds[] = array("text" => $lng->txt("sahs_insert_st_from_clip_inside_chap"),
146 "cmd" => "insertLMChapterClip", "as_subitem" => true);
147 }
148 }
149 }
150
151 // sco/asset inserts... after sco/assets
152 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
153 {
154 // scos
155 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
156 if ($ilUser->clipboardHasObjectsOfType("sco"))
157 {
158 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
159 "cmd" => "insertScoClip");
160 }
161
162 // assets
163 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
164 if ($ilUser->clipboardHasObjectsOfType("ass"))
165 {
166 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
167 "cmd" => "insertAssetClip");
168 }
169
170 // chapters
171 if ($a_node["depth"] == 2)
172 {
173 $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
174 if ($ilUser->clipboardHasObjectsOfType("chap"))
175 {
176 $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
177 "cmd" => "insertChapterClip");
178 }
179 }
180
181 // insert chapter from learning module
182 if ($ilUser->clipboardHasObjectsOfType("st") && ilEditClipboard::getAction() == "copy")
183 {
184 $cmds[] = array("text" => $lng->txt("sahs_insert_st_from_clip"),
185 "cmd" => "insertLMChapterClip");
186 }
187 }
188 //if ($a_node["type"] == "chap")
189 //{
190 // $cmds[] = array("text" => $lng->txt("sahs_insert_sub_chapter"), "cmd" => "insertSubchapter", "multi" => 10);
191 //}
192
193 // chapter inserts
194 if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
195 {
196 $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
197 if ($ilUser->clipboardHasObjectsOfType("chap"))
198 {
199 $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
200 "cmd" => "insertChapterClip");
201 }
202
203 // insert chapter from learning module
204 /*
205 if ($ilUser->clipboardHasObjectsOfType("st") && ilEditClipboard::getAction() == "copy")
206 {
207 $cmds[] = array("text" => $lng->txt("sahs_insert_st_from_clip"),
208 "cmd" => "insertLMChapterClip");
209 }*/
210
211 //check if parent chaper has sequencing scenario
212 // $cmds[] = array("text" => $lng->txt("sahs_insert_scenario"), "cmd" => "insertScenarioGUI", "multi" => 0);
213
214 }
215 }
216 else // drop area before first child of node
217 {
218 if ($a_node["type"] == "" && $a_node["node_id"] == 1) // top node
219 {
220 // scos
221 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
222 if ($ilUser->clipboardHasObjectsOfType("sco"))
223 {
224 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
225 "cmd" => "insertScoClip");
226 }
227
228 // assets
229 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
230 if ($ilUser->clipboardHasObjectsOfType("ass"))
231 {
232 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
233 "cmd" => "insertAssetClip");
234 }
235
236 // chapters
237 $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
238 if ($ilUser->clipboardHasObjectsOfType("chap"))
239 {
240 $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
241 "cmd" => "insertChapterClip");
242 }
243
244 // insert chapter from learning module
245 if ($ilUser->clipboardHasObjectsOfType("st") && ilEditClipboard::getAction() == "copy")
246 {
247 $cmds[] = array("text" => $lng->txt("sahs_insert_st_from_clip"),
248 "cmd" => "insertLMChapterClip");
249 }
250
251 // $cmds[] = array("text" => $lng->txt("sahs_insert_scenario"), "cmd" => "insertScenarioGUI", "multi" => 0);
252 }
253 if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
254 {
255 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
256 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
257 if ($ilUser->clipboardHasObjectsOfType("sco"))
258 {
259 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
260 "cmd" => "insertScoClip");
261 }
262 if ($ilUser->clipboardHasObjectsOfType("ass"))
263 {
264 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
265 "cmd" => "insertAssetClip");
266 }
267 // insert chapter from learning module
268 if ($ilUser->clipboardHasObjectsOfType("st") && ilEditClipboard::getAction() == "copy")
269 {
270 $cmds[] = array("text" => $lng->txt("sahs_insert_st_from_clip"),
271 "cmd" => "insertLMChapterClip");
272 }
273 }
274 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
275 {
276 $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10);
277 if ($page_layouts > 0)
278 {
279 $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10);
280 }
281 if ($special_pages > 0)
282 {
283 $cmds[] = array("text" => $lng->txt("sahs_insert_special_page"), "cmd" => "insertSpecialPage", "multi" => 10);
284 }
285
286 if ($ilUser->clipboardHasObjectsOfType("page"))
287 {
288 $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
289 "cmd" => "insertPageClip");
290 }
291 if (($ilUser->clipboardHasObjectsOfType("pg") && ilEditClipboard::getAction() == "copy"))
292 {
293 $cmds[] = array("text" => $lng->txt("sahs_insert_pg_from_clip"),
294 "cmd" => "insertPageClip");
295 }
296 }
297
298/* if ($a_childs["type"] == "")
299 {
300 $cmds[] = array("text" => "insert Chapter", "cmd" => "insertChapter", "multi" => 10);
301 }*/
302 }
303
304 return $cmds;
305 }
306
310 function nodeAllowsChilds($a_node)
311 {
312 if ($a_node["type"] == "pg" || $a_node["type"] == "page")
313 {
314 return false;
315 }
316 return true;
317 }
318
324 function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
325 {
326 global $lng;
327
328 if ($a_node["type"] == "ass")
329 {
330 $this->makeDragContent($a_node["node_id"], "grp_sco");
331 }
332 else
333 {
334 $this->makeDragContent($a_node["node_id"], "grp_".$a_node["type"]);
335 }
336
337 if (!$a_first_child_drop_area)
338 {
339 // page targets
340 if ($a_node["type"] == "page" || ($a_node["type"] == "sco" && count($a_childs) == 0)
341 || ($a_node["type"] == "ass" && count($a_childs) == 0))
342 {
343 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
344 {
345 $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
346 true, "");
347 }
348 else
349 {
350 $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
351 false, "");
352 }
353 }
354
355 if ($a_node["type"] == "chap" && count($a_childs) == 0)
356 {
357 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
358 true, $lng->txt("cont_insert_into_chap"));
359 }
360
361 // sco targets
362 if ($a_node["type"] == "sco" || $a_node["type"] == "ass" || $a_node["type"] == "chap")
363 {
364 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
365 false, $lng->txt("cont_insert_after_".$a_node["type"]));
366 }
367
368 //if ($a_node["type"] != "pg")
369 //{
370 // $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
371 // true, $lng->txt("cont_insert_as_subchapter"));
372 //}
373
374 // chapter targets // chapters
375 if ($a_node["depth"] == 2)
376 {
377 $this->makeDragTarget($a_node["node_id"], "grp_chap", $a_first_child_drop_area,
378 false, $lng->txt("sahs_insert_as_chapter"));
379// $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
380// false, $lng->txt("cont_insert_after_chap"));
381 }
382 }
383 else
384 {
385 if ($a_node["type"] == "" && $a_node["node_id"] == 1) // top node
386 {
387 $this->makeDragTarget($a_node["node_id"], "grp_chap", $a_first_child_drop_area,
388 true);
389 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
390 true);
391 }
392 if ($a_node["type"] == "chap")
393 {
394 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
395 true);
396 }
397 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
398 {
399 $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
400 true);
401 }
402 }
403 }
404
411 function getChildCommands($a_item)
412 {
413 global $lng, $ilCtrl;
414
415 $commands = array();
416//echo "-".$a_item["type"]."-";
417 switch ($a_item["type"])
418 {
419 case "sco":
420 $ilCtrl->setParameterByClass("ilscorm2004scogui", "obj_id",
421 $a_item["node_id"]);
422 $commands[] = array("text" => $lng->txt("edit"),
423 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
424 "ilscorm2004scogui"), "showOrganization"));
425 break;
426
427 case "ass":
428 $ilCtrl->setParameterByClass("ilscorm2004assetgui", "obj_id",
429 $a_item["node_id"]);
430 $commands[] = array("text" => $lng->txt("edit"),
431 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
432 "ilscorm2004assetgui"), "showOrganization"));
433 break;
434
435 case "chap":
436 $ilCtrl->setParameterByClass("ilscorm2004chaptergui", "obj_id",
437 $a_item["node_id"]);
438 $commands[] = array("text" => $lng->txt("edit"),
439 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
440 "ilscorm2004chaptergui"), "showOrganization"));
441 break;
442
443 case "seqc":
444 $ilCtrl->setParameterByClass("ilscorm2004seqchaptergui", "obj_id",
445 $a_item["node_id"]);
446 $commands[] = array("text" => $lng->txt("edit"),
447 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
448 "ilscorm2004seqchaptergui"), "showOrganization"));
449 break;
450
451 case "page":
452 $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id",
453 $a_item["node_id"]);
454 $commands[] = array("text" => $lng->txt("edit"),
455 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
456 "ilscorm2004pagenodegui"), "edit"));
457 break;
458 }
459
460 return $commands;
461 }
462
463}
This class represents a hierarchical form.
setCheckboxName($a_checkboxname)
Set Checkbox Name.
makeDragContent($a_id, $a_group)
Makes a node a drag content.
setExpandVariable($a_val)
Set expand variable.
makeDragTarget($a_id, $a_group, $a_first_child_drop_area=false, $a_as_subitem=false, $a_diss_text="")
Makes a nodes (following droparea) a drag target.
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
This class allows quick editing of a chapter/sco/page hierarchy.
nodeAllowsChilds($a_node)
Which nodes allow child nodes?
getMenuItems($a_node, $a_depth, $a_first_child=false, $a_next_sibling=null, $a_childs=null)
Get menu items.
manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area=false, $a_next_sibling=null, $a_childs=null)
Makes nodes drag and drop content and targets.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15