ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjContentObjectGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
33 {
35  protected \ILIAS\LearningModule\ReadingTime\SettingsGUI $reading_time_gui;
38  protected string $lang_switch_mode;
40  protected ilTabsGUI $tabs;
41  protected ilHelpGUI $help;
42  protected ilDBInterface $db;
43  protected ilLogger $log;
44  protected \ILIAS\DI\UIServices $ui;
46 
47  protected bool $to_props = false;
48  protected int $requested_obj_id = 0;
49  protected string $requested_new_type = "";
50  protected string $requested_baseClass = "";
51  protected int $requested_ref_id = 0;
52  protected string $requested_transl = "";
53  protected string $requested_backcmd = "";
54  protected int $requested_menu_entry = 0;
55  protected int $requested_lm_menu_expand = 0;
56  protected int $requested_search_root_expand = 0;
57  protected bool $requested_hierarchy = false;
58  protected int $requested_root_id = 0;
59  protected int $requested_glo_id = 0;
60  protected int $requested_glo_ref_id = 0;
61  protected string $requested_lang_switch_mode = "";
62  protected int $requested_active_node = 0;
63  protected int $requested_lmexpand = 0;
64  protected int $requested_link_ref_id = 0;
65  protected string $requested_totransl = "";
66  protected bool $requested_lmmovecopy = false;
69  protected \ILIAS\Style\Content\Service $content_style_service;
70 
71  protected ilLMTree $lm_tree;
72 
80  public function __construct(
81  $a_data,
82  int $a_id = 0,
83  bool $a_call_by_reference = true,
84  bool $a_prepare_output = false
85  ) {
86  global $DIC;
87 
88  $this->lng = $DIC->language();
89  $this->access = $DIC->access();
90  $this->tabs = $DIC->tabs();
91  $this->settings = $DIC->settings();
92  $this->user = $DIC->user();
93  $this->tpl = $DIC["tpl"];
94  $this->toolbar = $DIC->toolbar();
95  $this->rbacsystem = $DIC->rbac()->system();
96  $this->tree = $DIC->repositoryTree();
97  $this->help = $DIC["ilHelp"];
98  $this->locator = $DIC["ilLocator"];
99  $this->db = $DIC->database();
100  $this->log = $DIC["ilLog"];
101  $this->ui = $DIC->ui();
102  $lng = $DIC->language();
103  $ilCtrl = $DIC->ctrl();
104  $this->ctrl = $ilCtrl;
105  $this->component_repository = $DIC["component.repository"];
106  $lng->loadLanguageModule("content");
107  $lng->loadLanguageModule("obj");
108  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
109 
110  $this->edit_request = $DIC
111  ->learningModule()
112  ->internal()
113  ->gui()
114  ->editing()
115  ->request();
116 
118  $this->to_props = $req->getToProps();
119  $this->requested_obj_id = $req->getObjId();
120  $this->requested_ref_id = $req->getRefId();
121  $this->requested_root_id = $req->getRootId();
122  $this->requested_glo_id = $req->getGlossaryId();
123  $this->requested_glo_ref_id = $req->getGlossaryRefId();
124  $this->requested_menu_entry = $req->getMenuEntry();
125  $this->requested_lm_menu_expand = $req->getLMMenuExpand();
126  $this->requested_search_root_expand = $req->getSearchRootExpand();
127  $this->requested_new_type = $req->getNewType();
128  $this->requested_baseClass = $req->getBaseClass();
129  $this->requested_transl = $req->getTranslation();
130  $this->requested_backcmd = $req->getBackCmd();
131  $this->requested_hierarchy = $req->getHierarchy();
132  $this->lang_switch_mode = $req->getLangSwitchMode();
133  $this->requested_active_node = $req->getActiveNode();
134  $this->requested_lmexpand = $req->getLMExpand();
135  $this->requested_link_ref_id = $req->getLinkRefId();
136  $this->requested_totransl = $req->getToTranslation();
137  $this->requested_lmmovecopy = $req->getLMMoveCopy();
138  $this->content_style_service = $DIC
139  ->contentStyle();
140 
141  $id = (isset($this->object))
142  ? $this->object->getId()
143  : 0;
144  $this->reading_time_gui = new \ILIAS\LearningModule\ReadingTime\SettingsGUI($id);
145  }
146 
147  protected function checkCtrlPath(): void
148  {
149  if (!$this->getCreationMode()) {
150  $baseclass = strtolower($this->requested_baseClass);
151  $next_class = strtolower($this->ctrl->getNextClass());
152  // all calls must be routed through illmpresentationgui or
153  // illmeditorgui...
154  if (!in_array($baseclass, ["illmpresentationgui", "illmeditorgui"])) {
155  // ...except the comman action handler routes to
156  // activation/condition GUI, see https://mantis.ilias.de/view.php?id=32858
157  if (in_array($next_class, ["ilcommonactiondispatchergui"])) {
158  return;
159  }
160  throw new ilLMException("Wrong ctrl path");
161  }
162  }
163  }
164 
169  public function executeCommand(): void
170  {
171  $ilAccess = $this->access;
172  $lng = $this->lng;
173  $ilTabs = $this->tabs;
174  $ilCtrl = $this->ctrl;
175 
176  $this->checkCtrlPath();
177 
178  if ($this->ctrl->getRedirectSource() == "ilinternallinkgui") {
179  throw new ilLMException("No Explorer found.");
180  //$this->explorer();
181  //return "";
182  }
183 
184  if ($this->ctrl->getCmdClass() == "ilinternallinkgui") {
185  $this->ctrl->setReturn($this, "explorer");
186  }
187 
188  // get next class that processes or forwards current command
189  $next_class = $this->ctrl->getNextClass($this);
190 
191  // get current command
192  if ($this->to_props) {
193  $cmd = $this->ctrl->getCmd("properties");
194  } else {
195  $cmd = $this->ctrl->getCmd("chapters");
196  }
197 
198 
199  switch ($next_class) {
200  case 'illtiproviderobjectsettinggui':
201 
202  $this->setTabs();
203  $ilTabs->setTabActive("settings");
204  $this->setSubTabs("lti_provider");
205 
206  $lti_gui = new ilLTIProviderObjectSettingGUI($this->lm->getRefId());
207  $lti_gui->setCustomRolesForSelection($GLOBALS['DIC']->rbac()->review()->getLocalRoles($this->lm->getRefId()));
208  $lti_gui->offerLTIRolesForSelection(true);
209  $this->ctrl->forwardCommand($lti_gui);
210  break;
211 
212 
213 
214  case "illearningprogressgui":
215  $this->addHeaderAction();
216  $this->addLocations();
217  $this->setTabs("learning_progress");
218 
219  $new_gui = new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $this->lm->getRefId());
220  $this->ctrl->forwardCommand($new_gui);
221 
222  break;
223 
224  case 'ilobjectmetadatagui':
225  if (!$ilAccess->checkAccess('write', '', $this->lm->getRefId())) {
226  throw new ilPermissionException($this->lng->txt('permission_denied'));
227  }
228 
229  $this->addHeaderAction();
230  $this->addLocations();
231  $this->setTabs("meta");
232 
233  $md_gui = new ilObjectMetaDataGUI($this->lm);
234  $md_gui->addMDObserver($this->lm, 'MDUpdateListener', 'Educational'); // #9510
235  $md_gui->addMDObserver($this->lm, 'MDUpdateListener', 'General');
236  $this->ctrl->forwardCommand($md_gui);
237  break;
238 
239  case "ilobjectcontentstylesettingsgui":
240  $this->checkPermission("write");
241  $this->addHeaderAction();
242  $this->setTitleAndDescription();
243  $this->addLocations();
244  $this->setTabs("settings");
245  $this->setSubTabs("cont_style");
246 
247  $settings_gui = $this->content_style_service
248  ->gui()
249  ->objectSettingsGUIForRefId(
250  null,
251  $this->object->getRefId()
252  );
253  $this->ctrl->forwardCommand($settings_gui);
254  break;
255 
256 
257  case "illmpageobjectgui":
258  $this->setTitleAndDescription();
259  $ilTabs->setBackTarget(
260  $lng->txt("learning module"),
261  $ilCtrl->getLinkTarget($this, "chapters")
262  );
263  $this->ctrl->saveParameter($this, array("obj_id"));
264  $this->addLocations();
265  $this->ctrl->setReturn($this, "chapters");
266 
267  $pg_gui = new ilLMPageObjectGUI($this->lm);
268  if ($this->requested_obj_id > 0) {
270  $obj = ilLMObjectFactory::getInstance($this->lm, $this->requested_obj_id);
271  $pg_gui->setLMPageObject($obj);
272  }
273  $this->ctrl->forwardCommand($pg_gui);
274  break;
275 
276  case "ilstructureobjectgui":
277  $ilTabs->setBackTarget(
278  $lng->txt("learning module"),
279  $ilCtrl->getLinkTarget($this, "chapters")
280  );
281 
282  $this->ctrl->saveParameter($this, array("obj_id"));
283  $this->addLocations();
284  $this->ctrl->setReturn($this, "chapters");
285  $st_gui = new ilStructureObjectGUI($this->lm, $this->lm->lm_tree);
286  if ($this->requested_obj_id > 0) {
288  $obj = ilLMObjectFactory::getInstance($this->lm, $this->requested_obj_id);
289  $st_gui->setStructureObject($obj);
290  }
291  $this->ctrl->forwardCommand($st_gui);
292  if ($cmd == "save" || $cmd == "cancel") {
293  if ($this->requested_obj_id == 0) {
294  $this->ctrl->redirect($this, "chapters");
295  } else {
296  $this->ctrl->setCmd("subchap");
297  $this->executeCommand();
298  }
299  }
300  break;
301 
302  case 'ilpermissiongui':
303  if (strtolower($this->requested_baseClass) == "iladministrationgui") {
304  $this->prepareOutput();
305  } else {
306  $this->addHeaderAction();
307  $this->addLocations(true);
308  $this->setTabs("perm");
309  }
310  $perm_gui = new ilPermissionGUI($this);
311  $this->ctrl->forwardCommand($perm_gui);
312  break;
313 
314  // infoscreen
315  case 'ilinfoscreengui':
316  if (!$this->object->isInfoEnabled()) {
317  return;
318  }
319  $this->addHeaderAction();
320  $this->addLocations(true);
321  $this->setTabs("info");
322  $info = new ilInfoScreenGUI($this);
323  $info->enablePrivateNotes();
324  $info->enableLearningProgress();
325  $info->enableNews();
326  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
327  $info->enableNewsEditing();
328  $info->setBlockProperty("news", "settings", true);
329  }
330 
331  // show standard meta data section
332  $info->addMetaDataSections(
333  $this->lm->getId(),
334  0,
335  $this->lm->getType()
336  );
337 
338  $this->ctrl->forwardCommand($info);
339  break;
340 
341  case "ilexportgui":
342  // it is important to reset the "transl" parameter here
343  // otherwise it will effect the HTML export and overwrite the selected language
344  $this->ctrl->setParameterByClass(ilObjLearningModuleGUI::class, "transl", "");
345  $this->ctrl->setParameterByClass(ilLMEditorGUI::class, "transl", "");
346  $exp_gui = new ilExportGUI($this);
347  $exp_gui->addFormat("xml");
348  $ot = ilObjectTranslation::getInstance($this->lm->getId());
349  if ($ot->getContentActivated()) {
350  $exp_gui->addFormat("xml_master", "XML (" . $lng->txt("cont_master_language_only") . ")", $this, "export");
351  $exp_gui->addFormat("xml_masternomedia", "XML (" . $lng->txt("cont_master_language_only_no_media") . ")", $this, "export");
352 
353  $lng->loadLanguageModule("meta");
354  $langs = $ot->getLanguages();
355  foreach ($langs as $l => $ldata) {
356  $exp_gui->addFormat("html_" . $l, "HTML (" . $lng->txt("meta_l_" . $l) . ")", $this, "exportHTML");
357  }
358  $exp_gui->addFormat("html_all", "HTML (" . $lng->txt("cont_all_languages") . ")", $this, "exportHTML");
359  } else {
360  $exp_gui->addFormat("html", "", $this, "exportHTML");
361  }
362 
363  $exp_gui->addCustomColumn(
364  $lng->txt("cont_public_access"),
365  $this,
366  "getPublicAccessColValue"
367  );
368  $exp_gui->addCustomMultiCommand(
369  $lng->txt("cont_public_access"),
370  $this,
371  "publishExportFile"
372  );
373  $this->ctrl->forwardCommand($exp_gui);
374  $this->tpl->setOnScreenMessage('info', $this->lng->txt("lm_only_one_download_per_type"));
375  $this->addHeaderAction();
376  $this->addLocations(true);
377  $this->setTabs("export");
378  break;
379 
380  case 'ilobjecttranslationgui':
381  $this->addHeaderAction();
382  $this->addLocations(true);
383  $this->setTabs("settings");
384  $this->setSubTabs("obj_multilinguality");
385  $transgui = new ilObjectTranslationGUI($this);
386  $transgui->setTitleDescrOnlyMode(false);
387  $this->ctrl->forwardCommand($transgui);
388  break;
389 
390 
391  case "ilcommonactiondispatchergui":
393  $this->prepareOutput();
394  $this->ctrl->forwardCommand($gui);
395  break;
396 
397  case 'ilobjectcopygui':
398  $this->prepareOutput();
399  $cp = new ilObjectCopyGUI($this);
400  $cp->setType('lm');
401  $this->ctrl->forwardCommand($cp);
402  break;
403 
404  case "ilmobmultisrtuploadgui":
405  $this->addHeaderAction();
406  $this->addLocations(true);
407  $this->setTabs("content");
408  $this->setContentSubTabs("srt_files");
409  $gui = new ilMobMultiSrtUploadGUI(new ilLMMultiSrt($this->lm));
410  $this->ctrl->forwardCommand($gui);
411  break;
412 
413  case "illmimportgui":
414  $this->addHeaderAction();
415  $this->addLocations(true);
416  $this->setTabs("content");
417  $this->setContentSubTabs("import");
418  $gui = new ilLMImportGUI($this->lm);
419  $this->ctrl->forwardCommand($gui);
420  break;
421 
422  case "illmeditshorttitlesgui":
423  $this->addHeaderAction();
424  $this->addLocations(true);
425  $this->setTabs("content");
426  $this->setContentSubTabs("short_titles");
428  $lm_gui = $this;
429  $gui = new ilLMEditShortTitlesGUI(
430  $lm_gui,
431  $this->edit_request->getTranslation()
432  );
433  $this->ctrl->forwardCommand($gui);
434  break;
435 
436  default:
437  $new_type = $this->requested_new_type;
438 
439  if ($cmd == "create" &&
440  !in_array($new_type, array("lm"))) {
441  switch ($new_type) {
442  case "pg":
443  $this->setTabs();
444  $this->ctrl->setCmdClass("ilLMPageObjectGUI");
445  $this->executeCommand();
446  break;
447 
448  case "st":
449  $this->setTabs();
450  $this->ctrl->setCmdClass("ilStructureObjectGUI");
451  $this->executeCommand();
452  break;
453  }
454  } else {
455  // creation of new dbk/lm in repository
456  if ($this->getCreationMode() === true &&
457  $new_type === "lm") {
458  $this->prepareOutput();
459  if ($cmd == "") { // this may be due to too big upload files
460  $cmd = "create";
461  }
462  $cmd .= "Object";
463  } else {
464  $this->addHeaderAction();
465  $this->addLocations();
466  }
467  $this->$cmd();
468  }
469  break;
470  }
471  }
472 
476  public function properties(): void
477  {
478  $lng = $this->lng;
479 
480  $lng->loadLanguageModule("style");
481  $this->setTabs("settings");
482  $this->setSubTabs("settings");
483 
484  // lm properties
485  $this->initPropertiesForm();
486  $this->getPropertiesFormValues();
487 
488  // Edit ecs export settings
489  $ecs = new ilECSLearningModuleSettings($this->lm);
490  $ecs->addSettingsToForm($this->form, 'lm');
491 
492  $this->tpl->setContent($this->form->getHTML());
493  }
494 
498  public function initPropertiesForm(): void
499  {
500  $obj_service = $this->object_service;
501 
502  $ilCtrl = $this->ctrl;
503  $lng = $this->lng;
505 
506  $this->form = new ilPropertyFormGUI();
507 
508  // title
509  $ti = new ilTextInputGUI($lng->txt("title"), "title");
510  $ti->setRequired(true);
511  $this->form->addItem($ti);
512 
513  // description
514  $ta = new ilTextAreaInputGUI($lng->txt("desc"), "description");
515  $this->form->addItem($ta);
516 
517  $lng->loadLanguageModule("rep");
518  $section = new ilFormSectionHeaderGUI();
519  $section->setTitle($this->lng->txt('rep_activation_availability'));
520  $this->form->addItem($section);
521 
522  // online
523  $online = new ilCheckboxInputGUI($lng->txt("cont_online"), "cobj_online");
524  $this->form->addItem($online);
525 
526  // presentation
527  $section = new ilFormSectionHeaderGUI();
528  $section->setTitle($this->lng->txt('cont_presentation'));
529  $this->form->addItem($section);
530 
531  // tile image
532  $obj_service->commonSettings()->legacyForm($this->form, $this->lm)->addTileImage();
533 
534  // page header
535  $page_header = new ilSelectInputGUI($lng->txt("cont_page_header"), "lm_pg_header");
536  $option = array("st_title" => $this->lng->txt("cont_st_title"),
537  "pg_title" => $this->lng->txt("cont_pg_title"),
538  "none" => $this->lng->txt("cont_none"));
539  $page_header->setOptions($option);
540  $this->form->addItem($page_header);
541 
542  // chapter numeration
543  $chap_num = new ilCheckboxInputGUI($lng->txt("cont_act_number"), "cobj_act_number");
544  $this->form->addItem($chap_num);
545 
546  // toc mode
547  $toc_mode = new ilSelectInputGUI($lng->txt("cont_toc_mode"), "toc_mode");
548  $option = array("chapters" => $this->lng->txt("cont_chapters_only"),
549  "pages" => $this->lng->txt("cont_chapters_and_pages"));
550  $toc_mode->setOptions($option);
551  $this->form->addItem($toc_mode);
552 
553  // show progress icons
554  $progr_icons = new ilCheckboxInputGUI($lng->txt("cont_progress_icons"), "progr_icons");
555  $progr_icons->setInfo($this->lng->txt("cont_progress_icons_info"));
556  $this->form->addItem($progr_icons);
557 
558  $this->reading_time_gui->addSettingToForm($this->form);
559 
560  // self assessment
561  $section = new ilFormSectionHeaderGUI();
562  $section->setTitle($this->lng->txt('cont_self_assessment'));
563  $this->form->addItem($section);
564 
565  // tries
566  $radg = new ilRadioGroupInputGUI($lng->txt("cont_tries"), "store_tries");
567  $radg->setValue("0");
568  $op1 = new ilRadioOption($lng->txt("cont_tries_reset_on_visit"), "0", $lng->txt("cont_tries_reset_on_visit_info"));
569  $radg->addOption($op1);
570  $op2 = new ilRadioOption($lng->txt("cont_tries_store"), "1", $lng->txt("cont_tries_store_info"));
571  $radg->addOption($op2);
572  $this->form->addItem($radg);
573 
574  // restrict forward navigation
575  $qfeed = new ilCheckboxInputGUI($lng->txt("cont_restrict_forw_nav"), "restrict_forw_nav");
576  $qfeed->setInfo($this->lng->txt("cont_restrict_forw_nav_info"));
577  $this->form->addItem($qfeed);
578 
579  // notification
580  $not = new ilCheckboxInputGUI($lng->txt("cont_notify_on_blocked_users"), "notification_blocked_users");
581  $not->setInfo($this->lng->txt("cont_notify_on_blocked_users_info"));
582  $qfeed->addSubItem($not);
583 
584  // disable default feedback for questions
585  $qfeed = new ilCheckboxInputGUI($lng->txt("cont_disable_def_feedback"), "disable_def_feedback");
586  $qfeed->setInfo($this->lng->txt("cont_disable_def_feedback_info"));
587  $this->form->addItem($qfeed);
588 
589  // additional features
590  $section = new ilFormSectionHeaderGUI();
591  $section->setTitle($this->lng->txt('obj_features'));
592  $this->form->addItem($section);
593 
594  // public notes
595  if (!$ilSetting->get('disable_comments')) {
596  $this->lng->loadLanguageModule("notes");
597  $pub_nodes = new ilCheckboxInputGUI($lng->txt("notes_comments"), "cobj_pub_notes");
598  $pub_nodes->setInfo($this->lng->txt("cont_lm_comments_desc"));
599  $this->form->addItem($pub_nodes);
600  }
601 
602  // history user comments
603  $com = new ilCheckboxInputGUI($lng->txt("enable_hist_user_comments"), "cobj_user_comments");
604  $com->setInfo($this->lng->txt("enable_hist_user_comments_desc"));
605  $this->form->addItem($com);
606 
607  // rating
608  $this->lng->loadLanguageModule('rating');
609  $rate = new ilCheckboxInputGUI($this->lng->txt('rating_activate_rating'), 'rating');
610  $rate->setInfo($this->lng->txt('rating_activate_rating_info'));
611  $this->form->addItem($rate);
612  $ratep = new ilCheckboxInputGUI($this->lng->txt('lm_activate_rating'), 'rating_pages');
613  $this->form->addItem($ratep);
614 
615  $this->form->setTitle($lng->txt("cont_lm_properties"));
616  $this->form->addCommandButton("saveProperties", $lng->txt("save"));
617  $this->form->setFormAction($ilCtrl->getFormAction($this));
618 
620  $this->object->getId(),
621  $this->form,
622  [
624  ]
625  );
626  }
627 
631  public function getPropertiesFormValues(): void
632  {
633  $ilUser = $this->user;
634 
635  $values = array();
636 
637  $title = $this->lm->getTitle();
638  $description = $this->lm->getLongDescription();
639  $ot = ilObjectTranslation::getInstance($this->lm->getId());
640  if ($ot->getContentActivated()) {
641  $title = $ot->getDefaultTitle();
642  $description = $ot->getDefaultDescription();
643  }
644 
645  $values["title"] = $title;
646  $values["description"] = $description;
647  if (!$this->lm->getOfflineStatus()) {
648  $values["cobj_online"] = true;
649  }
650  //$values["lm_layout"] = $this->lm->getLayout();
651  $values["lm_pg_header"] = $this->lm->getPageHeader();
652  if ($this->lm->isActiveNumbering()) {
653  $values["cobj_act_number"] = true;
654  }
655  $values["toc_mode"] = $this->lm->getTOCMode();
656  if ($this->lm->publicNotes()) {
657  $values["cobj_pub_notes"] = true;
658  }
659  if ($this->lm->cleanFrames()) {
660  $values["cobj_clean_frames"] = true;
661  }
662  if ($this->lm->isActiveHistoryUserComments()) {
663  $values["cobj_user_comments"] = true;
664  }
665  //$values["layout_per_page"] = $this->lm->getLayoutPerPage();
666  $values["rating"] = $this->lm->hasRating();
667  $values["rating_pages"] = $this->lm->hasRatingPages();
668  $values["disable_def_feedback"] = $this->lm->getDisableDefaultFeedback();
669  $values["progr_icons"] = $this->lm->getProgressIcons();
670  $values["store_tries"] = (string) (int) $this->lm->getStoreTries();
671  $values["restrict_forw_nav"] = $this->lm->getRestrictForwardNavigation();
672 
673  $values["notification_blocked_users"] = ilNotification::hasNotification(
675  $ilUser->getId(),
676  $this->lm->getId()
677  );
678 
679  $values["cont_show_info_tab"] = $this->object->isInfoEnabled();
680  $this->form->setValuesByArray($values, true);
681  }
682 
686  public function saveProperties(): void
687  {
688  $lng = $this->lng;
689  $ilUser = $this->user;
691  $obj_service = $this->object_service;
692 
693  $add_info = "";
694 
695  $valid = false;
696  $this->initPropertiesForm();
697  $form = $this->form;
698  if ($form->checkInput()) {
699  $ot = ilObjectTranslation::getInstance($this->lm->getId());
700  if ($ot->getContentActivated()) {
701  $ot->setDefaultTitle($form->getInput('title'));
702  $ot->setDefaultDescription($form->getInput('description'));
703  $ot->save();
704  }
705 
706  $this->lm->setTitle($form->getInput('title'));
707  $this->lm->setDescription($form->getInput('description'));
708  $this->lm->setPageHeader($form->getInput("lm_pg_header"));
709  $this->lm->setTOCMode($form->getInput("toc_mode"));
710  $this->lm->setOfflineStatus(!($form->getInput('cobj_online')));
711  $this->lm->setActiveNumbering((bool) $form->getInput("cobj_act_number"));
712  $this->lm->setCleanFrames((bool) $form->getInput("cobj_clean_frames"));
713  if (!$ilSetting->get('disable_comments')) {
714  $this->lm->setPublicNotes($form->getInput("cobj_pub_notes"));
715  }
716  $this->lm->setHistoryUserComments((bool) $form->getInput("cobj_user_comments"));
717  $this->lm->setRating((bool) $form->getInput("rating"));
718  $this->lm->setRatingPages((bool) $form->getInput("rating_pages"));
719  $this->lm->setDisableDefaultFeedback((int) $form->getInput("disable_def_feedback"));
720  $this->lm->setProgressIcons((int) $form->getInput("progr_icons"));
721  $this->reading_time_gui->saveSettingFromForm($this->form);
722 
723  $add_info = "";
724  $store_tries = $form->getInput("store_tries");
725  if ($form->getInput("restrict_forw_nav") && !$form->getInput("store_tries")) {
726  $store_tries = 1;
727  $add_info = "</br>" . $lng->txt("cont_automatically_set_store_tries");
728  $add_info = str_replace("$1", $lng->txt("cont_tries_store"), $add_info);
729  $add_info = str_replace("$2", $lng->txt("cont_restrict_forw_nav"), $add_info);
730  }
731 
732  $this->lm->setStoreTries((int) $store_tries);
733  $this->lm->setRestrictForwardNavigation((int) $form->getInput("restrict_forw_nav"));
734  $this->lm->updateProperties();
735  $this->lm->update();
736 
737  // tile image
738  $obj_service->commonSettings()->legacyForm($this->form, $this->lm)->saveTileImage();
739 
742  $ilUser->getId(),
743  $this->lm->getId(),
744  (bool) $this->form->getInput("notification_blocked_users")
745  );
746 
747  // services
749  $this->object->getId(),
750  $this->form,
751  array(
753  )
754  );
755 
756 
757  // Update ecs export settings
758  $ecs = new ilECSLearningModuleSettings($this->lm);
759  if ($ecs->handleSettingsUpdate($form)) {
760  $valid = true;
761  }
762  }
763 
764  if ($valid) {
765  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified") . $add_info, true);
766  $this->ctrl->redirect($this, "properties");
767  } else {
768  $lng->loadLanguageModule("style");
769  $this->setTabs("settings");
770  $this->setSubTabs("cont_general_properties");
771 
772  $this->form->setValuesByPost();
773  $this->tpl->setContent($this->form->getHTML());
774  }
775  }
776 
777  public function initMenuForm(): ilPropertyFormGUI
778  {
779  $lng = $this->lng;
780  $ilCtrl = $this->ctrl;
781 
782  $form = new ilPropertyFormGUI();
783 
784  // enable menu
785  $menu = new ilCheckboxInputGUI($this->lng->txt("cont_active"), "cobj_act_lm_menu");
786  $menu->setChecked($this->lm->isActiveLMMenu());
787  $form->addItem($menu);
788 
789  // toc
790  /*
791  $toc = new ilCheckboxInputGUI($this->lng->txt("cont_toc"), "cobj_act_toc");
792 
793  $toc->setChecked($this->lm->isActiveTOC());
794  $form->addItem($toc);*/
795 
796  // print view
797  $print = new ilCheckboxInputGUI($this->lng->txt("cont_print_view"), "cobj_act_print");
798  $print->setChecked($this->lm->isActivePrintView());
799  $form->addItem($print);
800 
801  // prevent glossary appendix
802  $glo = new ilCheckboxInputGUI($this->lng->txt("cont_print_view_pre_glo"), "cobj_act_print_prev_glo");
803  $glo->setChecked($this->lm->isActivePreventGlossaryAppendix());
804  $print->addSubItem($glo);
805 
806  // hide header and footer in print view
807  $hhfp = new ilCheckboxInputGUI($this->lng->txt("cont_hide_head_foot_print"), "hide_head_foot_print");
808  $hhfp->setChecked($this->lm->getHideHeaderFooterPrint());
809  $print->addSubItem($hhfp);
810 
811  // downloads
812  $no_download_file_available =
813  " " . $lng->txt("cont_no_download_file_available") .
814  " <a href='" . $ilCtrl->getLinkTargetByClass("ilexportgui", "") . "'>" . $lng->txt("change") . "</a>";
815  $types = array("xml", "html");
816  foreach ($types as $type) {
817  if ($this->lm->getPublicExportFile($type) != "") {
818  if (is_file($this->lm->getExportDirectory($type) . "/" .
819  $this->lm->getPublicExportFile($type))) {
820  $no_download_file_available = "";
821  }
822  }
823  }
824  $dl = new ilCheckboxInputGUI($this->lng->txt("cont_downloads"), "cobj_act_downloads");
825  $dl->setInfo($this->lng->txt("cont_downloads_desc") . $no_download_file_available);
826  $dl->setChecked($this->lm->isActiveDownloads());
827  $form->addItem($dl);
828 
829  // downloads in public area
830  $pdl = new ilCheckboxInputGUI($this->lng->txt("cont_downloads_public_desc"), "cobj_act_downloads_public");
831  $pdl->setChecked($this->lm->isActiveDownloadsPublic());
832  $dl->addSubItem($pdl);
833 
834  $form->addCommandButton("saveMenuProperties", $lng->txt("save"));
835 
836  $form->setTitle($lng->txt("cont_lm_menu"));
837  $form->setFormAction($ilCtrl->getFormAction($this));
838 
839  return $form;
840  }
841 
842  public function editMenuProperties(): void
843  {
844  $lng = $this->lng;
845  $ilTabs = $this->tabs;
846  $ilCtrl = $this->ctrl;
847  $tpl = $this->tpl;
848  $ilToolbar = $this->toolbar;
849 
850  $lng->loadLanguageModule("style");
851  $this->setTabs();
852  $ilTabs->setTabActive("settings");
853  $this->setSubTabs("cont_lm_menu");
854 
855  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
856  $ilToolbar->addFormButton($this->lng->txt("add_menu_entry"), "addMenuEntry");
857  $ilToolbar->setCloseFormTag(false);
858 
859  $form = $this->initMenuForm();
860  $form->setOpenTag(false);
861  $form->setCloseTag(false);
862 
863  $this->__initLMMenuEditor();
864  $entries = $this->lmme_obj->getMenuEntries();
865  $table = new ilLMMenuItemsTableGUI($this, "editMenuProperties", $this->lmme_obj);
866  $table->setOpenFormTag(false);
867 
868  $tpl->setContent($form->getHTML() . "<br />" . $table->getHTML());
869  }
870 
871  public function saveMenuProperties(): void
872  {
873  $form = $this->initMenuForm();
874  if ($form->checkInput()) {
875  $this->lm->setActiveLMMenu((int) $form->getInput("cobj_act_lm_menu"));
876  //$this->lm->setActiveTOC((int) $form->getInput("cobj_act_toc"));
877  $this->lm->setActivePrintView((int) $form->getInput("cobj_act_print"));
878  $this->lm->setActivePreventGlossaryAppendix((int) $form->getInput("cobj_act_print_prev_glo"));
879  $this->lm->setHideHeaderFooterPrint((int) $form->getInput("hide_head_foot_print"));
880  $this->lm->setActiveDownloads((int) $form->getInput("cobj_act_downloads"));
881  $this->lm->setActiveDownloadsPublic((int) $form->getInput("cobj_act_downloads_public"));
882  $this->lm->updateProperties();
883  }
884 
885  $this->__initLMMenuEditor();
886  $this->lmme_obj->updateActiveStatus($this->edit_request->getMenuEntries());
887 
888  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
889  $this->ctrl->redirect($this, "editMenuProperties");
890  }
891 
892  public function proceedDragDrop(): void
893  {
894  $ilCtrl = $this->ctrl;
895 
897  $this->lm->executeDragDrop(
898  $req->getHFormPar("source_id"),
899  $req->getHFormPar("target_id"),
900  $req->getHFormPar("fc"),
901  $req->getHFormPar("as_subitem")
902  );
903  $ilCtrl->redirect($this, "chapters");
904  }
905 
906  protected function afterSave(ilObject $new_object): void
907  {
908  $new_object->setCleanFrames(true);
909  $new_object->update();
910 
911  // create content object tree
912  $new_object->createLMTree();
913 
914  // create a first chapter
915  $new_object->addFirstChapterAndPage();
916 
917  // always send a message
918  $this->tpl->setOnScreenMessage('success', $this->lng->txt($this->type . "_added"), true);
919  $this->ctrl->setParameterByClass(ilObjLearningModuleGUI::class, "ref_id", $new_object->getRefId());
920  $this->ctrl->redirectByClass([ilLMEditorGUI::class, ilObjLearningModuleGUI::class], "");
921  }
922 
923  protected function initImportForm(string $new_type): ilPropertyFormGUI
924  {
925  $form = parent::initImportForm($new_type);
926 
927  // validation
928  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_validate_file"), "validate");
929  $cb->setInfo($this->lng->txt(""));
930  $form->addItem($cb);
931  return $form;
932  }
933 
934  protected function importFileObject(int $parent_id = null): void
935  {
936  $tpl = $this->tpl;
937 
938  $form = $this->initImportForm("lm");
939 
940  try {
941  // the new import
942  parent::importFileObject(null);
943  return;
945  // we just run through in this case.
946  $no_manifest = true;
947  } catch (ilException $e) {
948  // display message and form again
949  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("obj_import_file_error") . " <br />" . $e->getMessage());
950  $form->setValuesByPost();
951  $tpl->setContent($form->getHTML());
952  return;
953  }
954 
955  if (!$no_manifest) {
956  return; // something different has gone wrong, but we have a manifest, this is definitely not "the old" import
957  }
958 
959  throw new ilLMOldExportFileException("This file seems to be from ILIAS version 5.0.x or lower. Import is not supported anymore.");
960  }
961 
965  public function chapters(): void
966  {
967  $lng = $this->lng;
968  $ilCtrl = $this->ctrl;
969 
970  $this->setTabs();
971  $this->setContentSubTabs("chapters");
972 
973  $ilCtrl->setParameter($this, "backcmd", "chapters");
974 
975  $form_gui = new ilChapterHierarchyFormGUI($this->lm->getType(), $this->requested_transl);
976  $form_gui->setFormAction($ilCtrl->getFormAction($this));
977  $form_gui->setTitle($this->lm->getTitle());
978  $form_gui->setIcon(ilUtil::getImagePath("standard/icon_lm.svg"));
979  $form_gui->setTree($this->lm_tree);
980  $form_gui->setMaxDepth(0);
981  $this->tree->readRootId();
982  $form_gui->setCurrentTopNodeId($this->tree->getRootId());
983  $form_gui->addMultiCommand($lng->txt("delete"), "delete");
984  $form_gui->addMultiCommand($lng->txt("cut"), "cutItems");
985  $form_gui->addMultiCommand($lng->txt("copy"), "copyItems");
986  if ($this->lm->getLayoutPerPage()) {
987  $form_gui->addMultiCommand($lng->txt("cont_set_layout"), "setPageLayoutInHierarchy");
988  }
989  $form_gui->setDragIcon(ilUtil::getImagePath("standard/icon_st.svg"));
990  $form_gui->addCommand($lng->txt("cont_save_all_titles"), "saveAllTitles");
991  $up_gui = "ilobjlearningmodulegui";
992 
993  $ctpl = new ilTemplate("tpl.chap_and_pages.html", true, true, "Modules/LearningModule");
994  $ctpl->setVariable("HIERARCHY_FORM", $form_gui->getHTML());
995  $ilCtrl->setParameter($this, "obj_id", null);
996 
997  $ml_head = self::getMultiLangHeader($this->lm->getId(), $this);
998 
999  $this->tpl->setContent($ml_head . $ctpl->get());
1000  }
1001 
1002  public static function getMultiLangHeader(
1003  int $a_lm_id,
1004  object $a_gui_class,
1005  string $a_mode = ""
1006  ): string {
1007  global $DIC;
1008 
1009  $lng = $DIC->language();
1010  $ilCtrl = $DIC->ctrl();
1011 
1012  $edit_request = $DIC
1013  ->learningModule()
1014  ->internal()
1015  ->gui()
1016  ->editing()
1017  ->request();
1018 
1019  $ui_renderer = $DIC->ui()->renderer();
1020  $ui_factory = $DIC->ui()->factory();
1021 
1022  $requested_transl = $edit_request->getTranslation();
1023  $requested_totransl = $edit_request->getToTranslation();
1024 
1025  $ml_head = "";
1026 
1027  // multi language
1028  $ot = ilObjectTranslation::getInstance($a_lm_id);
1029  if ($ot->getContentActivated()) {
1030  $ilCtrl->setParameter($a_gui_class, "lang_switch_mode", $a_mode);
1031  $lng->loadLanguageModule("meta");
1032 
1033  // info
1034  $ml_gui = new ilPageMultiLangGUI("lm", $a_lm_id);
1035  $ml_head = $ml_gui->getMultiLangInfo($requested_transl);
1036 
1037  $actions = [];
1038 
1039  // language switch
1040  $entries = false;
1041  if (!in_array($requested_transl, array("", "-"))) {
1042  $l = $ot->getMasterLanguage();
1043  $actions[] = $ui_factory->link()->standard(
1044  $lng->txt("cont_edit_language_version") . ": " .
1045  $lng->txt("meta_l_" . $l),
1046  $ilCtrl->getLinkTarget($a_gui_class, "editMasterLanguage")
1047  );
1048  $entries = true;
1049  }
1050 
1051  foreach ($ot->getLanguages() as $al => $lang) {
1052  if ($requested_transl != $al &&
1053  $al != $ot->getMasterLanguage()) {
1054  $ilCtrl->setParameter($a_gui_class, "totransl", $al);
1055  $actions[] = $ui_factory->link()->standard(
1056  $lng->txt("cont_edit_language_version") . ": " .
1057  $lng->txt("meta_l_" . $al),
1058  $ilCtrl->getLinkTarget($a_gui_class, "switchToLanguage")
1059  );
1060  $ilCtrl->setParameter($a_gui_class, "totransl", $requested_totransl);
1061  }
1062  $entries = true;
1063  }
1064 
1065  if ($entries) {
1066  $dd = $ui_factory->dropdown()->standard($actions)->withLabel($lng->txt("actions"));
1067 
1068  $ml_head = '<div class="ilFloatLeft">' . $ml_head . '</div><div style="margin: 5px 0;" class="small ilRight">' . $ui_renderer->render($dd) . "</div>";
1069  }
1070  $ilCtrl->setParameter($a_gui_class, "lang_switch_mode", "");
1071  }
1072 
1073  return $ml_head;
1074  }
1075 
1076  public function pages(): void
1077  {
1078  $tpl = $this->tpl;
1079  $ilToolbar = $this->toolbar;
1080  $ilCtrl = $this->ctrl;
1081  $lng = $this->lng;
1082 
1083  $this->setTabs();
1084  $this->setContentSubTabs("pages");
1085 
1086  $ilCtrl->setParameter($this, "backcmd", "pages");
1087  $ilCtrl->setParameterByClass("illmpageobjectgui", "new_type", "pg");
1088  $ilToolbar->addButton(
1089  $lng->txt("pg_add"),
1090  $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "create")
1091  );
1092  $ilCtrl->setParameterByClass("illmpageobjectgui", "new_type", "");
1093 
1094  $t = new ilLMPagesTableGUI($this, "pages", $this->lm);
1095  $tpl->setContent($t->getHTML());
1096  }
1097 
1101  public function listLinks(): void
1102  {
1103  $tpl = $this->tpl;
1104 
1105  $this->setTabs();
1106  $this->setContentSubTabs("internal_links");
1107 
1108  $table_gui = new ilLinksTableGUI(
1109  $this,
1110  "listLinks",
1111  $this->lm->getId(),
1112  $this->lm->getType()
1113  );
1114 
1115  $tpl->setContent($table_gui->getHTML());
1116  }
1117 
1121  public function showMaintenance(): void
1122  {
1123  $ilToolbar = $this->toolbar;
1124 
1125  $this->setTabs();
1126  $this->setContentSubTabs("maintenance");
1127 
1128  $ilToolbar->addButton(
1129  $this->lng->txt("cont_fix_tree"),
1130  $this->ctrl->getLinkTarget($this, "fixTreeConfirm")
1131  );
1132  }
1133 
1137  public function activatePages(): void
1138  {
1139  $ids = $this->edit_request->getIds();
1140  foreach ($ids as $id) {
1141  $act = ilLMPage::_lookupActive($id, $this->lm->getType());
1142  ilLMPage::_writeActive($id, $this->lm->getType(), !$act);
1143  }
1144 
1145  $this->ctrl->redirect($this, "pages");
1146  }
1147 
1151  public function pastePage(): void
1152  {
1153  if (ilEditClipboard::getContentObjectType() != "pg") {
1154  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_page_in_clipboard"), true);
1155  $this->ctrl->redirect($this, "pages");
1156  }
1157 
1158  // paste selected object
1160 
1161  // copy page, if action is copy
1162  if (ilEditClipboard::getAction() == "copy") {
1163  // check wether page belongs to lm
1165  == $this->lm->getId()) {
1166  $lm_page = new ilLMPageObject($this->lm, $id);
1167  $new_page = $lm_page->copy($this->lm);
1168  $id = $new_page->getId();
1169  } else {
1170  // get page from other content object into current content object
1173  $lm_obj = ilObjectFactory::getInstanceByObjId($lm_id);
1174  $lm_page = new ilLMPageObject($lm_obj, $id);
1175  $copied_nodes = array();
1176  $new_page = $lm_page->copyToOtherContObject($this->lm, $copied_nodes);
1177  $id = $new_page->getId();
1178  ilLMObject::updateInternalLinks($copied_nodes);
1179  }
1180  }
1181 
1182  // cut is not be possible in "all pages" form yet
1183  if (ilEditClipboard::getAction() == "cut") {
1184  // check wether page belongs not to lm
1186  != $this->lm->getId()) {
1189  $lm_obj = ilObjectFactory::getInstanceByObjId($lm_id);
1190  $lm_page = new ilLMPageObject($lm_obj, $id);
1191  $lm_page->setLMId($this->lm->getId());
1192  $lm_page->update();
1193  $page = $lm_page->getPageObject();
1194  $page->buildDom();
1195  $page->setParentId($this->lm->getId());
1196  $page->update();
1197  }
1198  }
1199 
1200 
1202  $this->ctrl->redirect($this, "pages");
1203  }
1204 
1205  public function copyPage(): void
1206  {
1207  $ids = $this->edit_request->getIds();
1208  if (count($ids) == 0) {
1209  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"));
1210  $this->ctrl->redirect($this, "pages");
1211  }
1212 
1213  ilLMObject::clipboardCopy($this->lm->getId(), $ids);
1215 
1216  $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_selected_items_have_been_copied"), true);
1217 
1218  $this->ctrl->redirect($this, "pages");
1219  }
1220 
1227  public function delete(int $a_parent_subobj_id = 0): void
1228  {
1229  $ids = $this->edit_request->getIds();
1230 
1231  if (count($ids) == 0) {
1232  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1233  $this->cancelDelete();
1234  }
1235 
1236  if (count($ids) == 1 && $ids[0] == ilTree::POS_FIRST_NODE) {
1237  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_select_item"), true);
1238  $this->cancelDelete();
1239  }
1240 
1241  if ($a_parent_subobj_id == 0) {
1242  $this->setTabs("content");
1243  }
1244 
1245  if ($a_parent_subobj_id != 0) {
1246  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "backcmd", $this->requested_backcmd);
1247  $this->ctrl->setParameterByClass("ilStructureObjectGUI", "obj_id", $a_parent_subobj_id);
1248  $form_action = $this->ctrl->getFormActionByClass("ilStructureObjectGUI");
1249  } else {
1250  $this->ctrl->setParameter($this, "backcmd", $this->requested_backcmd);
1251  $form_action = $this->ctrl->getFormAction($this);
1252  }
1253 
1254  // display confirmation message
1255  $cgui = new ilConfirmationGUI();
1256  $cgui->setFormAction($form_action);
1257  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1258  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
1259  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
1260 
1261  foreach ($ids as $id) {
1262  if ($id != ilTree::POS_FIRST_NODE) {
1263  $obj = new ilLMObject($this->lm, $id);
1264  $caption = $obj->getTitle();
1265 
1266  $cgui->addItem("id[]", $id, $caption);
1267  }
1268  }
1269 
1270  $this->tpl->setContent($cgui->getHTML());
1271  }
1272 
1273  public function cancelDelete(): void
1274  {
1275  $this->ctrl->redirect($this, $this->requested_backcmd);
1276  }
1277 
1285  public function confirmedDelete(int $a_parent_subobj_id = 0): void
1286  {
1287  $tree = new ilLMTree($this->lm->getId());
1288 
1289  $ids = $this->edit_request->getIds();
1290 
1291  // check number of objects
1292  if (count($ids) == 0) {
1293  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"));
1294  $this->ctrl->redirect($this, "cancelDelete");
1295  }
1296 
1297  // delete all selected objects
1298  foreach ($ids as $id) {
1299  if ($id != ilTree::POS_FIRST_NODE) {
1300  $obj = ilLMObjectFactory::getInstance($this->lm, $id, false);
1301  $node_data = $tree->getNodeData($id);
1302  if (is_object($obj)) {
1303  $obj->setLMId($this->lm->getId());
1304 
1306  $this->lm->getId(),
1307  "delete_" . $obj->getType(),
1308  array(ilLMObject::_lookupTitle($id), $id),
1309  $this->lm->getType()
1310  );
1311 
1312  $obj->delete();
1313  }
1314  if ($tree->isInTree($id)) {
1315  $tree->deleteTree($node_data);
1316  }
1317  }
1318  }
1319 
1320  // check the tree
1321  $this->lm->checkTree();
1322 
1323  // feedback
1324  $this->tpl->setOnScreenMessage('success', $this->lng->txt("info_deleted"), true);
1325 
1326  if ($a_parent_subobj_id == 0) {
1327  $this->ctrl->redirect($this, $this->requested_backcmd);
1328  }
1329  }
1330 
1331  public function getContextPath(
1332  int $a_endnode_id,
1333  int $a_startnode_id = 1
1334  ): string {
1335  $path = "";
1336 
1337  $tmpPath = $this->lm_tree->getPathFull($a_endnode_id, $a_startnode_id);
1338 
1339  // count -1, to exclude the learning module itself
1340  for ($i = 1; $i < (count($tmpPath) - 1); $i++) {
1341  if ($path != "") {
1342  $path .= " > ";
1343  }
1344 
1345  $path .= $tmpPath[$i]["title"];
1346  }
1347 
1348  return $path;
1349  }
1350 
1351  public function showActions(array $a_actions): void
1352  {
1353  $d = null;
1354  foreach ($a_actions as $name => $lng) {
1355  $d[$name] = array("name" => $name, "lng" => $lng);
1356  }
1357 
1358  $notoperations = array();
1359 
1360  $operations = array();
1361 
1362  if (is_array($d)) {
1363  foreach ($d as $row) {
1364  if (!in_array($row["name"], $notoperations)) {
1365  $operations[] = $row;
1366  }
1367  }
1368  }
1369 
1370  if (count($operations) > 0) {
1371  foreach ($operations as $val) {
1372  $this->tpl->setCurrentBlock("operation_btn");
1373  $this->tpl->setVariable("BTN_NAME", $val["name"]);
1374  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt($val["lng"]));
1375  $this->tpl->parseCurrentBlock();
1376  }
1377 
1378  $this->tpl->setCurrentBlock("operation");
1379  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("nav/arrow_downright.svg"));
1380  $this->tpl->parseCurrentBlock();
1381  }
1382  }
1383 
1384  public function view(): void
1385  {
1386  if (strtolower($this->requested_baseClass) == "iladministrationgui") {
1387  $this->prepareOutput();
1388  parent::viewObject();
1389  } else {
1390  $this->viewObject();
1391  }
1392  }
1393 
1394 
1398  public function moveChapter(int $a_parent_subobj_id = 0): void
1399  {
1400  $ids = $this->edit_request->getIds();
1401  if (count($ids) == 0) {
1402  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"));
1403  if ($a_parent_subobj_id == 0) {
1404  $this->ctrl->redirect($this, "chapters");
1405  }
1406  return;
1407  }
1408  if (count($ids) > 1) {
1409  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_select_max_one_item"));
1410  if ($a_parent_subobj_id == 0) {
1411  $this->ctrl->redirect($this, "chapters");
1412  }
1413  return;
1414  }
1415 
1416  if (count($ids) == 1 && $ids[0] == ilTree::POS_FIRST_NODE) {
1417  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_select_item"));
1418  if ($a_parent_subobj_id == 0) {
1419  $this->ctrl->redirect($this, "chapters");
1420  }
1421  }
1422 
1423  // SAVE POST VALUES
1424  ilEditClipboard::storeContentObject("st", $ids[0], "move");
1425 
1426  $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_chap_select_target_now"), true);
1427 
1428  if ($a_parent_subobj_id == 0) {
1429  $this->ctrl->redirect($this, "chapters");
1430  }
1431  }
1432 
1433  public function copyChapter(): void
1434  {
1435  $this->copyItems();
1436  }
1437 
1438  public function pasteChapter(): void
1439  {
1440  $this->insertChapterClip();
1441  }
1442 
1443  public function movePage(): void
1444  {
1445  $ids = $this->edit_request->getIds();
1446  if (count($ids) == 0) {
1447  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1448  $this->ctrl->redirect($this, "pages");
1449  }
1450 
1451  $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_selected_items_have_been_cut"), true);
1452 
1453  ilLMObject::clipboardCut($this->lm->getId(), $ids);
1455 
1456  $this->ctrl->redirect($this, "pages");
1457  }
1458 
1459  public function cancel(): void
1460  {
1461  if ($this->requested_new_type == "pg") {
1462  $this->ctrl->redirect($this, "pages");
1463  } else {
1464  $this->ctrl->redirect($this, "chapters");
1465  }
1466  }
1467 
1468  public function export(): void
1469  {
1470  $ot = ilObjectTranslation::getInstance($this->lm->getId());
1471  $opt = "";
1472  if ($ot->getContentActivated()) {
1473  $format = explode("_", $this->edit_request->getFormat());
1474  $opt = ilUtil::stripSlashes($format[1]);
1475  }
1476 
1477 
1478  $cont_exp = new ilContObjectExport($this->lm);
1479  $cont_exp->buildExportFile($opt);
1480  }
1481 
1485  public function getPublicAccessColValue(
1486  string $a_type,
1487  string $a_file
1488  ): string {
1489  $lng = $this->lng;
1490  $ilCtrl = $this->ctrl;
1491  $add = "";
1492 
1493  $changelink = "<a href='" . $ilCtrl->getLinkTarget($this, "editMenuProperties") . "'>" . $lng->txt("change") . "</a>";
1494  if (!$this->lm->isActiveLMMenu()) {
1495  $add = "<br />" . $lng->txt("cont_download_no_menu") . " " . $changelink;
1496  } elseif (!$this->lm->isActiveDownloads()) {
1497  $add = "<br />" . $lng->txt("cont_download_no_download") . " " . $changelink;
1498  }
1499 
1500  $basetype = explode("_", $a_type);
1501  $basetype = $basetype[0];
1502 
1503  if ($this->lm->getPublicExportFile($basetype) == $a_file) {
1504  return $lng->txt("yes") . $add;
1505  }
1506 
1507  return " ";
1508  }
1509 
1510  public function publishExportFile(
1511  ?array $a_files
1512  ): void {
1513  $ilCtrl = $this->ctrl;
1514 
1515  if (!isset($a_files)) {
1516  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1517  } else {
1518  foreach ($a_files as $f) {
1519  $file = explode(":", $f);
1520  if (is_int(strpos($file[0], "_"))) {
1521  $file[0] = explode("_", $file[0])[0];
1522  }
1523  $export_dir = $this->lm->getExportDirectory($file[0]);
1524 
1525  if ($this->lm->getPublicExportFile($file[0]) ==
1526  $file[1]) {
1527  $this->lm->setPublicExportFile($file[0], "");
1528  } else {
1529  $this->lm->setPublicExportFile($file[0], $file[1]);
1530  }
1531  }
1532  $this->lm->update();
1533  }
1534  $ilCtrl->redirectByClass("ilexportgui");
1535  }
1536 
1537  public function fixTreeConfirm(): void
1538  {
1539  $this->setTabs();
1540  $this->setContentSubTabs("maintenance");
1541 
1542  // display confirmation message
1543  $cgui = new ilConfirmationGUI();
1544  $cgui->setFormAction($this->ctrl->getFormAction($this));
1545  $cgui->setHeaderText($this->lng->txt("cont_fix_tree_confirm"));
1546  $cgui->setCancel($this->lng->txt("cancel"), "showMaintenance");
1547  $cgui->setConfirm($this->lng->txt("cont_fix_tree"), "fixTree");
1548  $issues = $this->lm->checkStructure();
1549  $mess = "";
1550  if (count($issues) > 0) {
1551  $mess = "Found Issues: <br>" . implode("<br>", $issues);
1552  }
1553  $this->tpl->setContent($cgui->getHTML() . $mess);
1554  }
1555 
1556  public function fixTree(): void
1557  {
1558  $this->lm->fixTree();
1559  $this->tpl->setOnScreenMessage('success', $this->lng->txt("cont_tree_fixed"), true);
1560  $this->ctrl->redirect($this, "showMaintenance");
1561  }
1562 
1563  public function exportHTML(): void
1564  {
1565  $ot = ilObjectTranslation::getInstance($this->lm->getId());
1566  $lang = "";
1567  if ($ot->getContentActivated()) {
1568  $format = explode("_", $this->edit_request->getFormat());
1569  $lang = ilUtil::stripSlashes($format[1]);
1570  }
1571  $cont_exp = new ilContObjectExport($this->lm, "html", $lang);
1572  $cont_exp->buildExportFile();
1573  }
1574 
1579  public function addLocations(
1580  bool $a_omit_obj_id = false
1581  ): void {
1583 
1584  $obj_id = 0;
1585  if (!$a_omit_obj_id) {
1587  }
1588  $lmtree = $this->lm->getTree();
1589  if (($obj_id != 0) && $lmtree->isInTree($obj_id)) {
1590  $path = $lmtree->getPathFull($obj_id);
1591  } else {
1592  $path = $lmtree->getPathFull($lmtree->getRootId());
1593  if ($obj_id != 0) {
1594  $path[] = array("type" => "pg", "child" => $this->obj_id,
1595  "title" => ilLMPageObject::_getPresentationTitle($this->obj_id));
1596  }
1597  }
1598 
1599  foreach ($path as $key => $row) {
1600  if ($row["child"] == 1) {
1601  $this->ctrl->setParameter($this, "obj_id", null);
1602  $locator->addItem($this->lm->getTitle(), $this->ctrl->getLinkTarget($this, "chapters"));
1603  } else {
1604  $title = $row["title"];
1605  switch ($row["type"]) {
1606  case "st":
1607  $this->ctrl->setParameterByClass("ilstructureobjectgui", "obj_id", $row["child"]);
1608  $locator->addItem($title, $this->ctrl->getLinkTargetByClass("ilstructureobjectgui", "view"));
1609  break;
1610 
1611  case "pg":
1612  $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $row["child"]);
1613  $locator->addItem($title, $this->ctrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
1614  break;
1615  }
1616  }
1617  }
1618  if (!$a_omit_obj_id) {
1619  $this->ctrl->setParameter($this, "obj_id", $this->requested_obj_id);
1620  }
1621  }
1622 
1626 
1627 
1628  public function listQuestions(): void
1629  {
1630  $tpl = $this->tpl;
1631 
1632  $this->setTabs("questions");
1633  $this->setQuestionsSubTabs("question_stats");
1634 
1635  $table = new ilLMQuestionListTableGUI($this, "listQuestions", $this->lm);
1636  $tpl->setContent($table->getHTML());
1637  }
1638 
1639  public function listBlockedUsers(): void
1640  {
1641  $tpl = $this->tpl;
1642 
1643  $this->setTabs("questions");
1644  $this->setQuestionsSubTabs("blocked_users");
1645 
1646  $table = new ilLMBlockedUsersTableGUI($this, "listBlockedUsers", $this->lm);
1647  $tpl->setContent($table->getHTML());
1648  }
1649 
1650  public function resetNumberOfTries(): void
1651  {
1652  $lng = $this->lng;
1653  $ilCtrl = $this->ctrl;
1654 
1655  $user_q_ids = $this->edit_request->getUserQuestionIds();
1656  if (count($user_q_ids) > 0) {
1657  foreach ($user_q_ids as $uqid) {
1658  $uqid = explode(":", $uqid);
1659  ilPageQuestionProcessor::resetTries((int) $uqid[0], (int) $uqid[1]);
1660  }
1661  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1662  }
1663  $ilCtrl->redirect($this, "listBlockedUsers");
1664  }
1665 
1666  public function unlockQuestion(): void
1667  {
1668  $lng = $this->lng;
1669  $ilCtrl = $this->ctrl;
1670 
1671  $user_q_ids = $this->edit_request->getUserQuestionIds();
1672  if (count($user_q_ids) > 0) {
1673  foreach ($user_q_ids as $uqid) {
1674  $uqid = explode(":", $uqid);
1675  ilPageQuestionProcessor::unlock((int) $uqid[0], (int) $uqid[1]);
1676  }
1677  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1678  }
1679  $ilCtrl->redirect($this, "listBlockedUsers");
1680  }
1681 
1682  public function sendMailToBlockedUsers(): void
1683  {
1684  $ilCtrl = $this->ctrl;
1685 
1686  $user_q_ids = $this->edit_request->getUserQuestionIds();
1687  if (count($user_q_ids) == 0) {
1688  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), 1);
1689  $ilCtrl->redirect($this, "listBlockedUsers");
1690  }
1691 
1692  $rcps = array();
1693  foreach ($user_q_ids as $uqid) {
1694  $uqid = explode(":", $uqid);
1695  $login = ilObjUser::_lookupLogin($uqid[1]);
1696  if (!in_array($login, $rcps)) {
1697  $rcps[] = $login;
1698  }
1699  }
1701  $this,
1702  'listBlockedUsers',
1703  array(),
1704  array(
1705  'type' => 'new',
1706  'rcp_to' => implode(',', $rcps),
1707  'sig' => $this->getBlockedUsersMailSignature()
1708  )
1709  ));
1710  }
1711 
1712  protected function getBlockedUsersMailSignature(): string
1713  {
1714  $link = chr(13) . chr(10) . chr(13) . chr(10);
1715  $link .= $this->lng->txt('cont_blocked_users_mail_link');
1716  $link .= chr(13) . chr(10) . chr(13) . chr(10);
1717  $link .= ilLink::_getLink($this->lm->getRefId());
1718  return rawurlencode(base64_encode($link));
1719  }
1720 
1721 
1725 
1726  protected function setTabs(string $a_act = ""): void
1727  {
1728  parent::setTitleAndDescription();
1729  $ilHelp = $this->help;
1730  $ilHelp->setScreenIdComponent("lm");
1731  $this->addTabs($a_act);
1732  }
1733 
1734  public function setContentSubTabs(string $a_active): void
1735  {
1736  $ilTabs = $this->tabs;
1737  $lng = $this->lng;
1738  $ilCtrl = $this->ctrl;
1739 
1740  $lm_set = new ilSetting("lm");
1741 
1742  // chapters
1743  $ilTabs->addSubTab(
1744  "chapters",
1745  $lng->txt("cont_chapters"),
1746  $ilCtrl->getLinkTarget($this, "chapters")
1747  );
1748 
1749  // all pages
1750  $ilTabs->addSubTab(
1751  "pages",
1752  $lng->txt("cont_all_pages"),
1753  $ilCtrl->getLinkTarget($this, "pages")
1754  );
1755 
1756  // all pages
1757  $ilTabs->addSubTab(
1758  "short_titles",
1759  $lng->txt("cont_short_titles"),
1760  $ilCtrl->getLinkTargetByClass("illmeditshorttitlesgui", "")
1761  );
1762 
1763  // export ids
1764  if ($lm_set->get("html_export_ids")) {
1765  if (!ilObjContentObject::isOnlineHelpModule($this->lm->getRefId())) {
1766  $ilTabs->addSubTab(
1767  "export_ids",
1768  $lng->txt("cont_html_export_ids"),
1769  $ilCtrl->getLinkTarget($this, "showExportIDsOverview")
1770  );
1771  }
1772  }
1773  if (ilObjContentObject::isOnlineHelpModule($this->lm->getRefId())) {
1774  $lng->loadLanguageModule("help");
1775  $ilTabs->addSubTab(
1776  "export_ids",
1777  $lng->txt("cont_online_help_ids"),
1778  $ilCtrl->getLinkTarget($this, "showExportIDsOverview")
1779  );
1780 
1781  $ilTabs->addSubTab(
1782  "help_tooltips",
1783  $lng->txt("help_tooltips"),
1784  $ilCtrl->getLinkTarget($this, "showTooltipList")
1785  );
1786  }
1787 
1788  // list links
1789  $ilTabs->addSubTab(
1790  "internal_links",
1791  $lng->txt("cont_internal_links"),
1792  $ilCtrl->getLinkTarget($this, "listLinks")
1793  );
1794 
1795  $ilTabs->addSubTab(
1796  "history",
1797  $lng->txt("history"),
1798  $this->ctrl->getLinkTarget($this, "history")
1799  );
1800 
1801  // maintenance
1802  $ilTabs->addSubTab(
1803  "maintenance",
1804  $lng->txt("cont_maintenance"),
1805  $ilCtrl->getLinkTarget($this, "showMaintenance")
1806  );
1807 
1808  // srt files
1809  $ilTabs->addSubTab(
1810  "srt_files",
1811  $lng->txt("cont_subtitle_files"),
1812  $ilCtrl->getLinkTargetByClass("ilmobmultisrtuploadgui", "")
1813  );
1814 
1815  // srt files
1816  $ilTabs->addSubTab(
1817  "import",
1818  $lng->txt("cont_import"),
1819  $ilCtrl->getLinkTargetByClass("illmimportgui", "")
1820  );
1821 
1822  $ilTabs->activateSubTab($a_active);
1823  $ilTabs->activateTab("content");
1824  }
1825 
1826  public function setQuestionsSubTabs(string $a_active): void
1827  {
1828  $ilTabs = $this->tabs;
1829  $lng = $this->lng;
1830  $ilCtrl = $this->ctrl;
1831 
1832  // chapters
1833  $ilTabs->addSubTab(
1834  "question_stats",
1835  $lng->txt("cont_question_stats"),
1836  $ilCtrl->getLinkTarget($this, "listQuestions")
1837  );
1838 
1839  // blocked users
1840  $ilTabs->addSubTab(
1841  "blocked_users",
1842  $lng->txt("cont_blocked_users"),
1843  $ilCtrl->getLinkTarget($this, "listBlockedUsers")
1844  );
1845 
1846  $ilTabs->activateSubTab($a_active);
1847  }
1848 
1849  public function addTabs(string $a_act = ""): void
1850  {
1851  $rbacsystem = $this->rbacsystem;
1852  $ilTabs = $this->tabs;
1853  $lng = $this->lng;
1854 
1855  // content
1856  $ilTabs->addTab(
1857  "content",
1858  $lng->txt("content"),
1859  $this->ctrl->getLinkTarget($this, "chapters")
1860  );
1861 
1862  // info
1863  if ($this->object->isInfoEnabled()) {
1864  $ilTabs->addTab(
1865  "info",
1866  $lng->txt("info_short"),
1867  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", 'showSummary')
1868  );
1869  }
1870 
1871  // settings
1872  $ilTabs->addTab(
1873  "settings",
1874  $lng->txt("settings"),
1875  $this->ctrl->getLinkTarget($this, 'properties')
1876  );
1877 
1878  // questions
1879  $ilTabs->addTab(
1880  "questions",
1881  $lng->txt("objs_qst"),
1882  $this->ctrl->getLinkTarget($this, "listQuestions")
1883  );
1884 
1885  // learning progress
1886  if (ilLearningProgressAccess::checkAccess($this->lm->getRefId()) and ($this->lm->getType() == 'lm')) {
1887  $ilTabs->addTab(
1888  'learning_progress',
1889  $lng->txt("learning_progress"),
1890  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'), '')
1891  );
1892  }
1893 
1894  // meta data
1895  $mdgui = new ilObjectMetaDataGUI($this->lm);
1896  $mdtab = $mdgui->getTab();
1897  if ($mdtab) {
1898  $ilTabs->addTab(
1899  "meta",
1900  $lng->txt("meta_data"),
1901  $mdtab
1902  );
1903  }
1904 
1905  // export
1906  $ilTabs->addTab(
1907  "export",
1908  $lng->txt("export"),
1909  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
1910  );
1911 
1912  // permissions
1913  if ($rbacsystem->checkAccess('edit_permission', $this->lm->getRefId())) {
1914  $ilTabs->addTab(
1915  "perm",
1916  $lng->txt("perm_settings"),
1917  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
1918  );
1919  }
1920 
1921  if ($a_act != "") {
1922  $ilTabs->activateTab($a_act);
1923  }
1924 
1925  // presentation view
1926  $ilTabs->addNonTabbedLink(
1927  "pres_mode",
1928  $lng->txt("cont_presentation_view"),
1929  "ilias.php?baseClass=ilLMPresentationGUI&ref_id=" . $this->lm->getRefId(),
1930  "_top"
1931  );
1932  }
1933 
1934  public function setSubTabs(string $a_active): void
1935  {
1936  $ilTabs = $this->tabs;
1938 
1939  if (in_array(
1940  $a_active,
1941  array("settings", "cont_style", "cont_lm_menu", "public_section",
1942  "cont_glossaries", "cont_multilinguality", "obj_multilinguality",
1943  "lti_provider")
1944  )) {
1945  // general properties
1946  $ilTabs->addSubTabTarget(
1947  "settings",
1948  $this->ctrl->getLinkTarget($this, 'properties'),
1949  "",
1950  ""
1951  );
1952 
1953  // style properties
1954  $ilTabs->addSubTabTarget(
1955  "cont_style",
1956  $this->ctrl->getLinkTargetByClass("ilObjectContentStyleSettingsGUI", ""),
1957  "",
1958  "ilObjectContentStyleSettingsGUI"
1959  );
1960 
1961  // menu properties
1962  $ilTabs->addSubTabTarget(
1963  "cont_lm_menu",
1964  $this->ctrl->getLinkTarget($this, 'editMenuProperties'),
1965  "",
1966  ""
1967  );
1968 
1969  // glossaries
1970  $ilTabs->addSubTabTarget(
1971  "cont_glossaries",
1972  $this->ctrl->getLinkTarget($this, 'editGlossaries'),
1973  "",
1974  ""
1975  );
1976 
1977  if ($ilSetting->get("pub_section")) {
1978  // public section
1979  $ilTabs->addSubTabTarget(
1980  "public_section",
1981  $this->ctrl->getLinkTarget($this, 'editPublicSection'),
1982  "",
1983  ""
1984  );
1985  }
1986 
1987  $ilTabs->addSubTabTarget(
1988  "obj_multilinguality",
1989  $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
1990  );
1991 
1992  $lti_settings = new ilLTIProviderObjectSettingGUI($this->lm->getRefId());
1993  if ($lti_settings->hasSettingsAccess()) {
1994  $ilTabs->addSubTabTarget(
1995  'lti_provider',
1996  $this->ctrl->getLinkTargetByClass(ilLTIProviderObjectSettingGUI::class)
1997  );
1998  }
1999 
2000  $ilTabs->setSubTabActive($a_active);
2001  }
2002  }
2003 
2004  public function editPublicSection(): void
2005  {
2006  $ilTabs = $this->tabs;
2007  $ilToolbar = $this->toolbar;
2008  $ilAccess = $this->access;
2009 
2010 
2011  if (!$ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, "read", "", $this->lm->getRefId())) {
2012  $this->tpl->setOnScreenMessage('info', $this->lng->txt("cont_anonymous_user_missing_perm"));
2013  }
2014 
2015  $this->setTabs();
2016  $this->setSubTabs("public_section");
2017  $ilTabs->setTabActive("settings");
2018 
2019  $this->tpl->addBlockFile(
2020  "ADM_CONTENT",
2021  "adm_content",
2022  "tpl.lm_public_selector.html",
2023  "Modules/LearningModule"
2024  );
2025 
2026  // get learning module object
2027  $this->lm_obj = new ilObjLearningModule($this->ref_id, true);
2028 
2029 
2030  // public mode
2031  $modes = array("complete" => $this->lng->txt("all_pages"), "selected" => $this->lng->txt("selected_pages_only"));
2032  $si = new ilSelectInputGUI($this->lng->txt("choose_public_mode"), "lm_public_mode");
2033  $si->setOptions($modes);
2034  $si->setValue($this->lm->getPublicAccessMode());
2035  $ilToolbar->addInputItem($si, true);
2036  $ilToolbar->addFormButton($this->lng->txt("save"), "savePublicSectionAccess");
2037  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "savePublicSectionAccess"));
2038 
2039  if ($this->lm->getPublicAccessMode() == "selected") {
2040  $this->tpl->setCurrentBlock("select_pages");
2041  $this->tpl->setVariable("FORMACTION", $this->ctrl->getLinkTarget($this, "savePublicSectionPages"));
2042 
2044  $this,
2045  "editPublicSection",
2046  $this->lm_obj,
2047  $this->edit_request->getTranslation()
2048  );
2049  $tree->setSelectMode("pages", true);
2050  $tree->setSkipRootNode(true);
2051 
2052  $this->tpl->setVariable("EXPLORER", $tree->getHTML());
2053  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2054 
2055  $this->tpl->parseCurrentBlock();
2056  }
2057  }
2058 
2059  public function savePublicSection(): void
2060  {
2061  $this->lm->setPublicAccessMode(
2062  $this->edit_request->getLMPublicMode()
2063  );
2064  $this->lm->updateProperties();
2066  $this->edit_request->getPublicPages(),
2067  $this->lm->getId()
2068  );
2069  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
2070  $this->ctrl->redirect($this, "editPublicSection");
2071  }
2072 
2076  public function savePublicSectionAccess(): void
2077  {
2078  $this->lm->setPublicAccessMode(
2079  $this->edit_request->getLMPublicMode()
2080  );
2081  $this->lm->updateProperties();
2082  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
2083  $this->ctrl->redirect($this, "editPublicSection");
2084  }
2085 
2089  public function savePublicSectionPages(): void
2090  {
2092  $this->edit_request->getPublicPages(),
2093  $this->lm->getId()
2094  );
2095  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
2096  $this->ctrl->redirect($this, "editPublicSection");
2097  }
2098 
2099  public function history(): void
2100  {
2101  $this->setTabs("content");
2102  $this->setContentSubTabs("history");
2103 
2104  $hist_gui = new ilHistoryTableGUI(
2105  $this,
2106  "history",
2107  $this->lm->getId(),
2108  $this->lm->getType()
2109  );
2110  $hist_gui->initTable();
2111  $hist_gui->setCommentVisibility($this->lm->isActiveHistoryUserComments());
2112 
2113  $this->tpl->setContent($hist_gui->getHTML());
2114  }
2115 
2116  public function __initLMMenuEditor(): void
2117  {
2118  $this->lmme_obj = new ilLMMenuEditor();
2119  $this->lmme_obj->setObjId($this->lm->getId());
2120  }
2121 
2125  public function addMenuEntry(?ilPropertyFormGUI $form = null): void
2126  {
2127  $ilTabs = $this->tabs;
2128  $ilToolbar = $this->toolbar;
2129  $ilCtrl = $this->ctrl;
2130 
2131  $this->setTabs();
2132 
2133  $ilTabs->setTabActive("settings");
2134  $this->setSubTabs("cont_lm_menu");
2135 
2136  $ilToolbar->addButton(
2137  $this->lng->txt("lm_menu_select_internal_object"),
2138  $ilCtrl->getLinkTarget($this, "showEntrySelector")
2139  );
2140 
2141  if (is_null($form)) {
2142  $form = $this->initMenuEntryForm("create");
2143  }
2144  $this->tpl->setContent($form->getHTML());
2145  }
2146 
2147  public function initMenuEntryForm(string $a_mode = "edit"): ilPropertyFormGUI
2148  {
2149  $lng = $this->lng;
2150  $ilCtrl = $this->ctrl;
2151 
2152  $form = new ilPropertyFormGUI();
2153 
2154  // title
2155  $ti = new ilTextInputGUI($this->lng->txt("lm_menu_entry_title"), "title");
2156  $ti->setMaxLength(255);
2157  $ti->setSize(40);
2158  $ti->setRequired(true);
2159  $form->addItem($ti);
2160 
2161  // target
2162  $ta = new ilTextInputGUI($this->lng->txt("lm_menu_entry_target"), "target");
2163  $ta->setMaxLength(255);
2164  $ta->setSize(40);
2165  $ta->setRequired(true);
2166  $form->addItem($ta);
2167 
2168  if ($a_mode == "edit") {
2169  $this->__initLMMenuEditor();
2170  $this->lmme_obj->readEntry($this->edit_request->getMenuEntry());
2171  $ti->setValue($this->lmme_obj->getTitle());
2172  $ta->setValue($this->lmme_obj->getTarget());
2173  }
2174 
2175  if ($this->requested_link_ref_id > 0) {
2176  $link_ref_id = $this->requested_link_ref_id;
2177  $obj_type = ilObject::_lookupType($link_ref_id, true);
2178  $obj_id = ilObject::_lookupObjectId($link_ref_id);
2179  $title = ilObject::_lookupTitle($obj_id);
2180 
2181  $target_link = $obj_type . "_" . $link_ref_id;
2182  $ti->setValue($title);
2183  $ta->setValue($target_link);
2184 
2185  // link ref id
2186  $hi = new ilHiddenInputGUI("link_ref_id");
2187  $hi->setValue($link_ref_id);
2188  $form->addItem($hi);
2189  }
2190 
2191 
2192  // save and cancel commands
2193  if ($a_mode == "create") {
2194  $form->addCommandButton("saveMenuEntry", $lng->txt("save"));
2195  $form->addCommandButton("editMenuProperties", $lng->txt("cancel"));
2196  $form->setTitle($lng->txt("lm_menu_new_entry"));
2197  } else {
2198  $form->addCommandButton("updateMenuEntry", $lng->txt("save"));
2199  $form->addCommandButton("editMenuProperties", $lng->txt("cancel"));
2200  $form->setTitle($lng->txt("lm_menu_edit_entry"));
2201  }
2202 
2203  $form->setFormAction($ilCtrl->getFormAction($this));
2204 
2205  return $form;
2206  }
2207 
2208  public function saveMenuEntry(): void
2209  {
2210  $form = $this->initMenuEntryForm("create");
2211  if ($form->checkInput()) {
2212  $this->__initLMMenuEditor();
2213  $this->lmme_obj->setTitle($form->getInput("title"));
2214  $this->lmme_obj->setTarget($form->getInput("target"));
2215  $this->lmme_obj->setLinkRefId((int) $form->getInput("link_ref_id"));
2216 
2217  if ($form->getInput("link_ref_id")) {
2218  $this->lmme_obj->setLinkType("intern");
2219  }
2220 
2221  $this->lmme_obj->create();
2222 
2223  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_entry_added"), true);
2224  $this->ctrl->redirect($this, "editMenuProperties");
2225  } else {
2226  $form->setValuesByPost();
2227  $this->addMenuEntry($form);
2228  }
2229  }
2230 
2231  public function deleteMenuEntry(): void
2232  {
2233  if (empty($this->requested_menu_entry)) {
2234  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_menu_entry_id"), true);
2235  $this->ctrl->redirect($this, "editMenuProperties");
2236  }
2237 
2238  $this->__initLMMenuEditor();
2239  $this->lmme_obj->delete($this->requested_menu_entry);
2240 
2241  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_entry_removed"), true);
2242  $this->ctrl->redirect($this, "editMenuProperties");
2243  }
2244 
2245  public function editMenuEntry(?ilPropertyFormGUI $form = null): void
2246  {
2247  $ilToolbar = $this->toolbar;
2248  $ilCtrl = $this->ctrl;
2249  $ilTabs = $this->tabs;
2250 
2251  $this->setTabs();
2252 
2253  $ilTabs->setTabActive("settings");
2254  $this->setSubTabs("cont_lm_menu");
2255 
2256 
2257  if (empty($this->requested_menu_entry)) {
2258  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_menu_entry_id"), true);
2259  $this->ctrl->redirect($this, "editMenuProperties");
2260  }
2261 
2262  $ilCtrl->saveParameter($this, array("menu_entry"));
2263  $ilToolbar->addButton(
2264  $this->lng->txt("lm_menu_select_internal_object"),
2265  $ilCtrl->getLinkTarget($this, "showEntrySelector")
2266  );
2267 
2268  if (is_null($form)) {
2269  $form = $this->initMenuEntryForm("edit");
2270  }
2271  $this->tpl->setContent($form->getHTML());
2272  }
2273 
2274  public function updateMenuEntry(): void
2275  {
2276  $form = $this->initMenuEntryForm("edit");
2277  if ($form->checkInput()) {
2278  if ($this->edit_request->getMenuEntry() == "") {
2279  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_menu_entry_id"), true);
2280  $this->ctrl->redirect($this, "editMenuProperties");
2281  }
2282 
2283  $this->__initLMMenuEditor();
2284  $this->lmme_obj->readEntry($this->edit_request->getMenuEntry());
2285  $this->lmme_obj->setTitle($form->getInput("title"));
2286  $this->lmme_obj->setTarget($form->getInput("target"));
2287  if ($form->getInput("link_ref_id")) {
2288  $this->lmme_obj->setLinkType("intern");
2289  }
2290  if (is_int(strpos($form->getInput("target"), "."))) {
2291  $this->lmme_obj->setLinkType("extern");
2292  }
2293  $this->lmme_obj->update();
2294  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_entry_updated"), true);
2295  $this->ctrl->redirect($this, "editMenuProperties");
2296  } else {
2297  $form->setValuesByPost();
2298  $this->editMenuEntry($form);
2299  }
2300  }
2301 
2302  public function showEntrySelector(): void
2303  {
2304  $ilTabs = $this->tabs;
2305  $ilCtrl = $this->ctrl;
2306 
2307  $this->setTabs();
2308 
2309  $ilTabs->setTabActive("settings");
2310  $this->setSubTabs("cont_lm_menu");
2311 
2312  $ilCtrl->saveParameter($this, array("menu_entry"));
2313 
2314  $this->tpl->setOnScreenMessage('info', $this->lng->txt("lm_menu_select_object_to_add"));
2315 
2317  $this,
2318  "showEntrySelector",
2319  $this,
2320  "addMenuEntry",
2321  "link_ref_id"
2322  );
2323  //$exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "glo", "fold"));
2324  $exp->setClickableTypes(array('mcst', 'mep', 'cat', 'lm','glo','frm','exc','tst','svy', 'chat', 'wiki', 'sahs', "crs", "grp", "book", "tst", "file"));
2325  if (!$exp->handleCommand()) {
2326  $this->tpl->setContent($exp->getHTML());
2327  }
2328  }
2329 
2333  public function selectHeader(): void
2334  {
2335  $ids = $this->edit_request->getIds();
2336  if (count($ids) == 0) {
2337  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
2338  $this->ctrl->redirect($this, "pages");
2339  }
2340  if (count($ids) > 1) {
2341  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_select_max_one_item"), true);
2342  $this->ctrl->redirect($this, "pages");
2343  }
2344  if ($ids[0] != $this->lm->getHeaderPage()) {
2345  $this->lm->setHeaderPage($ids[0]);
2346  } else {
2347  $this->lm->setHeaderPage(0);
2348  }
2349  $this->lm->updateProperties();
2350  $this->ctrl->redirect($this, "pages");
2351  }
2352 
2356  public function selectFooter(): void
2357  {
2358  $ids = $this->edit_request->getIds();
2359  if (count($ids) == 0) {
2360  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
2361  $this->ctrl->redirect($this, "pages");
2362  }
2363  if (count($ids) > 1) {
2364  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_select_max_one_item"), true);
2365  $this->ctrl->redirect($this, "pages");
2366  }
2367  if ($ids[0] != $this->lm->getFooterPage()) {
2368  $this->lm->setFooterPage($ids[0]);
2369  } else {
2370  $this->lm->setFooterPage(0);
2371  }
2372  $this->lm->updateProperties();
2373  $this->ctrl->redirect($this, "pages");
2374  }
2375 
2379  public function saveAllTitles(): void
2380  {
2381  $ilCtrl = $this->ctrl;
2382 
2384  $this->lm,
2385  $this->edit_request->getTitles(),
2387  );
2388 
2389  $this->tpl->setOnScreenMessage('success', $this->lng->txt("lm_save_titles"), true);
2390  $ilCtrl->redirect($this, "chapters");
2391  }
2392 
2396  public function insertChapter(): void
2397  {
2398  $ilCtrl = $this->ctrl;
2399  $lng = $this->lng;
2400 
2403 
2404  if (!ilChapterHierarchyFormGUI::getPostFirstChild()) { // insert after node id
2405  $parent_id = $this->lm_tree->getParentId($node_id);
2406  $target = $node_id;
2407  } else { // insert as first child
2408  $parent_id = $node_id;
2409  $target = ilTree::POS_FIRST_NODE;
2410  }
2411 
2412  for ($i = 1; $i <= $num; $i++) {
2413  $chap = new ilStructureObject($this->lm);
2414  $chap->setType("st");
2415  $chap->setTitle($lng->txt("cont_new_chap"));
2416  $chap->setLMId($this->lm->getId());
2417  $chap->create();
2418  ilLMObject::putInTree($chap, $parent_id, $target);
2419  }
2420 
2421  $ilCtrl->redirect($this, "chapters");
2422  }
2423 
2427  public function insertChapterClip(): void
2428  {
2429  $ilUser = $this->user;
2430  $ilCtrl = $this->ctrl;
2431  $ilLog = $this->log;
2432 
2435 
2436  if (!$first_child) { // insert after node id
2437  $parent_id = $this->lm_tree->getParentId($node_id);
2438  $target = $node_id;
2439  } else { // insert as first child
2440  $parent_id = $node_id;
2441  $target = ilTree::POS_FIRST_NODE;
2442  }
2443 
2444  // copy and paste
2445  $chapters = $ilUser->getClipboardObjects("st", true);
2446  $copied_nodes = array();
2447  foreach ($chapters as $chap) {
2448  $ilLog->write("Call pasteTree, Target LM: " . $this->lm->getId() . ", Chapter ID: " . $chap["id"]
2449  . ", Parent ID: " . $parent_id . ", Target: " . $target);
2450  $cid = ilLMObject::pasteTree(
2451  $this->lm,
2452  $chap["id"],
2453  $parent_id,
2454  $target,
2455  (string) ($chap["insert_time"] ?? ""),
2456  $copied_nodes,
2457  (ilEditClipboard::getAction() == "copy")
2458  );
2459  $target = $cid;
2460  }
2461  ilLMObject::updateInternalLinks($copied_nodes);
2462 
2463  if (ilEditClipboard::getAction() == "cut") {
2464  $ilUser->clipboardDeleteObjectsOfType("pg");
2465  $ilUser->clipboardDeleteObjectsOfType("st");
2467  }
2468 
2469  $this->lm->checkTree();
2470  $ilCtrl->redirect($this, "chapters");
2471  }
2472 
2473  public static function _goto(string $a_target): void
2474  {
2475  global $DIC;
2476  $main_tpl = $DIC->ui()->mainTemplate();
2477 
2478  $ilAccess = $DIC->access();
2479  $ilErr = $DIC["ilErr"];
2480  $lng = $DIC->language();
2481  $ctrl = $DIC->ctrl();
2482 
2483  if ($ilAccess->checkAccess("read", "", $a_target)) {
2484  $ctrl->setParameterByClass("ilLMPresentationGUI", "ref_id", $a_target);
2485  if (ilObjLearningModuleAccess::_lookupSetting("lm_starting_point") == "first") {
2486  $ctrl->redirectByClass("ilLMPresentationGUI", "");
2487  } else {
2488  $ctrl->redirectByClass("ilLMPresentationGUI", "resume");
2489  }
2490  } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
2491  $ctrl->setParameterByClass("ilLMPresentationGUI", "ref_id", $a_target);
2492  $ctrl->redirectByClass("ilLMPresentationGUI", "infoScreen");
2493  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
2494  $main_tpl->setOnScreenMessage('failure', sprintf(
2495  $lng->txt("msg_no_perm_read_item"),
2497  ), true);
2499  }
2500 
2501 
2502  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
2503  }
2504 
2505  public function cutItems(string $a_return = "chapters"): void
2506  {
2507  $ilCtrl = $this->ctrl;
2508  $lng = $this->lng;
2509 
2510  $ids = $this->edit_request->getIds();
2511  if (count($ids) == 0) {
2512  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
2513  $ilCtrl->redirect($this, $a_return);
2514  }
2515 
2516  $todel = array(); // delete IDs < 0 (needed for non-js editing)
2517  foreach ($ids as $k => $item) {
2518  if ($item < 0) {
2519  $todel[] = $k;
2520  }
2521  }
2522  foreach ($todel as $k) {
2523  unset($ids[$k]);
2524  }
2525  ilLMObject::clipboardCut($this->lm->getId(), $ids);
2527  $this->tpl->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_cut"), true);
2528 
2529  $ilCtrl->redirect($this, $a_return);
2530  }
2531 
2535  public function copyItems(): void
2536  {
2537  $ilCtrl = $this->ctrl;
2538  $lng = $this->lng;
2539 
2540  $ids = $this->edit_request->getIds();
2541  if (count($ids) == 0) {
2542  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
2543  $ilCtrl->redirect($this, "chapters");
2544  }
2545 
2546  $todel = array(); // delete IDs < 0 (needed for non-js editing)
2547  foreach ($ids as $k => $item) {
2548  if ($item < 0) {
2549  $todel[] = $k;
2550  }
2551  }
2552  foreach ($todel as $k) {
2553  unset($ids[$k]);
2554  }
2555  ilLMObject::clipboardCopy($this->lm->getId(), $ids);
2557  $this->tpl->setOnScreenMessage('info', $lng->txt("cont_selected_items_have_been_copied"), true);
2558  $ilCtrl->redirect($this, "chapters");
2559  }
2560 
2564  public function cutChapter(): void
2565  {
2566  $this->cutItems("chapters");
2567  }
2568 
2572 
2573  public function showExportIDsOverview(bool $a_validation = false): void
2574  {
2575  $tpl = $this->tpl;
2576  $ilToolbar = $this->toolbar;
2577  $lng = $this->lng;
2578  $ilCtrl = $this->ctrl;
2579 
2580  $this->setTabs();
2581  $this->setContentSubTabs("export_ids");
2582 
2583  if (ilObjContentObject::isOnlineHelpModule($this->lm->getRefId())) {
2584  // toolbar
2585  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
2586  $lm_tree = $this->lm->getTree();
2587  $childs = $lm_tree->getChilds($lm_tree->readRootId());
2588  $options = array("" => $lng->txt("all"));
2589  foreach ($childs as $c) {
2590  $options[$c["child"]] = $c["title"];
2591  }
2592  $si = new ilSelectInputGUI($this->lng->txt("help_component"), "help_chap");
2593  $si->setOptions($options);
2594  $si->setValue(ilSession::get("help_chap"));
2595  $ilToolbar->addInputItem($si, true);
2596  $ilToolbar->addFormButton($lng->txt("help_filter"), "filterHelpChapters");
2597 
2598  $tbl = new ilHelpMappingTableGUI($this, "showExportIDsOverview", $a_validation);
2599  } else {
2600  $tbl = new ilExportIDTableGUI($this, "showExportIDsOverview", $a_validation, false);
2601  }
2602 
2603  $tpl->setContent($tbl->getHTML());
2604  }
2605 
2606  public function filterHelpChapters(): void
2607  {
2608  $ilCtrl = $this->ctrl;
2609  ilSession::set("help_chap", $this->edit_request->getHelpChap());
2610  $ilCtrl->redirect($this, "showExportIDsOverview");
2611  }
2612 
2613  public function saveExportIds(): void
2614  {
2615  $ilCtrl = $this->ctrl;
2616  $lng = $this->lng;
2617 
2618  // check all export ids
2619  $ok = true;
2620  foreach ($this->edit_request->getExportIds() as $exp_id) {
2621  if ($exp_id != "" && !preg_match(
2622  "/^([a-zA-Z]+)[0-9a-zA-Z_]*$/",
2623  trim($exp_id)
2624  )) {
2625  $ok = false;
2626  }
2627  }
2628  if (!$ok) {
2629  $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_exp_ids_not_resp_format1") . ": a-z, A-Z, 0-9, '_'. " .
2630  $lng->txt("cont_exp_ids_not_resp_format3") . " " .
2631  $lng->txt("cont_exp_ids_not_resp_format2"));
2632  $this->showExportIDsOverview(true);
2633  return;
2634  }
2635 
2636 
2637  foreach ($this->edit_request->getExportIds() as $pg_id => $exp_id) {
2639  $this->lm->getId(),
2640  $pg_id,
2641  ilUtil::stripSlashes($exp_id),
2642  ilLMObject::_lookupType($pg_id)
2643  );
2644  }
2645 
2646  $this->tpl->setOnScreenMessage('success', $lng->txt("cont_saved_export_ids"), true);
2647  $ilCtrl->redirect($this, "showExportIdsOverview");
2648  }
2649 
2650  public function saveHelpMapping(): void
2651  {
2652  $lng = $this->lng;
2653  $ilCtrl = $this->ctrl;
2654  $help_map = $this->help->internal()->domain()->map();
2655 
2656  foreach ($this->edit_request->getScreenIds() as $chap => $ids) {
2657  $ids = explode("\n", $ids);
2658  $help_map->saveScreenIdsForChapter($chap, $ids);
2659  }
2660  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
2661  $ilCtrl->redirect($this, "showExportIdsOverview");
2662  }
2663 
2667 
2668  public function showTooltipList(): void
2669  {
2670  $tpl = $this->tpl;
2671  $ilToolbar = $this->toolbar;
2672  $ilCtrl = $this->ctrl;
2673  $lng = $this->lng;
2674 
2675  $this->setTabs();
2676  $this->setContentSubTabs("help_tooltips");
2677 
2678  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
2679  $ti = new ilTextInputGUI($this->lng->txt("help_tooltip_id"), "tooltip_id");
2680  $ti->setMaxLength(200);
2681  $ti->setSize(20);
2682  $ilToolbar->addInputItem($ti, true);
2683  $ilToolbar->addFormButton($lng->txt("add"), "addTooltip");
2684  $ilToolbar->addSeparator();
2685 
2686  $options = $this->help->internal()->domain()->tooltips()->getTooltipComponents();
2687  if (ilSession::get("help_tt_comp") != "") {
2688  $options[ilSession::get("help_tt_comp")] = ilSession::get("help_tt_comp");
2689  }
2690  $si = new ilSelectInputGUI($this->lng->txt("help_component"), "help_tt_comp");
2691  $si->setOptions($options);
2692  $si->setValue(ilSession::get("help_tt_comp"));
2693  $ilToolbar->addInputItem($si, true);
2694  $ilToolbar->addFormButton($lng->txt("help_filter"), "filterTooltips");
2695 
2696  $tbl = new ilHelpTooltipTableGUI($this, "showTooltipList", (string) ilSession::get("help_tt_comp"));
2697 
2698  $tpl->setContent($tbl->getHTML());
2699  }
2700 
2701  public function addTooltip(): void
2702  {
2703  $lng = $this->lng;
2704  $ilCtrl = $this->ctrl;
2705 
2706  $tt_id = $this->edit_request->getTooltipId();
2707  if (trim($tt_id) != "") {
2708  if (is_int(strpos($tt_id, "_"))) {
2709  $this->help->internal()->domain()->tooltips()->addTooltip(trim($tt_id), "");
2710  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
2711 
2712  $fu = strpos($tt_id, "_");
2713  $comp = substr($tt_id, 0, $fu);
2714  ilSession::set("help_tt_comp", ilUtil::stripSlashes($comp));
2715  } else {
2716  $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_help_no_valid_tooltip_id"), true);
2717  }
2718  }
2719  $ilCtrl->redirect($this, "showTooltipList");
2720  }
2721 
2722  public function filterTooltips(): void
2723  {
2724  $ilCtrl = $this->ctrl;
2725 
2727  "help_tt_comp",
2728  $this->edit_request->getTooltipComponent()
2729  );
2730  $ilCtrl->redirect($this, "showTooltipList");
2731  }
2732 
2733  public function saveTooltips(): void
2734  {
2735  $ilCtrl = $this->ctrl;
2736  $lng = $this->lng;
2737 
2738  $tooltip_ids = $this->edit_request->getTooltipIds();
2739  foreach ($this->edit_request->getTooltipTexts() as $id => $text) {
2740  $this->help->internal()->domain()->tooltips()->updateTooltip(
2741  (int) $id,
2742  $text,
2743  $tooltip_ids[(int) $id]
2744  );
2745  }
2746  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
2747  $ilCtrl->redirect($this, "showTooltipList");
2748  }
2749 
2750  public function deleteTooltips(): void
2751  {
2752  $lng = $this->lng;
2753  $ilCtrl = $this->ctrl;
2754 
2755  $ids = $this->edit_request->getIds();
2756  if (count($ids) > 0) {
2757  foreach ($ids as $id) {
2758  $this->help->internal()->domain()->tooltips()->deleteTooltip($id);
2759  }
2760  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
2761  }
2762  $ilCtrl->redirect($this, "showTooltipList");
2763  }
2764 
2768 
2769  public static function getLayoutOption(
2770  string $a_txt,
2771  string $a_var,
2772  string $a_def_option = ""
2774  global $DIC;
2775 
2776  $im_tag = "";
2777 
2778  $lng = $DIC->language();
2779 
2780  // default layout
2781  $layout = new ilRadioGroupInputGUI($a_txt, $a_var);
2782  if ($a_def_option != "") {
2783  if (is_file($im = ilUtil::getImagePath("layout_" . $a_def_option . ".png"))) {
2784  $im_tag = ilUtil::img($im, $a_def_option);
2785  }
2786  $layout->addOption(new ilRadioOption("<table><tr><td>" . $im_tag . "</td><td><strong>" .
2787  $lng->txt("cont_lm_default_layout") .
2788  "</strong>: " . $lng->txt("cont_layout_" . $a_def_option) .
2789  "</td></tr></table>", ""));
2790  }
2791  foreach (ilObjContentObject::getAvailableLayouts() as $l) {
2792  $im_tag = "";
2793  if (is_file($im = ilUtil::getImagePath("layout_" . $l . ".png"))) {
2794  $im_tag = ilUtil::img($im, $l);
2795  }
2796  $layout->addOption(new ilRadioOption("<table><tr><td style='padding: 0px 5px 5px;'>" .
2797  $im_tag . "</td><td style='padding:5px;'><strong>" . $lng->txt("cont_layout_" . $l) . "</strong>: " .
2798  $lng->txt("cont_layout_" . $l . "_desc") . "</td></tr></table>", $l));
2799  }
2800 
2801  return $layout;
2802  }
2803 
2807  public function setPageLayoutInHierarchy(): void
2808  {
2809  $ilCtrl = $this->ctrl;
2810  $ilCtrl->setParameter($this, "hierarchy", "1");
2811  $this->setPageLayout(true);
2812  }
2813 
2814 
2818  public function setPageLayout(
2819  bool $a_in_hierarchy = false
2820  ): void {
2821  $tpl = $this->tpl;
2822  $ilCtrl = $this->ctrl;
2823  $lng = $this->lng;
2824 
2825  $ids = $this->edit_request->getIds();
2826  if (count($ids) == 0) {
2827  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
2828 
2829  if ($a_in_hierarchy) {
2830  $ilCtrl->redirect($this, "chapters");
2831  } else {
2832  $ilCtrl->redirect($this, "pages");
2833  }
2834  }
2835 
2836  $this->initSetPageLayoutForm();
2837 
2838  $tpl->setContent($this->form->getHTML());
2839  }
2840 
2841  public function initSetPageLayoutForm(): void
2842  {
2843  $lng = $this->lng;
2844  $ilCtrl = $this->ctrl;
2845 
2846  $this->form = new ilPropertyFormGUI();
2847 
2848  $ids = $this->edit_request->getIds();
2849  foreach ($ids as $id) {
2850  $hi = new ilHiddenInputGUI("id[]");
2851  $hi->setValue($id);
2852  $this->form->addItem($hi);
2853  }
2854  $layout = self::getLayoutOption(
2855  $lng->txt("cont_layout"),
2856  "layout",
2857  $this->lm->getLayout()
2858  );
2859  $this->form->addItem($layout);
2860 
2861  $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
2862  $this->form->addCommandButton("pages", $lng->txt("cancel"));
2863 
2864  $this->form->setTitle($lng->txt("cont_set_layout"));
2865  $this->form->setFormAction($ilCtrl->getFormAction($this));
2866  }
2867 
2868  public function savePageLayout(): void
2869  {
2870  $lng = $this->lng;
2871  $ilCtrl = $this->ctrl;
2872 
2873  $ilCtrl->setParameter($this, "hierarchy", $this->requested_hierarchy);
2874 
2875  $ids = $this->edit_request->getIds();
2876  foreach ($ids as $id) {
2878  $id,
2879  $this->edit_request->getLayout(),
2880  $this->lm
2881  );
2882  }
2883  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
2884 
2885  if ($this->requested_hierarchy) {
2886  $ilCtrl->redirect($this, "chapters");
2887  } else {
2888  $ilCtrl->redirect($this, "pages");
2889  }
2890  }
2891 
2892  //
2893  // Auto glossaries
2894  //
2895 
2899  public function editGlossaries(): void
2900  {
2901  $tpl = $this->tpl;
2902  $ilToolbar = $this->toolbar;
2903  $lng = $this->lng;
2904  $ilCtrl = $this->ctrl;
2905  $ilTabs = $this->tabs;
2906 
2907  $this->setTabs();
2908  $ilTabs->setTabActive("settings");
2909  $this->setSubTabs("cont_glossaries");
2910 
2911  $ilToolbar->addButton(
2912  $lng->txt("add"),
2913  $ilCtrl->getLinkTarget($this, "showLMGlossarySelector")
2914  );
2915 
2916  $tab = new ilLMGlossaryTableGUI($this->lm, $this, "editGlossaries");
2917 
2918  $tpl->setContent($tab->getHTML());
2919  }
2920 
2921  public function showLMGlossarySelector(): void
2922  {
2923  $tpl = $this->tpl;
2924  $ilCtrl = $this->ctrl;
2925  $tree = $this->tree;
2926  $ilTabs = $this->tabs;
2927 
2928  $this->setTabs();
2929  $ilTabs->setTabActive("settings");
2930  $this->setSubTabs("cont_glossaries");
2931 
2932  $exp = new ilSearchRootSelector($ilCtrl->getLinkTarget($this, 'showLMGlossarySelector'));
2933  $exp->setExpand($this->requested_search_root_expand ?: $tree->readRootId());
2934  $exp->setPathOpen($this->object->getRefId());
2935  $exp->setExpandTarget($ilCtrl->getLinkTarget($this, 'showLMGlossarySelector'));
2936  $exp->setTargetClass(get_class($this));
2937  $exp->setCmd('confirmGlossarySelection');
2938  $exp->setClickableTypes(array("glo"));
2939  $exp->addFilter("glo");
2940 
2941  // build html-output
2942  $exp->setOutput(0);
2943  $tpl->setContent($exp->getOutput());
2944  }
2945 
2946  public function confirmGlossarySelection(): void
2947  {
2948  $ilCtrl = $this->ctrl;
2949  $tpl = $this->tpl;
2950  $lng = $this->lng;
2951 
2952  $cgui = new ilConfirmationGUI();
2953  $ilCtrl->setParameter($this, "glo_ref_id", $this->requested_root_id);
2954  $cgui->setFormAction($ilCtrl->getFormAction($this));
2955  $cgui->setHeaderText($lng->txt("cont_link_glo_in_lm"));
2956  $cgui->setCancel($lng->txt("no"), "selectLMGlossary");
2957  $cgui->setConfirm($lng->txt("yes"), "selectLMGlossaryLink");
2958  $tpl->setContent($cgui->getHTML());
2959  }
2960 
2961  public function selectLMGlossaryLink(): void
2962  {
2963  $glo_ref_id = $this->requested_glo_ref_id;
2964  $this->lm->autoLinkGlossaryTerms($glo_ref_id);
2965  $this->selectLMGlossary();
2966  }
2967 
2968  public function selectLMGlossary(): void
2969  {
2970  $ilCtrl = $this->ctrl;
2971  $lng = $this->lng;
2972 
2973  $glos = $this->lm->getAutoGlossaries();
2974  $glo_ref_id = $this->requested_glo_ref_id;
2975  $glo_id = ilObject::_lookupObjId($glo_ref_id);
2976  if (!in_array($glo_id, $glos)) {
2977  $glos[] = $glo_id;
2978  }
2979  $this->lm->setAutoGlossaries($glos);
2980  $this->lm->update();
2981 
2982  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
2983  $ilCtrl->redirect($this, "editGlossaries");
2984  }
2985 
2986  public function removeLMGlossary(): void
2987  {
2988  $ilCtrl = $this->ctrl;
2989  $lng = $this->lng;
2990 
2991  $this->lm->removeAutoGlossary($this->requested_glo_id);
2992  $this->lm->update();
2993 
2994  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
2995  $ilCtrl->redirect($this, "editGlossaries");
2996  }
2997 
2998  public function editMasterLanguage(): void
2999  {
3000  $ilCtrl = $this->ctrl;
3001 
3002  $ilCtrl->setParameter($this, "transl", "-");
3003  if ($this->lang_switch_mode == "short_titles") {
3004  $ilCtrl->redirectByClass("illmeditshorttitlesgui", "");
3005  }
3006  $ilCtrl->redirect($this, "chapters");
3007  }
3008 
3009  public function switchToLanguage(): void
3010  {
3011  $ilCtrl = $this->ctrl;
3012 
3013  $ilCtrl->setParameter($this, "transl", $this->requested_totransl);
3014  if ($this->lang_switch_mode == "short_titles") {
3015  $ilCtrl->redirectByClass("illmeditshorttitlesgui", "");
3016  }
3017  $ilCtrl->redirect($this, "chapters");
3018  }
3019 
3020  public function redrawHeaderAction(): void
3021  {
3022  // #12281
3023  parent::redrawHeaderActionObject();
3024  }
3025 
3029  protected function learningProgress(): void
3030  {
3031  $this->ctrl->redirectByClass(array('illearningprogressgui'), '');
3032  }
3033 }
static updateInternalLinks(array $a_copied_nodes, string $a_parent_type="lm")
Update internal links, after multiple pages have been copied.
showExportIDsOverview(bool $a_validation=false)
static get(string $a_var)
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)
static resetTries(int $a_q_id, int $a_user_id)
Reset tries for user and question.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPostMulti()
Get multi number of _POST input.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLayoutOption(string $a_txt, string $a_var, string $a_def_option="")
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
Class ilInfoScreenGUI.
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...
Import related features for learning modules.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
setPageLayoutInHierarchy()
Set layout for multiple pages.
static _writePublicAccessStatus(array $a_pages, int $a_cont_obj_id)
update public access flags in lm_data for all pages of a content object
const ANONYMOUS_USER_ID
Definition: constants.php:27
Explorer for selecting repository items.
This class represents a selection list property in a property form.
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...
moveChapter(int $a_parent_subobj_id=0)
move a single chapter (selection)
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
static _createEntry(int $a_obj_id, string $a_action, array $a_info_params=[], string $a_obj_type="", string $a_user_comment="", bool $a_update_last=false)
Creates a new history entry for an object.
static storeContentObject(string $a_type, int $a_id, string $a_action="cut")
GUI class for the workflow of copying objects.
static saveTitles(ilObjLearningModule $a_lm, array $a_titles, string $a_lang="-")
Save titles for lm objects.
const ROOT_FOLDER_ID
Definition: constants.php:32
setPageLayout(bool $a_in_hierarchy=false)
Set layout for multiple pages.
prepareOutput(bool $show_sub_objects=true)
setCloseTag(bool $a_val)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Help GUI class.
$valid
listLinks()
List all broken links.
static getInstance(ilObjLearningModule $a_content_obj, int $a_id=0, bool $a_halt=true)
activatePages()
activates or deactivates pages
static getPostNodeId()
Get node ID of _POST input.
isInTree(?int $a_node_id)
get all information of a node.
static getAvailableLayouts()
get all available lm layouts
addLocations(bool $a_omit_obj_id=false)
display locator
User Interface for Structure Objects Editing.
ilComponentRepository $component_repository
setParameterByClass(string $a_class, string $a_parameter, $a_value)
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...
deleteTree(array $a_node)
delete node and the whole subtree under this node
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions" ...
setOptions(array $a_options)
static clipboardCut(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
importFileObject(int $parent_id=null)
setOpenTag(bool $a_open)
getContextPath(int $a_endnode_id, int $a_startnode_id=1)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
getPublicAccessColValue(string $a_type, string $a_file)
Get public access value for export table.
saveAllTitles()
Save all titles of chapters/pages.
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-...
getPropertiesFormValues()
Get values for properties form.
static putInTree(ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
put this object into content object tree
$ilErr
Definition: raiseError.php:17
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
catch(\Exception $e) $req
Definition: xapiproxy.php:93
static _lookupTitle(int $a_obj_id)
global $DIC
Definition: feed.php:28
static getPostFirstChild()
Should node be inserted as first child of target node (true) or as successor (false) ...
Export User Interface Class.
const POS_FIRST_NODE
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
ilLanguage $lng
static _goto(string $a_target)
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...
selectFooter()
select page as footer
This class represents a property in a property form.
__construct(VocabulariesInterface $vocabularies)
UIFactory $ui_factory
ILIAS LearningModule ReadingTime SettingsGUI $reading_time_gui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
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.
$GLOBALS["DIC"]
Definition: wac.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static writeLayout(int $a_obj_id, string $a_layout, ?ilObjLearningModule $a_lm=null)
Write layout setting.
setFormAction(string $a_formaction)
properties()
edit properties form
copyItems()
Copy items to clipboard.
savePublicSectionAccess()
Saves lm access mode.
selectHeader()
select page as header
setScreenIdComponent(string $a_comp)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectGUI Basic methods of all Output classes.
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
insertChapterClip()
Insert Chapter from clipboard.
ilToolbarGUI $toolbar
static _lookupObjectId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjectService $object_service
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMenuEntry(?ilPropertyFormGUI $form=null)
display add menu entry form
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
setCustomRolesForSelection(array $a_roles)
Set custom roles for mapping to LTI roles.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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="")
static redirect(string $a_script)
ILIAS Style Content Service $content_style_service
$lang
Definition: xapiexit.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User Interface for Learning Module Page Objects Editing.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static unlock(int $a_q_id, int $a_user_id)
Unlock question for user.
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)
static saveExportId(int $a_lm_id, int $a_lmobj_id, string $a_exp_id, string $a_type="pg")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lm_set
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getPresentationTitle(int $a_pg_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)
presentation title doesn&#39;t have to be page title, it may be chapter title + page title or chapter tit...
global $ilSetting
Definition: privfeed.php:18
initMenuEntryForm(string $a_mode="edit")
cutItems(string $a_return="chapters")
This class represents a text area property in a property form.
ilAccessHandler $access
__construct( $a_data, int $a_id=0, bool $a_call_by_reference=true, bool $a_prepare_output=false)
static _lookupType(int $a_obj_id, int $a_lm_id=0)
initPropertiesForm()
Init properties form.
addItem(string $a_title, string $a_link, string $a_frame="", int $a_ref_id=0, ?string $type=null)
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
Class ilObjContentObjectGUI.
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
static _lookupContObjID(int $a_id)
get learning module id for lm object
savePublicSectionPages()
Saves public lm pages.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTabs()
set admin tabs
editGlossaries()
Edit automatically linked glossaries.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addHeaderAction()
Add header action menu.
ilLocatorGUI $locator
UIRenderer $ui_renderer
ilSetting $settings
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static set(string $a_var, $a_val)
Set a value.
confirmedDelete(int $a_parent_subobj_id=0)
delete page object or structure objects
editMenuEntry(?ilPropertyFormGUI $form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view...
GUI class for object translation handling.
static isOnlineHelpModule(int $a_id, bool $a_as_obj_id=false)
Is module an online module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
insertChapter()
Insert (multiple) chapters at node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static clipboardCopy(int $a_cont_obj_id, array $a_ids)
Copy a set of chapters/pages into the clipboard.
static _lookupLogin(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...