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