ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\LearningModule\Editing\EditSubObjectsGUI Class Reference
+ Collaboration diagram for ILIAS\LearningModule\Editing\EditSubObjectsGUI:

Public Member Functions

 __construct (protected InternalDomainService $domain, protected InternalGUIService $gui, protected string $sub_type, protected \ilObjLearningModule $lm, protected string $table_title)
 
 executeCommand ()
 
 switchToLanguage ()
 
 editMasterLanguage ()
 
 insertChapterClipBefore ()
 
 insertChapterClipAfter ()
 
 insertChapterClip ( $target=\ilTree::POS_LAST_NODE)
 
 insertPageClipBefore ()
 
 insertPageClipAfter ()
 
 insertPageClip (int $target=0)
 
 insertFirstPage ()
 
 insertPageAfter (int $id=0)
 
 savePageAfter ()
 
 insertPageBefore (int $id)
 
 savePageBefore ()
 
 insertFirstChapter ()
 
 insertChapterAfter (int $id=0)
 
 saveChapterAfter ()
 
 insertChapterBefore (int $id)
 
 saveChapterBefore ()
 
 editTitle (int $id)
 
 getTitlesFromForm ()
 
 getLayoutIdFromForm ()
 
 saveTitle ()
 
 saveOrder ()
 
 delete (array $ids)
 confirm deletion screen for page object and structure object deletion More...
 
 cancelDelete ()
 
 confirmedDelete (int $a_parent_subobj_id=0)
 delete page object or structure objects More...
 
 cutItems (array $ids)
 Copy items to clipboard, then cut them from the current tree. More...
 
 copyItems ($ids)
 Copy items to clipboard. More...
 
 activatePages (array $ids)
 

Protected Member Functions

 editPages ()
 
 getTable ()
 
 list ()
 
 getCurrentParentId ()
 
 insertPage (int $parent_id=0, int $target=0, array $titles=[], int $layout_id=0)
 
 insertChapter (int $parent_id=0, int $target=\ilTree::POS_LAST_NODE, array $titles=[])
 
 getAddPageForm ($cmd)
 
 getEditTitleForm (int $id, $cmd="saveTitle")
 

Protected Attributes

string $lang
 
array $page_layouts
 
EditingGUIRequest $request
 
int $lm_id
 
ilLMTree $lm_tree
 
int $sub_obj_id
 

Detailed Description

Definition at line 31 of file class.EditSubObjectsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::__construct ( protected InternalDomainService  $domain,
protected InternalGUIService  $gui,
protected string  $sub_type,
protected \ilObjLearningModule  $lm,
protected string  $table_title 
)

Definition at line 40 of file class.EditSubObjectsGUI.php.

46 {
47 $this->sub_obj_id = $this->gui->editing()->request()->getObjId();
48 $this->gui->ctrl()->saveParameterByClass(self::class, "sub_type");
49 $this->lm_id = $lm->getId();
50 $this->lm_tree = $this->domain->lmTree($this->lm_id);
51 $this->request = $this->gui->editing()->request();
52 $this->page_layouts = \ilPageLayout::activeLayouts(
54 );
55 $this->lang = $this->request->getTranslation();
56 $this->gui->initFetch();
57 }
static activeLayouts(int $a_module=0)
Get active layouts.

References ilPageLayout\activeLayouts(), ilObject\getId(), and ilPageLayout\MODULE_LM.

+ Here is the call graph for this function:

Member Function Documentation

◆ activatePages()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::activatePages ( array  $ids)

Definition at line 812 of file class.EditSubObjectsGUI.php.

