ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 {
152
153 $this->showHierarchy();
154 }
155
156
160 public function showHierarchy()
161 {
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 }
197
201 public function cutItems($a_return = "view")
202 {
205
206 $items = ilUtil::stripSlashesArray($_POST["id"]);
207 if (!is_array($items)) {
208 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
209 $ilCtrl->redirect($this, "showHierarchy");
210 }
211
212 $todel = array(); // delete IDs < 0 (needed for non-js editing)
213 foreach ($items as $k => $item) {
214 if ($item < 0) {
215 $todel[] = $k;
216 }
217 }
218 foreach ($todel as $k) {
219 unset($items[$k]);
220 }
221
222 if (!ilLMObject::uniqueTypesCheck($items)) {
223 ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
224 $ilCtrl->redirect($this, "showHierarchy");
225 }
226
227 ilLMObject::clipboardCut($this->content_object->getId(), $items);
229 //ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
230 ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_cut"), true);
231
232 $ilCtrl->redirect($this, $a_return);
233 }
234
238 public function copyItems($a_return = "view")
239 {
242
243 $items = ilUtil::stripSlashesArray($_POST["id"]);
244 if (!is_array($items)) {
245 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
246 $ilCtrl->redirect($this, "showHierarchy");
247 }
248
249 $todel = array(); // delete IDs < 0 (needed for non-js editing)
250 foreach ($items as $k => $item) {
251 if ($item < 0) {
252 $todel[] = $k;
253 }
254 }
255 foreach ($todel as $k) {
256 unset($items[$k]);
257 }
258
259 if (!ilLMObject::uniqueTypesCheck($items)) {
260 ilUtil::sendFailure($lng->txt("cont_choose_pages_or_chapters_only"), true);
261 $ilCtrl->redirect($this, "showHierarchy");
262 }
263
264 ilLMObject::clipboardCopy($this->content_object->getId(), $items);
266
267 ilUtil::sendInfo($lng->txt("cont_selected_items_have_been_copied"), true);
268 $ilCtrl->redirect($this, $a_return);
269 }
270
274 public function saveAllTitles()
275 {
277
278 ilLMObject::saveTitles($this->content_object, ilUtil::stripSlashesArray($_POST["title"]), $_GET["transl"]);
279
280 ilUtil::sendSuccess($this->lng->txt("lm_save_titles"), true);
281 $ilCtrl->redirect($this, "showHierarchy");
282 }
283
284 /*
285 * display subchapters of structure object
286 */
287 public function subchap()
288 {
293
294 $this->setTabs();
295
296 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
297 $num = 0;
298
299 $this->tpl->setCurrentBlock("form");
300 $this->ctrl->setParameter($this, "backcmd", "subchap");
301 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
302 $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_subchapters"));
303 $this->tpl->setVariable("CHECKBOX_TOP", IL_FIRST_NODE);
304
305 $cnt = 0;
306 $childs = $this->tree->getChilds($this->obj->getId());
307 foreach ($childs as $child) {
308 if ($child["type"] != "st") {
309 continue;
310 }
311 $this->tpl->setCurrentBlock("table_row");
312 // color changing
313 $css_row = ilUtil::switchColor($cnt++, "tblrow1", "tblrow2");
314
315 // checkbox
316 $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
317 $this->tpl->setVariable("CSS_ROW", $css_row);
318 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.svg"));
319
320 // type
321 $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
322 $link = $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view");
323 $this->tpl->setVariable("LINK_TARGET", $link);
324
325 // title
326 $this->tpl->setVariable(
327 "TEXT_CONTENT",
329 $child["obj_id"],
331 $this->content_object->isActiveNumbering()
332 )
333 );
334
335 $this->tpl->parseCurrentBlock();
336 }
337 if ($cnt == 0) {
338 $this->tpl->setCurrentBlock("notfound");
339 $this->tpl->setVariable("NUM_COLS", 3);
340 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
341 $this->tpl->parseCurrentBlock();
342 }
343 //else
344 //{
345 // SHOW VALID ACTIONS
346 $this->tpl->setVariable("NUM_COLS", 3);
347 $acts = array("delete" => "delete", "cutChapter" => "cut",
348 "copyChapter" => "copyChapter");
349 if ($ilUser->clipboardHasObjectsOfType("st")) {
350 $acts["pasteChapter"] = "pasteChapter";
351 }
352 $this->showActions($acts);
353 //}
354
355 // SHOW POSSIBLE SUB OBJECTS
356 $this->tpl->setVariable("NUM_COLS", 3);
357 //$this->showPossibleSubObjects("st");
358 $subobj = array("st");
359 $opts = ilUtil::formSelect(12, "new_type", $subobj);
360 //$this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
361 $this->tpl->setCurrentBlock("add_object");
362 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
363 //$this->tpl->setVariable("FORMACTION_OBJ_ADD", "adm_object.php?cmd=create&ref_id=".$_GET["ref_id"]);
364 $this->tpl->setVariable("BTN_NAME", "create");
365 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
366 $this->tpl->parseCurrentBlock();
367
368 //$this->tpl->setVariable("NUM_COLS", 2);
369 //$this->showPossibleSubObjects("st");
370
371 $this->tpl->setCurrentBlock("form");
372 $this->tpl->parseCurrentBlock();
373
374 $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
375 }
376
380 public function add_cell($val, $link = "")
381 {
382 if (!empty($link)) {
383 $this->tpl->setCurrentBlock("begin_link");
384 $this->tpl->setVariable("LINK_TARGET", $link);
385 $this->tpl->parseCurrentBlock();
386 $this->tpl->touchBlock("end_link");
387 }
388
389 $this->tpl->setCurrentBlock("text");
390 $this->tpl->setVariable("TEXT_CONTENT", $val);
391 $this->tpl->parseCurrentBlock();
392 $this->tpl->setCurrentBlock("table_cell");
393 $this->tpl->parseCurrentBlock();
394 }
395
396
400 public function save()
401 {
402 $this->obj = new ilStructureObject($this->content_object);
403
404 $this->obj->setType("st");
405 $this->obj->setTitle(ilUtil::stripSlashes($_POST["Fobject"]["title"]));
406 $this->obj->setDescription(ilUtil::stripSlashes($_POST["Fobject"]["desc"]));
407 $this->obj->setLMId($this->content_object->getId());
408 $this->obj->create();
409
410 $this->putInTree();
411
412 // check the tree
413 $this->checkTree();
414
415 if (!empty($_GET["obj_id"])) {
416 $this->ctrl->redirect($this, "subchap");
417 }
418 }
419
423 public function putInTree()
424 {
425 //echo "st:putInTree";
426 // chapters should be behind pages in the tree
427 // so if target is first node, the target is substituted with
428 // the last child of type pg
429 if ($_GET["target"] == IL_FIRST_NODE) {
430 $tree = new ilTree($this->content_object->getId());
431 $tree->setTableNames('lm_tree', 'lm_data');
432 $tree->setTreeTablePK("lm_id");
433
434 // determine parent node id
435 $parent_id = (!empty($_GET["obj_id"]))
436 ? $_GET["obj_id"]
437 : $tree->getRootId();
438 // determine last child of type pg
439 $childs = $tree->getChildsByType($parent_id, "pg");
440 if (count($childs) != 0) {
441 $_GET["target"] = $childs[count($childs) - 1]["obj_id"];
442 }
443 }
444 if (empty($_GET["target"])) {
445 $_GET["target"] = IL_LAST_NODE;
446 }
447
448 parent::putInTree();
449 }
450
454 public function cutPage()
455 {
456 $this->cutItems();
457 }
458
462 public function copyPage()
463 {
464 $this->copyItems();
465 }
466
470 public function pastePage()
471 {
474
475 if (!$ilUser->clipboardHasObjectsOfType("pg")) {
476 $ilErr->raiseError($this->lng->txt("no_page_in_clipboard"), $ilErr->MESSAGE);
477 }
478
479 return $this->insertPageClip();
480 }
481
482
486 public function cutChapter()
487 {
488 $this->cutItems("subchap");
489 }
490
494 public function copyChapter()
495 {
496 $this->copyItems("subchap");
497 }
498
502 public function pasteChapter()
503 {
505
506 return $this->insertChapterClip(false, "subchap");
507 }
508
512 public function activatePages()
513 {
515
516 if (is_array($_POST["id"])) {
517 $act_items = array();
518 // get all "top" ids, i.e. remove ids, that have a selected parent
519 foreach ($_POST["id"] as $id) {
520 $path = $this->tree->getPathId($id);
521 $take = true;
522 foreach ($path as $path_id) {
523 if ($path_id != $id && in_array($path_id, $_POST["id"])) {
524 $take = false;
525 }
526 }
527 if ($take) {
528 $act_items[] = $id;
529 }
530 }
531
532
533 foreach ($act_items as $id) {
534 $childs = $this->tree->getChilds($id);
535 foreach ($childs as $child) {
536 if (ilLMObject::_lookupType($child["child"]) == "pg") {
538 $child["child"],
539 $this->content_object->getType()
540 );
542 $child["child"],
543 $this->content_object->getType(),
544 !$act
545 );
546 }
547 }
548 if (ilLMObject::_lookupType($id) == "pg") {
550 $id,
551 $this->content_object->getType()
552 );
554 $id,
555 $this->content_object->getType(),
556 !$act
557 );
558 }
559 }
560 } else {
561 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
562 }
563
564 $this->ctrl->redirect($this, "view");
565 }
566
567 //
568 // Condition handling stuff
569 //
570
572 {
573 $this->condHI = new ilConditionHandlerGUI($this);
574 $this->condHI->setBackButtons(array());
575 $this->condHI->setAutomaticValidation(false);
576 $this->condHI->setTargetType("st");
577 $this->condHI->setTargetRefId($this->content_object->getRefId());
578 $this->condHI->setTargetId($this->obj->getId());
579 $this->condHI->setTargetTitle($this->obj->getTitle());
580 }
581
582
586 public function cancel()
587 {
588 if ($_GET["obj_id"] != 0) {
589 if ($_GET["new_type"] == "pg") {
590 $this->ctrl->redirect($this, "view");
591 } else {
592 $this->ctrl->redirect($this, "subchap");
593 }
594 }
595 }
596
597
601 public function setTabs()
602 {
603 $ilTabs = $this->tabs;
606
607 // subelements
608 $ilTabs->addTarget(
609 "cont_pages_and_subchapters",
610 $this->ctrl->getLinkTarget($this, 'showHierarchy'),
611 array("view", "showHierarchy"),
612 get_class($this)
613 );
614
615 // preconditions
616 $ilTabs->addTarget(
617 "preconditions",
618 $this->ctrl->getLinkTarget($this, 'listConditions'),
619 "listConditions",
620 get_class($this)
621 );
622
623 // metadata
624 $mdgui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
625 $mdtab = $mdgui->getTab();
626 if ($mdtab) {
627 $ilTabs->addTarget(
628 "meta_data",
629 $mdtab,
630 "",
631 "ilmdeditorgui"
632 );
633 }
634
635 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_st.svg"));
636 $this->tpl->setTitle(
637 $this->lng->txt($this->obj->getType()) . ": " . $this->obj->getTitle()
638 );
639
640 // presentation view
641 $ilTabs->addNonTabbedLink(
642 "pres_mode",
643 $lng->txt("cont_presentation_view"),
644 ILIAS_HTTP_PATH . "/goto.php?target=st_" . $this->obj->getId(),
645 "_top"
646 );
647 }
648
654 public static function _goto($a_target, $a_target_ref_id = "")
655 {
656 global $DIC;
657
658 $rbacsystem = $DIC->rbac()->system();
659 $ilErr = $DIC["ilErr"];
660 $lng = $DIC->language();
661 $ilAccess = $DIC->access();
662
663 // determine learning object
664 $lm_id = ilLMObject::_lookupContObjID($a_target);
665
666 // get all references
667 $ref_ids = ilObject::_getAllReferences($lm_id);
668
669 // always try passed ref id first
670 if (in_array($a_target_ref_id, $ref_ids)) {
671 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
672 }
673
674 // check read permissions
675 foreach ($ref_ids as $ref_id) {
676 // Permission check
677 if ($ilAccess->checkAccess("read", "", $ref_id)) {
678 // don't redirect anymore, just set parameters
679 // (goto.php includes "ilias.php")
680 $_GET["baseClass"] = "ilLMPresentationGUI";
681 $_GET["obj_id"] = $a_target;
682 $_GET["ref_id"] = $ref_id;
683 include_once("ilias.php");
684 exit;
685 ;
686 }
687 }
688
689 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
690 ilUtil::sendFailure(sprintf(
691 $lng->txt("msg_no_perm_read_item"),
693 ), true);
695 }
696
697 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
698 }
699
703 public function insertChapter($a_as_sub = false)
704 {
707
708
711
712 if ($a_as_sub) { // as subchapter
713 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert under parent
714 $parent_id = $node_id;
715 $target = "";
716 } else { // we shouldnt end up here
717 $ilCtrl->redirect($this, "showHierarchy");
718 return;
719 }
720 } else { // as chapter
721 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
722 $parent_id = $this->tree->getParentId($node_id);
723 $target = $node_id;
724 } else { // insert as first child
725 $parent_id = $node_id;
726 $target = IL_FIRST_NODE;
727 }
728 }
729 for ($i = 1; $i <= $num; $i++) {
730 $chap = new ilStructureObject($this->content_object);
731 $chap->setType("st");
732 $chap->setTitle($lng->txt("cont_new_chap"));
733 $chap->setLMId($this->content_object->getId());
734 $chap->create();
735 ilLMObject::putInTree($chap, $parent_id, $target);
736 }
737
738 $ilCtrl->redirect($this, "view");
739 }
740
744 public function insertSubchapter()
745 {
747
748 $this->insertChapter(true);
749 }
750
754 public function insertChapterClip($a_as_sub = false, $a_return = "view")
755 {
759
760 $ilLog->write("Insert Chapter From Clipboard");
761
762
765
766 if ($a_as_sub) { // as subchapter
767 if (!$first_child) { // insert under parent
768 $parent_id = $node_id;
769 $target = "";
770 } else { // we shouldnt end up here
771 $ilCtrl->redirect($this, "showHierarchy");
772 return;
773 }
774 } else { // as chapter
775 if (!$first_child) { // insert after node id
776 $parent_id = $this->tree->getParentId($node_id);
777 $target = $node_id;
778 } else { // insert as first child
779 $parent_id = $node_id;
780 $target = IL_FIRST_NODE;
781
782 // do not move a chapter in front of a page
783 $childs = $this->tree->getChildsByType($parent_id, "pg");
784 if (count($childs) != 0) {
785 $target = $childs[count($childs) - 1]["obj_id"];
786 }
787 }
788 }
789
790 // copy and paste
791 $chapters = $ilUser->getClipboardObjects("st", true);
792 $copied_nodes = array();
793
794 foreach ($chapters as $chap) {
795 $ilLog->write("Call pasteTree, Target LM: " . $this->content_object->getId() . ", Chapter ID: " . $chap["id"]
796 . ", Parent ID: " . $parent_id . ", Target: " . $target);
798 $this->content_object,
799 $chap["id"],
800 $parent_id,
801 $target,
802 $chap["insert_time"],
803 $copied_nodes,
804 (ilEditClipboard::getAction() == "copy")
805 );
806 $target = $cid;
807 }
808 ilLMObject::updateInternalLinks($copied_nodes);
809
810 if (ilEditClipboard::getAction() == "cut") {
811 $ilUser->clipboardDeleteObjectsOfType("pg");
812 $ilUser->clipboardDeleteObjectsOfType("st");
814 }
815
816 $this->content_object->checkTree();
817 $ilCtrl->redirect($this, $a_return);
818 }
819
823 public function insertSubchapterClip()
824 {
825 $this->insertChapterClip(true);
826 }
827
831 public function insertPage()
832 {
835
836
839
840 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
841 $parent_id = $this->tree->getParentId($node_id);
842 $target = $node_id;
843 } else { // insert as first child
844 $parent_id = $node_id;
845 $target = IL_FIRST_NODE;
846 }
847
848 for ($i = 1; $i <= $num; $i++) {
849 $page = new ilLMPageObject($this->content_object);
850 $page->setType("pg");
851 $page->setTitle($lng->txt("cont_new_page"));
852 $page->setLMId($this->content_object->getId());
853 $page->create();
854 ilLMObject::putInTree($page, $parent_id, $target);
855 }
856
857 $ilCtrl->redirect($this, "showHierarchy");
858 }
859
863 public function insertPageClip()
864 {
867
870
871 if (!$first_child) { // insert after node id
872 $parent_id = $this->tree->getParentId($node_id);
873 $target = $node_id;
874 } else { // insert as first child
875 $parent_id = $node_id;
876 $target = IL_FIRST_NODE;
877 }
878
879 // cut and paste
880 $pages = $ilUser->getClipboardObjects("pg");
881 $copied_nodes = array();
882 foreach ($pages as $pg) {
884 $this->content_object,
885 $pg["id"],
886 $parent_id,
887 $target,
888 $pg["insert_time"],
889 $copied_nodes,
890 (ilEditClipboard::getAction() == "copy")
891 );
892 $target = $cid;
893 }
894 ilLMObject::updateInternalLinks($copied_nodes);
895
896 if (ilEditClipboard::getAction() == "cut") {
897 $ilUser->clipboardDeleteObjectsOfType("pg");
898 $ilUser->clipboardDeleteObjectsOfType("st");
900 }
901
902 $ilCtrl->redirect($this, "view");
903 }
904
905
909 public function proceedDragDrop()
910 {
912
913 //echo "-".$_POST["il_hform_source_id"]."-".$_POST["il_hform_target_id"]."-".$_POST["il_hform_fc"]."-";
914 $this->content_object->executeDragDrop(
915 $_POST["il_hform_source_id"],
916 $_POST["il_hform_target_id"],
917 $_POST["il_hform_fc"],
918 $_POST["il_hform_as_subitem"]
919 );
920 $ilCtrl->redirect($this, "showHierarchy");
921 }
922
926
930 public function setPageLayout()
931 {
935
936 if (!is_array($_POST["id"])) {
937 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
938 $ilCtrl->redirect($this, "showHierarchy");
939 }
940
941 $this->initSetPageLayoutForm();
942
943 $tpl->setContent($this->form->getHTML());
944 }
945
949 public function initSetPageLayoutForm()
950 {
953
954 $this->form = new ilPropertyFormGUI();
955
956 if (is_array($_POST["id"])) {
957 foreach ($_POST["id"] as $id) {
958 $hi = new ilHiddenInputGUI("id[]");
959 $hi->setValue($id);
960 $this->form->addItem($hi);
961 }
962 }
964 $lng->txt("cont_layout"),
965 "layout",
966 $this->content_object->getLayout()
967 );
968
969 $this->form->addItem($layout);
970
971 $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
972 $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
973
974 $this->form->setTitle($lng->txt("cont_set_layout"));
975 $this->form->setFormAction($ilCtrl->getFormAction($this));
976 }
977
981 public function savePageLayout()
982 {
985
986 foreach ($_POST["id"] as $id) {
987 $id = ilUtil::stripSlashes($id);
990 ilUtil::stripSlashes($_POST["layout"]),
991 $this->content_object
992 );
993 }
994 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
995 $ilCtrl->redirect($this, "showHierarchy");
996 }
997
1004 public function editMasterLanguage()
1005 {
1007
1008 $ilCtrl->setParameter($this, "transl", "");
1009 $ilCtrl->redirect($this, "showHierarchy");
1010 }
1011
1018 public function switchToLanguage()
1019 {
1021
1022 $ilCtrl->setParameter($this, "transl", $_GET["totransl"]);
1023 $ilCtrl->redirect($this, "showHierarchy");
1024 }
1025
1029 public function insertTemplate()
1030 {
1032 $ui = $this->ui;
1033 $lng = $this->lng;
1034
1035 $this->setTabs();
1037 $tabs->clearTargets();
1038 $tabs->setBackTarget($lng->txt("back"), $ctrl->getLinkTarget($this, "showHierarchy"));
1039
1040 $ctrl->setParameter($this, "multi", ilChapterHierarchyFormGUI::getPostMulti());
1041 $ctrl->setParameter($this, "node_id", ilChapterHierarchyFormGUI::getPostNodeId());
1042 $ctrl->setParameter($this, "first_child", ilChapterHierarchyFormGUI::getPostFirstChild());
1043 $ctrl->saveParameter($this, "obj_id");
1044 $form = $this->initInsertTemplateForm();
1045 $this->tpl->setContent($ui->renderer()->render($form) . ilLMPageObjectGUI::getLayoutCssFix());
1046 }
1047
1048
1053 public function initInsertTemplateForm()
1054 {
1055 $ui = $this->ui;
1056 $f = $ui->factory();
1058 $lng = $this->lng;
1059
1060 $fields["title"] = $f->input()->field()->text($lng->txt("title"), "");
1061 $ts = ilPageLayoutGUI::getTemplateSelection(ilPageLayout::MODULE_LM);
1062 if (!is_null($ts)) {
1063 $fields["layout_id"] = $ts;
1064 }
1065
1066 // section
1067 $section1 = $f->input()->field()->section($fields, $lng->txt("cont_insert_pagelayout"));
1068
1069 $form_action = $ctrl->getLinkTarget($this, "insertPageFromTemplate");
1070 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
1071 }
1072
1076 public function insertPageFromTemplate()
1077 {
1078 global $DIC;
1079
1081
1082 $form = $this->initInsertTemplateForm();
1083 $form = $form->withRequest($DIC->http()->request());
1084 $data = $form->getData();
1085 $layout_id = $data["sec"]["layout_id"];
1086 $node_id = $_REQUEST["node_id"];
1088 $this->content_object->getId(),
1089 (int) $_REQUEST["multi"],
1090 $node_id,
1091 $_REQUEST["first_child"],
1092 $layout_id,
1093 $data["sec"]["title"]
1094 );
1095
1096 $ilCtrl->setParameter($this, "highlight", $page_ids);
1097 $ilCtrl->redirect($this, "showHierarchy", "node_" . $node_id);
1098 }
1099}
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 _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static _writeActive($a_id, $a_parent_type, $a_active, $a_reset_scheduled_activation=true, $a_lang="-")
write 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.
global $ilCtrl
Definition: ilias.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
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46