ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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;
34  public ilLMTree $tree;
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();
84  $this->ctrl->forwardCommand($this->condHI);
85  $ilTabs->setTabActive('preconditions');
86  break;
87 
88  default:
89  if ($cmd == 'listConditions') {
90  $this->setTabs();
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  {
124  $lng = $this->lng;
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("standard/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("standard/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  $this->tpl->setContent($ml_head . $ctpl->get());
157  $this->tpl->addOnloadCode("window.setTimeout(() => { il.repository.core.trigger('il-lm-editor-tree'); }, 500);");
158  }
159 
163  public function cutItems(
164  string $a_return = "view"
165  ): void {
166  $ilCtrl = $this->ctrl;
167  $lng = $this->lng;
168 
169  $items = $this->request->getIds();
170  if (count($items) == 0) {
171  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
172  $ilCtrl->redirect($this, "showHierarchy");
173  }
174 
175  $todel = array(); // delete IDs < 0 (needed for non-js editing)
176  foreach ($items as $k => $item) {
177  if ($item < 0) {
178  $todel[] = $k;
179  }
180  }
181  foreach ($todel as $k) {
182  unset($items[$k]);
183  }
184 
185  if (!ilLMObject::uniqueTypesCheck($items)) {
186  $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_choose_pages_or_chapters_only"), true);
187  $ilCtrl->redirect($this, "showHierarchy");
188  }
189 
190  ilLMObject::clipboardCut($this->content_object->getId(), $items);
192  $this->tpl->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_cut"), true);
193 
194  $ilCtrl->redirect($this, $a_return);
195  }
196 
200  public function copyItems(
201  string $a_return = "view"
202  ): void {
203  $ilCtrl = $this->ctrl;
204  $lng = $this->lng;
205 
206  $items = $this->request->getIds();
207  if (count($items) == 0) {
208  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
209  $ilCtrl->redirect($this, "showHierarchy");
210  }
211 
212  $todel = array(); // delete IDs < 0 (needed for non-js editing)
213  foreach ($items as $k => $item) {
214  if ($item < 0) {
215  $todel[] = $k;
216  }
217  }
218  foreach ($todel as $k) {
219  unset($items[$k]);
220  }
221 
222  if (!ilLMObject::uniqueTypesCheck($items)) {
223  $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_choose_pages_or_chapters_only"), true);
224  $ilCtrl->redirect($this, "showHierarchy");
225  }
226 
227  ilLMObject::clipboardCopy($this->content_object->getId(), $items);
229 
230  $this->tpl->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_copied"), true);
231  $ilCtrl->redirect($this, $a_return);
232  }
233 
237  public function saveAllTitles(): void
238  {
239  $ilCtrl = $this->ctrl;
240 
241  $titles = $this->request->getTitles();
242  ilLMObject::saveTitles($this->content_object, $titles, $this->requested_transl);
243 
244  $this->tpl->setOnScreenMessage('success', $this->lng->txt("lm_save_titles"), true);
245  $ilCtrl->redirect($this, "showHierarchy");
246  }
247 
251  public function subchap(): void
252  {
253  $ilCtrl = $this->ctrl;
254  $ilUser = $this->user;
255 
256  $this->setTabs();
257 
258  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.structure_edit.html", "Modules/LearningModule");
259  $num = 0;
260 
261  $this->tpl->setCurrentBlock("form");
262  $this->ctrl->setParameter($this, "backcmd", "subchap");
263  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
264  $this->tpl->setVariable("HEADER_TEXT", $this->lng->txt("cont_subchapters"));
265  $this->tpl->setVariable("CHECKBOX_TOP", ilTree::POS_FIRST_NODE);
266 
267  $cnt = 0;
268  $childs = $this->tree->getChilds($this->obj->getId());
269  foreach ($childs as $child) {
270  if ($child["type"] != "st") {
271  continue;
272  }
273  $this->tpl->setCurrentBlock("table_row");
274 
275  // checkbox
276  $this->tpl->setVariable("CHECKBOX_ID", $child["obj_id"]);
277  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("standard/icon_st.svg"));
278 
279  // type
280  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $child["obj_id"]);
281  $link = $this->ctrl->getLinkTargetByClass("ilStructureObjectGUI", "view");
282  $this->tpl->setVariable("LINK_TARGET", $link);
283 
284  // title
285  $this->tpl->setVariable(
286  "TEXT_CONTENT",
288  $child["obj_id"],
290  $this->content_object->isActiveNumbering()
291  )
292  );
293 
294  $this->tpl->parseCurrentBlock();
295  $cnt++;
296  }
297 
298  if ($cnt == 0) {
299  $this->tpl->setCurrentBlock("notfound");
300  $this->tpl->setVariable("NUM_COLS", 3);
301  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
302  $this->tpl->parseCurrentBlock();
303  }
304  //else
305  //{
306  // SHOW VALID ACTIONS
307  $this->tpl->setVariable("NUM_COLS", 3);
308  $acts = array("delete" => "delete", "cutChapter" => "cut",
309  "copyChapter" => "copyChapter");
310  if ($ilUser->clipboardHasObjectsOfType("st")) {
311  $acts["pasteChapter"] = "pasteChapter";
312  }
313  $this->showActions($acts);
314  //}
315 
316  // SHOW POSSIBLE SUB OBJECTS
317  $this->tpl->setVariable("NUM_COLS", 3);
318  $subobj = array("st");
319  $opts = ilLegacyFormElementsUtil::formSelect(12, "new_type", $subobj);
320  $this->tpl->setCurrentBlock("add_object");
321  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
322  $this->tpl->setVariable("BTN_NAME", "create");
323  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("insert"));
324  $this->tpl->parseCurrentBlock();
325 
326  $this->tpl->setCurrentBlock("form");
327  $this->tpl->parseCurrentBlock();
328 
329  $ilCtrl->setParameter($this, "obj_id", $this->requested_obj_id);
330  }
331 
332  public function save(): void
333  {
334  $form = $this->getCreateForm();
335 
336  if ($form->checkInput()) {
337  $this->obj = new ilStructureObject($this->content_object);
338  $this->obj->setType("st");
339  $this->obj->setTitle($form->getInput("title"));
340  $this->obj->setDescription($form->getInput("desc"));
341  $this->obj->setLMId($this->content_object->getId());
342  $this->obj->create();
343 
344  $this->putInTree();
345 
346  // check the tree
347  $this->checkTree();
348  }
349 
350  if ($this->requested_obj_id > 0) {
351  $this->ctrl->redirect($this, "subchap");
352  }
353  }
354 
358  public function putInTree(
359  ?int $target = null
360  ): void {
361  $target = $this->requested_target;
362  //echo "st:putInTree";
363  // chapters should be behind pages in the tree
364  // so if target is first node, the target is substituted with
365  // the last child of type pg
366  if ($target == ilTree::POS_FIRST_NODE) {
367  $tree = new ilTree($this->content_object->getId());
368  $tree->setTableNames('lm_tree', 'lm_data');
369  $tree->setTreeTablePK("lm_id");
370 
371  // determine parent node id
372  $parent_id = ($this->requested_obj_id > 0)
373  ? $this->requested_obj_id
374  : $tree->getRootId();
375  // determine last child of type pg
376  $childs = $tree->getChildsByType($parent_id, "pg");
377  if (count($childs) != 0) {
378  $target = $childs[count($childs) - 1]["obj_id"];
379  }
380  }
381  if ($target == "") {
382  $target = ilTree::POS_LAST_NODE;
383  }
384 
385  parent::putInTree($target);
386  }
387 
388  public function cutPage(): void
389  {
390  $this->cutItems();
391  }
392 
393  public function copyPage(): void
394  {
395  $this->copyItems();
396  }
397 
398  public function pastePage(): void
399  {
400  $ilUser = $this->user;
401 
402  if (!$ilUser->clipboardHasObjectsOfType("pg")) {
403  throw new ilLMException($this->lng->txt("no_page_in_clipboard"));
404  }
405 
406  $this->insertPageClip();
407  }
408 
409  public function cutChapter(): void
410  {
411  $this->cutItems("subchap");
412  }
413 
417  public function copyChapter(): void
418  {
419  $this->copyItems("subchap");
420  }
421 
422  public function pasteChapter(): void
423  {
424  $this->insertChapterClip(false, "subchap");
425  }
426 
427  public function activatePages(): void
428  {
429  $lng = $this->lng;
430 
431  $ids = $this->request->getIds();
432  if (count($ids) > 0) {
433  $act_items = array();
434  // get all "top" ids, i.e. remove ids, that have a selected parent
435  foreach ($ids as $id) {
436  $path = $this->tree->getPathId($id);
437  $take = true;
438  foreach ($path as $path_id) {
439  if ($path_id != $id && in_array($path_id, $ids)) {
440  $take = false;
441  }
442  }
443  if ($take) {
444  $act_items[] = $id;
445  }
446  }
447 
448 
449  foreach ($act_items as $id) {
450  $childs = $this->tree->getChilds($id);
451  foreach ($childs as $child) {
452  if (ilLMObject::_lookupType($child["child"]) == "pg") {
454  $child["child"],
455  $this->content_object->getType()
456  );
458  $child["child"],
459  $this->content_object->getType(),
460  !$act
461  );
462  }
463  }
464  if (ilLMObject::_lookupType($id) == "pg") {
466  $id,
467  $this->content_object->getType()
468  );
470  $id,
471  $this->content_object->getType(),
472  !$act
473  );
474  }
475  }
476  } else {
477  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
478  }
479 
480  $this->ctrl->redirect($this, "view");
481  }
482 
483  public function initConditionHandlerInterface(): void
484  {
485  $this->condHI = new ilConditionHandlerGUI();
486  $this->condHI->setBackButtons(array());
487  $this->condHI->setAutomaticValidation(false);
488  $this->condHI->setTargetType("st");
489  $this->condHI->setTargetRefId($this->content_object->getRefId());
490  $this->condHI->setTargetId($this->obj->getId());
491  $this->condHI->setTargetTitle($this->obj->getTitle());
492  }
493 
494 
498  public function cancel(): void
499  {
500  if ($this->requested_obj_id != 0) {
501  if ($this->requested_new_type == "pg") {
502  $this->ctrl->redirect($this, "view");
503  } else {
504  $this->ctrl->redirect($this, "subchap");
505  }
506  }
507  }
508 
509  public function setTabs(): void
510  {
511  $ilTabs = $this->tabs;
512  $lng = $this->lng;
513 
514  // subelements
515  $ilTabs->addTarget(
516  "cont_pages_and_subchapters",
517  $this->ctrl->getLinkTarget($this, 'showHierarchy'),
518  array("view", "showHierarchy"),
519  get_class($this)
520  );
521 
522  // preconditions
523  $ilTabs->addTarget(
524  "preconditions",
525  $this->ctrl->getLinkTarget($this, 'listConditions'),
526  "listConditions",
527  get_class($this)
528  );
529 
530  // metadata
531  $mdgui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
532  $mdtab = $mdgui->getTab();
533  if ($mdtab) {
534  $ilTabs->addTarget(
535  "meta_data",
536  $mdtab,
537  "",
538  "ilmdeditorgui"
539  );
540  }
541 
542  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_st.svg"));
543  $this->tpl->setTitle(
544  $this->lng->txt($this->obj->getType()) . ": " . $this->obj->getTitle()
545  );
546 
547  // presentation view
548  $ilTabs->addNonTabbedLink(
549  "pres_mode",
550  $lng->txt("cont_presentation_view"),
551  ILIAS_HTTP_PATH . "/goto.php?target=st_" . $this->obj->getId(),
552  "_top"
553  );
554  }
555 
559  public static function _goto(
560  string $a_target,
561  int $a_target_ref_id = 0
562  ): void {
563  global $DIC;
564  $main_tpl = $DIC->ui()->mainTemplate();
565 
566  $lng = $DIC->language();
567  $ilAccess = $DIC->access();
568  $ctrl = $DIC->ctrl();
569 
570  // determine learning object
571  $lm_id = ilLMObject::_lookupContObjID($a_target);
572 
573  // get all references
574  $ref_ids = ilObject::_getAllReferences($lm_id);
575 
576  // always try passed ref id first
577  if (in_array($a_target_ref_id, $ref_ids)) {
578  $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
579  }
580 
581  // check read permissions
582  foreach ($ref_ids as $ref_id) {
583  // Permission check
584  if ($ilAccess->checkAccess("read", "", $ref_id)) {
585  $ctrl->setParameterByClass("ilLMPresentationGUI", "obj_id", $a_target);
586  $ctrl->setParameterByClass("ilLMPresentationGUI", "ref_id", $ref_id);
587  $ctrl->redirectByClass("ilLMPresentationGUI", "");
588  }
589  }
590 
591  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
592  $main_tpl->setOnScreenMessage('failure', sprintf(
593  $lng->txt("msg_no_perm_read_item"),
594  ilObject::_lookupTitle($lm_id)
595  ), true);
597  }
598 
599  throw new ilPermissionException($lng->txt("msg_no_perm_read_lm"));
600  }
601 
605  public function insertChapter(
606  bool $a_as_sub = false
607  ): void {
608  $ilCtrl = $this->ctrl;
609  $lng = $this->lng;
610 
613 
614  if ($a_as_sub) { // as subchapter
615  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert under parent
616  $parent_id = $node_id;
617  $target = "";
618  } else { // we shouldnt end up here
619  $ilCtrl->redirect($this, "showHierarchy");
620  return;
621  }
622  } else { // as chapter
623  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
624  $parent_id = $this->tree->getParentId($node_id);
625  $target = $node_id;
626  } else { // insert as first child
627  $parent_id = $node_id;
628  $target = ilTree::POS_FIRST_NODE;
629  }
630  }
631  for ($i = 1; $i <= $num; $i++) {
632  $chap = new ilStructureObject($this->content_object);
633  $chap->setType("st");
634  $chap->setTitle($lng->txt("cont_new_chap"));
635  $chap->setLMId($this->content_object->getId());
636  $chap->create();
637  ilLMObject::putInTree($chap, (int) $parent_id, (int) $target);
638  }
639 
640  $ilCtrl->redirect($this, "view");
641  }
642 
646  public function insertSubchapter(): void
647  {
648  $this->insertChapter(true);
649  }
650 
654  public function insertChapterClip(
655  bool $a_as_sub = false,
656  string $a_return = "view"
657  ): void {
658  $ilUser = $this->user;
659  $ilCtrl = $this->ctrl;
660  $ilLog = $this->log;
661 
662  $ilLog->write("Insert Chapter From Clipboard");
663 
664 
667 
668  if ($a_as_sub) { // as subchapter
669  if (!$first_child) { // insert under parent
670  $parent_id = $node_id;
671  $target = "";
672  } else { // we shouldnt end up here
673  $ilCtrl->redirect($this, "showHierarchy");
674  return;
675  }
676  } else { // as chapter
677  if (!$first_child) { // insert after node id
678  $parent_id = $this->tree->getParentId($node_id);
679  $target = $node_id;
680  } else { // insert as first child
681  $parent_id = $node_id;
682  $target = ilTree::POS_FIRST_NODE;
683 
684  // do not move a chapter in front of a page
685  $childs = $this->tree->getChildsByType($parent_id, "pg");
686  if (count($childs) != 0) {
687  $target = $childs[count($childs) - 1]["obj_id"];
688  }
689  }
690  }
691 
692  // copy and paste
693  $chapters = $ilUser->getClipboardObjects("st", true);
694  $copied_nodes = array();
695 
696  foreach ($chapters as $chap) {
697  $ilLog->write("Call pasteTree, Target LM: " . $this->content_object->getId() . ", Chapter ID: " . $chap["id"]
698  . ", Parent ID: " . $parent_id . ", Target: " . $target);
699  $cid = ilLMObject::pasteTree(
700  $this->content_object,
701  $chap["id"],
702  $parent_id,
703  (int) $target,
704  (string) ($chap["insert_time"] ?? ""),
705  $copied_nodes,
706  (ilEditClipboard::getAction() == "copy")
707  );
708  $target = $cid;
709  }
710  ilLMObject::updateInternalLinks($copied_nodes);
711 
712  if (ilEditClipboard::getAction() == "cut") {
713  $ilUser->clipboardDeleteObjectsOfType("pg");
714  $ilUser->clipboardDeleteObjectsOfType("st");
716  }
717 
718  $this->content_object->checkTree();
719  $ilCtrl->redirect($this, $a_return);
720  }
721 
722  public function insertSubchapterClip(): void
723  {
724  $this->insertChapterClip(true);
725  }
726 
727  public function insertPage(): void
728  {
729  $ilCtrl = $this->ctrl;
730  $lng = $this->lng;
731 
734 
735  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
736  $parent_id = $this->tree->getParentId($node_id);
737  $target = $node_id;
738  } else { // insert as first child
739  $parent_id = $node_id;
740  $target = ilTree::POS_FIRST_NODE;
741  }
742 
743  for ($i = 1; $i <= $num; $i++) {
744  $page = new ilLMPageObject($this->content_object);
745  $page->setType("pg");
746  $page->setTitle($lng->txt("cont_new_page"));
747  $page->setLMId($this->content_object->getId());
748  $page->create();
749  ilLMObject::putInTree($page, $parent_id, $target);
750  }
751 
752  if ($num == 1) {
753  $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_page_added"), true);
754  } else {
755  $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_pages_added"), true);
756  }
757 
758  $ilCtrl->redirect($this, "showHierarchy");
759  }
760 
761  public function insertPageClip(): void
762  {
763  $ilCtrl = $this->ctrl;
764  $ilUser = $this->user;
765 
768 
769  if (!$first_child) { // insert after node id
770  $parent_id = $this->tree->getParentId($node_id);
771  $target = $node_id;
772  } else { // insert as first child
773  $parent_id = $node_id;
774  $target = ilTree::POS_FIRST_NODE;
775  }
776 
777  // cut and paste
778  $pages = $ilUser->getClipboardObjects("pg");
779  $copied_nodes = array();
780  foreach ($pages as $pg) {
781  $cid = ilLMObject::pasteTree(
782  $this->content_object,
783  $pg["id"],
784  $parent_id,
785  $target,
786  (string) ($pg["insert_time"] ?? ""),
787  $copied_nodes,
788  (ilEditClipboard::getAction() == "copy")
789  );
790  $target = $cid;
791  }
792  ilLMObject::updateInternalLinks($copied_nodes);
793 
794  if (ilEditClipboard::getAction() == "cut") {
795  $ilUser->clipboardDeleteObjectsOfType("pg");
796  $ilUser->clipboardDeleteObjectsOfType("st");
798  }
799 
800  $ilCtrl->redirect($this, "view");
801  }
802 
803  public function proceedDragDrop(): void
804  {
805  $ilCtrl = $this->ctrl;
806 
808  $this->content_object->executeDragDrop(
809  $req->getHFormPar("source_id"),
810  $req->getHFormPar("target_id"),
811  $req->getHFormPar("fc"),
812  $req->getHFormPar("as_subitem")
813  );
814  $ilCtrl->redirect($this, "showHierarchy");
815  }
816 
820 
824  public function setPageLayout(): void
825  {
826  $tpl = $this->tpl;
827  $ilCtrl = $this->ctrl;
828  $lng = $this->lng;
829 
830  $ids = $this->request->getIds();
831  if (count($ids) == 0) {
832  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
833  $ilCtrl->redirect($this, "showHierarchy");
834  }
835 
836  $this->initSetPageLayoutForm();
837 
838  $tpl->setContent($this->form->getHTML());
839  }
840 
844  public function initSetPageLayoutForm(): void
845  {
846  $lng = $this->lng;
847  $ilCtrl = $this->ctrl;
848 
849  $this->form = new ilPropertyFormGUI();
850 
851  $ids = $this->request->getIds();
852  foreach ($ids as $id) {
853  $hi = new ilHiddenInputGUI("id[]");
854  $hi->setValue($id);
855  $this->form->addItem($hi);
856  }
858  $lng->txt("cont_layout"),
859  "layout",
860  $this->content_object->getLayout()
861  );
862 
863  $this->form->addItem($layout);
864 
865  $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
866  $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
867 
868  $this->form->setTitle($lng->txt("cont_set_layout"));
869  $this->form->setFormAction($ilCtrl->getFormAction($this));
870  }
871 
875  public function savePageLayout(): void
876  {
877  $lng = $this->lng;
878  $ilCtrl = $this->ctrl;
879 
880  $ids = $this->request->getIds();
881  $layout = $this->request->getLayout();
882  foreach ($ids as $id) {
884  $id,
885  $layout,
886  $this->content_object
887  );
888  }
889  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
890  $ilCtrl->redirect($this, "showHierarchy");
891  }
892 
893  public function editMasterLanguage(): void
894  {
895  $ilCtrl = $this->ctrl;
896 
897  $ilCtrl->setParameter($this, "transl", "-");
898  $ilCtrl->redirect($this, "showHierarchy");
899  }
900 
901  public function switchToLanguage(): void
902  {
903  $ilCtrl = $this->ctrl;
904 
905  $ilCtrl->setParameter($this, "transl", $this->requested_totransl);
906  $ilCtrl->redirect($this, "showHierarchy");
907  }
908 
912  public function insertTemplate(): void
913  {
914  $ctrl = $this->ctrl;
915  $ui = $this->ui;
916  $lng = $this->lng;
917 
918  $this->setTabs();
919  $tabs = $this->tabs;
920  $tabs->clearTargets();
921  $tabs->setBackTarget($lng->txt("back"), $ctrl->getLinkTarget($this, "showHierarchy"));
922 
925  $ctrl->setParameter($this, "first_child", (int) ilChapterHierarchyFormGUI::getPostFirstChild());
926  $ctrl->saveParameter($this, "obj_id");
927  $form = $this->initInsertTemplateForm();
928  $this->tpl->setContent($ui->renderer()->render($form) . ilLMPageObjectGUI::getLayoutCssFix());
929  }
930 
932  {
933  $ui = $this->ui;
934  $f = $ui->factory();
935  $ctrl = $this->ctrl;
936  $lng = $this->lng;
937 
938  $fields["title"] = $f->input()->field()->text($lng->txt("title"), "");
939  $ts = ilPageLayoutGUI::getTemplateSelection(ilPageLayout::MODULE_LM);
940  if (!is_null($ts)) {
941  $fields["layout_id"] = $ts;
942  }
943 
944  // section
945  $section1 = $f->input()->field()->section($fields, $lng->txt("cont_insert_pagelayout"));
946 
947  $form_action = $ctrl->getLinkTarget($this, "insertPageFromTemplate");
948  return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
949  }
950 
954  public function insertPageFromTemplate(): void
955  {
956  global $DIC;
957 
958  $ilCtrl = $this->ctrl;
959 
960  $form = $this->initInsertTemplateForm();
961  $form = $form->withRequest($DIC->http()->request());
962  $data = $form->getData();
963  $layout_id = $data["sec"]["layout_id"];
964  $node_id = $this->request->getNodeId();
966  $this->content_object->getId(),
967  $this->request->getMulti(),
968  $node_id,
969  $this->request->getFirstChild(),
970  $layout_id,
971  $data["sec"]["title"]
972  );
973 
974  if ($this->request->getMulti() <= 1) {
975  $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_page_added"), true);
976  } else {
977  $this->tpl->setOnScreenMessage("success", $this->lng->txt("lm_pages_added"), true);
978  }
979 
980  //$ilCtrl->setParameter($this, "highlight", $page_ids);
981  $ilCtrl->redirect($this, "showHierarchy", "node_" . $node_id);
982  }
983 }
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)
EditingGUIRequest $request
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)
static getPostMulti()
Get multi number of _POST input.
saveAllTitles()
Save all titles of chapters/pages.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilConditionHandlerGUI
static getLayoutOption(string $a_txt, string $a_var, string $a_def_option="")
insertChapter(bool $a_as_sub=false)
Insert (multiple) chapters at node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes commonalities between all forms.
Definition: Form.php:32
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
initSetPageLayoutForm()
Init set page layout form.
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static saveTitles(ilObjLearningModule $a_lm, array $a_titles, string $a_lang="-")
Save titles for lm objects.
const ROOT_FOLDER_ID
Definition: constants.php:32
write(string $message, $level=ilLogLevel::INFO, array $context=[])
write log message
checkTree()
check the content object tree
static _getAllReferences(int $id)
get all reference ids for object ID
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static uniqueTypesCheck(array $a_items)
Check for unique types (all pages or all chapters)
static _goto(string $a_target, int $a_target_ref_id=0)
addMDObserver(object $class, string $method, string $section)
static getPostNodeId()
Get node ID of _POST input.
User Interface for Structure Objects Editing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
setTreeTablePK(string $a_column_name)
set column containing primary key in tree table
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.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
insertSubchapter()
Insert (multiple) subchapters at node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
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-...
cancel()
cancel creation of new page or chapter
Base class for ilStructureObjects and ilPageObjects (see ILIAS DTD)
static putInTree(ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
put this object into content object tree
$path
Definition: ltiservices.php:32
cutItems(string $a_return="view")
Copy items to clipboard, then cut them from the current tree.
setStructureObject(ilStructureObject $a_st_object)
setPageLayout()
Set layout for multipl pages.
catch(\Exception $e) $req
Definition: xapiproxy.php:93
global $DIC
Definition: feed.php:28
static getPostFirstChild()
Should node be inserted as first child of target node (true) or as successor (false) ...
__construct(ilObjLearningModule $a_content_obj, ilLMTree $a_tree)
const POS_FIRST_NODE
getChildsByType(int $a_node_id, string $a_type)
get child nodes of given node by object type
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 &#39;obj_id&#39; You may use...
$ref_id
Definition: ltiauth.php:67
__construct(VocabulariesInterface $vocabularies)
ilConditionHandlerGUI $condHI
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
setContent(string $a_html)
Sets content for standard template.
insertPageFromTemplate()
Insert (multiple) pages templates at node.
static writeLayout(int $a_obj_id, string $a_layout, ?ilObjLearningModule $a_lm=null)
Write layout setting.
setFormAction(string $a_formaction)
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.
setBackTarget(string $a_title, string $a_target, string $a_frame="")
clearTargets()
clear all targets
putInTree(?int $target=null)
put chapter into tree
This describes a standard form.
Definition: Standard.php:26
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="")
copyChapter()
copy a single chapter (selection)
User Interface for Learning Module Page Objects Editing.
savePageLayout()
Save page layout.
const POS_LAST_NODE
form( $class_path, string $cmd, string $submit_caption="")
getLinkTarget(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveParameter(object $a_gui_obj, $a_parameter)
static _lookupType(int $a_obj_id, int $a_lm_id=0)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
subchap()
display subchapters of structure object
static _lookupContObjID(int $a_id)
get learning module id for lm object
ILIAS DI UIServices $ui
showActions(array $a_actions)
show possible action (form buttons)
copyItems(string $a_return="view")
Copy items to clipboard.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
insertTemplate()
Displays GUI to select template for page.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
getTab(string $base_class=null)
Get tab link if available.
static clipboardCopy(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
insertChapterClip(bool $a_as_sub=false, string $a_return="view")
Insert Chapter from clipboard.