ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004NodeGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
15 {
18 
24  function ilSCORM2004NodeGUI($a_slm_obj, $a_node_id = 0)
25  {
26  $this->slm_object = $a_slm_obj;
27  $this->node_object = null;
28 
29  if ($a_node_id > 0)
30  {
31  $this->getNodeObject($a_node_id);
32  }
33  }
34 
40  function setParentGUI($a_parentgui)
41  {
42  $this->parentgui = $a_parentgui;
43  }
44 
50  function getParentGUI()
51  {
52  return $this->parentgui;
53  }
54 
58  function getNodeObject($a_node_id)
59  {
60  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
61  $this->node_object = ilSCORM2004NodeFactory::getInstance($this->slm_object,
62  $a_node_id, false);
63  }
64 
70  function putInTree($a_parent_id, $a_target)
71  {
72  $tree = new ilTree($this->slm_object->getId());
73  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
74  $tree->setTreeTablePK("slm_id");
75 
76  /*$parent_id = (!empty($_GET["obj_id"]))
77  ? $_GET["obj_id"]
78  : $tree->getRootId();*/
79 
80 /* if (!empty($_GET["target"]))
81  {
82  $target = $_GET["target"];
83  }
84  else
85  {
86  // determine last child of current type
87  $childs =& $tree->getChildsByType($parent_id, $this->obj->getType());
88  if (count($childs) == 0)
89  {
90  $target = IL_FIRST_NODE;
91  }
92  else
93  {
94  $target = $childs[count($childs) - 1]["obj_id"];
95  }
96  }*/
97  if (!$tree->isInTree($this->node_obj->getId()))
98  {
99  $tree->insertNode($this->node_obj->getId(), $parent_id, $target);
100  }
101  }
102 
103 
109 /* function delete()
110  {
111  $this->setTabs();
112 
113  $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
114  true, false);
115  $cont_obj_gui->delete($this->obj->getId());
116  }
117 */
118 
119 
125 /* function cancelDelete()
126  {
127  ilSession::clear("saved_post");
128  $this->ctrl->redirect($this, $_GET["backcmd"]);
129  }*/
130 
131 
137 /* function confirmedDelete()
138  {
139  $cont_obj_gui =& new ilObjContentObjectGUI("",$this->content_object->getRefId(),
140  true, false);
141  $cont_obj_gui->confirmedDelete($this->obj->getId());
142  $this->ctrl->redirect($this, $_GET["backcmd"]);
143  }
144 */
145 
146 
152 /* function checkTree()
153  {
154  $this->content_object->checkTree();
155  }
156 */
157 
161  function showOrganization()
162  {
163  global $lng, $ilCtrl, $tpl, $ilTabs;
164 
165  $this->setTabs();
166  $ilTabs->setTabActive("sahs_organization");
167  $this->setLocator();
168  $this->getParentGUI()->showOrganization($this->node_object->getId(),
169  $ilCtrl->getFormAction($this), $this->node_object->getTitle(),
170  ilUtil::getImagePath("icon_".$this->node_object->getType().".png"),
171  $this, "showOrganization");
172  }
173 
177  function insertChapter()
178  {
179  global $ilCtrl;
180 
181  $res = $this->getParentGUI()->insertChapter(false);
182  $ilCtrl->setParameter($this, "highlight", $res["items"]);
183  $ilCtrl->redirect($this, "showOrganization", "node_".$res["node_id"]);
184  }
185 
189  function insertSco()
190  {
191  global $ilCtrl;
192 
193  $res = $this->getParentGUI()->insertSco(false);
194  $ilCtrl->setParameter($this, "highlight", $res["items"]);
195  $ilCtrl->redirect($this, "showOrganization", "node_".$res["node_id"]);
196  }
197 
201  function insertAsset()
202  {
203  global $ilCtrl;
204 
205  $res = $this->getParentGUI()->insertAsset(false);
206  $ilCtrl->setParameter($this, "highlight", $res["items"]);
207  $ilCtrl->redirect($this, "showOrganization", "node_".$res["node_id"]);
208  }
209 
213  function insertPage()
214  {
215  global $ilCtrl;
216 
217  $res = $this->getParentGUI()->insertPage(false);
218  $ilCtrl->setParameter($this, "highlight", $res["items"]);
219  $ilCtrl->redirect($this, "showOrganization", "node_".$res["node_id"]);
220  }
221 
225  function insertTemplateGUI()
226  {
227  global $ilCtrl;
228  $this->getParentGUI()->insertTemplateGUI(true);
229  }
230 
234  function insertSpecialPage()
235  {
236  global $ilCtrl;
237  $this->getParentGUI()->insertSpecialPage(true);
238  }
239 
243  function collapseAll()
244  {
245  global $ilCtrl;
246 
247  $this->getParentGUI()->collapseAll(false);
248  $ilCtrl->redirect($this, "showOrganization");
249  }
250 
254  function ExpandAll()
255  {
256  global $ilCtrl;
257 
258  $this->getParentGUI()->expandAll(false);
259  $ilCtrl->redirect($this, "showOrganization");
260  }
261 
265  function saveAllTitles()
266  {
267  global $ilCtrl;
268 
269  $this->getParentGUI()->saveAllTitles(false);
270  $ilCtrl->redirect($this, "showOrganization");
271  }
272 
276  function deleteNodes()
277  {
278  global $ilCtrl;
279 
280  $ilCtrl->setParameter($this, "backcmd", $_GET["backcmd"]);
281  $this->getParentGUI()->deleteNodes($ilCtrl->getFormAction($this));
282  }
283 
287  function cancelDelete()
288  {
289  global $ilCtrl;
290  $ilCtrl->redirect($this, "showOrganization");
291  }
292 
296  function confirmedDelete()
297  {
298  global $ilCtrl;
299 
300  $this->getParentGUI()->confirmedDelete(false);
301  $ilCtrl->redirect($this, "showOrganization");
302  }
303 
307  function setLocator()
308  {
309  global $ilLocator, $tpl, $ilCtrl;
310 
311  $ilLocator->addRepositoryItems($_GET["ref_id"]);
312  $this->getParentGUI()->addLocatorItems();
313 
314  if ($_GET["obj_id"] > 0)
315  {
316  $tree = new ilTree($this->slm_object->getId());
317  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
318  $tree->setTreeTablePK("slm_id");
319  $path = $tree->getPathFull($_GET["obj_id"]);
320  for( $i = 1; $i < count($path); $i++)
321  {
322 //var_dump($path[$i]);
323  switch($path[$i]["type"])
324  {
325  case "chap":
326  $ilCtrl->setParameterByClass("ilscorm2004chaptergui", "obj_id",
327  $path[$i]["child"]);
328  $ilLocator->addItem($path[$i]["title"],
329  $ilCtrl->getLinkTargetByClass("ilscorm2004chaptergui",
330  "showOrganization"), "", 0, $path[$i]["type"],
331  ilUtil::getImagePath("icon_chap_s.png"));
332  break;
333 
334  case "seqc":
335  $ilCtrl->setParameterByClass("ilscorm2004seqchaptergui", "obj_id",
336  $path[$i]["child"]);
337  $ilLocator->addItem($path[$i]["title"],
338  $ilCtrl->getLinkTargetByClass("ilscorm2004seqchaptergui",
339  "showOrganization"), "", 0, $path[$i]["type"],
340  ilUtil::getImagePath("icon_chap_s.png"));
341  break;
342 
343  case "sco":
344  $ilCtrl->setParameterByClass("ilscorm2004scogui", "obj_id",
345  $path[$i]["child"]);
346  $ilLocator->addItem($path[$i]["title"],
347  $ilCtrl->getLinkTargetByClass("ilscorm2004scogui",
348  "showOrganization"), "", 0, $path[$i]["type"],
349  ilUtil::getImagePath("icon_sco_s.png"));
350  break;
351 
352  case "ass":
353  $ilCtrl->setParameterByClass("ilscorm2004assetgui", "obj_id",
354  $path[$i]["child"]);
355  $ilLocator->addItem($path[$i]["title"],
356  $ilCtrl->getLinkTargetByClass("ilscorm2004assetgui",
357  "showOrganization"), "", 0, $path[$i]["type"],
358  ilUtil::getImagePath("icon_sca_s.png"));
359  break;
360 
361  case "page":
362  $ilCtrl->setParameterByClass("ilscorm2004pagegui", "obj_id",
363  $path[$i]["child"]);
364  $ilLocator->addItem($path[$i]["title"],
365  $ilCtrl->getLinkTargetByClass("ilscorm2004pagegui",
366  "edit"), "", 0, $path[$i]["type"],
367  ilUtil::getImagePath("icon_pg_s.png"));
368  break;
369  }
370  }
371  }
372  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
373 
374  $tpl->setLocator();
375  }
376 
380  function setContentStyle()
381  {
382  global $tpl;
383 
384  // content styles
385  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
386  $tpl->setCurrentBlock("ContentStyle");
387  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
388  ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId()));
389  $tpl->setVariable("LOCATION_ADDITIONAL_STYLESHEET",
391  $tpl->parseCurrentBlock();
392 
393  $tpl->setCurrentBlock("SyntaxStyle");
394  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
396  $tpl->parseCurrentBlock();
397  }
398 
402  function copyItems($a_return = "showOrganization")
403  {
404  global $ilCtrl, $lng;
405 
406  $items = ilUtil::stripSlashesArray($_POST["id"]);
407  $todel = array(); // delete IDs < 0 (needed for non-js editing)
408  foreach($items as $k => $item)
409  {
410  if ($item < 0)
411  {
412  $todel[] = $k;
413  }
414  }
415  foreach($todel as $k)
416  {
417  unset($items[$k]);
418  }
420  {
421  ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
422  $ilCtrl->redirect($this, $a_return);
423  }
424  ilSCORM2004Node::clipboardCopy($this->slm_object->getId(), $items);
425 
426  // @todo: move this to a service since it can be used here, too
427  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
429  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
430 
431  $ilCtrl->redirect($this, $a_return);
432  }
433 
437  function cutItems($a_return = "showOrganization")
438  {
439  global $ilCtrl, $lng;
440 
441  $items = ilUtil::stripSlashesArray($_POST["id"]);
442  $todel = array(); // delete IDs < 0 (needed for non-js editing)
443  foreach($items as $k => $item)
444  {
445  if ($item < 0)
446  {
447  $todel[] = $k;
448  }
449  }
450  foreach($todel as $k)
451  {
452  unset($items[$k]);
453  }
454 
456  {
457  ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
458  $ilCtrl->redirect($this, $a_return);
459  }
460 
461  ilSCORM2004Node::clipboardCut($this->slm_object->getId(), $items);
462 
463  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
465 
466  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
467 
468  $ilCtrl->redirect($this, $a_return);
469  }
470 
474  function insertPageClip()
475  {
476  global $ilCtrl, $ilUser;
477 
478  ilSCORM2004Node::insertPageClip($this->slm_object);
479 
480  $ilCtrl->redirect($this, "showOrganization",
482  }
483 
487  function insertScoClip()
488  {
489  global $ilCtrl, $ilUser;
490 
491  ilSCORM2004Node::insertScoClip($this->slm_object);
492 
493  $ilCtrl->redirect($this, "showOrganization",
495  }
496 
500  function insertAssetClip()
501  {
502  global $ilCtrl, $ilUser;
503 
504  ilSCORM2004Node::insertAssetClip($this->slm_object);
505 
506  $ilCtrl->redirect($this, "showOrganization",
508  }
509 
510 }
511 ?>