ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
19  protected $lng;
20 
24  protected $ctrl;
25 
29  protected $tpl;
30 
34  protected $tabs;
35 
39  protected $locator;
40 
44  protected $user;
45 
46  public $node_object;
47  public $slm_object;
48 
54  public function __construct($a_slm_obj, $a_node_id = 0)
55  {
56  global $DIC;
57 
58  $this->lng = $DIC->language();
59  $this->ctrl = $DIC->ctrl();
60  $this->tpl = $DIC["tpl"];
61  $this->tabs = $DIC->tabs();
62  $this->locator = $DIC["ilLocator"];
63  $this->user = $DIC->user();
64  $this->slm_object = $a_slm_obj;
65  $this->node_object = null;
66 
67  if ($a_node_id > 0) {
68  $this->getNodeObject($a_node_id);
69  }
70  }
71 
77  public function setParentGUI($a_parentgui)
78  {
79  $this->parentgui = $a_parentgui;
80  }
81 
87  public function getParentGUI()
88  {
89  return $this->parentgui;
90  }
91 
95  public function getNodeObject($a_node_id)
96  {
97  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
98  $this->node_object = ilSCORM2004NodeFactory::getInstance(
99  $this->slm_object,
100  $a_node_id,
101  false
102  );
103  }
104 
110  public function putInTree($a_parent_id, $a_target)
111  {
112  $tree = new ilTree($this->slm_object->getId());
113  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
114  $tree->setTreeTablePK("slm_id");
115 
116  /*$parent_id = (!empty($_GET["obj_id"]))
117  ? $_GET["obj_id"]
118  : $tree->getRootId();*/
119 
120  /* if (!empty($_GET["target"]))
121  {
122  $target = $_GET["target"];
123  }
124  else
125  {
126  // determine last child of current type
127  $childs =& $tree->getChildsByType($parent_id, $this->obj->getType());
128  if (count($childs) == 0)
129  {
130  $target = IL_FIRST_NODE;
131  }
132  else
133  {
134  $target = $childs[count($childs) - 1]["obj_id"];
135  }
136  }*/
137  if (!$tree->isInTree($this->node_obj->getId())) {
138  $tree->insertNode($this->node_obj->getId(), $parent_id, $target);
139  }
140  }
141 
142 
148  /* function delete()
149  {
150  $this->setTabs();
151 
152  $cont_obj_gui = new ilObjContentObjectGUI("",$this->content_object->getRefId(),
153  true, false);
154  $cont_obj_gui->delete($this->obj->getId());
155  }
156  */
157 
158 
164  /* function cancelDelete()
165  {
166  ilSession::clear("saved_post");
167  $this->ctrl->redirect($this, $_GET["backcmd"]);
168  }*/
169 
170 
176  /* function confirmedDelete()
177  {
178  $cont_obj_gui = new ilObjContentObjectGUI("",$this->content_object->getRefId(),
179  true, false);
180  $cont_obj_gui->confirmedDelete($this->obj->getId());
181  $this->ctrl->redirect($this, $_GET["backcmd"]);
182  }
183  */
184 
185 
191  /* function checkTree()
192  {
193  $this->content_object->checkTree();
194  }
195  */
196 
200  public function showOrganization()
201  {
202  $lng = $this->lng;
204  $tpl = $this->tpl;
205  $ilTabs = $this->tabs;
206 
207  $this->setTabs();
208  $ilTabs->setTabActive("sahs_organization");
209  $this->setLocator();
210  $this->getParentGUI()->showOrganization(
211  $this->node_object->getId(),
212  $ilCtrl->getFormAction($this),
213  $this->node_object->getTitle(),
214  ilUtil::getImagePath("icon_" . $this->node_object->getType() . ".svg"),
215  $this,
216  "showOrganization"
217  );
218  }
219 
223  public function insertChapter()
224  {
226 
227  $res = $this->getParentGUI()->insertChapter(false);
228  $ilCtrl->setParameter($this, "highlight", $res["items"]);
229  $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
230  }
231 
235  public function insertSco()
236  {
238 
239  $res = $this->getParentGUI()->insertSco(false);
240  $ilCtrl->setParameter($this, "highlight", $res["items"]);
241  $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
242  }
243 
247  public function insertAsset()
248  {
250 
251  $res = $this->getParentGUI()->insertAsset(false);
252  $ilCtrl->setParameter($this, "highlight", $res["items"]);
253  $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
254  }
255 
259  public function insertPage()
260  {
262 
263  $res = $this->getParentGUI()->insertPage(false);
264  $ilCtrl->setParameter($this, "highlight", $res["items"]);
265  $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
266  }
267 
271  public function insertTemplateGUI()
272  {
274  $this->getParentGUI()->insertTemplateGUI(true);
275  }
276 
280  public function insertSpecialPage()
281  {
283  $this->getParentGUI()->insertSpecialPage(true);
284  }
285 
289  public function collapseAll()
290  {
292 
293  $this->getParentGUI()->collapseAll(false);
294  $ilCtrl->redirect($this, "showOrganization");
295  }
296 
300  public function ExpandAll()
301  {
303 
304  $this->getParentGUI()->expandAll(false);
305  $ilCtrl->redirect($this, "showOrganization");
306  }
307 
311  public function saveAllTitles()
312  {
314 
315  $this->getParentGUI()->saveAllTitles(false);
316  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
317  $ilCtrl->redirect($this, "showOrganization");
318  }
319 
323  public function deleteNodes()
324  {
326 
327  $ilCtrl->setParameter($this, "backcmd", $_GET["backcmd"]);
328  $this->getParentGUI()->deleteNodes($ilCtrl->getFormAction($this));
329  }
330 
334  public function cancelDelete()
335  {
337  $ilCtrl->redirect($this, "showOrganization");
338  }
339 
343  public function confirmedDelete()
344  {
346 
347  $this->getParentGUI()->confirmedDelete(false);
348  $ilCtrl->redirect($this, "showOrganization");
349  }
350 
354  public function setLocator()
355  {
356  $ilLocator = $this->locator;
357  $tpl = $this->tpl;
359 
360  $ilLocator->addRepositoryItems($_GET["ref_id"]);
361  $this->getParentGUI()->addLocatorItems();
362 
363  if ($_GET["obj_id"] > 0) {
364  $tree = new ilTree($this->slm_object->getId());
365  $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
366  $tree->setTreeTablePK("slm_id");
367  $path = $tree->getPathFull($_GET["obj_id"]);
368  for ($i = 1; $i < count($path); $i++) {
369  //var_dump($path[$i]);
370  switch ($path[$i]["type"]) {
371  case "chap":
372  $ilCtrl->setParameterByClass(
373  "ilscorm2004chaptergui",
374  "obj_id",
375  $path[$i]["child"]
376  );
377  $ilLocator->addItem(
378  $path[$i]["title"],
379  $ilCtrl->getLinkTargetByClass(
380  "ilscorm2004chaptergui",
381  "showOrganization"
382  ),
383  "",
384  0,
385  $path[$i]["type"],
386  ilUtil::getImagePath("icon_chap.svg")
387  );
388  break;
389 
390  case "seqc":
391  $ilCtrl->setParameterByClass(
392  "ilscorm2004seqchaptergui",
393  "obj_id",
394  $path[$i]["child"]
395  );
396  $ilLocator->addItem(
397  $path[$i]["title"],
398  $ilCtrl->getLinkTargetByClass(
399  "ilscorm2004seqchaptergui",
400  "showOrganization"
401  ),
402  "",
403  0,
404  $path[$i]["type"],
405  ilUtil::getImagePath("icon_chap.svg")
406  );
407  break;
408 
409  case "sco":
410  $ilCtrl->setParameterByClass(
411  "ilscorm2004scogui",
412  "obj_id",
413  $path[$i]["child"]
414  );
415  $ilLocator->addItem(
416  $path[$i]["title"],
417  $ilCtrl->getLinkTargetByClass(
418  "ilscorm2004scogui",
419  "showOrganization"
420  ),
421  "",
422  0,
423  $path[$i]["type"],
424  ilUtil::getImagePath("icon_sco.svg")
425  );
426  break;
427 
428  case "ass":
429  $ilCtrl->setParameterByClass(
430  "ilscorm2004assetgui",
431  "obj_id",
432  $path[$i]["child"]
433  );
434  $ilLocator->addItem(
435  $path[$i]["title"],
436  $ilCtrl->getLinkTargetByClass(
437  "ilscorm2004assetgui",
438  "showOrganization"
439  ),
440  "",
441  0,
442  $path[$i]["type"],
443  ilUtil::getImagePath("icon_sca.svg")
444  );
445  break;
446 
447  case "page":
448  $ilCtrl->setParameterByClass(
449  "ilscorm2004pagegui",
450  "obj_id",
451  $path[$i]["child"]
452  );
453  $ilLocator->addItem(
454  $path[$i]["title"],
455  $ilCtrl->getLinkTargetByClass(
456  "ilscorm2004pagegui",
457  "edit"
458  ),
459  "",
460  0,
461  $path[$i]["type"],
462  ilUtil::getImagePath("icon_pg.svg")
463  );
464  break;
465  }
466  }
467  }
468  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
469 
470  $tpl->setLocator();
471  }
472 
476  public function setContentStyle()
477  {
478  $tpl = $this->tpl;
479 
480  // content styles
481  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
482  $tpl->setCurrentBlock("ContentStyle");
483  $tpl->setVariable(
484  "LOCATION_CONTENT_STYLESHEET",
485  ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId())
486  );
487  $tpl->setVariable(
488  "LOCATION_ADDITIONAL_STYLESHEET",
490  );
491  $tpl->parseCurrentBlock();
492 
493  $tpl->setCurrentBlock("SyntaxStyle");
494  $tpl->setVariable(
495  "LOCATION_SYNTAX_STYLESHEET",
497  );
498  $tpl->parseCurrentBlock();
499  }
500 
504  public function copyItems($a_return = "showOrganization")
505  {
507  $lng = $this->lng;
508 
509  $items = ilUtil::stripSlashesArray($_POST["id"]);
510  $todel = array(); // delete IDs < 0 (needed for non-js editing)
511  foreach ($items as $k => $item) {
512  if ($item < 0) {
513  $todel[] = $k;
514  }
515  }
516  foreach ($todel as $k) {
517  unset($items[$k]);
518  }
519  if (!ilSCORM2004Node::uniqueTypesCheck($items)) {
520  ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
521  $ilCtrl->redirect($this, $a_return);
522  }
523  ilSCORM2004Node::clipboardCopy($this->slm_object->getId(), $items);
524 
525  // @todo: move this to a service since it can be used here, too
526  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
528  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
529 
530  $ilCtrl->redirect($this, $a_return);
531  }
532 
536  public function cutItems($a_return = "showOrganization")
537  {
539  $lng = $this->lng;
540 
541  $items = ilUtil::stripSlashesArray($_POST["id"]);
542  $todel = array(); // delete IDs < 0 (needed for non-js editing)
543  foreach ($items as $k => $item) {
544  if ($item < 0) {
545  $todel[] = $k;
546  }
547  }
548  foreach ($todel as $k) {
549  unset($items[$k]);
550  }
551 
552  if (!ilSCORM2004Node::uniqueTypesCheck($items)) {
553  ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
554  $ilCtrl->redirect($this, $a_return);
555  }
556 
557  ilSCORM2004Node::clipboardCut($this->slm_object->getId(), $items);
558 
559  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
561 
562  ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
563 
564  $ilCtrl->redirect($this, $a_return);
565  }
566 
570  public function insertPageClip()
571  {
574 
575  ilSCORM2004Node::insertPageClip($this->slm_object);
576 
577  $ilCtrl->redirect(
578  $this,
579  "showOrganization",
581  );
582  }
583 
587  public function insertScoClip()
588  {
591 
592  ilSCORM2004Node::insertScoClip($this->slm_object);
593 
594  $ilCtrl->redirect(
595  $this,
596  "showOrganization",
598  );
599  }
600 
604  public function insertAssetClip()
605  {
608 
609  ilSCORM2004Node::insertAssetClip($this->slm_object);
610 
611  $ilCtrl->redirect(
612  $this,
613  "showOrganization",
615  );
616  }
617 
621  public function insertLMChapterClip()
622  {
625 
626  $this->setLocator();
627  $this->setTabs();
628  $this->getParentGUI()->insertLMChapterClip();
629  }
630 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
static clipboardCopy($a_slm_obj_id, $a_ids)
Copy a set of chapters/pages/scos into the clipboard.
setParentGUI($a_parentgui)
Set Parent GUI class (ilObjSCORM2004LearningModuleGUI).
Class ilSCORM2004NodeGUI.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
__construct($a_slm_obj, $a_node_id=0)
constructor
static clipboardCut($a_slm_obj_id, $a_ids)
Cut and copy a set of chapters/pages into the clipboard.
static getPostNodeId()
Get node ID of _POST input.
getParentGUI()
Get Parent GUI class (ilObjSCORM2004LearningModuleGUI).
static insertPageClip($a_slm_obj)
Insert pages from clipboard.
setLocator()
Set Locator Items.
static insertScoClip($a_slm_obj)
Insert scos from clipboard.
getNodeObject($a_node_id)
Get node object (chapter/sco/page)
user()
Definition: user.php:4
insertScoClip()
Insert scos from clipboard.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
cutItems($a_return="showOrganization")
Copy items to clipboard, then cut them from the current tree.
foreach($_POST as $key=> $value) $res
static getInstance($a_slm_object, $a_id=0, $a_halt=true)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
insertPageClip()
Insert pages from clipboard.
$ilUser
Definition: imgupload.php:18
insertLMChapterClip()
Insert scos from clipboard.
confirmedDelete()
confirmed delete
putInTree($a_parent_id, $a_target)
put this object into content object tree
showOrganization()
Confirm deletion screen (delete page or structure objects)
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be &#39;obj_id&#39; You may use...
static getSyntaxStylePath()
get syntax style path
static uniqueTypesCheck($a_items)
Check for unique types (all pages or all chapters or all scos)
static getContentStylePath($a_style_id, $add_random=true)
get content style path
insertAssetClip()
Insert assets from clipboard.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
deleteNodes()
Delete nodes in the hierarchy.
insertSpecialPage()
Insert special page.
$i
Definition: disco.tpl.php:19
copyItems($a_return="showOrganization")
Copy items to clipboard.
static setAction($a_action)
setContentStyle()
Set content style sheet.
insertTemplateGUI()
Insert Page with Layout.
static insertAssetClip($a_slm_obj, $a_type="ass")
Insert assets from clipboard.
insertChapter()
Insert Chapter.
$_POST["username"]