ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 include_once("./Services/Style/classes/class.ilPageLayout.php");
38 $page_layouts = (count(ilPageLayout::activeLayouts()) > 0);
39 $special_pages = (count(ilPageLayout::activeLayouts(true)) > 0);
40
41 $cmds = array();
42//echo "+".$a_depth."-";
43 if (!$a_first_child) // drop area of node
44 {
45 // page inserts
46 if ($a_node["type"] == "page" || ($a_node["type"] == "sco" && count($a_childs) == 0) ||
47 ($a_node["type"] == "ass" && count($a_childs) == 0))
48 {
49 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
50 {
51 $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10,
52 "as_subitem" => true);
53 if ($page_layouts > 0)
54 {
55 $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10,
56 "as_subitem" => true);
57 }
58 if ($special_pages > 0)
59 {
60 $cmds[] = array("text" => $lng->txt("sahs_insert_special_page"), "cmd" => "insertSpecialPage", "multi" => 10,
61 "as_subitem" => true);
62 }
63 if ($ilUser->clipboardHasObjectsOfType("page"))
64 {
65 $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
66 "cmd" => "insertPageClip", "as_subitem" => true);
67 }
68 }
69 else
70 {
71 $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10);
72 if ($page_layouts > 0)
73 {
74 $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10);
75 }
76 if ($special_pages > 0)
77 {
78 $cmds[] = array("text" => $lng->txt("sahs_insert_special_page"), "cmd" => "insertSpecialPage", "multi" => 10);
79 }
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/asset inserts... in/after chapters
90 if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
91 {
92 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
93 if (count($a_childs) == 0)
94 {
95 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_inside_chap"), "cmd" => "insertAsset", "multi" => 10,
96 "as_subitem" => true);
97 }
98 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
99 if (count($a_childs) == 0)
100 {
101 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_inside_chap"), "cmd" => "insertSco", "multi" => 10,
102 "as_subitem" => true);
103 }
104 if ($ilUser->clipboardHasObjectsOfType("sco"))
105 {
106 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
107 "cmd" => "insertScoClip", "as_subitem" => false);
108 if (count($a_childs) == 0)
109 {
110 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip_inside_chap"),
111 "cmd" => "insertScoClip", "as_subitem" => true);
112 }
113 }
114 if ($ilUser->clipboardHasObjectsOfType("ass"))
115 {
116 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
117 "cmd" => "insertAssetClip", "as_subitem" => false);
118 if (count($a_childs) == 0)
119 {
120 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip_inside_chap"),
121 "cmd" => "insertAssetClip", "as_subitem" => true);
122 }
123 }
124 }
125
126 // sco/asset inserts... after sco/assets
127 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
128 {
129 // scos
130 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
131 if ($ilUser->clipboardHasObjectsOfType("sco"))
132 {
133 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
134 "cmd" => "insertScoClip");
135 }
136
137 // assets
138 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
139 if ($ilUser->clipboardHasObjectsOfType("ass"))
140 {
141 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
142 "cmd" => "insertAssetClip");
143 }
144
145 // chapters
146 if ($a_node["depth"] == 2)
147 {
148 $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
149 if ($ilUser->clipboardHasObjectsOfType("chap"))
150 {
151 $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
152 "cmd" => "insertChapterClip");
153 }
154 }
155 }
156 //if ($a_node["type"] == "chap")
157 //{
158 // $cmds[] = array("text" => $lng->txt("sahs_insert_sub_chapter"), "cmd" => "insertSubchapter", "multi" => 10);
159 //}
160
161 // chapter inserts
162 if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
163 {
164 $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
165 if ($ilUser->clipboardHasObjectsOfType("chap"))
166 {
167 $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
168 "cmd" => "insertChapterClip");
169 }
170
171 //check if parent chaper has sequencing scenario
172 // $cmds[] = array("text" => $lng->txt("sahs_insert_scenario"), "cmd" => "insertScenarioGUI", "multi" => 0);
173
174 }
175 }
176 else // drop area before first child of node
177 {
178 if ($a_node["type"] == "" && $a_node["node_id"] == 1) // top node
179 {
180 // scos
181 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
182 if ($ilUser->clipboardHasObjectsOfType("sco"))
183 {
184 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
185 "cmd" => "insertScoClip");
186 }
187
188 // assets
189 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
190 if ($ilUser->clipboardHasObjectsOfType("ass"))
191 {
192 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
193 "cmd" => "insertAssetClip");
194 }
195
196 // chapters
197 $cmds[] = array("text" => $lng->txt("sahs_insert_chapter"), "cmd" => "insertChapter", "multi" => 10);
198 if ($ilUser->clipboardHasObjectsOfType("chap"))
199 {
200 $cmds[] = array("text" => $lng->txt("sahs_insert_chap_from_clip"),
201 "cmd" => "insertChapterClip");
202 }
203 // $cmds[] = array("text" => $lng->txt("sahs_insert_scenario"), "cmd" => "insertScenarioGUI", "multi" => 0);
204 }
205 if ($a_node["type"] == "chap" || $a_node["type"] == "seqc")
206 {
207 $cmds[] = array("text" => $lng->txt("sahs_insert_sco"), "cmd" => "insertSco", "multi" => 10);
208 $cmds[] = array("text" => $lng->txt("sahs_insert_ass"), "cmd" => "insertAsset", "multi" => 10);
209 if ($ilUser->clipboardHasObjectsOfType("sco"))
210 {
211 $cmds[] = array("text" => $lng->txt("sahs_insert_sco_from_clip"),
212 "cmd" => "insertScoClip");
213 }
214 if ($ilUser->clipboardHasObjectsOfType("ass"))
215 {
216 $cmds[] = array("text" => $lng->txt("sahs_insert_ass_from_clip"),
217 "cmd" => "insertAssetClip");
218 }
219 }
220 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
221 {
222 $cmds[] = array("text" => $lng->txt("sahs_insert_page"), "cmd" => "insertPage", "multi" => 10);
223 if ($page_layouts > 0)
224 {
225 $cmds[] = array("text" => $lng->txt("sahs_insert_pagelayout"), "cmd" => "insertTemplateGUI", "multi" => 10);
226 }
227 if ($special_pages > 0)
228 {
229 $cmds[] = array("text" => $lng->txt("sahs_insert_special_page"), "cmd" => "insertSpecialPage", "multi" => 10);
230 }
231
232 if ($ilUser->clipboardHasObjectsOfType("page"))
233 {
234 $cmds[] = array("text" => $lng->txt("sahs_insert_page_from_clip"),
235 "cmd" => "insertPageClip");
236 }
237 }
238
239/* if ($a_childs["type"] == "")
240 {
241 $cmds[] = array("text" => "insert Chapter", "cmd" => "insertChapter", "multi" => 10);
242 }*/
243 }
244
245 return $cmds;
246 }
247
251 function nodeAllowsChilds($a_node)
252 {
253 if ($a_node["type"] == "pg")
254 {
255 return false;
256 }
257 return true;
258 }
259
265 function manageDragAndDrop($a_node, $a_depth, $a_first_child_drop_area = false, $a_next_sibling = null, $a_childs = null)
266 {
267 global $lng;
268
269 if ($a_node["type"] == "ass")
270 {
271 $this->makeDragContent($a_node["node_id"], "grp_sco");
272 }
273 else
274 {
275 $this->makeDragContent($a_node["node_id"], "grp_".$a_node["type"]);
276 }
277
278 if (!$a_first_child_drop_area)
279 {
280 // page targets
281 if ($a_node["type"] == "page" || ($a_node["type"] == "sco" && count($a_childs) == 0)
282 || ($a_node["type"] == "ass" && count($a_childs) == 0))
283 {
284 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
285 {
286 $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
287 true, "");
288 }
289 else
290 {
291 $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
292 false, "");
293 }
294 }
295
296 if ($a_node["type"] == "chap" && count($a_childs) == 0)
297 {
298 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
299 true, $lng->txt("cont_insert_into_chap"));
300 }
301
302 // sco targets
303 if ($a_node["type"] == "sco" || $a_node["type"] == "ass" || $a_node["type"] == "chap")
304 {
305 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
306 false, $lng->txt("cont_insert_after_".$a_node["type"]));
307 }
308
309 //if ($a_node["type"] != "pg")
310 //{
311 // $this->makeDragTarget($a_node["node_id"], "grp_st", $a_first_child_drop_area,
312 // true, $lng->txt("cont_insert_as_subchapter"));
313 //}
314
315 // chapter targets // chapters
316 if ($a_node["depth"] == 2)
317 {
318 $this->makeDragTarget($a_node["node_id"], "grp_chap", $a_first_child_drop_area,
319 false, $lng->txt("sahs_insert_as_chapter"));
320// $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
321// false, $lng->txt("cont_insert_after_chap"));
322 }
323 }
324 else
325 {
326 if ($a_node["type"] == "" && $a_node["node_id"] == 1) // top node
327 {
328 $this->makeDragTarget($a_node["node_id"], "grp_chap", $a_first_child_drop_area,
329 true);
330 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
331 true);
332 }
333 if ($a_node["type"] == "chap")
334 {
335 $this->makeDragTarget($a_node["node_id"], "grp_sco", $a_first_child_drop_area,
336 true);
337 }
338 if ($a_node["type"] == "sco" || $a_node["type"] == "ass")
339 {
340 $this->makeDragTarget($a_node["node_id"], "grp_page", $a_first_child_drop_area,
341 true);
342 }
343 }
344 }
345
352 function getChildCommands($a_item)
353 {
354 global $lng, $ilCtrl;
355
356 $commands = array();
357//echo "-".$a_item["type"]."-";
358 switch ($a_item["type"])
359 {
360 case "sco":
361 $ilCtrl->setParameterByClass("ilscorm2004scogui", "obj_id",
362 $a_item["node_id"]);
363 $commands[] = array("text" => $lng->txt("edit"),
364 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
365 "ilscorm2004scogui"), "showOrganization"));
366 break;
367
368 case "ass":
369 $ilCtrl->setParameterByClass("ilscorm2004assetgui", "obj_id",
370 $a_item["node_id"]);
371 $commands[] = array("text" => $lng->txt("edit"),
372 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
373 "ilscorm2004assetgui"), "showOrganization"));
374 break;
375
376 case "chap":
377 $ilCtrl->setParameterByClass("ilscorm2004chaptergui", "obj_id",
378 $a_item["node_id"]);
379 $commands[] = array("text" => $lng->txt("edit"),
380 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
381 "ilscorm2004chaptergui"), "showOrganization"));
382 break;
383
384 case "seqc":
385 $ilCtrl->setParameterByClass("ilscorm2004seqchaptergui", "obj_id",
386 $a_item["node_id"]);
387 $commands[] = array("text" => $lng->txt("edit"),
388 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
389 "ilscorm2004seqchaptergui"), "showOrganization"));
390 break;
391
392 case "page":
393 $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id",
394 $a_item["node_id"]);
395 $commands[] = array("text" => $lng->txt("edit"),
396 "link" => $ilCtrl->getLinkTargetByClass(array("ilobjscorm2004learningmodulegui",
397 "ilscorm2004pagenodegui"), "edit"));
398 break;
399 }
400
401 return $commands;
402 }
403
404}
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