ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
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 // 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//
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 // {
139 // $tree->insertNode($this->node_obj->getId(), $parent_id, $target);
140 // }
141 // }
142
143
149 /* function delete()
150 {
151 $this->setTabs();
152
153 $cont_obj_gui = new ilObjContentObjectGUI("",$this->content_object->getRefId(),
154 true, false);
155 $cont_obj_gui->delete($this->obj->getId());
156 }
157 */
158
159
165 /* function cancelDelete()
166 {
167 ilSession::clear("saved_post");
168 $this->ctrl->redirect($this, $_GET["backcmd"]);
169 }*/
170
171
177 /* function confirmedDelete()
178 {
179 $cont_obj_gui = new ilObjContentObjectGUI("",$this->content_object->getRefId(),
180 true, false);
181 $cont_obj_gui->confirmedDelete($this->obj->getId());
182 $this->ctrl->redirect($this, $_GET["backcmd"]);
183 }
184 */
185
186
192 /* function checkTree()
193 {
194 $this->content_object->checkTree();
195 }
196 */
197
201 public function showOrganization()
202 {
206 $ilTabs = $this->tabs;
207
208 $this->setTabs();
209 $ilTabs->setTabActive("sahs_organization");
210 $this->setLocator();
211 $this->getParentGUI()->showOrganization(
212 $this->node_object->getId(),
213 $ilCtrl->getFormAction($this),
214 $this->node_object->getTitle(),
215 ilUtil::getImagePath("icon_" . $this->node_object->getType() . ".svg"),
216 $this,
217 "showOrganization"
218 );
219 }
220
224 public function insertChapter()
225 {
227
228 $res = $this->getParentGUI()->insertChapter(false);
229 $ilCtrl->setParameter($this, "highlight", $res["items"]);
230 $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
231 }
232
236 public function insertSco()
237 {
239
240 $res = $this->getParentGUI()->insertSco(false);
241 $ilCtrl->setParameter($this, "highlight", $res["items"]);
242 $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
243 }
244
248 public function insertAsset()
249 {
251
252 $res = $this->getParentGUI()->insertAsset(false);
253 $ilCtrl->setParameter($this, "highlight", $res["items"]);
254 $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
255 }
256
260 public function insertPage()
261 {
263
264 $res = $this->getParentGUI()->insertPage(false);
265 $ilCtrl->setParameter($this, "highlight", $res["items"]);
266 $ilCtrl->redirect($this, "showOrganization", "node_" . $res["node_id"]);
267 }
268
272 public function insertTemplateGUI()
273 {
275 $this->getParentGUI()->insertTemplateGUI(true);
276 }
277
281 public function insertSpecialPage()
282 {
284 $this->getParentGUI()->insertSpecialPage(true);
285 }
286
290 public function collapseAll()
291 {
293
294 $this->getParentGUI()->collapseAll(false);
295 $ilCtrl->redirect($this, "showOrganization");
296 }
297
301 public function ExpandAll()
302 {
304
305 $this->getParentGUI()->expandAll(false);
306 $ilCtrl->redirect($this, "showOrganization");
307 }
308
312 public function saveAllTitles()
313 {
315
316 $this->getParentGUI()->saveAllTitles(false);
317 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
318 $ilCtrl->redirect($this, "showOrganization");
319 }
320
324 public function deleteNodes()
325 {
327
328 $ilCtrl->setParameter($this, "backcmd", $_GET["backcmd"]);
329 $this->getParentGUI()->deleteNodes($ilCtrl->getFormAction($this));
330 }
331
335 public function cancelDelete()
336 {
338 $ilCtrl->redirect($this, "showOrganization");
339 }
340
344 public function confirmedDelete()
345 {
347
348 $this->getParentGUI()->confirmedDelete(false);
349 $ilCtrl->redirect($this, "showOrganization");
350 }
351
355 public function setLocator()
356 {
357 $ilLocator = $this->locator;
360
361 $ilLocator->addRepositoryItems($_GET["ref_id"]);
362 $this->getParentGUI()->addLocatorItems();
363
364 if ($_GET["obj_id"] > 0) {
365 $tree = new ilTree($this->slm_object->getId());
366 $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
367 $tree->setTreeTablePK("slm_id");
368 $path = $tree->getPathFull($_GET["obj_id"]);
369 for ($i = 1; $i < count($path); $i++) {
370 //var_dump($path[$i]);
371 switch ($path[$i]["type"]) {
372 case "chap":
373 $ilCtrl->setParameterByClass(
374 "ilscorm2004chaptergui",
375 "obj_id",
376 $path[$i]["child"]
377 );
378 $ilLocator->addItem(
379 $path[$i]["title"],
380 $ilCtrl->getLinkTargetByClass(
381 "ilscorm2004chaptergui",
382 "showOrganization"
383 ),
384 "",
385 0,
386 $path[$i]["type"],
387 ilUtil::getImagePath("icon_chap.svg")
388 );
389 break;
390
391 case "seqc":
392 $ilCtrl->setParameterByClass(
393 "ilscorm2004seqchaptergui",
394 "obj_id",
395 $path[$i]["child"]
396 );
397 $ilLocator->addItem(
398 $path[$i]["title"],
399 $ilCtrl->getLinkTargetByClass(
400 "ilscorm2004seqchaptergui",
401 "showOrganization"
402 ),
403 "",
404 0,
405 $path[$i]["type"],
406 ilUtil::getImagePath("icon_chap.svg")
407 );
408 break;
409
410 case "sco":
411 $ilCtrl->setParameterByClass(
412 "ilscorm2004scogui",
413 "obj_id",
414 $path[$i]["child"]
415 );
416 $ilLocator->addItem(
417 $path[$i]["title"],
418 $ilCtrl->getLinkTargetByClass(
419 "ilscorm2004scogui",
420 "showOrganization"
421 ),
422 "",
423 0,
424 $path[$i]["type"],
425 ilUtil::getImagePath("icon_sco.svg")
426 );
427 break;
428
429 case "ass":
430 $ilCtrl->setParameterByClass(
431 "ilscorm2004assetgui",
432 "obj_id",
433 $path[$i]["child"]
434 );
435 $ilLocator->addItem(
436 $path[$i]["title"],
437 $ilCtrl->getLinkTargetByClass(
438 "ilscorm2004assetgui",
439 "showOrganization"
440 ),
441 "",
442 0,
443 $path[$i]["type"],
444 ilUtil::getImagePath("icon_sca.svg")
445 );
446 break;
447
448 case "page":
449 $ilCtrl->setParameterByClass(
450 "ilscorm2004pagegui",
451 "obj_id",
452 $path[$i]["child"]
453 );
454 $ilLocator->addItem(
455 $path[$i]["title"],
456 $ilCtrl->getLinkTargetByClass(
457 "ilscorm2004pagegui",
458 "edit"
459 ),
460 "",
461 0,
462 $path[$i]["type"],
463 ilUtil::getImagePath("icon_pg.svg")
464 );
465 break;
466 }
467 }
468 }
469 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
470
471 $tpl->setLocator();
472 }
473
477 public function setContentStyle()
478 {
480
481 // content styles
482 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
483 $tpl->setCurrentBlock("ContentStyle");
484 $tpl->setVariable(
485 "LOCATION_CONTENT_STYLESHEET",
486 ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId())
487 );
488 $tpl->setVariable(
489 "LOCATION_ADDITIONAL_STYLESHEET",
491 );
492 $tpl->parseCurrentBlock();
493
494 $tpl->setCurrentBlock("SyntaxStyle");
495 $tpl->setVariable(
496 "LOCATION_SYNTAX_STYLESHEET",
498 );
499 $tpl->parseCurrentBlock();
500 }
501
505 public function copyItems($a_return = "showOrganization")
506 {
509
510 $items = ilUtil::stripSlashesArray($_POST["id"]);
511 $todel = array(); // delete IDs < 0 (needed for non-js editing)
512 foreach ($items as $k => $item) {
513 if ($item < 0) {
514 $todel[] = $k;
515 }
516 }
517 foreach ($todel as $k) {
518 unset($items[$k]);
519 }
521 ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
522 $ilCtrl->redirect($this, $a_return);
523 }
524 ilSCORM2004Node::clipboardCopy($this->slm_object->getId(), $items);
525
526 // @todo: move this to a service since it can be used here, too
527 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
529 ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
530
531 $ilCtrl->redirect($this, $a_return);
532 }
533
537 public function cutItems($a_return = "showOrganization")
538 {
541
542 $items = ilUtil::stripSlashesArray($_POST["id"]);
543 $todel = array(); // delete IDs < 0 (needed for non-js editing)
544 foreach ($items as $k => $item) {
545 if ($item < 0) {
546 $todel[] = $k;
547 }
548 }
549 foreach ($todel as $k) {
550 unset($items[$k]);
551 }
552
554 ilUtil::sendFailure($lng->txt("sahs_choose_pages_chap_scos_ass_only"), true);
555 $ilCtrl->redirect($this, $a_return);
556 }
557
558 ilSCORM2004Node::clipboardCut($this->slm_object->getId(), $items);
559
560 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
562
563 ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
564
565 $ilCtrl->redirect($this, $a_return);
566 }
567
571 public function insertPageClip()
572 {
575
576 ilSCORM2004Node::insertPageClip($this->slm_object);
577
578 $ilCtrl->redirect(
579 $this,
580 "showOrganization",
582 );
583 }
584
588 public function insertScoClip()
589 {
592
593 ilSCORM2004Node::insertScoClip($this->slm_object);
594
595 $ilCtrl->redirect(
596 $this,
597 "showOrganization",
599 );
600 }
601
605 public function insertAssetClip()
606 {
609
610 ilSCORM2004Node::insertAssetClip($this->slm_object);
611
612 $ilCtrl->redirect(
613 $this,
614 "showOrganization",
616 );
617 }
618
622 public function insertLMChapterClip()
623 {
626
627 $this->setLocator();
628 $this->setTabs();
629 $this->getParentGUI()->insertLMChapterClip();
630 }
631}
user()
Definition: user.php:4
$path
Definition: aliased.php:25
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static setAction($a_action)
static getPostNodeId()
Get node ID of _POST input.
static getSyntaxStylePath()
get syntax style path
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static getInstance($a_slm_object, $a_id=0, $a_halt=true)
Class ilSCORM2004NodeGUI.
copyItems($a_return="showOrganization")
Copy items to clipboard.
insertAssetClip()
Insert assets from clipboard.
getNodeObject($a_node_id)
Get node object (chapter/sco/page)
cutItems($a_return="showOrganization")
Copy items to clipboard, then cut them from the current tree.
__construct($a_slm_obj, $a_node_id=0)
constructor
insertPageClip()
Insert pages from clipboard.
insertSpecialPage()
Insert special page.
showOrganization()
put this object into content object tree
setContentStyle()
Set content style sheet.
setParentGUI($a_parentgui)
Set Parent GUI class (ilObjSCORM2004LearningModuleGUI).
deleteNodes()
Delete nodes in the hierarchy.
insertLMChapterClip()
Insert scos from clipboard.
getParentGUI()
Get Parent GUI class (ilObjSCORM2004LearningModuleGUI).
confirmedDelete()
confirmed delete
setLocator()
Set Locator Items.
insertTemplateGUI()
Insert Page with Layout.
insertScoClip()
Insert scos from clipboard.
static uniqueTypesCheck($a_items)
Check for unique types (all pages or all chapters or all scos)
static insertAssetClip($a_slm_obj, $a_type="ass")
Insert assets from clipboard.
static clipboardCopy($a_slm_obj_id, $a_ids)
Copy a set of chapters/pages/scos into the clipboard.
static insertPageClip($a_slm_obj)
Insert pages from clipboard.
static insertScoClip($a_slm_obj)
Insert scos from clipboard.
static clipboardCut($a_slm_obj_id, $a_ids)
Cut and copy a set of chapters/pages into the clipboard.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
$i
Definition: disco.tpl.php:19
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18