ILIAS  release_8 Revision v8.24
class.ilStructureObjectGUI.php
Go to the documentation of this file.
1<?php
2
20
28{
31 protected ilObjUser $user;
32 protected ilTabsGUI $tabs;
33 protected ilLogger $log;
35
36 public function __construct(
37 ilObjLearningModule $a_content_obj,
38 ilLMTree $a_tree
39 ) {
40 global $DIC;
41
42 $this->user = $DIC->user();
43 $this->ctrl = $DIC->ctrl();
44 $this->lng = $DIC->language();
45 $this->tabs = $DIC->tabs();
46 $this->log = $DIC["ilLog"];
47 $this->tpl = $DIC->ui()->mainTemplate();
48 parent::__construct($a_content_obj);
49 $this->tree = $a_tree;
50 }
51
52 public function setStructureObject(
53 ilStructureObject $a_st_object
54 ): void {
55 $this->obj = $a_st_object;
56 }
57
58 public function getType(): string
59 {
60 return "st";
61 }
62
63 public function executeCommand(): void
64 {
65 $next_class = $this->ctrl->getNextClass($this);
66 $cmd = $this->ctrl->getCmd();
67
68 switch ($next_class) {
69 case 'ilobjectmetadatagui':
70
71 $this->setTabs();
72
73 $md_gui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
74 $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'General');
75 $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'Educational'); // #9510
76 $this->ctrl->forwardCommand($md_gui);
77 break;
78
79 case "ilconditionhandlergui":
80 $ilTabs = $this->tabs;
81
82 $this->setTabs();
83 $this->initConditionHandlerInterface();
84 $this->ctrl->forwardCommand($this->condHI);
85 $ilTabs->setTabActive('preconditions');
86 break;
87
88 default:
89 if ($cmd == 'listConditions') {
90 $this->setTabs();
91 $this->initConditionHandlerInterface();
92 $this->condHI->executeCommand();
93 } elseif (($cmd == "create") && ($this->requested_new_type == "pg")) {
94 $this->setTabs();
95 $pg_gui = new ilLMPageObjectGUI($this->content_object);
96 $pg_gui->executeCommand();
97 } else {
98 $this->$cmd();
99 }
100 break;
101 }
102 }
103
104 public function create(): void
105 {
106 if ($this->requested_obj_id != 0) {
107 $this->setTabs();
108 }
109 parent::create();
110 }
111
112 public function edit(): void
113 {
114 $this->view();
115 }
116
117 public function view(): void
118 {
119 $this->showHierarchy();
120 }
121
122 public function showHierarchy(): void
123 {
125 $ilCtrl = $this->ctrl;
126
127 $this->setTabs();
128
129 $ilCtrl->setParameter($this, "backcmd", "showHierarchy");
130
131 $form_gui = new ilChapterHierarchyFormGUI($this->content_object->getType(), $this->requested_transl);
132 $form_gui->setFormAction($ilCtrl->getFormAction($this));
133 $form_gui->setTitle($this->obj->getTitle());
134 $form_gui->setIcon(ilUtil::getImagePath("icon_st.svg"));
135 $form_gui->setTree($this->tree);
136 $form_gui->setCurrentTopNodeId($this->obj->getId());
137 $form_gui->addMultiCommand($lng->txt("delete"), "delete");
138 $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
139 $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
140 $form_gui->addMultiCommand($lng->txt("cont_de_activate"), "activatePages");
141 if ($this->content_object->getLayoutPerPage()) {
142 $form_gui->addMultiCommand($lng->txt("cont_set_layout"), "setPageLayout");
143 }
144 $form_gui->setDragIcon(ilUtil::getImagePath("icon_pg.svg"));
145 $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
146 $form_gui->addHelpItem($lng->txt("cont_chapters_after_pages"));
147 $up_gui = "ilobjlearningmodulegui";
148 $ilCtrl->setParameterByClass($up_gui, "active_node", $this->obj->getId());
149 $ilCtrl->setParameterByClass($up_gui, "active_node", null);
150
151 $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
152 $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
153 $ilCtrl->setParameter($this, "obj_id", $this->requested_obj_id);
154
155 $ml_head = ilObjContentObjectGUI::getMultiLangHeader($this->content_object->getId(), $this);
156
157 $this->tpl->setContent($ml_head . $ctpl->get());
158 $this->tpl->addOnloadCode("window.setTimeout(() => { $('body').trigger('il-lm-editor-tree'); }, 500);");
159 }
160
164 public function cutItems(
165 string $a_return = "view"
166 ): void {
167 $ilCtrl = $this->ctrl;
169
170 $items = $this->request->getIds();
171 if (count($items) == 0) {
172 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
173 $ilCtrl->redirect($this, "showHierarchy");
174 }
175
176 $todel = array(); // delete IDs < 0 (needed for non-js editing)
177 foreach ($items as $k => $item) {
178 if ($item < 0) {
179 $todel[] = $k;
180 }
181 }
182 foreach ($todel as $k) {
183 unset($items[$k]);
184 }
185
186 if (!ilLMObject::uniqueTypesCheck($items)) {
187 $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_choose_pages_or_chapters_only"), true);
188 $ilCtrl->redirect($this, "showHierarchy");
189 }
190
191 ilLMObject::clipboardCut($this->content_object->getId(), $items);
193 $this->tpl->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_cut"), true);
194
195 $ilCtrl->redirect($this, $a_return);
196 }
197
201 public function copyItems(
202 string $a_return = "view"
203 ): void {
204 $ilCtrl = $this->ctrl;
206
207 $items = $this->request->getIds();
208 if (count($items) == 0) {
209 $this->tpl->setOnScreenMessage('failure', $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 $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_choose_pages_or_chapters_only"), true);
225 $ilCtrl->redirect($this, "showHierarchy");
226 }
227
228 ilLMObject::clipboardCopy($this->content_object->getId(), $items);
230
231 $this->tpl->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_copied"), true);
232 $ilCtrl->redirect($this, $a_return);
233 }
234
238 public function saveAllTitles(): void
239 {
240 $ilCtrl = $this->ctrl;
241
242 $titles = $this->request->getTitles();
243 ilLMObject::saveTitles($this->content_object, $titles, $this->requested_transl);
244
245 $this->tpl->setOnScreenMessage('success', $this->lng->txt("lm_save_titles"), true);
246 $ilCtrl->redirect($this, "showHierarchy");
247 }
248
252 public function subchap(): void
253 {
254 $ilCtrl = $this->ctrl;
255 $ilUser = $this->user;
256
257 $this->setTabs();
258
259 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
260 $num = 0;
261
262 $this->tpl->setCurrentBlock("form");
263 $this->ctrl->setParameter($this, "backcmd", "subchap");
264 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
265 $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_subchapters"));
266 $this->tpl->setVariable("CHECKBOX_TOP", ilTree::POS_FIRST_NODE);
267
268 $cnt = 0;
269 $childs = $this->tree->getChilds($this->obj->getId());
270 foreach ($childs as $child) {
271 if ($child["type"] != "st") {
272 continue;
273 }
274 $this->tpl->setCurrentBlock("table_row");
275
276 // checkbox
277 $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
278 $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_st.svg"));
279
280 // type
281 $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
282 $link = $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view");
283 $this->tpl->setVariable("LINK_TARGET", $link);
284
285 // title
286 $this->tpl->setVariable(
287 "TEXT_CONTENT",
289 $child["obj_id"],
291 $this->content_object->isActiveNumbering()
292 )
293 );
294
295 $this->tpl->parseCurrentBlock();
296 $cnt++;
297 }
298
299 if ($cnt == 0) {
300 $this->tpl->setCurrentBlock("notfound");
301 $this->tpl->setVariable("NUM_COLS", 3);
302 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
303 $this->tpl->parseCurrentBlock();
304 }
305 //else
306 //{
307 // SHOW VALID ACTIONS
308 $this->tpl->setVariable("NUM_COLS", 3);
309 $acts = array("delete" => "delete", "cutChapter" => "cut",
310 "copyChapter" => "copyChapter");
311 if ($ilUser->clipboardHasObjectsOfType("st")) {
312 $acts["pasteChapter"] = "pasteChapter";
313 }
314 $this->showActions($acts);
315 //}
316
317 // SHOW POSSIBLE SUB OBJECTS
318 $this->tpl->setVariable("NUM_COLS", 3);
319 $subobj = array("st");
320 $opts = ilLegacyFormElementsUtil::formSelect(12, "new_type", $subobj);
321 $this->tpl->setCurrentBlock("add_object");
322 $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
323 $this->tpl->setVariable("BTN_NAME", "create");
324 $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
325 $this->tpl->parseCurrentBlock();
326
327 $this->tpl->setCurrentBlock("form");
328 $this->tpl->parseCurrentBlock();
329
330 $ilCtrl->setParameter($this, "obj_id", $this->requested_obj_id);
331 }
332
333 public function save(): void
334 {
335 $form = $this->getCreateForm();
336
337 if ($form->checkInput()) {
338 $this->obj = new ilStructureObject($this->content_object);
339 $this->obj->setType("st");
340 $this->obj->setTitle($form->getInput("title"));
341 $this->obj->setDescription($form->getInput("desc"));
342 $this->obj->setLMId($this->content_object->getId());
343 $this->obj->create();
344
345 $this->putInTree();
346
347 // check the tree
348 $this->checkTree();
349 }
350
351 if ($this->requested_obj_id > 0) {
352 $this->ctrl->redirect($this, "subchap");
353 }
354 }
355
359 public function putInTree(
360 ?int $target = null
361 ): void {
362 $target = $this->requested_target;
363 //echo "st:putInTree";
364 // chapters should be behind pages in the tree
365 // so if target is first node, the target is substituted with
366 // the last child of type pg
367 if ($target == ilTree::POS_FIRST_NODE) {
368 $tree = new ilTree($this->content_object->getId());
369 $tree->setTableNames('lm_tree', 'lm_data');
370 $tree->setTreeTablePK("lm_id");
371
372 // determine parent node id
373 $parent_id = ($this->requested_obj_id > 0)
374 ? $this->requested_obj_id
375 : $tree->getRootId();
376 // determine last child of type pg
377 $childs = $tree->getChildsByType($parent_id, "pg");
378 if (count($childs) != 0) {
379 $target = $childs[count($childs) - 1]["obj_id"];
380 }
381 }
382 if ($target == "") {
383 $target = ilTree::POS_LAST_NODE;
384 }
385
386 parent::putInTree($target);
387 }
388
389 public function cutPage(): void
390 {
391 $this->cutItems();
392 }
393
394 public function copyPage(): void
395 {
396 $this->copyItems();
397 }
398
399 public function pastePage(): void
400 {
401 $ilUser = $this->user;
402
403 if (!$ilUser->clipboardHasObjectsOfType("pg")) {
404 throw new ilLMException($this->lng->txt("no_page_in_clipboard"));
405 }
406
407 $this->insertPageClip();
408 }
409
410 public function cutChapter(): void
411 {
412 $this->cutItems("subchap");
413 }
414
418 public function copyChapter(): void
419 {
420 $this->copyItems("subchap");
421 }
422
423 public function pasteChapter(): void
424 {
425 $this->insertChapterClip(false, "subchap");
426 }
427
428 public function activatePages(): void
429 {
431
432 $ids = $this->request->getIds();
433 if (count($ids) > 0) {
434 $act_items = array();
435 // get all "top" ids, i.e. remove ids, that have a selected parent
436 foreach ($ids as $id) {
437 $path = $this->tree->getPathId($id);
438 $take = true;
439 foreach ($path as $path_id) {
440 if ($path_id != $id && in_array($path_id, $ids)) {
441 $take = false;
442 }
443 }
444 if ($take) {
445 $act_items[] = $id;
446 }
447 }
448
449
450 foreach ($act_items as $id) {
451 $childs = $this->tree->getChilds($id);
452 foreach ($childs as $child) {
453 if (ilLMObject::_lookupType($child["child"]) == "pg") {
455 $child["child"],
456 $this->content_object->getType()
457 );
459 $child["child"],
460 $this->content_object->getType(),
461 !$act
462 );
463 }
464 }
465 if (ilLMObject::_lookupType($id) == "pg") {
467 $id,
468 $this->content_object->getType()
469 );
471 $id,
472 $this->content_object->getType(),
473 !$act
474 );
475 }
476 }
477 } else {
478 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
479 }
480
481 $this->ctrl->redirect($this, "view");
482 }
483
484 public function initConditionHandlerInterface(): void
485 {
486 $this->condHI = new ilConditionHandlerGUI();
487 $this->condHI->setBackButtons(array());
488 $this->condHI->setAutomaticValidation(false);
489 $this->condHI->setTargetType("st");
490 $this->condHI->setTargetRefId($this->content_object->getRefId());
491 $this->condHI->setTargetId($this->obj->getId());
492 $this->condHI->setTargetTitle($this->obj->getTitle());
493 }
494
495
499 public function cancel(): void
500 {
501 if ($this->requested_obj_id != 0) {
502 if ($this->requested_new_type == "pg") {
503 $this->ctrl->redirect($this, "view");
504 } else {
505 $this->ctrl->redirect($this, "subchap");
506 }
507 }
508 }
509
510 public function setTabs(): void
511 {
512 $ilTabs = $this->tabs;
514
515 // subelements
516 $ilTabs->addTarget(
517 "cont_pages_and_subchapters",
518 $this->ctrl->getLinkTarget($this, 'showHierarchy'),
519 array("view", "showHierarchy"),
520 get_class($this)
521 );
522
523 // preconditions
524 $ilTabs->addTarget(
525 "preconditions",
526 $this->ctrl->getLinkTarget($this, 'listConditions'),
527 "listConditions",
528 get_class($this)
529 );
530
531 // metadata
532 $mdgui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
533 $mdtab = $mdgui->getTab();
534 if ($mdtab) {
535 $ilTabs->addTarget(
536 "meta_data",
537 $mdtab,
538 "",
539 "ilmdeditorgui"
540 );
541 }
542
543 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_st.svg"));
544 $this->tpl->setTitle(
545 $this->lng->txt($this->obj->getType()) . ": " . $this->obj->getTitle()
546 );
547
548 // presentation view
549 $ilTabs->addNonTabbedLink(
550 "pres_mode",
551 $lng->txt("cont_presentation_view"),
552 ILIAS_HTTP_PATH . "/goto.php?target=st_" . $this->obj->getId(),
553 "_top"
554 );
555 }
556
560 public static function _goto(
561 string $a_target,
562 int $a_target_ref_id = 0
563 ): void {
564 global $DIC;
565 $main_tpl = $DIC->ui()->mainTemplate();
566
567 $lng = $DIC->language();
568 $ilAccess = $DIC->access();
569 $ctrl = $DIC->ctrl();
570
571 // determine learning object
572 $lm_id = ilLMObject::_lookupContObjID($a_target);
573
574 // get all references
575 $ref_ids = ilObject::_getAllReferences($lm_id);
576
577 // always try passed ref id first
578 if (in_array($a_target_ref_id, $ref_ids)) {
579 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
580 }
581
582 // check read permissions
583 foreach ($ref_ids as $ref_id) {
584 // Permission check
585 if ($ilAccess->checkAccess("read", "", $ref_id)) {
586 $ctrl->setParameterByClass("ilLMPresentationGUI", "obj_id", $a_target);
587 $ctrl->setParameterByClass("ilLMPresentationGUI", "ref_id", $ref_id);
588 $ctrl->redirectByClass("ilLMPresentationGUI", "");
589 }
590 }
591
592 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
593 $main_tpl->setOnScreenMessage('failure', sprintf(
594 $lng->txt("msg_no_perm_read_item"),
596 ), true);
598 }
599
600 throw new ilPermissionException($lng->txt("msg_no_perm_read_lm"));
601 }
602
606 public function insertChapter(
607 bool $a_as_sub = false
608 ): void {
609 $ilCtrl = $this->ctrl;
611
614
615 if ($a_as_sub) { // as subchapter
616 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert under parent
617 $parent_id = $node_id;
618 $target = "";
619 } else { // we shouldnt end up here
620 $ilCtrl->redirect($this, "showHierarchy");
621 return;
622 }
623 } else { // as chapter
624 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
625 $parent_id = $this->tree->getParentId($node_id);
626 $target = $node_id;
627 } else { // insert as first child
628 $parent_id = $node_id;
629 $target = ilTree::POS_FIRST_NODE;
630 }
631 }
632 for ($i = 1; $i <= $num; $i++) {
633 $chap = new ilStructureObject($this->content_object);
634 $chap->setType("st");
635 $chap->setTitle($lng->txt("cont_new_chap"));
636 $chap->setLMId($this->content_object->getId());
637 $chap->create();
638 ilLMObject::putInTree($chap, (int) $parent_id, (int) $target);
639 }
640
641 $ilCtrl->redirect($this, "view");
642 }
643
647 public function insertSubchapter(): void
648 {
649 $this->insertChapter(true);
650 }
651
655 public function insertChapterClip(
656 bool $a_as_sub = false,
657 string $a_return = "view"
658 ): void {
659 $ilUser = $this->user;
660 $ilCtrl = $this->ctrl;
661 $ilLog = $this->log;
662
663 $ilLog->write("Insert Chapter From Clipboard");
664
665
668
669 if ($a_as_sub) { // as subchapter
670 if (!$first_child) { // insert under parent
671 $parent_id = $node_id;
672 $target = "";
673 } else { // we shouldnt end up here
674 $ilCtrl->redirect($this, "showHierarchy");
675 return;
676 }
677 } else { // as chapter
678 if (!$first_child) { // insert after node id
679 $parent_id = $this->tree->getParentId($node_id);
680 $target = $node_id;
681 } else { // insert as first child
682 $parent_id = $node_id;
683 $target = ilTree::POS_FIRST_NODE;
684
685 // do not move a chapter in front of a page
686 $childs = $this->tree->getChildsByType($parent_id, "pg");
687 if (count($childs) != 0) {
688 $target = $childs[count($childs) - 1]["obj_id"];
689 }
690 }
691 }
692
693 // copy and paste
694 $chapters = $ilUser->getClipboardObjects("st", true);
695 $copied_nodes = array();
696
697 foreach ($chapters as $chap) {
698 $ilLog->write("Call pasteTree, Target LM: " . $this->content_object->getId() . ", Chapter ID: " . $chap["id"]
699 . ", Parent ID: " . $parent_id . ", Target: " . $target);
700 $cid = ilLMObject::pasteTree(
701 $this->content_object,
702 $chap["id"],
703 $parent_id,
704 (int) $target,
705 (string) ($chap["insert_time"] ?? ""),
706 $copied_nodes,
707 (ilEditClipboard::getAction() == "copy")
708 );
709 $target = $cid;
710 }
711 ilLMObject::updateInternalLinks($copied_nodes);
712
713 if (ilEditClipboard::getAction() == "cut") {
714 $ilUser->clipboardDeleteObjectsOfType("pg");
715 $ilUser->clipboardDeleteObjectsOfType("st");
717 }
718
719 $this->content_object->checkTree();
720 $ilCtrl->redirect($this, $a_return);
721 }
722
723 public function insertSubchapterClip(): void
724 {
725 $this->insertChapterClip(true);
726 }
727
728 public function insertPage(): void
729 {
730 $ilCtrl = $this->ctrl;
732
735
736 if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
737 $parent_id = $this->tree->getParentId($node_id);
738 $target = $node_id;
739 } else { // insert as first child
740 $parent_id = $node_id;
741 $target = ilTree::POS_FIRST_NODE;
742 }
743
744 for ($i = 1; $i <= $num; $i++) {
745 $page = new ilLMPageObject($this->content_object);
746 $page->setType("pg");
747 $page->setTitle($lng->txt("cont_new_page"));
748 $page->setLMId($this->content_object->getId());
749 $page->create();
750 ilLMObject::putInTree($page, $parent_id, $target);
751 }
752
753 if ($num == 1) {
754 $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_page_added"), true);
755 } else {
756 $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_pages_added"), true);
757 }
758
759 $ilCtrl->redirect($this, "showHierarchy");
760 }
761
762 public function insertPageClip(): void
763 {
764 $ilCtrl = $this->ctrl;
765 $ilUser = $this->user;
766
769
770 if (!$first_child) { // insert after node id
771 $parent_id = $this->tree->getParentId($node_id);
772 $target = $node_id;
773 } else { // insert as first child
774 $parent_id = $node_id;
775 $target = ilTree::POS_FIRST_NODE;
776 }
777
778 // cut and paste
779 $pages = $ilUser->getClipboardObjects("pg");
780 $copied_nodes = array();
781 foreach ($pages as $pg) {
782 $cid = ilLMObject::pasteTree(
783 $this->content_object,
784 $pg["id"],
785 $parent_id,
786 $target,
787 (string) ($pg["insert_time"] ?? ""),
788 $copied_nodes,
789 (ilEditClipboard::getAction() == "copy")
790 );
791 $target = $cid;
792 }
793 ilLMObject::updateInternalLinks($copied_nodes);
794
795 if (ilEditClipboard::getAction() == "cut") {
796 $ilUser->clipboardDeleteObjectsOfType("pg");
797 $ilUser->clipboardDeleteObjectsOfType("st");
799 }
800
801 $ilCtrl->redirect($this, "view");
802 }
803
804 public function proceedDragDrop(): void
805 {
806 $ilCtrl = $this->ctrl;
807
808 $req = $this->request;
809 $this->content_object->executeDragDrop(
810 $req->getHFormPar("source_id"),
811 $req->getHFormPar("target_id"),
812 $req->getHFormPar("fc"),
813 $req->getHFormPar("as_subitem")
814 );
815 $ilCtrl->redirect($this, "showHierarchy");
816 }
817
821
825 public function setPageLayout(): void
826 {
828 $ilCtrl = $this->ctrl;
830
831 $ids = $this->request->getIds();
832 if (count($ids) == 0) {
833 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
834 $ilCtrl->redirect($this, "showHierarchy");
835 }
836
837 $this->initSetPageLayoutForm();
838
839 $tpl->setContent($this->form->getHTML());
840 }
841
845 public function initSetPageLayoutForm(): void
846 {
848 $ilCtrl = $this->ctrl;
849
850 $this->form = new ilPropertyFormGUI();
851
852 $ids = $this->request->getIds();
853 foreach ($ids as $id) {
854 $hi = new ilHiddenInputGUI("id[]");
855 $hi->setValue($id);
856 $this->form->addItem($hi);
857 }
859 $lng->txt("cont_layout"),
860 "layout",
861 $this->content_object->getLayout()
862 );
863
864 $this->form->addItem($layout);
865
866 $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
867 $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
868
869 $this->form->setTitle($lng->txt("cont_set_layout"));
870 $this->form->setFormAction($ilCtrl->getFormAction($this));
871 }
872
876 public function savePageLayout(): void
877 {
879 $ilCtrl = $this->ctrl;
880
881 $ids = $this->request->getIds();
882 $layout = $this->request->getLayout();
883 foreach ($ids as $id) {
885 $id,
886 $layout,
887 $this->content_object
888 );
889 }
890 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
891 $ilCtrl->redirect($this, "showHierarchy");
892 }
893
894 public function editMasterLanguage(): void
895 {
896 $ilCtrl = $this->ctrl;
897
898 $ilCtrl->setParameter($this, "transl", "-");
899 $ilCtrl->redirect($this, "showHierarchy");
900 }
901
902 public function switchToLanguage(): void
903 {
904 $ilCtrl = $this->ctrl;
905
906 $ilCtrl->setParameter($this, "transl", $this->requested_totransl);
907 $ilCtrl->redirect($this, "showHierarchy");
908 }
909
913 public function insertTemplate(): void
914 {
915 $ctrl = $this->ctrl;
916 $ui = $this->ui;
918
919 $this->setTabs();
920 $tabs = $this->tabs;
921 $tabs->clearTargets();
922 $tabs->setBackTarget($lng->txt("back"), $ctrl->getLinkTarget($this, "showHierarchy"));
923
924 $ctrl->setParameter($this, "multi", ilChapterHierarchyFormGUI::getPostMulti());
925 $ctrl->setParameter($this, "node_id", ilChapterHierarchyFormGUI::getPostNodeId());
926 $ctrl->setParameter($this, "first_child", (int) ilChapterHierarchyFormGUI::getPostFirstChild());
927 $ctrl->saveParameter($this, "obj_id");
928 $form = $this->initInsertTemplateForm();
929 $this->tpl->setContent($ui->renderer()->render($form) . ilLMPageObjectGUI::getLayoutCssFix());
930 }
931
933 {
934 $ui = $this->ui;
935 $f = $ui->factory();
936 $ctrl = $this->ctrl;
938
939 $fields["title"] = $f->input()->field()->text($lng->txt("title"), "");
940 $ts = ilPageLayoutGUI::getTemplateSelection(ilPageLayout::MODULE_LM);
941 if (!is_null($ts)) {
942 $fields["layout_id"] = $ts;
943 }
944
945 // section
946 $section1 = $f->input()->field()->section($fields, $lng->txt("cont_insert_pagelayout"));
947
948 $form_action = $ctrl->getLinkTarget($this, "insertPageFromTemplate");
949 return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
950 }
951
955 public function insertPageFromTemplate(): void
956 {
957 global $DIC;
958
959 $ilCtrl = $this->ctrl;
960
961 $form = $this->initInsertTemplateForm();
962 $form = $form->withRequest($DIC->http()->request());
963 $data = $form->getData();
964 $layout_id = $data["sec"]["layout_id"];
965 $node_id = $this->request->getNodeId();
967 $this->content_object->getId(),
968 $this->request->getMulti(),
969 $node_id,
970 $this->request->getFirstChild(),
971 $layout_id,
972 $data["sec"]["title"]
973 );
974
975 if ($this->request->getMulti() <= 1) {
976 $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_page_added"), true);
977 } else {
978 $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_pages_added"), true);
979 }
980
981 //$ilCtrl->setParameter($this, "highlight", $page_ids);
982 $ilCtrl->redirect($this, "showHierarchy", "node_" . $node_id);
983 }
984}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilConditionHandlerGUI
static setAction(string $a_action)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Base class for ilStructureObjects and ilPageObjects (see ILIAS DTD)
static writeLayout(int $a_obj_id, string $a_layout, ?ilObjLearningModule $a_lm=null)
Write layout setting.
static clipboardCut(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
static saveTitles(ilObjLearningModule $a_lm, array $a_titles, string $a_lang="-")
Save titles for lm objects.
static _lookupContObjID(int $a_id)
get learning module id for lm object
static clipboardCopy(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
static updateInternalLinks(array $a_copied_nodes, string $a_parent_type="lm")
Update internal links, after multiple pages have been copied.
static putInTree(ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
put this object into content object tree
static uniqueTypesCheck(array $a_items)
Check for unique types (all pages or all chapters)
static _lookupType(int $a_obj_id, int $a_lm_id=0)
User Interface for Learning Module Page Objects Editing.
static getLayoutCssFix()
Get layout css fix (workaround for broken radio options)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static insertPagesFromTemplate(int $lm_id, int $num, int $node_id, bool $first_child, int $layout_id, string $title="")
Insert (multiple) pages templates at node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
Component logger with individual log levels by component id.
static getMultiLangHeader(int $a_lm_id, object $a_gui_class, string $a_mode="")
static getLayoutOption(string $a_txt, string $a_var, string $a_def_option="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
static _writeActive(int $a_id, string $a_parent_type, bool $a_active)
write activation status
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
User Interface for Structure Objects Editing.
initSetPageLayoutForm()
Init set page layout form.
static _goto(string $a_target, int $a_target_ref_id=0)
insertPageFromTemplate()
Insert (multiple) pages templates at node.
create()
structure / page object creation form
putInTree(?int $target=null)
put chapter into tree
saveAllTitles()
Save all titles of chapters/pages.
cancel()
cancel creation of new page or chapter
insertSubchapter()
Insert (multiple) subchapters at node.
__construct(ilObjLearningModule $a_content_obj, ilLMTree $a_tree)
ilConditionHandlerGUI $condHI
copyChapter()
copy a single chapter (selection)
subchap()
display subchapters of structure object
insertTemplate()
Displays GUI to select template for page.
insertChapterClip(bool $a_as_sub=false, string $a_return="view")
Insert Chapter from clipboard.
setStructureObject(ilStructureObject $a_st_object)
insertChapter(bool $a_as_sub=false)
Insert (multiple) chapters at node.
setPageLayout()
Set layout for multipl pages.
cutItems(string $a_return="view")
Copy items to clipboard, then cut them from the current tree.
copyItems(string $a_return="view")
Copy items to clipboard.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getPresentationTitle(int $a_st_id, string $a_mode=self::CHAPTER_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-", bool $a_include_short=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setBackTarget(string $a_title, string $a_target, string $a_frame="")
clearTargets()
clear all targets
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const POS_LAST_NODE
setTreeTablePK(string $a_column_name)
set column containing primary key in tree table
setTableNames(string $a_table_tree, string $a_table_obj_data, string $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be 'obj_id' You may use...
getChildsByType(int $a_node_id, string $a_type)
get child nodes of given node by object type
const POS_FIRST_NODE
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This describes commonalities between all forms.
Definition: Form.php:33
This describes a standard form.
Definition: Standard.php:27
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$ref_id
Definition: ltiauth.php:67
$path
Definition: ltiservices.php:32
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
catch(\Exception $e) $req
Definition: xapiproxy.php:93
$log
Definition: result.php:33
$lng