812 : void
813 {
814 $ctrl = $this->gui->ctrl();
815 $mt = $this->gui->mainTemplate();
816 $lng = $this->domain->lng();
817 $lm_tree = $this->domain->lmTree($this->lm_id);
818
819 $ids = $ids;
820 if (count($ids) > 0) {
821 $act_items = array();
822 // get all "top" ids, i.e. remove ids, that have a selected parent
823 foreach ($ids as $id) {
825 $take = true;
826 foreach ($path as $path_id) {
827 if ($path_id != $id && in_array($path_id, $ids)) {
828 $take = false;
829 }
830 }
831 if ($take) {
832 $act_items[] = $id;
833 }
834 }
835
836
837 foreach ($act_items as $id) {
838 $childs = $lm_tree->getChilds($id);
839 foreach ($childs as $child) {
840 if (ilLMObject::_lookupType($child["child"]) == "pg") {
842 $child["child"],
843 $this->lm->getType()
844 );
846 $child["child"],
847 $this->lm->getType(),
848 !$act
849 );
850 }
851 }
852 if (ilLMObject::_lookupType($id) == "pg") {
854 $id,
855 $this->lm->getType()
856 );
858 $id,
859 $this->lm->getType(),
860 !$act
861 );
862 }
863 }
864 } else {
865 $mt->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
866 }
867
868 $ctrl->redirect($this, "list");
869 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupType(int $a_obj_id, int $a_lm_id=0)
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
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
getPathId(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
$path
Definition: ltiservices.php:30
global $lng
Definition: privfeed.php:31

References $id, $lng, $path, ilPageObject\_lookupActive(), ilLMObject\_lookupType(), and ilPageObject\_writeActive().

+ Here is the call graph for this function:

◆ cancelDelete()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::cancelDelete ( )

Definition at line 698 of file class.EditSubObjectsGUI.php.

698 : void
699 {
700 $this->gui->ctrl()->redirect($this, "list");
701 }

◆ confirmedDelete()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::confirmedDelete ( int  $a_parent_subobj_id = 0)

delete page object or structure objects

Parameters
int$a_parent_subobj_idid of parent object (structure object) of the objects, that should be deleted (or no parent object id for top level)

Definition at line 710 of file class.EditSubObjectsGUI.php.

710 : void
711 {
712 $tree = $this->domain->lmTree($this->lm_id);
713 $ids = $this->request->getIds();
714 $mt = $this->gui->mainTemplate();
715 $ctrl = $this->gui->ctrl();
716 $lng = $this->domain->lng();
717
718 // check number of objects
719 if (count($ids) == 0) {
720 $mt->setOnScreenMessage('failure', $lng->txt("no_checkbox"));
721 $ctrl->redirect($this, "list");
722 }
723
724 // delete all selected objects
725 foreach ($ids as $id) {
726 if ($id != \ilTree::POS_FIRST_NODE) {
727 $obj = \ilLMObjectFactory::getInstance($this->lm, $id, false);
728 $node_data = $tree->getNodeData($id);
729 if (is_object($obj)) {
730 $obj->setLMId($this->lm->getId());
731 $obj->delete();
732 }
733 if ($tree->isInTree($id)) {
734 $tree->deleteTree($node_data);
735 }
736 }
737 }
738
739 // check the tree
740 $this->lm->checkTree();
741
742 // feedback
743 $mt->setOnScreenMessage('success', $lng->txt("info_deleted"), true);
744 $ctrl->redirect($this, "list");
745 }
static getInstance(ilObjLearningModule $a_content_obj, int $a_id=0, bool $a_halt=true)
const POS_FIRST_NODE

References $id, $lng, ilLMObjectFactory\getInstance(), and ilTree\POS_FIRST_NODE.

+ Here is the call graph for this function:

◆ copyItems()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::copyItems (   $ids)

Copy items to clipboard.

Definition at line 782 of file class.EditSubObjectsGUI.php.

782 : void
783 {
784
785 $ctrl = $this->gui->ctrl();
786 $lng = $this->domain->lng();
787 $mt = $this->gui->mainTemplate();
788
789 $items = $ids;
790 if (count($items) == 0) {
791 $mt->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
792 $ctrl->redirect($this, "list");
793 }
794
795 $todel = array(); // delete IDs < 0 (needed for non-js editing)
796 foreach ($items as $k => $item) {
797 if ($item < 0) {
798 $todel[] = $k;
799 }
800 }
801 foreach ($todel as $k) {
802 unset($items[$k]);
803 }
804
805 \ilLMObject::clipboardCopy($this->lm_id, $items);
807
808 $mt->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_copied"), true);
809 $ctrl->redirect($this, "list");
810 }
static setAction(string $a_action)
static clipboardCopy(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.

References $lng, ilLMObject\clipboardCopy(), and ilEditClipboard\setAction().

+ Here is the call graph for this function:

◆ cutItems()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::cutItems ( array  $ids)

Copy items to clipboard, then cut them from the current tree.

Definition at line 750 of file class.EditSubObjectsGUI.php.

750 : void
751 {
752 $ctrl = $this->gui->ctrl();
753 $mt = $this->gui->mainTemplate();
754 $lng = $this->domain->lng();
755
756 $items = $ids;
757 if (count($items) == 0) {
758 $mt->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
759 $ctrl->redirect($this, "list");
760 }
761
762 $todel = array(); // delete IDs < 0 (needed for non-js editing)
763 foreach ($items as $k => $item) {
764 if ($item < 0) {
765 $todel[] = $k;
766 }
767 }
768 foreach ($todel as $k) {
769 unset($items[$k]);
770 }
771
772 \ilLMObject::clipboardCut($this->lm_id, $items);
774 $mt->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_cut"), true);
775
776 $ctrl->redirect($this, "list");
777 }
static clipboardCut(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.

References $lng, ilLMObject\clipboardCut(), and ilEditClipboard\setAction().

+ Here is the call graph for this function:

◆ delete()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::delete ( array  $ids)

confirm deletion screen for page object and structure object deletion

Parameters
int$a_parent_subobj_idid of parent object (structure object) of the objects, that should be deleted (or no parent object id for top level)

Definition at line 660 of file class.EditSubObjectsGUI.php.

660 : void
661 {
662 $a_parent_subobj_id = $this->sub_obj_id;
663 $mt = $this->gui->mainTemplate();
664 $lng = $this->domain->lng();
665 $ctrl = $this->gui->ctrl();
666
667 if (count($ids) == 0) {
668 $mt->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
669 $this->cancelDelete();
670 }
671
672 if (count($ids) == 1 && $ids[0] == \ilTree::POS_FIRST_NODE) {
673 $mt->setOnScreenMessage('failure', $lng->txt("cont_select_item"), true);
674 $this->cancelDelete();
675 }
676
677 $form_action = $ctrl->getFormActionByClass(self::class);
678
679 // display confirmation message
680 $cgui = new \ilConfirmationGUI();
681 $cgui->setFormAction($form_action);
682 $cgui->setHeaderText($lng->txt("info_delete_sure"));
683 $cgui->setCancel($lng->txt("cancel"), "cancelDelete");
684 $cgui->setConfirm($lng->txt("confirm"), "confirmedDelete");
685
686 foreach ($ids as $id) {
687 if ($id != \ilTree::POS_FIRST_NODE) {
688 $obj = new \ilLMObject($this->lm, $id);
689 $caption = $obj->getTitle();
690
691 $cgui->addItem("id[]", (string) $id, $caption);
692 }
693 }
694
695 $mt->setContent($cgui->getHTML());
696 }

References $id, $lng, and ilTree\POS_FIRST_NODE.

◆ editMasterLanguage()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::editMasterLanguage ( )

Definition at line 110 of file class.EditSubObjectsGUI.php.

110 : void
111 {
112 $ctrl = $this->gui->ctrl();
113 $ctrl->setParameter($this, "transl", "-");
114 $ctrl->redirect($this, "list");
115 }

◆ editPages()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::editPages ( )
protected

Definition at line 86 of file class.EditSubObjectsGUI.php.

86 : void
87 {
88 $this->gui->ctrl()->setParameterByClass(self::class, "sub_type", "pg");
89 $this->gui->ctrl()->redirectByClass(static::class, "list");
90 }

◆ editTitle()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::editTitle ( int  $id)

Definition at line 558 of file class.EditSubObjectsGUI.php.

558 : void
559 {
560 $lng = $this->domain->lng();
561 $this->gui->clearAsnyOnloadCode();
562 $modal = $this->gui->modal($lng->txt("cont_edit_title"))->form($this->getEditTitleForm($id));
563 $modal->send();
564 }

References $id, and $lng.

◆ executeCommand()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::executeCommand ( )

Definition at line 59 of file class.EditSubObjectsGUI.php.

59 : void
60 {
61 $ctrl = $this->gui->ctrl();
62 $next_class = $ctrl->getNextClass($this);
63 $cmd = $ctrl->getCmd("list");
64
65 switch ($next_class) {
66 default:
67 if (in_array($cmd, [
68 "list", "tableCommand", "editPages",
69 "insertChapterAfter", "insertChapterBefore", "insertFirstChapter",
70 "insertPageAfter", "insertPageBefore", "insertFirstPage",
71 "editTitle", "saveTitle", "saveOrder",
72 "confirmedDelete", "delete", "cancelDelete",
73 "insertPageClip", "insertPageClipBefore", "insertPageClipAfter",
74 "insertChapterClip", "insertChapterClipBefore", "insertChapterClipAfter",
75 "activatePages",
76 "insertLayoutBefore", "insertLayoutAfter", "insertPageFromLayout",
77 "switchToLanguage", "editMasterLanguage",
78 "savePageAfter", "savePageBefore",
79 "saveChapterAfter", "saveChapterBefore",
80 ])) {
81 $this->$cmd();
82 }
83 }
84 }

◆ getAddPageForm()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::getAddPageForm (   $cmd)
protected

Definition at line 511 of file class.EditSubObjectsGUI.php.

511 : FormAdapterGUI
512 {
513 $this->domain->lng()->loadLanguageModule("copg");
514 $form = $this->getEditTitleForm(0, $cmd);
516 if (count($arr_templates) > 0) {
517 $form = $form->optional("use_template", $this->domain->lng()->txt("copg_use_template"));
518 $form = \ilPageLayoutGUI::addTemplateSelection((string) \ilPageLayout::MODULE_LM, $form);
519 $form = $form->end();
520 }
521 return $form;
522 }

References ilPageLayout\activeLayouts(), and ilPageLayout\MODULE_LM.

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentParentId()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::getCurrentParentId ( )
protected

Definition at line 186 of file class.EditSubObjectsGUI.php.

186 : int
187 {
188 $parent = $this->sub_obj_id;
189 if ($parent === 0) {
190 $parent = $this->lm_tree->readRootId();
191 }
192 return $parent;
193 }

References ILIAS\LearningModule\Editing\EditSubObjectsGUI\$sub_obj_id.

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\insertChapterClipBefore().

+ Here is the caller graph for this function:

◆ getEditTitleForm()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::getEditTitleForm ( int  $id,
  $cmd = "saveTitle" 
)
protected

Definition at line 524 of file class.EditSubObjectsGUI.php.

524 : FormAdapterGUI
525 {
526 $lng = $this->domain->lng();
527 $this->gui->ctrl()->setParameterByClass(self::class, "edit_id", $id);
528 $ot = $this->domain->translation($this->lm->getId());
529 $ml = "";
530 if ($ot->getContentTranslationActivated()) {
531 $ml = " (" . $lng->txt("meta_l_" . $ot->getBaseLanguage()) . ")";
532 }
533
534 $form = $this
535 ->gui
536 ->form([self::class], $cmd)
537 ->text("title", $lng->txt('title') . $ml, "", ilLMObject::_lookupTitle($id), 200);
538 if ($ot->getContentTranslationActivated()) {
539 foreach ($ot->getLanguages() as $lang) {
540 $code = $lang->getLanguageCode();
541 if ($code === $ot->getBaseLanguage()) {
542 continue;
543 }
544 $lmobjtrans = new \ilLMObjTranslation($id, $code);
545 $title = $lmobjtrans->getTitle();
546 $form = $form->text(
547 "title_" . $code,
548 $lng->txt('title') . " (" . $lng->txt("meta_l_" . $code) . ")",
549 "",
550 $title,
551 200
552 );
553 }
554 }
555 return $form;
556 }
static _lookupTitle(int $a_obj_id)

References $id, $lng, and ilLMObject\_lookupTitle().

+ Here is the call graph for this function:

◆ getLayoutIdFromForm()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::getLayoutIdFromForm ( )

Definition at line 587 of file class.EditSubObjectsGUI.php.

587 : int
588 {
589 $form = $this->getAddPageForm("");
590 if ($form->isValid()) {
591 if ($form->getData("use_template")) {
592 return (int) $form->getData("template_id");
593 }
594 }
595 return 0;
596 }

◆ getTable()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::getTable ( )
protected

Definition at line 92 of file class.EditSubObjectsGUI.php.

92 : TableAdapterGUI
93 {
94 return $this->gui->editing()->subObjectTableBuilder(
95 $this->table_title,
96 $this->lm_id,
97 $this->sub_type,
98 $this,
99 "list"
100 )->getTable();
101 }

References ILIAS\Repository\Table\TableAdapterGUI\getTable().

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitlesFromForm()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::getTitlesFromForm ( )

Definition at line 566 of file class.EditSubObjectsGUI.php.

566 : array
567 {
568 $titles = [];
569 $form = $this->getEditTitleForm($this->request->getEditId());
570 if ($form->isValid()) {
571 $titles["-"] = $form->getData("title");
572
573 $ot = $this->domain->translation($this->lm->getId());
574 if ($ot->getContentTranslationActivated()) {
575 foreach ($ot->getLanguages() as $lang) {
576 $code = $lang->getLanguageCode();
577 if ($code === $ot->getBaseLanguage()) {
578 continue;
579 }
580 $titles[$code] = $form->getData("title_" . $code);
581 }
582 }
583 }
584 return $titles;
585 }

◆ insertChapter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertChapter ( int  $parent_id = 0,
int  $target = \ilTree::POS_LAST_NODE,
array  $titles = [] 
)
protected

Definition at line 479 of file class.EditSubObjectsGUI.php.

483 : void {
484 $lng = $this->domain->lng();
485 $ctrl = $this->gui->ctrl();
486 $chap = new \ilStructureObject($this->lm);
487 $chap->setType("st");
488 $chap->setTitle($lng->txt("cont_new_chap"));
489 $chap->setLMId($this->lm_id);
490 $chap->create();
491 \ilLMObject::putInTree($chap, $parent_id, $target);
492
493 if (count($titles) > 0) {
494 \ilLMObject::saveTitle($chap->getId(), $titles["-"]);
495
496 $ot = $this->domain->translation($this->lm->getId());
497 if ($ot->getContentTranslationActivated()) {
498 foreach ($ot->getLanguages() as $lang) {
499 $code = $lang->getLanguageCode();
500 if ($code === $ot->getBaseLanguage()) {
501 continue;
502 }
503 \ilLMObject::saveTitle($chap->getId(), $titles[$code], $code);
504 }
505 }
506 }
507
508 $ctrl->redirect($this, "list");
509 }
static saveTitle(int $id, string $title, string $lang="-")
static putInTree(ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
put this object into content object tree

◆ insertChapterAfter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertChapterAfter ( int  $id = 0)

Definition at line 424 of file class.EditSubObjectsGUI.php.

424 : void
425 {
426 $lng = $this->domain->lng();
427 $this->gui->ctrl()->setParameterByClass(
428 self::class,
429 "target_id",
430 $id
431 );
432 $this->gui->clearAsnyOnloadCode();
433 $modal = $this->gui->modal($lng->txt("lm_insert_chapter"))->form($this->getEditTitleForm(0, "saveChapterAfter"));
434 $modal->send();
435 }

References $id, and $lng.

◆ insertChapterBefore()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertChapterBefore ( int  $id)

Definition at line 447 of file class.EditSubObjectsGUI.php.

447 : void
448 {
449 $lng = $this->domain->lng();
450 $this->gui->ctrl()->setParameterByClass(
451 self::class,
452 "target_id",
453 $id
454 );
455 $this->gui->clearAsnyOnloadCode();
456 $modal = $this->gui->modal($lng->txt("lm_insert_chapter"))->form($this->getEditTitleForm(0, "saveChapterBefore"));
457 $modal->send();
458 }

References $id, and $lng.

◆ insertChapterClip()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertChapterClip (   $target = \ilTree::POS_LAST_NODE)

Definition at line 219 of file class.EditSubObjectsGUI.php.

221 : void {
222 $user = $this->domain->user();
223 $ctrl = $this->gui->ctrl();
224 $parent_id = $this->request->getObjId();
225
226 // copy and paste
227 $chapters = $user->getClipboardObjects("st", true);
228 $copied_nodes = array();
229
230 foreach ($chapters as $chap) {
231 $cid = ilLMObject::pasteTree(
232 $this->lm,
233 $chap["id"],
234 $parent_id,
235 (int) $target,
236 (string) ($chap["insert_time"] ?? ""),
237 $copied_nodes,
238 (\ilEditClipboard::getAction() == "copy")
239 );
240 $target = $cid;
241 }
242 ilLMObject::updateInternalLinks($copied_nodes);
243
244 if (\ilEditClipboard::getAction() == "cut") {
245 $user->clipboardDeleteObjectsOfType("pg");
246 $user->clipboardDeleteObjectsOfType("st");
248 }
249
250 $this->lm->checkTree();
251 $ctrl->redirect($this, "list");
252 }
static updateInternalLinks(array $a_copied_nodes, string $a_parent_type="lm")
Update internal links, after multiple pages have been copied.

Referenced by ILIAS\LearningModule\Editing\EditSubObjectsGUI\insertChapterClipAfter(), and ILIAS\LearningModule\Editing\EditSubObjectsGUI\insertChapterClipBefore().

+ Here is the caller graph for this function:

◆ insertChapterClipAfter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertChapterClipAfter ( )

Definition at line 212 of file class.EditSubObjectsGUI.php.

212 : void
213 {
214 $this->insertChapterClip(
215 $this->request->getTargetId()
216 );
217 }

References ILIAS\LearningModule\Editing\EditSubObjectsGUI\insertChapterClip().

+ Here is the call graph for this function:

◆ insertChapterClipBefore()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertChapterClipBefore ( )

Definition at line 195 of file class.EditSubObjectsGUI.php.

195 : void
196 {
197 $parent = $this->getCurrentParentId();
198 $target_id = $this->request->getTargetId();
199 $before_target = \ilTree::POS_FIRST_NODE;
200 foreach ($this->lm_tree->getChilds($parent) as $node) {
201 if ((int) $node["obj_id"] !== $target_id) {
202 $before_target = (int) $node["obj_id"];
203 } else {
204 break;
205 }
206 }
207 $this->insertChapterClip(
208 $before_target
209 );
210 }

References ILIAS\LearningModule\Editing\EditSubObjectsGUI\getCurrentParentId(), ILIAS\LearningModule\Editing\EditSubObjectsGUI\insertChapterClip(), ILIAS\Repository\int(), and ilTree\POS_FIRST_NODE.

+ Here is the call graph for this function:

◆ insertFirstChapter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertFirstChapter ( )

Definition at line 417 of file class.EditSubObjectsGUI.php.

417 : void
418 {
419 $this->insertChapter(
420 $this->sub_obj_id
421 );
422 }
insertChapter(int $parent_id=0, int $target=\ilTree::POS_LAST_NODE, array $titles=[])

◆ insertFirstPage()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertFirstPage ( )

Definition at line 312 of file class.EditSubObjectsGUI.php.

312 : void
313 {
314 $this->insertPage(
315 $this->sub_obj_id
316 );
317 }
insertPage(int $parent_id=0, int $target=0, array $titles=[], int $layout_id=0)

◆ insertPage()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertPage ( int  $parent_id = 0,
int  $target = 0,
array  $titles = [],
int  $layout_id = 0 
)
protected

Definition at line 383 of file class.EditSubObjectsGUI.php.

388 : void {
389 $lng = $this->domain->lng();
390 $ctrl = $this->gui->ctrl();
391
392 $page = new \ilLMPageObject($this->lm);
393 $page->setType("pg");
394 $page->setTitle($lng->txt("cont_new_page"));
395 $page->setLMId($this->lm_id);
396 $page->create(false, false, $layout_id);
397 \ilLMObject::putInTree($page, $parent_id, $target);
398
399 if (count($titles) > 0) {
400 \ilLMObject::saveTitle($page->getId(), $titles["-"]);
401
402 $ot = $this->domain->translation($this->lm->getId());
403 if ($ot->getContentTranslationActivated()) {
404 foreach ($ot->getLanguages() as $lang) {
405 $code = $lang->getLanguageCode();
406 if ($code === $ot->getBaseLanguage()) {
407 continue;
408 }
409 \ilLMObject::saveTitle($page->getId(), $titles[$code], $code);
410 }
411 }
412 }
413
414 $ctrl->redirect($this, "list");
415 }

◆ insertPageAfter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertPageAfter ( int  $id = 0)

Definition at line 318 of file class.EditSubObjectsGUI.php.

318 : void
319 {
320 $lng = $this->domain->lng();
321 $this->gui->ctrl()->setParameterByClass(
322 self::class,
323 "target_id",
324 $id
325 );
326 $this->gui->clearAsnyOnloadCode();
327 $modal = $this->gui->modal($lng->txt("lm_insert_page"))->form($this->getAddPageForm("savePageAfter"));
328 $modal->send();
329 }

References $id, and $lng.

◆ insertPageBefore()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertPageBefore ( int  $id)

Definition at line 346 of file class.EditSubObjectsGUI.php.

346 : void
347 {
348 $lng = $this->domain->lng();
349 $this->gui->ctrl()->setParameterByClass(
350 self::class,
351 "target_id",
352 $id
353 );
354 $this->gui->clearAsnyOnloadCode();
355 $modal = $this->gui->modal($lng->txt("lm_insert_page"))->form($this->getAddPageForm("savePageBefore"));
356 $modal->send();
357 }

References $id, and $lng.

◆ insertPageClip()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertPageClip ( int  $target = 0)

Definition at line 278 of file class.EditSubObjectsGUI.php.

280 : void {
281 $user = $this->domain->user();
282 $ctrl = $this->gui->ctrl();
283
284 $parent_id = $this->request->getObjId();
285
286 // cut and paste
287 $pages = $user->getClipboardObjects("pg");
288 $copied_nodes = array();
289 foreach ($pages as $pg) {
290 $cid = ilLMObject::pasteTree(
291 $this->lm,
292 $pg["id"],
293 $parent_id,
294 $target,
295 (string) ($pg["insert_time"] ?? ""),
296 $copied_nodes,
297 (\ilEditClipboard::getAction() == "copy")
298 );
299 $target = $cid;
300 }
302
303 if (\ilEditClipboard::getAction() == "cut") {
304 $user->clipboardDeleteObjectsOfType("pg");
305 $user->clipboardDeleteObjectsOfType("st");
307 }
308
309 $ctrl->redirect($this, "list");
310 }

◆ insertPageClipAfter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertPageClipAfter ( )

Definition at line 271 of file class.EditSubObjectsGUI.php.

271 : void
272 {
273 $this->insertPageClip(
274 $this->request->getTargetId()
275 );
276 }

◆ insertPageClipBefore()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::insertPageClipBefore ( )

Definition at line 254 of file class.EditSubObjectsGUI.php.

254 : void
255 {
256 $parent = $this->sub_obj_id;
257 $target_id = $this->request->getTargetId();
258 $before_target = \ilTree::POS_FIRST_NODE;
259 foreach ($this->lm_tree->getChildsByType($parent, "pg") as $node) {
260 if ((int) $node["obj_id"] !== $target_id) {
261 $before_target = (int) $node["obj_id"];
262 } else {
263 break;
264 }
265 }
266 $this->insertPageClip(
267 $before_target
268 );
269 }

References ILIAS\Repository\int(), and ilTree\POS_FIRST_NODE.

+ Here is the call graph for this function:

◆ list()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::list ( )
protected

Definition at line 118 of file class.EditSubObjectsGUI.php.

118 : void
119 {
120 $lng = $this->domain->lng();
121 $ctrl = $this->gui->ctrl();
122 $main_tpl = $this->gui->mainTemplate();
123 $user = $this->domain->user();
124
125 if ($this->getTable()->handleCommand()) {
126 return;
127 }
128
129 $retrieval = $this->domain->subObjectRetrieval(
130 $this->lm_id,
131 $this->sub_type,
132 $this->sub_obj_id,
133 $this->lang
134 );
135
136 $ml_head = \ilObjLearningModuleGUI::getMultiLangHeader($this->lm_id, $this);
137
138 if ($this->sub_type === "st") {
139 $modal = $this->gui->modal(
140 $lng->txt("lm_insert_chapter")
141 )->form($this->getAddPageForm("saveChapterAfter"))->getAsyncTriggerButtonComponents(
142 $lng->txt("lm_insert_chapter"),
143 $this->gui->ctrl()->getLinkTargetByClass(self::class, "insertChapterAfter"),
144 false
145 );
146 $this->gui->toolbar()->addComponent($modal["button"]);
147 $this->gui->toolbar()->addComponent($modal["modal"]);
148 /*
149 $this->gui->button(
150 $lng->txt("lm_insert_chapter"),
151 $ctrl->getLinkTargetByClass(self::class, "insertFirstChapter")
152 )->toToolbar();*/
153 if ($user->clipboardHasObjectsOfType("st")) {
154 $this->gui->button(
155 $lng->txt("lm_insert_chapter_clip"),
156 $ctrl->getLinkTargetByClass(self::class, "insertChapterClip")
157 )->toToolbar();
158 }
159 } else {
160 $modal = $this->gui->modal(
161 $lng->txt("lm_insert_page")
162 )->form($this->getAddPageForm("savePageAfter"))->getAsyncTriggerButtonComponents(
163 $lng->txt("lm_insert_page"),
164 $this->gui->ctrl()->getLinkTargetByClass(self::class, "insertPageAfter"),
165 false
166 );
167 $this->gui->toolbar()->addComponent($modal["button"]);
168 $this->gui->toolbar()->addComponent($modal["modal"]);
169 /*$this->gui->button(
170 $lng->txt("lm_insert_page"),
171 $ctrl->getLinkTargetByClass(self::class, "insertFirstPage")
172 )->toToolbar();*/
173 if ($user->clipboardHasObjectsOfType("pg")) {
174 $this->gui->button(
175 $lng->txt("lm_insert_page_clip"),
176 $ctrl->getLinkTargetByClass(self::class, "insertPageClip")
177 )->toToolbar();
178 }
179 }
180 $table = $this->getTable();
181
182 $main_tpl->setContent($ml_head . $table->render());
183 $main_tpl->addOnloadCode("window.setTimeout(() => { il.repository.core.trigger('il-lm-editor-tree'); }, 500);");
184 }
static getMultiLangHeader(int $a_lm_id, object $a_gui_class, string $a_mode="")

References $lng, ILIAS\LearningModule\Editing\EditSubObjectsGUI\getAddPageForm(), ilObjContentObjectGUI\getMultiLangHeader(), and ILIAS\LearningModule\Editing\EditSubObjectsGUI\getTable().

+ Here is the call graph for this function:

◆ saveChapterAfter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::saveChapterAfter ( )

Definition at line 437 of file class.EditSubObjectsGUI.php.

437 : void
438 {
439 $target_id = $this->request->getTargetId();
440 $this->insertChapter(
441 $this->sub_obj_id,
442 $target_id,
443 $this->getTitlesFromForm()
444 );
445 }

◆ saveChapterBefore()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::saveChapterBefore ( )

Definition at line 460 of file class.EditSubObjectsGUI.php.

460 : void
461 {
462 $parent = $this->getCurrentParentId();
463 $target_id = $this->request->getTargetId();
464 $before_target = \ilTree::POS_FIRST_NODE;
465 foreach ($this->lm_tree->getChilds($parent) as $node) {
466 if ((int) $node["obj_id"] !== $target_id) {
467 $before_target = (int) $node["obj_id"];
468 } else {
469 break;
470 }
471 }
472 $this->insertChapter(
473 $parent,
474 $before_target,
475 $this->getTitlesFromForm()
476 );
477 }

References ILIAS\Repository\int(), and ilTree\POS_FIRST_NODE.

+ Here is the call graph for this function:

◆ saveOrder()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::saveOrder ( )

Definition at line 621 of file class.EditSubObjectsGUI.php.

621 : void
622 {
623 $mt = $this->gui->mainTemplate();
624 $lng = $this->domain->lng();
625 $tree = $this->domain->lmTree($this->lm_id);
626 $table = $this->getTable();
627 $data = $table->getData();
628 $parent = ($this->sub_obj_id > 0)
629 ? $this->sub_obj_id
630 : $tree->readRootId();
631 if (!is_array($data)) {
632 return;
633 }
634
635 // note: moveTree has a bug and does not use the last parameter
636 // target will always be "last node"
637 // since all chapters must follow all pages
638 // we can simple call moveTree in the correct order for the chapters
639 // but if we order the pages, we must append all chapters to the data first
640 if ($this->sub_type === "pg") {
641 foreach ($tree->getChilds($parent) as $child) {
642 if ($child["type"] == "st") {
643 $data[] = $child["child"];
644 }
645 }
646 }
647 foreach ($data as $id) {
648 $tree->moveTree((int) $id, $parent);
649 }
650 $mt->setContent("success", $lng->txt("msg_obj_modified"), true);
651 $this->gui->ctrl()->redirect($this, "list");
652 }

References $data, $id, and $lng.

◆ savePageAfter()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::savePageAfter ( )

Definition at line 331 of file class.EditSubObjectsGUI.php.

331 : void
332 {
333 $mt = $this->gui->ui()->mainTemplate();
334 $lng = $this->domain->lng();
335 $target_id = $this->request->getTargetId();
336 $this->insertPage(
337 $this->sub_obj_id,
338 $target_id,
339 $this->getTitlesFromForm(),
340 $this->getLayoutIdFromForm()
341 );
342 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
343 $this->gui->ctrl()->redirect($this, "list");
344 }

References $lng.

◆ savePageBefore()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::savePageBefore ( )

Definition at line 359 of file class.EditSubObjectsGUI.php.

359 : void
360 {
361 $mt = $this->gui->ui()->mainTemplate();
362 $lng = $this->domain->lng();
363 $parent = $this->sub_obj_id;
364 $target_id = $this->request->getTargetId();
365 $before_target = \ilTree::POS_FIRST_NODE;
366 foreach ($this->lm_tree->getChildsByType($parent, "pg") as $node) {
367 if ((int) $node["obj_id"] !== $target_id) {
368 $before_target = (int) $node["obj_id"];
369 } else {
370 break;
371 }
372 }
373 $this->insertPage(
374 $parent,
375 $before_target,
376 $this->getTitlesFromForm(),
377 $this->getLayoutIdFromForm()
378 );
379 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
380 $this->gui->ctrl()->redirect($this, "list");
381 }

References $lng, ILIAS\Repository\int(), and ilTree\POS_FIRST_NODE.

+ Here is the call graph for this function:

◆ saveTitle()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::saveTitle ( )

Definition at line 598 of file class.EditSubObjectsGUI.php.

598 : void
599 {
600 $mt = $this->gui->mainTemplate();
601 $lng = $this->domain->lng();
602 $form = $this->getEditTitleForm($this->request->getEditId());
603 if ($form->isValid()) {
604 \ilLMObject::saveTitle($this->request->getEditId(), $form->getData("title"));
605
606 $ot = $this->lm->getObjectProperties()->getPropertyTranslations();
607 if ($ot->getContentTranslationActivated()) {
608 foreach ($ot->getLanguages() as $lang) {
609 $code = $lang->getLanguageCode();
610 if ($code === $ot->getBaseLanguage()) {
611 continue;
612 }
613 \ilLMObject::saveTitle($this->request->getEditId(), $form->getData("title_" . $code), $code);
614 }
615 }
616 }
617 $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
618 $this->gui->ctrl()->redirect($this, "list");
619 }

References $lng, and ilLMObject\saveTitle().

+ Here is the call graph for this function:

◆ switchToLanguage()

ILIAS\LearningModule\Editing\EditSubObjectsGUI::switchToLanguage ( )

Definition at line 103 of file class.EditSubObjectsGUI.php.

103 : void
104 {
105 $ctrl = $this->gui->ctrl();
106 $ctrl->setParameter($this, "transl", $this->request->getToTranslation());
107 $ctrl->redirect($this, "list");
108 }

Field Documentation

◆ $lang

string ILIAS\LearningModule\Editing\EditSubObjectsGUI::$lang
protected

Definition at line 33 of file class.EditSubObjectsGUI.php.

◆ $lm_id

int ILIAS\LearningModule\Editing\EditSubObjectsGUI::$lm_id
protected

Definition at line 36 of file class.EditSubObjectsGUI.php.

◆ $lm_tree

ilLMTree ILIAS\LearningModule\Editing\EditSubObjectsGUI::$lm_tree
protected

Definition at line 37 of file class.EditSubObjectsGUI.php.

◆ $page_layouts

array ILIAS\LearningModule\Editing\EditSubObjectsGUI::$page_layouts
protected

Definition at line 34 of file class.EditSubObjectsGUI.php.

◆ $request

EditingGUIRequest ILIAS\LearningModule\Editing\EditSubObjectsGUI::$request
protected

Definition at line 35 of file class.EditSubObjectsGUI.php.

◆ $sub_obj_id

int ILIAS\LearningModule\Editing\EditSubObjectsGUI::$sub_obj_id
protected

The documentation for this class was generated from the following file: