19declare(strict_types=1);
43 protected string $sub_type,
45 protected string $table_title
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();
55 $this->lang = $this->request->getTranslation();
56 $this->gui->initFetch();
61 $ctrl = $this->gui->ctrl();
62 $next_class = $ctrl->getNextClass($this);
63 $cmd = $ctrl->getCmd(
"list");
65 switch ($next_class) {
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",
76 "insertLayoutBefore",
"insertLayoutAfter",
"insertPageFromLayout",
77 "switchToLanguage",
"editMasterLanguage",
78 "savePageAfter",
"savePageBefore",
79 "saveChapterAfter",
"saveChapterBefore",
88 $this->gui->ctrl()->setParameterByClass(self::class,
"sub_type",
"pg");
89 $this->gui->ctrl()->redirectByClass(static::class,
"list");
94 return $this->gui->editing()->subObjectTableBuilder(
105 $ctrl = $this->gui->ctrl();
106 $ctrl->setParameter($this,
"transl", $this->request->getToTranslation());
107 $ctrl->redirect($this,
"list");
112 $ctrl = $this->gui->ctrl();
113 $ctrl->setParameter($this,
"transl",
"-");
114 $ctrl->redirect($this,
"list");
118 protected function list(): void
120 $lng = $this->domain->lng();
121 $ctrl = $this->gui->ctrl();
122 $main_tpl = $this->gui->mainTemplate();
123 $user = $this->domain->user();
125 if ($this->
getTable()->handleCommand()) {
129 $retrieval = $this->domain->subObjectRetrieval(
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"),
146 $this->gui->toolbar()->addComponent($modal[
"button"]);
147 $this->gui->toolbar()->addComponent($modal[
"modal"]);
153 if ($user->clipboardHasObjectsOfType(
"st")) {
155 $lng->txt(
"lm_insert_chapter_clip"),
156 $ctrl->getLinkTargetByClass(self::class,
"insertChapterClip")
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"),
167 $this->gui->toolbar()->addComponent($modal[
"button"]);
168 $this->gui->toolbar()->addComponent($modal[
"modal"]);
173 if ($user->clipboardHasObjectsOfType(
"pg")) {
175 $lng->txt(
"lm_insert_page_clip"),
176 $ctrl->getLinkTargetByClass(self::class,
"insertPageClip")
182 $main_tpl->setContent($ml_head . $table->render());
183 $main_tpl->addOnloadCode(
"window.setTimeout(() => { il.repository.core.trigger('il-lm-editor-tree'); }, 500);");
190 $parent = $this->lm_tree->readRootId();
198 $target_id = $this->request->getTargetId();
200 foreach ($this->lm_tree->getChilds($parent) as $node) {
201 if ((
int) $node[
"obj_id"] !== $target_id) {
202 $before_target = (
int) $node[
"obj_id"];
215 $this->request->getTargetId()
222 $user = $this->domain->
user();
223 $ctrl = $this->gui->ctrl();
224 $parent_id = $this->request->getObjId();
227 $chapters = $user->getClipboardObjects(
"st",
true);
228 $copied_nodes = array();
230 foreach ($chapters as $chap) {
231 $cid = ilLMObject::pasteTree(
236 (
string) ($chap[
"insert_time"] ??
""),
245 $user->clipboardDeleteObjectsOfType(
"pg");
246 $user->clipboardDeleteObjectsOfType(
"st");
250 $this->lm->checkTree();
251 $ctrl->redirect($this,
"list");
256 $parent = $this->sub_obj_id;
257 $target_id = $this->request->getTargetId();
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"];
266 $this->insertPageClip(
273 $this->insertPageClip(
274 $this->request->getTargetId()
281 $user = $this->domain->
user();
282 $ctrl = $this->gui->ctrl();
284 $parent_id = $this->request->getObjId();
287 $pages = $user->getClipboardObjects(
"pg");
288 $copied_nodes = array();
289 foreach ($pages as $pg) {
290 $cid = ilLMObject::pasteTree(
295 (
string) ($pg[
"insert_time"] ??
""),
304 $user->clipboardDeleteObjectsOfType(
"pg");
305 $user->clipboardDeleteObjectsOfType(
"st");
309 $ctrl->redirect($this,
"list");
320 $lng = $this->domain->lng();
321 $this->gui->ctrl()->setParameterByClass(
326 $this->gui->clearAsnyOnloadCode();
327 $modal = $this->gui->modal(
$lng->txt(
"lm_insert_page"))->form($this->getAddPageForm(
"savePageAfter"));
333 $mt = $this->gui->ui()->mainTemplate();
334 $lng = $this->domain->lng();
335 $target_id = $this->request->getTargetId();
339 $this->getTitlesFromForm(),
340 $this->getLayoutIdFromForm()
342 $mt->setOnScreenMessage(
"success",
$lng->txt(
"msg_obj_modified"),
true);
343 $this->gui->ctrl()->redirect($this,
"list");
348 $lng = $this->domain->lng();
349 $this->gui->ctrl()->setParameterByClass(
354 $this->gui->clearAsnyOnloadCode();
355 $modal = $this->gui->modal(
$lng->txt(
"lm_insert_page"))->form($this->getAddPageForm(
"savePageBefore"));
361 $mt = $this->gui->ui()->mainTemplate();
362 $lng = $this->domain->lng();
363 $parent = $this->sub_obj_id;
364 $target_id = $this->request->getTargetId();
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"];
376 $this->getTitlesFromForm(),
377 $this->getLayoutIdFromForm()
379 $mt->setOnScreenMessage(
"success",
$lng->txt(
"msg_obj_modified"),
true);
380 $this->gui->ctrl()->redirect($this,
"list");
390 $ctrl = $this->gui->ctrl();
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);
399 if (count($titles) > 0) {
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()) {
414 $ctrl->redirect($this,
"list");
419 $this->insertChapter(
426 $lng = $this->domain->lng();
427 $this->gui->ctrl()->setParameterByClass(
432 $this->gui->clearAsnyOnloadCode();
433 $modal = $this->gui->modal(
$lng->txt(
"lm_insert_chapter"))->form($this->getEditTitleForm(0,
"saveChapterAfter"));
439 $target_id = $this->request->getTargetId();
440 $this->insertChapter(
443 $this->getTitlesFromForm()
449 $lng = $this->domain->lng();
450 $this->gui->ctrl()->setParameterByClass(
455 $this->gui->clearAsnyOnloadCode();
456 $modal = $this->gui->modal(
$lng->txt(
"lm_insert_chapter"))->form($this->getEditTitleForm(0,
"saveChapterBefore"));
462 $parent = $this->getCurrentParentId();
463 $target_id = $this->request->getTargetId();
465 foreach ($this->lm_tree->getChilds($parent) as $node) {
466 if ((
int) $node[
"obj_id"] !== $target_id) {
467 $before_target = (
int) $node[
"obj_id"];
472 $this->insertChapter(
475 $this->getTitlesFromForm()
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);
493 if (count($titles) > 0) {
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()) {
508 $ctrl->redirect($this,
"list");
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"));
519 $form = $form->end();
526 $lng = $this->domain->lng();
527 $this->gui->ctrl()->setParameterByClass(self::class,
"edit_id",
$id);
528 $ot = $this->domain->translation($this->lm->getId());
530 if ($ot->getContentTranslationActivated()) {
531 $ml =
" (" .
$lng->txt(
"meta_l_" . $ot->getBaseLanguage()) .
")";
536 ->form([self::class], $cmd)
538 if ($ot->getContentTranslationActivated()) {
539 foreach ($ot->getLanguages() as $lang) {
540 $code = $lang->getLanguageCode();
541 if ($code === $ot->getBaseLanguage()) {
544 $lmobjtrans = new \ilLMObjTranslation(
$id, $code);
545 $title = $lmobjtrans->getTitle();
548 $lng->txt(
'title') .
" (" .
$lng->txt(
"meta_l_" . $code) .
")",
560 $lng = $this->domain->lng();
561 $this->gui->clearAsnyOnloadCode();
562 $modal = $this->gui->modal(
$lng->txt(
"cont_edit_title"))->form($this->getEditTitleForm(
$id));
569 $form = $this->getEditTitleForm($this->request->getEditId());
570 if ($form->isValid()) {
571 $titles[
"-"] = $form->getData(
"title");
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()) {
580 $titles[$code] = $form->getData(
"title_" . $code);
589 $form = $this->getAddPageForm(
"");
590 if ($form->isValid()) {
591 if ($form->getData(
"use_template")) {
592 return (
int) $form->getData(
"template_id");
600 $mt = $this->gui->mainTemplate();
601 $lng = $this->domain->lng();
602 $form = $this->getEditTitleForm($this->request->getEditId());
603 if ($form->isValid()) {
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()) {
617 $mt->setOnScreenMessage(
"success",
$lng->txt(
"msg_obj_modified"),
true);
618 $this->gui->ctrl()->redirect($this,
"list");
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)
630 : $tree->readRootId();
631 if (!is_array(
$data)) {
640 if ($this->sub_type ===
"pg") {
641 foreach ($tree->getChilds($parent) as $child) {
642 if ($child[
"type"] ==
"st") {
643 $data[] = $child[
"child"];
648 $tree->moveTree((
int)
$id, $parent);
650 $mt->setContent(
"success",
$lng->txt(
"msg_obj_modified"),
true);
651 $this->gui->ctrl()->redirect($this,
"list");
660 public function delete(array $ids):
void
662 $a_parent_subobj_id = $this->sub_obj_id;
663 $mt = $this->gui->mainTemplate();
664 $lng = $this->domain->lng();
665 $ctrl = $this->gui->ctrl();
667 if (count($ids) == 0) {
668 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
669 $this->cancelDelete();
673 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"cont_select_item"),
true);
674 $this->cancelDelete();
677 $form_action = $ctrl->getFormActionByClass(self::class);
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");
686 foreach ($ids as
$id) {
688 $obj = new \ilLMObject($this->lm,
$id);
689 $caption = $obj->getTitle();
691 $cgui->addItem(
"id[]", (
string)
$id, $caption);
695 $mt->setContent($cgui->getHTML());
700 $this->gui->ctrl()->redirect($this,
"list");
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();
719 if (count($ids) == 0) {
720 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"));
721 $ctrl->redirect($this,
"list");
725 foreach ($ids as
$id) {
728 $node_data = $tree->getNodeData(
$id);
729 if (is_object($obj)) {
730 $obj->setLMId($this->lm->getId());
733 if ($tree->isInTree(
$id)) {
734 $tree->deleteTree($node_data);
740 $this->lm->checkTree();
743 $mt->setOnScreenMessage(
'success',
$lng->txt(
"info_deleted"),
true);
744 $ctrl->redirect($this,
"list");
752 $ctrl = $this->gui->ctrl();
753 $mt = $this->gui->mainTemplate();
754 $lng = $this->domain->lng();
757 if (count($items) == 0) {
758 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
759 $ctrl->redirect($this,
"list");
763 foreach ($items as $k => $item) {
768 foreach ($todel as $k) {
774 $mt->setOnScreenMessage(
'info',
$lng->txt(
"cont_selected_items_have_been_cut"),
true);
776 $ctrl->redirect($this,
"list");
785 $ctrl = $this->gui->ctrl();
786 $lng = $this->domain->lng();
787 $mt = $this->gui->mainTemplate();
790 if (count($items) == 0) {
791 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
792 $ctrl->redirect($this,
"list");
796 foreach ($items as $k => $item) {
801 foreach ($todel as $k) {
808 $mt->setOnScreenMessage(
'info',
$lng->txt(
"cont_selected_items_have_been_copied"),
true);
809 $ctrl->redirect($this,
"list");
814 $ctrl = $this->gui->ctrl();
815 $mt = $this->gui->mainTemplate();
816 $lng = $this->domain->lng();
817 $lm_tree = $this->domain->lmTree($this->lm_id);
820 if (count($ids) > 0) {
821 $act_items = array();
823 foreach ($ids as
$id) {
826 foreach (
$path as $path_id) {
827 if ($path_id !=
$id && in_array($path_id, $ids)) {
837 foreach ($act_items as
$id) {
838 $childs = $lm_tree->getChilds(
$id);
839 foreach ($childs as $child) {
847 $this->lm->getType(),
859 $this->lm->getType(),
865 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
868 $ctrl->redirect($this,
"list");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
insertPage(int $parent_id=0, int $target=0, array $titles=[], int $layout_id=0)
insertChapterClip( $target=\ilTree::POS_LAST_NODE)
EditingGUIRequest $request
insertChapterClipBefore()
insertPageAfter(int $id=0)
copyItems($ids)
Copy items to clipboard.
insertChapter(int $parent_id=0, int $target=\ilTree::POS_LAST_NODE, array $titles=[])
activatePages(array $ids)
__construct(protected InternalDomainService $domain, protected InternalGUIService $gui, protected string $sub_type, protected \ilObjLearningModule $lm, protected string $table_title)
cutItems(array $ids)
Copy items to clipboard, then cut them from the current tree.
getEditTitleForm(int $id, $cmd="saveTitle")
insertChapterAfter(int $id=0)
insertPageClip(int $target=0)
insertChapterBefore(int $id)
confirmedDelete(int $a_parent_subobj_id=0)
delete page object or structure objects
insertPageBefore(int $id)
static setAction(string $a_action)
static getInstance(ilObjLearningModule $a_content_obj, int $a_id=0, bool $a_halt=true)
static saveTitle(int $id, string $title, string $lang="-")
static clipboardCut(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
static _lookupTitle(int $a_obj_id)
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 _lookupType(int $a_obj_id, int $a_lm_id=0)
static getMultiLangHeader(int $a_lm_id, object $a_gui_class, string $a_mode="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static activeLayouts(int $a_module=0)
Get active layouts.
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...