19 declare(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" 86 $this->gui->ctrl()->setParameterByClass(self::class,
"sub_type",
"pg");
87 $this->gui->ctrl()->redirectByClass(static::class,
"list");
92 return $this->gui->editing()->subObjectTableBuilder(
103 $ctrl = $this->gui->ctrl();
104 $ctrl->setParameter($this,
"transl", $this->request->getToTranslation());
105 $ctrl->redirect($this,
"list");
110 $ctrl = $this->gui->ctrl();
111 $ctrl->setParameter($this,
"transl",
"-");
112 $ctrl->redirect($this,
"list");
116 protected function list(): void
118 $lng = $this->domain->lng();
119 $ctrl = $this->gui->ctrl();
120 $main_tpl = $this->gui->mainTemplate();
121 $user = $this->domain->user();
123 if ($this->
getTable()->handleCommand()) {
127 $retrieval = $this->domain->subObjectRetrieval(
136 if ($retrieval->count() === 0) {
137 if ($this->sub_type ===
"st") {
139 $lng->txt(
"lm_insert_chapter"),
140 $ctrl->getLinkTargetByClass(self::class,
"insertFirstChapter")
142 if ($user->clipboardHasObjectsOfType(
"st")) {
144 $lng->txt(
"lm_insert_chapter_clip"),
145 $ctrl->getLinkTargetByClass(self::class,
"insertChapterClip")
150 $lng->txt(
"lm_insert_page"),
151 $ctrl->getLinkTargetByClass(self::class,
"insertFirstPage")
153 if ($user->clipboardHasObjectsOfType(
"pg")) {
155 $lng->txt(
"lm_insert_page_clip"),
156 $ctrl->getLinkTargetByClass(self::class,
"insertPageClip")
163 $main_tpl->setContent($ml_head . $table->render());
164 $main_tpl->addOnloadCode(
"window.setTimeout(() => { il.repository.core.trigger('il-lm-editor-tree'); }, 500);");
170 $target_id = $this->request->getTargetId();
172 foreach ($this->lm_tree->getChilds($parent) as $node) {
173 if ((
int) $node[
"obj_id"] !== $target_id) {
174 $before_target = (
int) $node[
"obj_id"];
187 $this->request->getTargetId()
194 $user = $this->domain->user();
195 $ctrl = $this->gui->ctrl();
196 $parent_id = $this->request->getObjId();
199 $chapters = $user->getClipboardObjects(
"st",
true);
200 $copied_nodes = array();
202 foreach ($chapters as $chap) {
203 $cid = ilLMObject::pasteTree(
208 (
string) ($chap[
"insert_time"] ??
""),
217 $user->clipboardDeleteObjectsOfType(
"pg");
218 $user->clipboardDeleteObjectsOfType(
"st");
222 $this->lm->checkTree();
223 $ctrl->redirect($this,
"list");
229 $target_id = $this->request->getTargetId();
231 foreach ($this->lm_tree->getChildsByType($parent,
"pg") as $node) {
232 if ((
int) $node[
"obj_id"] !== $target_id) {
233 $before_target = (
int) $node[
"obj_id"];
246 $this->request->getTargetId()
253 $user = $this->domain->user();
254 $ctrl = $this->gui->ctrl();
256 $parent_id = $this->request->getObjId();
259 $pages = $user->getClipboardObjects(
"pg");
260 $copied_nodes = array();
261 foreach ($pages as $pg) {
262 $cid = ilLMObject::pasteTree(
267 (
string) ($pg[
"insert_time"] ??
""),
276 $user->clipboardDeleteObjectsOfType(
"pg");
277 $user->clipboardDeleteObjectsOfType(
"st");
281 $ctrl->redirect($this,
"list");
292 $target_id = $this->request->getTargetId();
302 $target_id = $this->request->getTargetId();
304 foreach ($this->lm_tree->getChildsByType($parent,
"pg") as $node) {
305 if ((
int) $node[
"obj_id"] !== $target_id) {
306 $before_target = (
int) $node[
"obj_id"];
321 $lng = $this->domain->lng();
322 $ctrl = $this->gui->ctrl();
324 $chap = new \ilLMPageObject($this->lm);
325 $chap->setType(
"pg");
326 $chap->setTitle(
$lng->txt(
"cont_new_page"));
327 $chap->setLMId($this->lm_id);
338 $ctrl->redirect($this,
"list");
349 $target_id = $this->request->getTargetId();
360 $parent = $this->lm_tree->getRootId();
362 $target_id = $this->request->getTargetId();
364 foreach ($this->lm_tree->getChilds($parent) as $node) {
365 if ((
int) $node[
"obj_id"] !== $target_id) {
366 $before_target = (
int) $node[
"obj_id"];
381 $lng = $this->domain->lng();
382 $ctrl = $this->gui->ctrl();
383 $chap = new \ilStructureObject($this->lm);
384 $chap->setType(
"st");
385 $chap->setTitle(
$lng->txt(
"cont_new_chap"));
386 $chap->setLMId($this->lm_id);
397 $ctrl->redirect($this,
"list");
402 $lng = $this->domain->lng();
403 $this->gui->ctrl()->setParameterByClass(self::class,
"edit_id", $id);
404 $ot = (
new TranslationsRepository($this->domain->database()))->getFor($this->lm->getId());
406 if ($ot->getContentTranslationActivated()) {
407 $ml =
" (" .
$lng->txt(
"meta_l_" . $ot->getBaseLanguage()) .
")";
412 ->form(self::class,
"saveTitle")
414 if ($ot->getContentTranslationActivated()) {
415 foreach ($ot->getLanguages() as
$lang) {
416 $code = $lang->getLanguageCode();
417 if ($code === $ot->getBaseLanguage()) {
420 $lmobjtrans = new \ilLMObjTranslation($id, $code);
421 $title = $lmobjtrans->getTitle();
424 $lng->txt(
'title') .
" (" .
$lng->txt(
"meta_l_" . $code) .
")",
435 $this->gui->clearAsnyOnloadCode();
442 $mt = $this->gui->mainTemplate();
443 $lng = $this->domain->lng();
445 if ($form->isValid()) {
448 $ot = $this->lm->getObjectProperties()->getPropertyTranslations();
449 if ($ot->getContentTranslationActivated()) {
450 foreach ($ot->getLanguages() as
$lang) {
451 $code = $lang->getLanguageCode();
452 if ($code === $ot->getBaseLanguage()) {
459 $mt->setContent(
"success",
$lng->txt(
"msg_obj_modified"),
true);
460 $this->gui->ctrl()->redirect($this,
"list");
465 $mt = $this->gui->mainTemplate();
466 $lng = $this->domain->lng();
467 $tree = $this->domain->lmTree($this->lm_id);
469 $data = $table->getData();
470 $parent = ($this->sub_obj_id > 0)
472 : $tree->readRootId();
473 if (!is_array(
$data)) {
482 if ($this->sub_type ===
"pg") {
483 foreach ($tree->getChilds($parent) as $child) {
484 if ($child[
"type"] ==
"st") {
485 $data[] = $child[
"child"];
490 $tree->moveTree((
int) $id, $parent);
492 $mt->setContent(
"success",
$lng->txt(
"msg_obj_modified"),
true);
493 $this->gui->ctrl()->redirect($this,
"list");
502 public function delete(array $ids):
void 505 $mt = $this->gui->mainTemplate();
506 $lng = $this->domain->lng();
507 $ctrl = $this->gui->ctrl();
509 if (count($ids) == 0) {
510 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
515 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"cont_select_item"),
true);
519 $form_action = $ctrl->getFormActionByClass(self::class);
522 $cgui = new \ilConfirmationGUI();
523 $cgui->setFormAction($form_action);
524 $cgui->setHeaderText(
$lng->txt(
"info_delete_sure"));
525 $cgui->setCancel(
$lng->txt(
"cancel"),
"cancelDelete");
526 $cgui->setConfirm(
$lng->txt(
"confirm"),
"confirmedDelete");
528 foreach ($ids as
$id) {
530 $obj = new \ilLMObject($this->lm, $id);
531 $caption = $obj->getTitle();
533 $cgui->addItem(
"id[]", (
string) $id, $caption);
537 $mt->setContent($cgui->getHTML());
542 $this->gui->ctrl()->redirect($this,
"list");
554 $tree = $this->domain->lmTree($this->lm_id);
555 $ids = $this->request->getIds();
556 $mt = $this->gui->mainTemplate();
557 $ctrl = $this->gui->ctrl();
558 $lng = $this->domain->lng();
561 if (count($ids) == 0) {
562 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"));
563 $ctrl->redirect($this,
"list");
567 foreach ($ids as
$id) {
570 $node_data = $tree->getNodeData($id);
571 if (is_object($obj)) {
572 $obj->setLMId($this->lm->getId());
575 if ($tree->isInTree($id)) {
576 $tree->deleteTree($node_data);
582 $this->lm->checkTree();
585 $mt->setOnScreenMessage(
'success',
$lng->txt(
"info_deleted"),
true);
586 $ctrl->redirect($this,
"list");
594 $ctrl = $this->gui->ctrl();
595 $mt = $this->gui->mainTemplate();
596 $lng = $this->domain->lng();
599 if (count($items) == 0) {
600 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
601 $ctrl->redirect($this,
"list");
605 foreach ($items as $k => $item) {
610 foreach ($todel as $k) {
616 $mt->setOnScreenMessage(
'info',
$lng->txt(
"cont_selected_items_have_been_cut"),
true);
618 $ctrl->redirect($this,
"list");
627 $ctrl = $this->gui->ctrl();
628 $lng = $this->domain->lng();
629 $mt = $this->gui->mainTemplate();
632 if (count($items) == 0) {
633 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
634 $ctrl->redirect($this,
"list");
638 foreach ($items as $k => $item) {
643 foreach ($todel as $k) {
650 $mt->setOnScreenMessage(
'info',
$lng->txt(
"cont_selected_items_have_been_copied"),
true);
651 $ctrl->redirect($this,
"list");
656 $ctrl = $this->gui->ctrl();
657 $mt = $this->gui->mainTemplate();
658 $lng = $this->domain->lng();
659 $lm_tree = $this->domain->lmTree($this->lm_id);
662 if (count($ids) > 0) {
663 $act_items = array();
665 foreach ($ids as
$id) {
666 $path = $lm_tree->getPathId($id);
668 foreach (
$path as $path_id) {
669 if ($path_id != $id && in_array($path_id, $ids)) {
679 foreach ($act_items as $id) {
680 $childs = $lm_tree->getChilds($id);
681 foreach ($childs as $child) {
689 $this->lm->getType(),
701 $this->lm->getType(),
707 $mt->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
710 $ctrl->redirect($this,
"list");
725 $ctrl = $this->gui->ctrl();
726 $ui = $this->gui->ui();
727 $mt = $this->gui->mainTemplate();
729 $ctrl->setParameterByClass(self::class,
"before",
"1");
731 $ctrl->saveParameterByClass(self::class, [
"obj_id",
"target_id"]);
738 $ui = $this->gui->ui();
740 $ctrl = $this->gui->ctrl();
741 $lng = $this->domain->lng();
743 $fields[
"title"] =
$f->input()->field()->text(
$lng->txt(
"title"),
"");
746 $fields[
"layout_id"] = $ts;
750 $section1 =
$f->input()->field()->section($fields,
$lng->txt(
"cont_insert_pagelayout"));
752 $form_action = $ctrl->getLinkTarget($this,
"insertPageFromLayout");
753 return $f->input()->container()->form()->standard($form_action, [
"sec" => $section1]);
760 $ctrl = $this->gui->ctrl();
761 $mt = $this->gui->mainTemplate();
762 $lng = $this->domain->lng();
766 $target_id = $this->request->getTargetId();
768 $first_child =
false;
769 if ($this->request->getBefore()) {
772 foreach ($this->lm_tree->getChildsByType($parent,
"pg") as $node) {
773 if ((
int) $node[
"obj_id"] !== $target_id) {
774 $before_target = (
int) $node[
"obj_id"];
775 $first_child =
false;
780 $target_id = $before_target;
784 $form = $form->withRequest($DIC->http()->request());
785 $data = $form->getData();
786 $layout_id =
$data[
"sec"][
"layout_id"];
793 $data[
"sec"][
"title"]
796 $mt->setOnScreenMessage(
"success",
$lng->txt(
"lm_page_added"),
true);
798 $ctrl->redirect($this,
"list");
insertLayout(bool $before=false)
static updateInternalLinks(array $a_copied_nodes, string $a_parent_type="lm")
Update internal links, after multiple pages have been copied.
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static setAction(string $a_action)
__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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insertPage(int $parent_id=0, int $target=\ilTree::POS_LAST_NODE)
static getInstance(ilObjLearningModule $a_content_obj, int $a_id=0, bool $a_halt=true)
insertChapter(int $parent_id=0, int $target=\ilTree::POS_LAST_NODE)
activatePages(array $ids)
static getLayoutCssFix()
Get layout css fix (workaround for broken radio options)
static clipboardCut(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
copyItems($ids)
Copy items to clipboard.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static putInTree(ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
put this object into content object tree
insertChapterClip( $target=\ilTree::POS_LAST_NODE)
static _lookupTitle(int $a_obj_id)
confirmedDelete(int $a_parent_subobj_id=0)
delete page object or structure objects
static activeLayouts(int $a_module=0)
Get active layouts.
static insertPagesFromTemplate(int $lm_id, int $num, int $node_id, bool $first_child, int $layout_id, string $title="")
Insert (multiple) pages templates at node.
static saveTitle(int $id, string $title, string $lang="-")
getEditTitleForm(int $id)
static _writeActive(int $a_id, string $a_parent_type, bool $a_active)
write activation status
static getMultiLangHeader(int $a_lm_id, object $a_gui_class, string $a_mode="")
insertChapterClipBefore()
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _lookupType(int $a_obj_id, int $a_lm_id=0)
insertPageClip(int $target=0)
EditingGUIRequest $request
static clipboardCopy(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.