ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilStructureObjectGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
18{
22 protected $user;
23
27 protected $error;
28
32 protected $tabs;
33
37 protected $log;
38
39 public $obj; // structure object
40 public $tree;
41
46 public function __construct(&$a_content_obj, &$a_tree)
47 {
48 global $DIC;
49
50 $this->tree = $DIC->repositoryTree();
51 $this->user = $DIC->user();
52 $this->ctrl = $DIC->ctrl();
53 $this->lng = $DIC->language();
54 $this->error = $DIC["ilErr"];
55 $this->tabs = $DIC->tabs();
56 $this->log = $DIC["ilLog"];
57 $this->tpl = $DIC["tpl"];
58 parent::__construct($a_content_obj);
59 $this->tree = $a_tree;
60 }
61
67 public function setStructureObject(&$a_st_object)
68 {
69 $this->obj = $a_st_object;
70 }
71
72
76 public function getType()
77 {
78 return "st";
79 }
80
84 public function executeCommand()
85 {
86 //echo "<br>:cmd:".$this->ctrl->getCmd().":cmdClass:".$this->ctrl->getCmdClass().":";
87 $next_class = $this->ctrl->getNextClass($this);
88 $cmd = $this->ctrl->getCmd();
89
90 switch ($next_class) {
91 case 'ilobjectmetadatagui':
92
93 $this->setTabs();
94
95 $md_gui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
96 $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'General');
97 $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'Educational'); // #9510
98 $this->ctrl->forwardCommand($md_gui);
99 break;
100
101 case "ilconditionhandlergui":
102 $ilTabs = $this->tabs;
103
104 $this->setTabs();
106 $this->ctrl->forwardCommand($this->condHI);
107 $ilTabs->setTabActive('preconditions');
108 break;
109
110 default:
111 if ($cmd == 'listConditions') {
112 $this->setTabs();
114 $this->condHI->executeCommand();
115 } elseif (($cmd == "create") && ($_POST["new_type"] == "pg")) {
116 $this->setTabs();
117 $pg_gui = new ilLMPageObjectGUI($this->content_object);
118 $pg_gui->executeCommand();
119 } else {
120 $this->$cmd();
121 }
122 break;
123 }
124 }
125
126
130 public function create()
131 {
132 if ($_GET["obj_id"] != "") {
133 $this->setTabs();
134 }
135 parent::create();
136 }
137
138 public function edit()
139 {
140 $this->view();
141 }
142
143 /*
144 * display pages of structure object
145 */
146 public function view()
147 {
150 $ilCtrl = $this->ctrl;
152
153 $this->showHierarchy();
154 }
155
156
160 public function showHierarchy()
161 {
163 $ilCtrl = $this->ctrl;
164
165 $this->setTabs();
166
167 $ilCtrl->setParameter($this, "backcmd", "showHierarchy");
168
169 $form_gui = new ilChapterHierarchyFormGUI($this->content_object->getType(), $_GET["transl"]);
170 $form_gui->setFormAction($ilCtrl->getFormAction($this));
171 $form_gui->setTitle($this->obj->getTitle());
172 $form_gui->setIcon(ilUtil::getImagePath("icon_st.svg"));
173 $form_gui->setTree($this->tree);
174 $form_gui->setCurrentTopNodeId($this->obj->getId());
175 $form_gui->addMultiCommand($lng->txt("delete"), "delete");
176 $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
177 $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
178 $form_gui->addMultiCommand($lng->txt("cont_de_activate"), "activatePages");
179 if ($this->content_object->getLayoutPerPage()) {
180 $form_gui->addMultiCommand($lng->txt("cont_set_layout"), "setPageLayout");
181 }
182 $form_gui->setDragIcon(ilUtil::getImagePath("icon_pg.svg"));
183 $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
184 $form_gui->addHelpItem($lng->txt("cont_chapters_after_pages"));
185 $up_gui = "ilobjlearningmodulegui";
186 $ilCtrl->setParameterByClass($up_gui, "active_node", $this->obj->getId());
187 $ilCtrl->setParameterByClass($up_gui, "active_node", "");
188
189 $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
190 $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
191 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
192
193 $ml_head = ilObjContentObjectGUI::getMultiLangHeader($this->content_object->getId(), $this);
194
195 $this->tpl->setContent($ml_head . $ctpl->get());
196 $this->tpl->addOnloadCode("window.setTimeout(() => { $('body').trigger('il-lm-editor-tree'); }, 500);");
197 }
198
202 public function cutItems($a_return = "view")
203 {
204 $ilCtrl = $this->ctrl;
206
207 $items = ilUtil::stripSlashesArray($_POST["id"]);
208 if (!is_array($items)) {
209 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
210 $ilCtrl->redirect($this, "showHierarchy");
211 }
212
213 $todel = array(); // delete IDs < 0 (needed for non-js editing)
214 foreach ($items as $k => $item) {
215 if ($item < 0) {
216 $todel[] = $k;
217 }
218 }
219 foreach ($todel as $k) {
220 unset($items[$k]);
221 }
222
223 if (!ilLMObject::uniqueTypesCheck($items)) {
224 ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
225 $ilCtrl->redirect($this, "showHierarchy");
226 }
227
228 ilLMObject::clipboardCut($this->content_object->getId(), $items);
230 //ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
231 ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
232
233 $ilCtrl->redirect($this, $a_return);
234 }
235
239 public function copyItems($a_return = "view")
240 {
241 $ilCtrl = $this->ctrl;
243
244 $items = ilUtil::stripSlashesArray($_POST["id"]);
245 if (!is_array($items)) {
246 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
247 $ilCtrl->redirect($this, "showHierarchy");
248 }
249
250 $todel = array(); // delete IDs < 0 (needed for non-js editing)
251 foreach ($items as $k => $item) {
252 if ($item < 0) {
253 $todel[] = $k;
254 }
255 }
256 foreach ($todel as $k) {
257 unset($items[$k]);
258 }
259
260 if (!ilLMObject::uniqueTypesCheck($items)) {
261 ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
262 $ilCtrl->redirect($this, "showHierarchy");
263 }
264
265 ilLMObject::clipboardCopy($this->content_object->getId(), $items);
267
268 ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
269 $ilCtrl->redirect($this, $a_return);
270 }
271
275 public function saveAllTitles()
276 {
277 $ilCtrl = $this->ctrl;
278
279 ilLMObject::saveTitles($this->content_object, ilUtil::stripSlashesArray($_POST["title"]), $_GET["transl"]);
280
281 ilUtil::sendSuccess($this->lng->txt("lm_save_titles"), true);
282 $ilCtrl->redirect($this, "showHierarchy");
283 }
284
285 /*
286 * display subchapters of structure object
287 */
288 public function subchap()
289 {
291 $ilCtrl = $this->ctrl;
294
295 $this->setTabs();
296
297 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
298 $num = 0;
299
300 $this->tpl->setCurrentBlock("form");
301 $this->ctrl->setParameter($this, "backcmd", "subchap");
302 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
303 $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_subchapters"));
304 $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
305
306 $cnt = 0;
307 $childs = $this->tree->getChilds($this->obj->getId());
308 foreach ($childs as $child) {
309 if ($child["type"] != "st") {
310 continue;
311 }
312 $this->tpl->setCurrentBlock("table_row");
313 // color changing
314 $css_row = ilUtil::switchColor($cnt++, "tblrow1", "tblrow2");
315
316 // checkbox
317 $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
318 $this->tpl->setVariable("CSS_ROW", $css_row);
319 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.svg"));
320
321 // type
322 $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
323 $link = $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view");
324 $this->tpl->setVariable("LINK_TARGET", $link);
325
326 // title
327 $this->tpl->setVariable(
328 "TEXT_CONTENT",
330 $child["obj_id"],
332 $this->content_object->isActiveNumbering()
333 )
334 );
335
336 $this->tpl->parseCurrentBlock();
337 }
338 if ($cnt == 0) {
339 $this->tpl->setCurrentBlock("notfound");
340 $this->tpl->setVariable("NUM_COLS", 3);
341 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
342 $this->tpl->parseCurrentBlock();
343 }
344 //else
345 //{
346 // SHOW VALID ACTIONS
347 $this->tpl->setVariable("NUM_COLS", 3);
348 $acts = array("delete" => "delete", "cutChapter" => "cut",
349 "copyChapter" => "copyChapter");
350 if ($ilUser->clipboardHasObjectsOfType("st")) {
351 $acts["pasteChapter"] = "pasteChapter";
352 }
353 $this->showActions($acts);
354 //}
355
356 // SHOW POSSIBLE SUB OBJECTS
357 $this->tpl->setVariable("NUM_COLS", 3);
358 //$this->showPossibleSubObjects("st");
359 $subobj = array("st");
360 $opts = ilUtil::formSelect(12, "new_type", $subobj);
361 //$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
362 $this->tpl->setCurrentBlock("add_object");
363 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
364 //$this->tpl->setVariable("FORMACTION_OBJ_ADD", "adm_object.php?cmd=create&ref_id=".$_GET["ref_id"]);
365 $this->tpl->setVariable("BTN_NAME", "create");
366 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
367 $this->tpl->parseCurrentBlock();
368
369 //$this->tpl->setVariable("NUM_COLS", 2);
370 //$this->showPossibleSubObjects("st");
371
372 $this->tpl->setCurrentBlock("form");
373 $this->tpl->parseCurrentBlock();
374
375 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
376 }
377
381 public function add_cell($val, $link = "")
382 {
383 if (!empty($link)) {
384 $this->tpl->setCurrentBlock("begin_link");
385 $this->tpl->setVariable("LINK_TARGET", $link);
386 $this->tpl->parseCurrentBlock();
387 $this->tpl->touchBlock("end_link");
388 }
389
390 $this->tpl->setCurrentBlock("text");
391 $this->tpl->setVariable("TEXT_CONTENT", $val);
392 $this->tpl->parseCurrentBlock();
393 $this->tpl->setCurrentBlock("table_cell");
394 $this->tpl->parseCurrentBlock();
395 }
396
397
401 public function save()
402 {
403 $this->obj = new ilStructureObject($this->content_object);
404
405 $this->obj->setType("st");
406 $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
407 $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
408 $this->obj->setLMId($this->content_object->getId());
409 $this->obj->create();
410
411 $this->putInTree();
412
413 // check the tree
414 $this->checkTree();
415
416 if (!empty($_GET["obj_id"])) {
417 $this->ctrl->redirect($this, "subchap");
418 }
419 }
420
424 public function putInTree()
425 {
426 //echo "st:putInTree";
427 // chapters should be behind pages in the tree
428 // so if target is first node, the target is substituted with
429 // the last child of type pg
430 if ($_GET["target"] == IL_FIRST_NODE) {
431 $tree = new ilTree($this->content_object->getId());
432 $tree->setTableNames('lm_tree', 'lm_data');
433 $tree->setTreeTablePK("lm_id");
434
435 // determine parent node id
436 $parent_id = (!empty($_GET["obj_id"]))
437 ? $_GET["obj_id"]
438 : $tree->getRootId();
439 // determine last child of type pg
440 $childs = $tree->getChildsByType($parent_id, "pg");
441 if (count($childs) != 0) {
442 $_GET["target"] = $childs[count($childs) - 1]["obj_id"];
443 }
444 }
445 if (empty($_GET["target"])) {
446 $_GET["target"] = IL_LAST_NODE;
447 }
448
449 parent::putInTree();
450 }
451
455 public function cutPage()
456 {
457 $this->cutItems();
458 }
459
463 public function copyPage()
464 {
465 $this->copyItems();
466 }
467
471 public function pastePage()
472 {
475
476 if (!$ilUser->clipboardHasObjectsOfType("pg")) {
477 $ilErr->raiseError($this->lng->txt("no_page_in_clipboard"), $ilErr->MESSAGE);
478 }
479
480 return $this->insertPageClip();
481 }
482
483
487 public function cutChapter()
488 {
489 $this->cutItems("subchap");
490 }
491
495 public function copyChapter()
496 {
497 $this->copyItems("subchap");
498 }
499
503 public function pasteChapter()
504 {
506
507 return $this->insertChapterClip(false, "subchap");
508 }
509
513 public function activatePages()
514 {
516
517 if (is_array($_POST["id"])) {
518 $act_items = array();
519 // get all "top" ids, i.e. remove ids, that have a selected parent
520 foreach ($_POST["id"] as $id) {
521 $path = $this->tree->getPathId($id);
522 $take = true;
523 foreach ($path as $path_id) {
524 if ($path_id != $id && in_array($path_id, $_POST["id"])) {
525 $take = false;
526 }
527 }
528 if ($take) {
529 $act_items[] = $id;
530 }
531 }
532
533
534 foreach ($act_items as $id) {
535 $childs = $this->tree->getChilds($id);
536 foreach ($childs as $child) {
537 if (ilLMObject::_lookupType($child["child"]) == "pg") {
539 $child["child"],
540 $this->content_object->getType()
541 );
543 $child["child"],
544 $this->content_object->getType(),
545 !$act
546 );
547 }
548 }
549 if (ilLMObject::_lookupType($id) == "pg") {
551 $id,
552 $this->content_object->getType()
553 );
555 $id,
556 $this->content_object->getType(),
557 !$act
558 );
559 }
560 }
561 } else {
562 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
563 }
564
565 $this->ctrl->redirect($this, "view");
566 }
567
568 //
569 // Condition handling stuff
570 //
571
573 {
574 $this->condHI = new ilConditionHandlerGUI($this);
575 $this->condHI->setBackButtons(array());
576 $this->condHI->setAutomaticValidation(false);
577 $this->condHI->setTargetType("st");
578 $this->condHI->setTargetRefId($this->content_object->getRefId());
579 $this->condHI->setTargetId($this->obj->getId());
580 $this->condHI->setTargetTitle($this->obj->getTitle());
581 }
582
583
587 public function cancel()
588 {
589 if ($_GET["obj_id"] != 0) {
590 if ($_GET["new_type"] == "pg") {
591 $this->ctrl->redirect($this, "view");
592 } else {
593 $this->ctrl->redirect($this, "subchap");
594 }
595 }
596 }
597
598
602 public function setTabs()
603 {
604 $ilTabs = $this->tabs;
607
608 // subelements
609 $ilTabs->addTarget(
610 "cont_pages_and_subchapters",
611 $this->ctrl->getLinkTarget($this, 'showHierarchy'),
612 array("view", "showHierarchy"),
613 get_class($this)
614 );
615
616 // preconditions
617 $ilTabs->addTarget(
618 "preconditions",
619 $this->ctrl->getLinkTarget($this, 'listConditions'),
620 "listConditions",
621 get_class($this)
622 );
623
624 // metadata
625 $mdgui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
626 $mdtab = $mdgui->getTab();
627 if ($mdtab) {
628 $ilTabs->addTarget(
629 "meta_data",
630 $mdtab,
631 "",
632 "ilmdeditorgui"
633 );
634 }
635
636 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_st.svg"));
637 $this->tpl->setTitle(
638 $this->lng->txt($this->obj->getType()) . ": " . $this->obj->getTitle()
639 );
640
641 // presentation view
642 $ilTabs->addNonTabbedLink(
643 "pres_mode",
644 $lng->txt("cont_presentation_view"),
645 ILIAS_HTTP_PATH . "/goto.php?target=st_" . $this->obj->getId(),
646 "_top"
647 );
648 }
649
655 public static function _goto($a_target, $a_target_ref_id = "")
656 {
657 global $DIC;
658
659 $rbacsystem = $DIC->rbac()->system();
660 $ilErr = $DIC["ilErr"];
661 $lng = $DIC->language();
662 $ilAccess = $DIC->access();
663
664 // determine learning object
665 $lm_id = ilLMObject::_lookupContObjID($a_target);
666
667 // get all references
668 $ref_ids = ilObject::_getAllReferences($lm_id);
669
670 // always try passed ref id first
671 if (in_array($a_target_ref_id, $ref_ids)) {
672 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
673 }
674
675 // check read permissions
676 foreach ($ref_ids as $ref_id) {
677 // Permission check
678 if ($ilAccess->checkAccess("read", "", $ref_id)) {
679 // don't redirect anymore, just set parameters
680 // (goto.php includes "ilias.php")
681 $_GET["baseClass"] = "ilLMPresentationGUI";
682 $_GET["obj_id"] = $a_target;
683 $_GET["ref_id"] = $ref_id;
684 include_once("ilias.php");
685 exit;
686 ;
687 }
688 }
689
690 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
691 ilUtil::sendFailure(sprintf(
692 $lng->txt("msg_no_perm_read_item"),
694 ), true);
696 }
697
698 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
699 }
700
704 public function insertChapter($a_as_sub = false)
705 {
706 $ilCtrl = $this->ctrl;
708
709
712
713 if ($a_as_sub) { // as subchapter
714 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert under parent
715 $parent_id = $node_id;
716 $target = "";
717 } else { // we shouldnt end up here
718 $ilCtrl->redirect($this, "showHierarchy");
719 return;
720 }
721 } else { // as chapter
722 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
723 $parent_id = $this->tree->getParentId($node_id);
724 $target = $node_id;
725 } else { // insert as first child
726 $parent_id = $node_id;
727 $target = IL_FIRST_NODE;
728 }
729 }
730 for ($i = 1; $i <= $num; $i++) {
731 $chap = new ilStructureObject($this->content_object);
732 $chap->setType("st");
733 $chap->setTitle($lng->txt("cont_new_chap"));
734 $chap->setLMId($this->content_object->getId());
735 $chap->create();
736 ilLMObject::putInTree($chap, $parent_id, $target);
737 }
738
739 $ilCtrl->redirect($this, "view");
740 }
741
745 public function insertSubchapter()
746 {
747 $ilCtrl = $this->ctrl;
748
749 $this->insertChapter(true);
750 }
751
755 public function insertChapterClip($a_as_sub = false, $a_return = "view")
756 {
758 $ilCtrl = $this->ctrl;
759 $ilLog = $this->log;
760
761 $ilLog->write("Insert Chapter From Clipboard");
762
763
766
767 if ($a_as_sub) { // as subchapter
768 if (!$first_child) { // insert under parent
769 $parent_id = $node_id;
770 $target = "";
771 } else { // we shouldnt end up here
772 $ilCtrl->redirect($this, "showHierarchy");
773 return;
774 }
775 } else { // as chapter
776 if (!$first_child) { // insert after node id
777 $parent_id = $this->tree->getParentId($node_id);
778 $target = $node_id;
779 } else { // insert as first child
780 $parent_id = $node_id;
781 $target = IL_FIRST_NODE;
782
783 // do not move a chapter in front of a page
784 $childs = $this->tree->getChildsByType($parent_id, "pg");
785 if (count($childs) != 0) {
786 $target = $childs[count($childs) - 1]["obj_id"];
787 }
788 }
789 }
790
791 // copy and paste
792 $chapters = $ilUser->getClipboardObjects("st", true);
793 $copied_nodes = array();
794
795 foreach ($chapters as $chap) {
796 $ilLog->write("Call pasteTree, Target LM: " . $this->content_object->getId() . ", Chapter ID: " . $chap["id"]
797 . ", Parent ID: " . $parent_id . ", Target: " . $target);
799 $this->content_object,
800 $chap["id"],
801 $parent_id,
802 $target,
803 $chap["insert_time"],
804 $copied_nodes,
805 (ilEditClipboard::getAction() == "copy")
806 );
807 $target = $cid;
808 }
809 ilLMObject::updateInternalLinks($copied_nodes);
810
811 if (ilEditClipboard::getAction() == "cut") {
812 $ilUser->clipboardDeleteObjectsOfType("pg");
813 $ilUser->clipboardDeleteObjectsOfType("st");
815 }
816
817 $this->content_object->checkTree();
818 $ilCtrl->redirect($this, $a_return);
819 }
820
824 public function insertSubchapterClip()
825 {
826 $this->insertChapterClip(true);
827 }
828
832 public function insertPage()
833 {
834 $ilCtrl = $this->ctrl;
836
837
840
841 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
842 $parent_id = $this->tree->getParentId($node_id);
843 $target = $node_id;
844 } else { // insert as first child
845 $parent_id = $node_id;
846 $target = IL_FIRST_NODE;
847 }
848
849 for ($i = 1; $i <= $num; $i++) {
850 $page = new ilLMPageObject($this->content_object);
851 $page->setType("pg");
852 $page->setTitle($lng->txt("cont_new_page"));
853 $page->setLMId($this->content_object->getId());
854 $page->create();
855 ilLMObject::putInTree($page, $parent_id, $target);
856 }
857
858 $ilCtrl->redirect($this, "showHierarchy");
859 }
860
864 public function insertPageClip()
865 {
866 $ilCtrl = $this->ctrl;
868
871
872 if (!$first_child) { // insert after node id
873 $parent_id = $this->tree->getParentId($node_id);
874 $target = $node_id;
875 } else { // insert as first child
876 $parent_id = $node_id;
877 $target = IL_FIRST_NODE;
878 }
879
880 // cut and paste
881 $pages = $ilUser->getClipboardObjects("pg");
882 $copied_nodes = array();
883 foreach ($pages as $pg) {
885 $this->content_object,
886 $pg["id"],
887 $parent_id,
888 $target,
889 $pg["insert_time"],
890 $copied_nodes,
891 (ilEditClipboard::getAction() == "copy")
892 );
893 $target = $cid;
894 }
895 ilLMObject::updateInternalLinks($copied_nodes);
896
897 if (ilEditClipboard::getAction() == "cut") {
898 $ilUser->clipboardDeleteObjectsOfType("pg");
899 $ilUser->clipboardDeleteObjectsOfType("st");
901 }
902
903 $ilCtrl->redirect($this, "view");
904 }
905
906
910 public function proceedDragDrop()
911 {
912 $ilCtrl = $this->ctrl;
913
914 //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
915 $this->content_object->executeDragDrop(
916 $_POST["il_hform_source_id"],
917 $_POST["il_hform_target_id"],
918 $_POST["il_hform_fc"],
919 $_POST["il_hform_as_subitem"]
920 );
921 $ilCtrl->redirect($this, "showHierarchy");
922 }
923
927
931 public function setPageLayout()
932 {
934 $ilCtrl = $this->ctrl;
936
937 if (!is_array($_POST["id"])) {
938 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
939 $ilCtrl->redirect($this, "showHierarchy");
940 }
941
942 $this->initSetPageLayoutForm();
943
944 $tpl->setContent($this->form->getHTML());
945 }
946
950 public function initSetPageLayoutForm()
951 {
953 $ilCtrl = $this->ctrl;
954
955 $this->form = new ilPropertyFormGUI();
956
957 if (is_array($_POST["id"])) {
958 foreach ($_POST["id"] as $id) {
959 $hi = new ilHiddenInputGUI("id[]");
960 $hi->setValue($id);
961 $this->form->addItem($hi);
962 }
963 }
965 $lng->txt("cont_layout"),
966 "layout",
967 $this->content_object->getLayout()
968 );
969
970 $this->form->addItem($layout);
971
972 $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
973 $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
974
975 $this->form->setTitle($lng->txt("cont_set_layout"));
976 $this->form->setFormAction($ilCtrl->getFormAction($this));
977 }
978
982 public function savePageLayout()
983 {
985 $ilCtrl = $this->ctrl;
986
987 foreach ($_POST["id"] as $id) {
988 $id = ilUtil::stripSlashes($id);
991 ilUtil::stripSlashes($_POST["layout"]),
992 $this->content_object
993 );
994 }
995 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
996 $ilCtrl->redirect($this, "showHierarchy");
997 }
998
1005 public function editMasterLanguage()
1006 {
1007 $ilCtrl = $this->ctrl;
1008
1009 $ilCtrl->setParameter($this, "transl", "");
1010 $ilCtrl->redirect($this, "showHierarchy");
1011 }
1012
1019 public function switchToLanguage()
1020 {
1021 $ilCtrl = $this->ctrl;
1022
1023 $ilCtrl->setParameter($this, "transl", $_GET["totransl"]);
1024 $ilCtrl->redirect($this, "showHierarchy");
1025 }
1026
1030 public function insertTemplate()
1031 {
1033 $ui = $this->ui;
1034 $lng = $this->lng;
1035
1036 $this->setTabs();
1038 $tabs->clearTargets();
1039 $tabs->setBackTarget($lng->txt("back"), $ctrl->getLinkTarget($this, "showHierarchy"));
1040
1041 $ctrl->setParameter($this, "multi", ilChapterHierarchyFormGUI::getPostMulti());
1042 $ctrl->setParameter($this, "node_id", ilChapterHierarchyFormGUI::getPostNodeId());
1043 $ctrl->setParameter($this, "first_child", ilChapterHierarchyFormGUI::getPostFirstChild());
1044 $ctrl->saveParameter($this, "obj_id");
1045 $form = $this->initInsertTemplateForm();
1046 $this->tpl->setContent($ui->renderer()->render($form) . ilLMPageObjectGUI::getLayoutCssFix());
1047 }
1048
1049
1054 public function initInsertTemplateForm()
1055 {
1056 $ui = $this->ui;
1057 $f = $ui->factory();
1059 $lng = $this->lng;
1060
1061 $fields["title"] = $f->input()->field()->text($lng->txt("title"), "");
1062 $ts = ilPageLayoutGUI::getTemplateSelection(ilPageLayout::MODULE_LM);
1063 if (!is_null($ts)) {
1064 $fields["layout_id"] = $ts;
1065 }
1066
1067 // section
1068 $section1 = $f->input()->field()->section($fields, $lng->txt("cont_insert_pagelayout"));
1069
1070 $form_action = $ctrl->getLinkTarget($this, "insertPageFromTemplate");
1071 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
1072 }
1073
1077 public function insertPageFromTemplate()
1078 {
1079 global $DIC;
1080
1081 $ilCtrl = $this->ctrl;
1082
1083 $form = $this->initInsertTemplateForm();
1084 $form = $form->withRequest($DIC->http()->request());
1085 $data = $form->getData();
1086 $layout_id = $data["sec"]["layout_id"];
1087 $node_id = $_REQUEST["node_id"];
1089 $this->content_object->getId(),
1090 (int) $_REQUEST["multi"],
1091 $node_id,
1092 $_REQUEST["first_child"],
1093 $layout_id,
1094 $data["sec"]["title"]
1095 );
1096
1097 $ilCtrl->setParameter($this, "highlight", $page_ids);
1098 $ilCtrl->redirect($this, "showHierarchy", "node_" . $node_id);
1099 }
1100}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
const IL_LAST_NODE
Definition: class.ilTree.php:4
const IL_FIRST_NODE
Definition: class.ilTree.php:5
This class represents a hierarchical form.
class ilConditionHandlerGUI
static setAction($a_action)
This class represents a hidden form property in a property form.
static getPostNodeId()
Get node ID of _POST input.
static getPostFirstChild()
Should node be inserted as first child of target node (true) or as successor (false)
static getPostMulti()
Get multi number of _POST input.
Class ilLMObject.
showActions($a_actions)
show possible action (form buttons)
checkTree()
check the content object tree
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
static clipboardCopy($a_cont_obj_id, $a_ids)
Copy a set of chapters/pages into the clipboard.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static clipboardCut($a_cont_obj_id, $a_ids)
Copy a set of chapters/pages into the clipboard.
static saveTitles($a_lm, $a_titles, $a_lang="-")
Save titles for lm objects.
static uniqueTypesCheck($a_items)
Check for unique types (all pages or all chapters)
static updateInternalLinks($a_copied_nodes, $a_parent_type="lm")
Update internal links, after multiple pages have been copied.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
static writeLayout($a_obj_id, $a_layout, $a_lm=null)
Write layout setting.
static pasteTree( $a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_source_lm=null)
Paste item (tree) from clipboard to current lm.
Class ilLMPageObjectGUI.
static getLayoutCssFix()
Get layout css fix (workaround for broken radio options)
Class ilLMPageObject.
static insertPagesFromTemplate($lm_id, $num, $node_id, $first_child, $layout_id, $title="")
Insert (multiple) pages templates at node.
static getMultiLangHeader($a_lm_id, $a_gui_class, $a_mode="")
Get multi lang header.
static getLayoutOption($a_txt, $a_var, $a_def_option="")
Get layout option.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
Class ilObjectMetaDataGUI.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _writeActive( $a_id, $a_parent_type, $a_active, $a_reset_scheduled_activation=true, $a_lang="-")
write activation status
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
This class represents a property form user interface.
Class ilStructureObjectGUI.
proceedDragDrop()
Perform drag and drop action.
initSetPageLayoutForm()
Init set page layout form.
add_cell($val, $link="")
output a cell in object list
copyItems($a_return="view")
Copy items to clipboard.
insertSubchapterClip()
Insert Chapter from clipboard.
insertPageFromTemplate()
Insert (multiple) pages templates at node.
create()
create new page or chapter in chapter
activatePages()
activates or deactivates pages
__construct(&$a_content_obj, &$a_tree)
Constructor @access public.
initInsertTemplateForm()
Init insert template form.
editMasterLanguage()
Edit master language.
saveAllTitles()
Save all titles of chapters/pages.
putInTree()
put chapter into tree
insertChapterClip($a_as_sub=false, $a_return="view")
Insert Chapter from clipboard.
cancel()
cancel creation of new page or chapter
insertPage()
Insert (multiple) pages at node.
insertSubchapter()
Insert (multiple) subchapters at node.
copyChapter()
copy a single chapter (selection)
showHierarchy()
Show subhiearchy of pages and subchapters.
insertTemplate()
Displays GUI to select template for page.
static _goto($a_target, $a_target_ref_id="")
redirect script
switchToLanguage()
Switch to language.
insertChapter($a_as_sub=false)
Insert (multiple) chapters at node.
insertPageClip()
Insert pages from clipboard.
cutItems($a_return="view")
Copy items to clipboard, then cut them from the current tree.
setPageLayout()
Set layout for multipl pages.
setStructureObject(&$a_st_object)
set structure object
getType()
this function is called by condition handler gui interface
Class ilStructreObject.
static _getPresentationTitle( $a_st_id, $a_mode=self::CHAPTER_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-", $a_include_short=false)
get presentation title
special template class to simplify handling of ITX/PEAR
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 switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
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.
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:18
$data
Definition: storeScorm.php:23