ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjWikiGUI.php
Go to the documentation of this file.
1 <?php
2 
24 
40 {
41  protected \ILIAS\Wiki\InternalDomainService $domain;
42  protected \ILIAS\Wiki\InternalGUIService $gui;
43  protected \ILIAS\Wiki\Content\GUIService $content_gui;
44  protected \ILIAS\Wiki\Navigation\ImportantPageManager $imp_pages;
45  protected \ILIAS\Wiki\Page\PageManager $pm;
47  protected \ILIAS\HTTP\Services $http;
48  protected string $requested_page;
50  protected ilTabsGUI $tabs;
51  protected ilHelpGUI $help;
52  protected ilLogger $log;
54  protected \ILIAS\DI\UIServices $ui;
55  protected bool $req_with_comments = false;
57  protected \ILIAS\Style\Content\GUIService $content_style_gui;
58  protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
59 
60  public function __construct(
61  $a_data,
62  int $a_id,
63  bool $a_call_by_reference,
64  bool $a_prepare_output = true
65  ) {
66  global $DIC;
67 
68  $gui = $DIC->wiki()->internal()->gui();
69  $domain = $DIC->wiki()->internal()->domain();
70  $this->gui = $gui;
71  $this->domain = $domain;
72 
73  $this->ctrl = $gui->ctrl();
74  $this->lng = $domain->lng();
75  $this->tabs = $gui->tabs();
76  $this->help = $gui->help();
77  $this->locator = $gui->locator();
78  $this->http = $gui->http();
79  $this->ot = $gui->wiki()->translation();
80 
81  $this->type = "wiki";
82 
83  $this->log = ilLoggerFactory::getLogger('wiki');
84 
85  $this->tool_context = $gui->globalScreen()->tool()->context();
86  $this->ui = $gui->ui();
87 
88  $this->edit_request = $gui->request();
89  $this->content_gui = $gui->content();
90 
91  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
92  $this->lng->loadLanguageModule("obj");
93  $this->lng->loadLanguageModule("wiki");
94 
95  $this->requested_page = $this->edit_request->getPage();
96  if ($this->requested_page !== "") {
97  $this->ctrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($this->requested_page));
98  }
99  $this->ctrl->saveParameterByClass(self::class, "transl");
100  $this->ctrl->saveParameterByClass(self::class, "wpg_id");
101  $this->req_with_comments = $this->edit_request->getWithComments();
102  $cs = $DIC->contentStyle();
103  $this->content_style_gui = $cs->gui();
104  if (is_object($this->object)) {
105  $this->content_style_domain = $cs->domain()->styleForRefId($this->object->getRefId());
106  $this->pm = $this->domain->page()->page($this->object->getRefId());
107  $this->imp_pages = $this->domain->importantPage($this->object->getRefId());
108  }
109  }
110 
111  public function executeCommand(): void
112  {
113  $ilCtrl = $this->ctrl;
114  $tpl = $this->tpl;
115  $ilTabs = $this->tabs;
116  $ilAccess = $this->access;
117 
118  $next_class = $this->ctrl->getNextClass($this);
119  $cmd = $this->ctrl->getCmd();
120 
121  $this->triggerAssignmentTool();
122 
123  $this->prepareOutput();
124  $this->gui->initFetch();
125 
126  // see ilWikiPageGUI::printViewOrderList()
127  // printView() cannot be in ilWikiPageGUI because of stylesheet confusion
128  if ($cmd === "printView") {
129  $next_class = null;
130  }
131 
132  switch ($next_class) {
133  case "ilinfoscreengui":
134  $this->checkPermission("visible");
135  $this->addHeaderAction();
136  $this->infoScreen(); // forwards command
137  break;
138 
139  case 'ilpermissiongui':
140  $this->addHeaderAction();
141  $ilTabs->activateTab("perm_settings");
142  $perm_gui = new ilPermissionGUI($this);
143  $this->ctrl->forwardCommand($perm_gui);
144  break;
145 
146  case 'ilsettingspermissiongui':
147  $this->checkPermission("write");
148  $this->addHeaderAction();
149  $ilTabs->activateTab("settings");
150  $this->setSettingsSubTabs("permission_settings");
151  $perm_gui = new ilSettingsPermissionGUI($this);
152  $perm_gui->setPermissions(array("edit_wiki_navigation", "add_pages", "delete_wiki_pages", "activate_wiki_protection",
153  "wiki_html_export"));
154  $perm_gui->setRoleRequiredPermissions(array("edit_content"));
155  $perm_gui->setRoleProhibitedPermissions(array("write"));
156  $this->ctrl->forwardCommand($perm_gui);
157  break;
158 
159  case 'ilobjecttranslationgui':
160  $this->checkPermission("read");
161  $this->addHeaderAction();
162  $ilTabs->activateTab("settings");
163  $this->setSettingsSubTabs("obj_multilinguality");
164  $transgui = new ilObjectTranslationGUI($this);
165  $transgui->setTitleDescrOnlyMode(false);
166  $this->ctrl->forwardCommand($transgui);
167  break;
168 
169  case 'ilwikipagegui':
170  $this->checkPermission("read");
171  $requested_page = $this->requested_page;
172  if ($this->edit_request->getWikiPageId() > 0) {
173  $requested_page = $this->pm->getTitle(
174  $this->edit_request->getWikiPageId(),
175  $this->edit_request->getTranslation()
176  );
177  }
178  $wpage_gui = $this->content_gui->getCurrentPageGUI();
179  $wpage_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
180  $this->setContentStyleSheet();
181  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()) &&
182  (
183  !$ilAccess->checkAccess("edit_content", "", $this->object->getRefId()) ||
184  $wpage_gui->getPageObject()->getBlocked()
185  )) {
186  $wpage_gui->setEnableEditing(false);
187  }
188 
189  // alter title and description
190  // $tpl->setTitle($wpage_gui->getPageObject()->getTitle());
191  // $tpl->setDescription($this->object->getTitle());
192  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
193  $wpage_gui->activateMetaDataEditor($this->object, "wpg", $wpage_gui->getId());
194  }
195 
196  $ret = $this->ctrl->forwardCommand($wpage_gui);
197  if ($ret != "") {
198  $tpl->setContent($ret);
199  }
200  break;
201 
202  case 'ilobjectcopygui':
203  $cp = new ilObjectCopyGUI($this);
204  $cp->setType('wiki');
205  $this->ctrl->forwardCommand($cp);
206  break;
207 
208  case 'ilpublicuserprofilegui':
209  $profile_gui = new ilPublicUserProfileGUI(
210  $this->edit_request->getUserId()
211  );
212  $ret = $this->ctrl->forwardCommand($profile_gui);
213  $tpl->setContent($ret);
214  break;
215 
216  case "ilobjectcontentstylesettingsgui":
217  $this->checkPermission("write");
218  $this->addHeaderAction();
219  $ilTabs->activateTab("settings");
220  $this->setSettingsSubTabs("style");
221 
222  $settings_gui = $this->content_style_gui
223  ->objectSettingsGUIForRefId(
224  null,
225  $this->object->getRefId()
226  );
227  $this->ctrl->forwardCommand($settings_gui);
228  break;
229 
230  case "ilexportgui":
231  $this->addHeaderAction();
232  $ilTabs->activateTab("export");
233  $exp_gui = new ilExportGUI($this);
234  $this->ctrl->forwardCommand($exp_gui);
235  break;
236 
237  case "ilcommonactiondispatchergui":
239  $this->ctrl->forwardCommand($gui);
240  break;
241 
242  case "ilratinggui":
243  // for rating category editing
244  $this->checkPermission("write");
245  $this->addHeaderAction();
246  $ilTabs->activateTab("settings");
247  $this->setSettingsSubTabs("rating_categories");
248  $gui = new ilRatingGUI();
249  $gui->setObject($this->object->getId(), $this->object->getType());
250  $gui->setExportCallback(array($this, "getSubObjectTitle"), $this->lng->txt("page"));
251  $this->ctrl->forwardCommand($gui);
252  break;
253 
254  case "ilwikistatgui":
255  $this->checkPermission("statistics_read");
256 
257  $this->addHeaderAction();
258  $ilTabs->activateTab("statistics");
259  $gui = new ilWikiStatGUI($this->object->getId());
260  $this->ctrl->forwardCommand($gui);
261  break;
262 
263  case "ilwikipagetemplategui":
264  $this->checkPermission("write");
265  $this->addHeaderAction();
266  $ilTabs->activateTab("settings");
267  $this->setSettingsSubTabs("page_templates");
268  $wptgui = new ilWikiPageTemplateGUI($this);
269  $this->ctrl->forwardCommand($wptgui);
270  break;
271 
272  case 'ilobjectmetadatagui':
273  $this->checkPermission("write");
274  $this->addHeaderAction();
275  $ilTabs->activateTab("advmd");
276  $md_gui = new ilObjectMetaDataGUI($this->object, "wpg");
277  $this->ctrl->forwardCommand($md_gui);
278  break;
279 
280  case 'ilrepositoryobjectsearchgui':
281  $this->addHeaderAction();
282  $this->setSideBlock();
283  $ilTabs->setTabActive("wiki_search_results");
284  $ilCtrl->setReturn($this, 'view');
285  $ilCtrl->setParameterByClass(ilWikiPageGUI::class, "wpg_id", null);
286  $ilCtrl->setParameterByClass(ilObjWikiGUI::class, "wpg_id", null);
287  $search_gui = new ilRepositoryObjectSearchGUI(
288  $this->object->getRefId(),
289  $this,
290  'view'
291  );
292  $ilCtrl->forwardCommand($search_gui);
293  break;
294 
295  case 'ilobjnotificationsettingsgui':
296  $this->addHeaderAction();
297  $ilTabs->activateTab("settings");
298  $this->setSettingsSubTabs("notifications");
299  $gui = new ilObjNotificationSettingsGUI($this->object->getRefId());
300  $this->ctrl->forwardCommand($gui);
301  break;
302 
303  case 'illtiproviderobjectsettinggui':
304  $this->addHeaderAction();
305  $ilTabs->activateTab("settings");
306  $this->setSettingsSubTabs("lti_provider");
307  $lti_gui = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
308  $lti_gui->setCustomRolesForSelection($GLOBALS['DIC']->rbac()->review()->getLocalRoles($this->object->getRefId()));
309  $lti_gui->offerLTIRolesForSelection(false);
310  $this->ctrl->forwardCommand($lti_gui);
311  break;
312 
313  case strtolower(SettingsGUI::class):
314  $this->addHeaderAction();
315  $ilTabs->activateTab("settings");
316  $this->setSettingsSubTabs("general_settings");
317  $this->getTabs();
318  $gui = $this->gui->settings()->settingsGUI(
319  $this->object->getId(),
320  $this->object->getRefId()
321  );
322  $this->ctrl->forwardCommand($gui);
323  break;
324 
325  default:
326  $this->addHeaderAction();
327  if (!$cmd) {
328  $cmd = "infoScreen";
329  }
330  $cmd .= "Object";
331  if ($cmd !== "cancelObject") {
332  if ($cmd !== "infoScreenObject") {
333  if (!in_array($cmd, array("createObject", "saveObject", "routeImportCmdObject"))) {
334  $this->checkPermission("read");
335  }
336  } else {
337  $this->checkPermission("visible");
338  }
339  }
340  $this->$cmd();
341  break;
342  }
343  }
344 
345  public function viewObject(): void
346  {
347  $this->checkPermission("read");
348  $this->gotoStartPageObject();
349  }
350 
351  protected function initCreateForm(string $new_type): StandardForm
352  {
353  $f = $this->gui->ui()->factory();
354  $lng = $this->lng;
355  $form = parent::initCreateForm($new_type);
356  $inputs = $form->getInputs();
357  $inputs["start_page"] = $f->input()->field()->text(
358  $lng->txt("wiki_start_page")
359  )->withRequired(true);
360  return $this->ui_factory->input()->container()->form()->standard(
361  $this->ctrl->getFormAction($this, 'save'),
362  $inputs
363  )->withSubmitLabel($this->lng->txt($new_type . '_add'));
364  }
365 
366  protected function afterSave(ilObject $new_object): void
367  {
368  $form = $this
369  ->initCreateForm($this->requested_new_type)
370  ->withRequest($this->request);
371  $data = $form->getData();
372  $new_object->setStartPage($data["start_page"]);
373  $new_object->update();
374 
375  // always send a message
376  $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
377  $this->ctrl->setParameterByClass(
378  static::class,
379  "ref_id",
380  $new_object->getRefId()
381  );
382  $this->ctrl->redirectByClass([
383  ilWikiHandlerGUI::class,
384  ilObjWikiGUI::class,
385  SettingsGUI::class
386  ]);
387  }
388 
394  public function infoScreenObject(): void
395  {
396  $this->checkPermission("visible");
397  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
398  }
399 
400  public function infoScreen(): void
401  {
402  $ilAccess = $this->access;
403  $ilUser = $this->user;
404  $ilTabs = $this->tabs;
405  $lng = $this->lng;
406 
407  $ilTabs->activateTab("info_short");
408 
409  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId())) {
410  throw new ilPermissionException($this->lng->txt("permission_denied"));
411  }
412 
413  $info = new ilInfoScreenGUI($this);
414  $info->enablePrivateNotes();
415  if (trim($this->object->getIntroduction()) !== "") {
416  $info->addSection($lng->txt("wiki_introduction"));
417  $info->addProperty("", nl2br($this->object->getIntroduction()));
418  }
419 
420  // feedback from tutor; mark, status, comment
421  $lpcomment = ilLPMarks::_lookupComment($ilUser->getId(), $this->object->getId());
422  $mark = ilLPMarks::_lookupMark($ilUser->getId(), $this->object->getId());
423  $status = ilWikiContributor::_lookupStatus($this->object->getId(), $ilUser->getId());
424  if ($lpcomment !== "" || $mark !== "" || (int) $status !== ilWikiContributor::STATUS_NOT_GRADED) {
425  $info->addSection($this->lng->txt("wiki_feedback_from_tutor"));
426  if ($lpcomment !== "") {
427  $info->addProperty(
428  $this->lng->txt("wiki_comment"),
429  $lpcomment
430  );
431  }
432  if ($mark !== "") {
433  $info->addProperty(
434  $this->lng->txt("wiki_mark"),
435  $mark
436  );
437  }
438 
439  if ((int) $status === ilWikiContributor::STATUS_PASSED) {
440  $info->addProperty(
441  $this->lng->txt("status"),
442  $this->lng->txt("wiki_passed")
443  );
444  }
445  if ((int) $status === ilWikiContributor::STATUS_FAILED) {
446  $info->addProperty(
447  $this->lng->txt("status"),
448  $this->lng->txt("wiki_failed")
449  );
450  }
451  }
452 
453  if ($ilAccess->checkAccess("read", "", $this->object->getRefId())) {
454  $info->addButton($lng->txt("wiki_start_page"), self::getGotoLink($this->object->getRefId()));
455  }
456 
457  // general information
458  $this->lng->loadLanguageModule("meta");
459  $this->lng->loadLanguageModule("wiki");
460 
461  // forward the command
462  $this->ctrl->forwardCommand($info);
463  }
464 
465  public function gotoStartPageObject(): void
466  {
467  ilUtil::redirect(self::getGotoLink($this->object->getRefId()));
468  }
469 
470  public function addPageTabs(): void
471  {
472  $ilTabs = $this->tabs;
473  $ilCtrl = $this->ctrl;
474 
475  $ilCtrl->setParameter(
476  $this,
477  "wpg_id",
478  ilWikiPage::getPageIdForTitle($this->object->getId(), ilWikiUtil::makeDbTitle($this->requested_page))
479  );
480  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($this->requested_page));
481  $ilTabs->addTarget(
482  "wiki_what_links_here",
483  $this->ctrl->getLinkTargetByClass(
484  "ilwikipagegui",
485  "whatLinksHere"
486  ),
487  "whatLinksHere"
488  );
489  $ilTabs->addTarget(
490  "wiki_print_view",
491  $this->ctrl->getLinkTargetByClass(
492  "ilwikipagegui",
493  "printViewSelection"
494  ),
495  "printViewSelection"
496  );
497  }
498 
499  public function addPagesSubTabs(): void
500  {
501  $ilTabs = $this->tabs;
502  $ilCtrl = $this->ctrl;
503 
504  $ilTabs->activateTab("wiki_pages");
505 
506  $ilCtrl->setParameter(
507  $this,
508  "wpg_id",
510  $this->object->getId(),
511  ilWikiUtil::makeDbTitle($this->requested_page)
512  )
513  );
514  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($this->requested_page));
515  $ilTabs->addSubTabTarget(
516  "wiki_all_pages",
517  $this->ctrl->getLinkTarget($this, "allPages"),
518  "allPages"
519  );
520  $ilTabs->addSubTabTarget(
521  "wiki_recent_changes",
522  $this->ctrl->getLinkTarget($this, "recentChanges"),
523  "recentChanges"
524  );
525  $ilTabs->addSubTabTarget(
526  "wiki_new_pages",
527  $this->ctrl->getLinkTarget($this, "newPages"),
528  "newPages"
529  );
530  $ilTabs->addSubTabTarget(
531  "wiki_popular_pages",
532  $this->ctrl->getLinkTarget($this, "popularPages"),
533  "popularPages"
534  );
535  $ilTabs->addSubTabTarget(
536  "wiki_orphaned_pages",
537  $this->ctrl->getLinkTarget($this, "orphanedPages"),
538  "orphanedPages"
539  );
540  }
541 
542  protected function getTabs(): void
543  {
544  $ilCtrl = $this->ctrl;
545  $ilAccess = $this->access;
546  $lng = $this->lng;
547  $ilHelp = $this->help;
548 
549  $ilHelp->setScreenIdComponent("wiki");
550 
551 
552  // wiki tabs
553  if (in_array(strtolower($ilCtrl->getNextClass($this)), [strtolower(SettingsGUI::class)]) ||
554  in_array(
555  strtolower($ilCtrl->getCmdClass()),
556  array("", "ilobjectcontentstylesettingsgui", "ilobjwikigui",
557  "ilinfoscreengui", "ilpermissiongui", "ilexportgui", "ilratingcategorygui", "ilobjnotificationsettingsgui", "iltaxmdgui",
558  "ilwikistatgui", "ilwikipagetemplategui", "iladvancedmdsettingsgui", "ilsettingspermissiongui", 'ilrepositoryobjectsearchgui',
559  'ilobjecttranslationgui')
560  ) || $ilCtrl->getNextClass() === "ilpermissiongui") {
561  if ($this->requested_page !== "") {
562  $page_id = ($this->edit_request->getWikiPageId() > 0)
563  ? $this->edit_request->getWikiPageId()
564  : $this->pm->getPageIdForTitle(
565  $this->requested_page,
566  $this->edit_request->getTranslation()
567  );
568  if (is_null($page_id) && $this->edit_request->getFromPage() !== "") {
569  $page_id = $this->pm->getPageIdForTitle(
570  $this->edit_request->getFromPage(),
571  $this->edit_request->getTranslation()
572  );
573  }
574  if (!is_null($page_id)) {
575  $this->tabs_gui->setBackTarget(
576  $lng->txt("wiki_last_visited_page"),
577  $this->pm->getPermaLink(
578  $page_id,
579  $this->edit_request->getTranslation()
580  )
581  );
582  }
583  }
584 
585  // pages
586  if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
587  $this->tabs_gui->addTab(
588  "wiki_pages",
589  $lng->txt("wiki_pages"),
590  $this->ctrl->getLinkTarget($this, "allPages")
591  );
592  }
593 
594  // info screen
595  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId())) {
596  $this->tabs_gui->addTab(
597  "info_short",
598  $lng->txt("info_short"),
599  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
600  );
601  }
602 
603  // settings
604  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
605  $this->tabs_gui->addTab(
606  "settings",
607  $lng->txt("settings"),
608  $this->ctrl->getLinkTargetByClass(SettingsGUI::class)
609  );
610 
611  // metadata
612  $mdgui = new ilObjectMetaDataGUI($this->object, "wpg");
613  $mdtab = $mdgui->getTab();
614  if ($mdtab) {
615  $this->tabs_gui->addTab(
616  "advmd",
617  $this->lng->txt("meta_data"),
618  $mdtab
619  );
620  }
621  }
622 
623  // contributors
624  if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
625  $this->tabs_gui->addTab(
626  "wiki_contributors",
627  $lng->txt("wiki_contributors"),
628  $this->ctrl->getLinkTarget($this, "listContributors")
629  );
630  }
631 
632  // statistics
633  if ($ilAccess->checkAccess('statistics_read', "", $this->object->getRefId())) {
634  $this->tabs_gui->addTab(
635  "statistics",
636  $lng->txt("statistics"),
637  $this->ctrl->getLinkTargetByClass("ilWikiStatGUI", "initial")
638  );
639  }
640 
641  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
642  $this->tabs_gui->addTab(
643  "export",
644  $lng->txt("export"),
645  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
646  );
647  }
648 
649  // edit permissions
650  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
651  $this->tabs_gui->addTab(
652  "perm_settings",
653  $lng->txt("perm_settings"),
654  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
655  );
656  }
657  }
658  }
659 
660  public function setSettingsSubTabs(string $a_active): void
661  {
662  $ilTabs = $this->tabs;
663  $ilCtrl = $this->ctrl;
664  $lng = $this->lng;
665  $ilAccess = $this->access;
666  if (in_array(
667  $a_active,
668  array("general_settings", "style", "imp_pages", "rating_categories", "obj_multilinguality",
669  "page_templates", "advmd", "permission_settings", "notifications", "lti_provider")
670  )) {
671  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
672  // general properties
673  $ilTabs->addSubTab(
674  "general_settings",
675  $lng->txt("wiki_general_settings"),
676  $ilCtrl->getLinkTarget($this, 'editSettings')
677  );
678 
679  // permission settings
680  $ilTabs->addSubTab(
681  "permission_settings",
682  $lng->txt("obj_permission_settings"),
683  $this->ctrl->getLinkTargetByClass("ilsettingspermissiongui", "")
684  );
685 
686  // style properties
687  $ilTabs->addSubTab(
688  "style",
689  $lng->txt("wiki_style"),
690  $ilCtrl->getLinkTargetByClass("ilObjectContentStyleSettingsGUI", "")
691  );
692  }
693 
694  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
695  // important pages
696  $ilTabs->addSubTab(
697  "imp_pages",
698  $lng->txt("wiki_navigation"),
699  $ilCtrl->getLinkTarget($this, 'editImportantPages')
700  );
701  }
702 
703  if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
704  // page templates
705  $ilTabs->addSubTab(
706  "page_templates",
707  $lng->txt("wiki_page_templates"),
708  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "")
709  );
710 
711  // rating categories
712  if ($this->object->getRatingPages() && $this->object->getRatingCategories()) {
713  $lng->loadLanguageModule("rating");
714  $ilTabs->addSubTab(
715  "rating_categories",
716  $lng->txt("rating_categories"),
717  $ilCtrl->getLinkTargetByClass(array('ilratinggui', 'ilratingcategorygui'), '')
718  );
719  }
720 
721  $ilTabs->addSubTab(
722  'notifications',
723  $lng->txt("notifications"),
724  $ilCtrl->getLinkTargetByClass("ilobjnotificationsettingsgui", '')
725  );
726 
727  $ilTabs->addSubTab(
728  'obj_multilinguality',
729  $lng->txt("obj_multilinguality"),
730  $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
731  );
732  }
733 
734  // LTI Provider
735  $lti_settings = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
736  if ($lti_settings->hasSettingsAccess()) {
737  $ilTabs->addSubTabTarget(
738  'lti_provider',
739  $this->ctrl->getLinkTargetByClass(ilLTIProviderObjectSettingGUI::class)
740  );
741  }
742 
743  $ilTabs->activateSubTab($a_active);
744  }
745  }
746 
747  public function editSettingsObject(): void
748  {
749  $this->ctrl->redirectByClass(SettingsGUI::class);
750  }
751 
752  public function listContributorsObject(): void
753  {
754  $tpl = $this->tpl;
755  $ilTabs = $this->tabs;
756 
757  $this->checkPermission("write");
758  $ilTabs->activateTab("wiki_contributors");
759 
760  $table_gui = new ilWikiContributorsTableGUI(
761  $this,
762  "listContributors",
763  $this->object->getId()
764  );
765 
766  $tpl->setContent($table_gui->getHTML());
767 
768  $this->setSideBlock();
769  }
770 
771  public function saveGradingObject(): void
772  {
773  $ilCtrl = $this->ctrl;
774  $lng = $this->lng;
775 
776  $this->checkPermission("write");
777 
778  $users = $this->edit_request->getUserIds();
779  $marks = $this->edit_request->getMarks();
780  $comments = $this->edit_request->getComments();
781  $status = $this->edit_request->getStatus();
782 
783  $saved = false;
784  foreach ($users as $user_id) {
785  if ($user_id != "") {
786  $marks_obj = new ilLPMarks($this->object->getId(), $user_id);
787  $new_mark = ilUtil::stripSlashes($marks[$user_id]);
788  $new_comment = ilUtil::stripSlashes($comments[$user_id] ?? "");
789  $new_status = ilUtil::stripSlashes($status[$user_id]);
790 
791  if ($marks_obj->getMark() !== $new_mark ||
792  $marks_obj->getComment() !== $new_comment ||
793  (int) ilWikiContributor::_lookupStatus($this->object->getId(), $user_id) !== (int) $new_status) {
794  ilWikiContributor::_writeStatus($this->object->getId(), $user_id, $new_status);
795  $marks_obj->setMark($new_mark);
796  $marks_obj->setComment($new_comment);
797  $marks_obj->update();
798  $saved = true;
799  }
800  }
801  }
802  if ($saved) {
803  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
804  }
805 
806  $ilCtrl->redirect($this, "listContributors");
807  }
808 
809  // add wiki to locator
810  protected function addLocatorItems(): void
811  {
812  $ilLocator = $this->locator;
813 
814  if (is_object($this->object)) {
815  $ilLocator->addItem(
816  $this->object->getTitle(),
817  self::getGotoLink($this->object->getRefId()),
818  "",
819  $this->requested_ref_id
820  );
821  }
822  }
823 
824  public static function _goto(string $a_target): void
825  {
826  global $DIC;
827  $main_tpl = $DIC->ui()->mainTemplate();
828 
829  $wpg_id = 0;
830  $lang = "";
831  $ilAccess = $DIC->access();
832  $lng = $DIC->language();
833  $ctrl = $DIC->ctrl();
834  $transl = $DIC->wiki()->internal()->gui()->request()->getTranslation();
835  $DIC->ctrl()->setParameterByClass(self::class, "transl", $transl);
836 
837 
838  $i = strpos($a_target, "_");
839  $a_page = "";
840  if ($i > 0) {
841  $a_page = substr($a_target, $i + 1);
842  $a_target = substr($a_target, 0, $i);
843  }
844 
845  if ($a_target === "wpage") {
846  $a_page_arr = explode("_", $a_page);
847  $wpg_id = (int) $a_page_arr[0];
848  $ref_id = (int) ($a_page_arr[1] ?? 0);
849  $lang = ($a_page_arr[2] ?? "");
850  $w_id = ilWikiPage::lookupWikiId($wpg_id);
851  if ($ref_id > 0) {
852  $refs = array($ref_id);
853  } else {
854  $refs = ilObject::_getAllReferences($w_id);
855  }
856  foreach ($refs as $r) {
857  if ($ilAccess->checkAccess("read", "", $r)) {
858  $a_target = $r;
859  $a_page = ilWikiPage::lookupTitle($wpg_id);
860  }
861  }
862  }
863 
864  if ($ilAccess->checkAccess("read", "", $a_target)) {
865  if ($wpg_id > 0) {
867  "ilobjwikigui",
868  "wpg_id",
869  $wpg_id
870  );
871  } else {
873  "ilobjwikigui",
874  "page",
875  ilWikiUtil::makeUrlTitle($a_page)
876  );
877  }
878  if ($lang != "") {
880  "ilobjwikigui",
881  "transl",
882  $lang
883  );
884  }
886  "ilwikihandlergui",
887  "ref_id",
888  $a_target
889  );
890  if ($a_page != "") {
892  ["ilwikihandlergui", "ilobjwikigui"],
893  "viewPage"
894  );
895  } else {
897  ["ilwikihandlergui"],
898  "view"
899  );
900  }
901  } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
902  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
903  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
904  $main_tpl->setOnScreenMessage('failure', sprintf(
905  $lng->txt("msg_no_perm_read_item"),
907  ), true);
909  }
910 
911  throw new ilPermissionException($lng->txt("permission_denied"));
912  }
913 
914  public static function getGotoLink(
915  int $a_ref_id,
916  string $a_page = "",
917  string $lang = "-"
918  ): string {
919  if ($a_page === "") {
921  }
922 
923  $append = (!in_array($lang, ["", "-"]))
924  ? "&transl=" . $lang
925  : "";
926  $goto = "goto.php?target=wiki_" . $a_ref_id . "_" .
927  ilWikiUtil::makeUrlTitle($a_page) . $append;
928  return $goto;
929  }
930 
931  public function viewPageObject(): void
932  {
933  $lng = $this->lng;
934  $ilCtrl = $this->ctrl;
935  $tpl = $this->tpl;
936  $ilTabs = $this->tabs;
937  $ilAccess = $this->access;
938 
939  $this->checkPermission("read");
940 
941  $ilTabs->clearTargets();
943 
944  $wpage_gui = $this->gui->content()->getCurrentPageGUI();
945 
946  // page exists, show it !
947  $ilCtrl->setParameter(
948  $this,
949  "page",
950  ilWikiUtil::makeUrlTitle($wpage_gui->getPageObject()->getTitle())
951  );
952 
953  $wpage_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
954 
955  $this->setContentStyleSheet();
956 
957  //$wpage_gui->setSideBlock();
958  $ilCtrl->redirectByClass(ilWikiPageGUI::class, "preview");
959  }
960 
961  public function allPagesObject(): void
962  {
963  $tpl = $this->tpl;
964 
965  $this->checkPermission("read");
966 
967  $this->addPagesSubTabs();
968 
969  $table_gui = new ilWikiPagesTableGUI(
970  $this,
971  "allPages",
972  $this->object->getId(),
974  );
975 
976  //$this->setSideBlock();
977  $tpl->setContent($table_gui->getHTML());
978  }
979 
983  public function popularPagesObject(): void
984  {
985  $tpl = $this->tpl;
986 
987  $this->checkPermission("read");
988 
989  $this->addPagesSubTabs();
990 
991  $table_gui = new ilWikiPagesTableGUI(
992  $this,
993  "popularPages",
994  $this->object->getId(),
996  );
997 
998  //$this->setSideBlock();
999  $tpl->setContent($table_gui->getHTML());
1000  }
1001 
1005  public function orphanedPagesObject(): void
1006  {
1007  $tpl = $this->tpl;
1008 
1009  $this->checkPermission("read");
1010 
1011  $this->addPagesSubTabs();
1012 
1013  $table_gui = new ilWikiPagesTableGUI(
1014  $this,
1015  "orphanedPages",
1016  $this->object->getId(),
1018  );
1019 
1020  //$this->setSideBlock();
1021  $tpl->setContent($table_gui->getHTML());
1022  }
1023 
1027  public function gotoPageObject(
1028  string $a_page = ""
1029  ): void {
1030  $ilCtrl = $this->ctrl;
1031 
1032  if ($a_page === "") {
1033  $a_page = $this->requested_page;
1034  }
1035 
1036  if ($this->pm->existsByTitle(
1037  ilWikiUtil::makeDbTitle($a_page),
1038  $this->edit_request->getTranslation()
1039  )) {
1040  // to do: get rid of this redirect
1041  ilUtil::redirect(self::getGotoLink($this->object->getRefId(), $a_page, $this->edit_request->getTranslation()));
1042  } else {
1043  if (!$this->access->checkAccess("add_pages", "", $this->object->getRefId())) {
1044  $this->tpl->setOnScreenMessage("failure", $this->lng->txt("no_permission"), true);
1045  $from_page_id = $this->pm->getPageIdForTitle($this->edit_request->getFromPage(), $this->edit_request->getTranslation());
1046  ilUtil::redirect($this->pm->getPermaLink($from_page_id, $this->edit_request->getTranslation()));
1047  }
1048  if ($this->isNewTranslatedPage()) {
1049  return;
1050  }
1051  if (!$this->object->getTemplateSelectionOnCreation()) {
1052  // check length
1053  if (ilStr::strLen(ilWikiUtil::makeDbTitle($a_page)) > 200) {
1054  $this->tpl->setOnScreenMessage(
1055  'failure',
1056  $this->lng->txt("wiki_page_title_too_long") . " (" . $a_page . ")",
1057  true
1058  );
1059  $ilCtrl->setParameterByClass(
1060  "ilwikipagegui",
1061  "page",
1062  ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1063  );
1064  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1065  }
1066 
1067  $this->pm->createWikiPage(
1068  $a_page,
1069  0,
1070  $this->edit_request->getTranslation()
1071  );
1072 
1073  // redirect to newly created page
1074  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1075  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1076  } else {
1077  $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($this->requested_page));
1078  $ilCtrl->setParameter(
1079  $this,
1080  "from_page",
1081  ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1082  );
1083  $ilCtrl->redirect($this, "showTemplateSelection");
1084  }
1085  }
1086  }
1087 
1088  protected function isNewTranslatedPage(): bool
1089  {
1090  if (in_array($this->edit_request->getTranslation(), ["-", ""])) {
1091  return false;
1092  }
1093  $page = $this->requested_page;
1095  $this->object->getId(),
1096  ilWikiUtil::makeDbTitle($page),
1097  $this->edit_request->getTranslation()
1098  )) {
1099  $this->tabs_gui->clearTargets();
1100  $this->tabs_gui->setBackTarget(
1101  $this->lng->txt("back"),
1102  $this->pm->getPermaLink(
1103  $this->pm->getPageIdForTitle(
1104  $this->edit_request->getFromPage(),
1105  $this->edit_request->getTranslation()
1106  ),
1107  $this->edit_request->getTranslation()
1108  )
1109  );
1110  $form = $this->getNewTranslatedPageForm();
1111  $this->tpl->setContent($this->getRenderedTranslationInfo() . $form->render());
1112  return true;
1113  }
1114  return false;
1115  }
1116 
1117  protected function getRenderedTranslationInfo()
1118  {
1119  $mess = $this->gui->ui()->factory()->messageBox()->info(
1120  $this->lng->txt("wiki_translate_page_master_info")
1121  );
1122  return $this->gui->ui()->renderer()->render($mess);
1123  }
1124 
1125  protected function getNewTranslatedPageForm(): \ILIAS\Repository\Form\FormAdapterGUI
1126  {
1127  $pm = $this->domain->page()->page($this->object->getRefId());
1128  $options = [];
1129  foreach ($pm->getMasterPagesWithoutTranslation($this->edit_request->getTranslation()) as $page) {
1130  $options[$page->getId()] = $page->getTitle();
1131  }
1132  $append = " '" . $this->edit_request->getPage() . "'";
1133  $append .= " (" . $this->lng->txt("meta_l_" . $this->edit_request->getTranslation()) . ")";
1134  $append2 = " (" . $this->lng->txt("meta_l_" . $this->ot->getMasterLanguage()) . ")";
1135  $form = $this->gui->form([self::class], "createNewTranslatedPage")
1136  ->section("sec", $this->lng->txt("wiki_translation_page") . $append)
1137  ->switch("type", $this->lng->txt("wiki_page_in_master_language") . $append2, "", "existing")
1138  ->group("existing", $this->lng->txt("wiki_master_existing"))
1139  ->select("master_id", $this->lng->txt("wiki_master_title"), $options)
1140  ->required()
1141  ->group("new", $this->lng->txt("wiki_no_master"))
1142  ->text("master_title", $this->lng->txt("wiki_master_title"))
1143  ->end();
1144 
1145  if ($this->object->getTemplateSelectionOnCreation($this->edit_request->getTranslation())) {
1146  $form = $form->radio("page_templ", $this->lng->txt("wiki_page_template"), "", "0")->required();
1147  if ($this->object->getEmptyPageTemplate()) {
1148  $form = $form->radioOption("0", $this->lng->txt("wiki_empty_page"));
1149  }
1150  $wt = new ilWikiPageTemplate($this->object->getId());
1151  $ts = $wt->getAllInfo(ilWikiPageTemplate::TYPE_NEW_PAGES, $this->edit_request->getTranslation());
1152  foreach ($ts as $t) {
1153  $form = $form->radioOption($t["wpage_id"], $t["title"]);
1154  }
1155  }
1156 
1157  return $form;
1158  }
1159 
1160  protected function createNewTranslatedPageObject(): void
1161  {
1162  $form = $this->getNewTranslatedPageForm();
1163  if ($form->isValid()) {
1164  $page_template_id = 0;
1165  if ($this->object->getTemplateSelectionOnCreation($this->edit_request->getTranslation())) {
1166  $page_template_id = (int) $form->getData("page_templ");
1167  }
1168  if ($form->getData("type") === "new") {
1169  $wpg_id = $this->pm->createWikiPage(
1170  $form->getData("master_title")
1171  );
1172  } else {
1173  $wpg_id = $form->getData("master_id");
1174  }
1175  $wpg_id = $this->pm->createWikiPage(
1176  $this->edit_request->getPage(),
1177  $wpg_id,
1178  $this->edit_request->getTranslation(),
1179  $page_template_id
1180  );
1181  }
1182  $this->ctrl->setParameterByClass(ilWikiPageGUI::class, "wpg_id", $wpg_id);
1183  $this->ctrl->redirectByClass(ilWikiPageGUI::class, "preview");
1184  }
1185 
1186  public function randomPageObject(): void
1187  {
1188  $this->checkPermission("read");
1189 
1190  $page = ilWikiPage::getRandomPage($this->object->getId());
1191  $this->gotoPageObject($page);
1192  }
1193 
1194  public function recentChangesObject(): void
1195  {
1196  $tpl = $this->tpl;
1197 
1198  $this->checkPermission("read");
1199 
1200  $this->addPagesSubTabs();
1201 
1202  $table_gui = new ilWikiRecentChangesTableGUI(
1203  $this,
1204  "recentChanges",
1205  $this->object->getId()
1206  );
1207 
1208  //$this->setSideBlock();
1209  $tpl->setContent($table_gui->getHTML());
1210  }
1211 
1212  public function setSideBlock(int $a_wpg_id = 0): void
1213  {
1214  self::renderSideBlock($a_wpg_id, $this->object->getRefId());
1215  }
1216 
1217  public static function renderSideBlock(
1218  int $a_wpg_id,
1219  int $a_wiki_ref_id,
1220  ?ilWikiPage $a_wp = null
1221  ): void {
1222  global $DIC;
1223 
1224  $tpl = $DIC["tpl"];
1225  $lng = $DIC->language();
1226  $ilAccess = $DIC->access();
1227  $ilCtrl = $DIC->ctrl();
1228 
1229  $debug = false;
1230  if ($debug) {
1231  $tpl->addJavaScript("../components/ILIAS/Wiki/resources/WikiPres.js");
1232  } else {
1233  $tpl->addJavaScript("assets/js/WikiPres.js");
1234  }
1235 
1236  // setting asynch to false fixes #0019457, since otherwise ilBlockGUI would act on asynch and output html when side blocks
1237  // being processed during the export. This is a flaw in ilCtrl and/or ilBlockGUI.
1238  $tpl->addOnLoadCode("il.Wiki.Pres.init('" . $ilCtrl->getLinkTargetByClass("ilobjwikigui", "", "", false, false) . "');");
1239 
1240  if ($a_wpg_id > 0 && !$a_wp) {
1241  $a_wp = new ilWikiPage($a_wpg_id);
1242  }
1243 
1244  // search block
1245  $rcontent = ilRepositoryObjectSearchGUI::getSearchBlockHTML($lng->txt('wiki_search'));
1246 
1247 
1248  // quick navigation
1249  if ($a_wpg_id > 0) {
1250  // rating
1251  $wiki_id = ilObject::_lookupObjId($a_wiki_ref_id);
1252  if (ilObjWiki::_lookupRating($wiki_id) &&
1253  // ilObjWiki::_lookupRatingAsBlock($wiki_id) &&
1254  $a_wp->getRating()) {
1255  $rgui = new ilRatingGUI();
1256  $rgui->setObject($wiki_id, "wiki", $a_wpg_id, "wpg");
1257  $rgui->enableCategories(ilObjWiki::_lookupRatingCategories($wiki_id));
1258  $rgui->setYourRatingText("#");
1259  $rcontent .= $rgui->getBlockHTML($lng->txt("wiki_rate_page"));
1260  }
1261 
1262  // advanced metadata
1263  if (!ilWikiPage::lookupAdvancedMetadataHidden($a_wpg_id)) {
1264  $cmd = null;
1265  if ($ilAccess->checkAccess("write", "", $a_wiki_ref_id) ||
1266  $ilAccess->checkAccess("edit_page_meta", "", $a_wiki_ref_id)) {
1267  $cmd = array(
1268  "edit" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "editAdvancedMetaData"),
1269  "hide" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "hideAdvancedMetaData")
1270  );
1271  }
1272  $wiki = new ilObjWiki($a_wiki_ref_id);
1273  $callback = $wiki->getLinkMetadataValues()
1274  ? array($wiki, "decorateAdvMDValue")
1275  : null;
1276  $mdgui = new ilObjectMetaDataGUI($wiki, "wpg", $a_wpg_id);
1277  $rcontent .= $mdgui->getBlockHTML($cmd, $callback); // #17291
1278  }
1279  }
1280 
1281  // important pages
1282  $imp_pages_block = new ilWikiImportantPagesBlockGUI();
1283  $rcontent .= $imp_pages_block->getHTML();
1284 
1285  // wiki functions block
1286  if ($a_wpg_id > 0) {
1287  $wiki_functions_block = new ilWikiFunctionsBlockGUI();
1288  $wiki_functions_block->setPageObject($a_wp);
1289  $rcontent .= $wiki_functions_block->getHTML();
1290  }
1291 
1292  $tpl->setRightContent($rcontent);
1293  }
1294 
1295  public function newPagesObject(): void
1296  {
1297  $tpl = $this->tpl;
1298 
1299  $this->checkPermission("read");
1300 
1301  $this->addPagesSubTabs();
1302 
1303  $table_gui = new ilWikiPagesTableGUI(
1304  $this,
1305  "newPages",
1306  $this->object->getId(),
1308  );
1309 
1310  //$this->setSideBlock();
1311  $tpl->setContent($table_gui->getHTML());
1312  }
1313 
1314  protected function getPrintPageIds(): array
1315  {
1316  $page_ids = [];
1317  $ordering = $this->edit_request->getPrintOrdering();
1318 
1319  // multiple ordered page ids
1320  if (count($ordering) > 0) {
1321  asort($ordering);
1322  $page_ids = array_keys($ordering);
1323  }
1324  // single page
1325  elseif ($this->edit_request->getWikiPageId()) {
1326  $page_ids = array($this->edit_request->getWikiPageId());
1327  }
1328  return $page_ids;
1329  }
1330 
1331  public function getPrintView(bool $export = false): \ILIAS\Export\PrintProcessGUI
1332  {
1333  $page_ids = $export
1334  ? null
1335  : $this->getPrintPageIds();
1336  $provider = new \ILIAS\Wiki\WikiPrintViewProviderGUI(
1337  $this->lng,
1338  $this->ctrl,
1339  $this->object->getRefId(),
1340  $page_ids
1341  );
1342 
1343  return new \ILIAS\Export\PrintProcessGUI(
1344  $provider,
1345  $this->http,
1346  $this->ui,
1347  $this->lng
1348  );
1349  }
1350 
1351  public function printViewObject(): void
1352  {
1353  $print_view = $this->getPrintView();
1354  $print_view->sendPrintView();
1355  }
1356 
1357  public function performSearchObject(): void
1358  {
1359  $tpl = $this->tpl;
1360  $ilTabs = $this->tabs;
1361  $ilCtrl = $this->ctrl;
1362  $lng = $this->lng;
1363 
1364  $this->checkPermission("read");
1365 
1366  $ilTabs->setTabActive("wiki_search_results");
1367 
1368  if ($this->edit_request->getSearchTerm() === "") {
1369  $this->tpl->setOnScreenMessage('failure', $lng->txt("wiki_please_enter_search_term"), true);
1370  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1371  }
1372 
1373  $search_results = ilObjWiki::_performSearch(
1374  $this->object->getId(),
1375  $this->edit_request->getSearchTerm()
1376  );
1377  $table_gui = new ilWikiSearchResultsTableGUI(
1378  $this,
1379  "performSearch",
1380  $this->object->getId(),
1381  $search_results,
1382  $this->edit_request->getSearchTerm()
1383  );
1384 
1385  $this->setSideBlock();
1386  $tpl->setContent($table_gui->getHTML());
1387  }
1388 
1389  public function setContentStyleSheet(): void
1390  {
1391  $tpl = $this->tpl;
1392 
1393  if ($tpl == null) {
1394  $tpl = $this->tpl;
1395  }
1396 
1397  $this->content_style_gui->addCss($tpl, $this->object->getRefId());
1399  }
1400 
1401 
1402  //
1403  // Important pages
1404  //
1405 
1406  public function editImportantPagesObject(): void
1407  {
1408  $tpl = $this->tpl;
1409  $ilToolbar = $this->toolbar;
1410  $ilTabs = $this->tabs;
1411  $lng = $this->lng;
1412  $ilCtrl = $this->ctrl;
1413 
1414  $this->checkPermission("edit_wiki_navigation");
1415 
1416  $this->tpl->setOnScreenMessage('info', $lng->txt("wiki_navigation_info"));
1417 
1418  $ipages_ids = $this->imp_pages->getImportantPageIds();
1419 
1420  // list pages
1421  $pages = $this->pm->getAllPagesInfo();
1422  $options = array("" => $lng->txt("please_select"));
1423  foreach ($pages as $p) {
1424  if (!in_array($p->getId(), $ipages_ids)) {
1425  $options[$p->getId()] = ilStr::shortenTextExtended($p->getTitle(), 60, true);
1426  }
1427  }
1428  if (count($options) > 0) {
1429  $si = new ilSelectInputGUI($lng->txt("wiki_pages"), "imp_page_id");
1430  $si->setOptions($options);
1431  $si->setInfo($lng->txt(""));
1432  $ilToolbar->addInputItem($si);
1433  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1434  $ilToolbar->addFormButton($lng->txt("add"), "addImportantPage");
1435  }
1436 
1437 
1438  $ilTabs->activateTab("settings");
1439  $this->setSettingsSubTabs("imp_pages");
1440 
1441  $imp_table = new ilImportantPagesTableGUI($this, "editImportantPages");
1442 
1443  $tpl->setContent($imp_table->getHTML());
1444  }
1445 
1446  public function addImportantPageObject(): void
1447  {
1448  $ilCtrl = $this->ctrl;
1449  $lng = $this->lng;
1450 
1451  $this->checkPermission("edit_wiki_navigation");
1452 
1453  $imp_page_id = $this->edit_request->getImportantPageId();
1454  if ($imp_page_id > 0) {
1455  $this->imp_pages->add($imp_page_id);
1456  $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_imp_page_added"), true);
1457  }
1458  $ilCtrl->redirect($this, "editImportantPages");
1459  }
1460 
1461  public function confirmRemoveImportantPagesObject(): void
1462  {
1463  $ilCtrl = $this->ctrl;
1464  $tpl = $this->tpl;
1465  $lng = $this->lng;
1466 
1467  $imp_page_ids = $this->edit_request->getImportantPageIds();
1468  if (count($imp_page_ids) === 0) {
1469  $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
1470  $ilCtrl->redirect($this, "editImportantPages");
1471  } else {
1472  $cgui = new ilConfirmationGUI();
1473  $cgui->setFormAction($ilCtrl->getFormAction($this));
1474  $cgui->setHeaderText($lng->txt("wiki_sure_remove_imp_pages"));
1475  $cgui->setCancel($lng->txt("cancel"), "editImportantPages");
1476  $cgui->setConfirm($lng->txt("remove"), "removeImportantPages");
1477 
1478  foreach ($imp_page_ids as $i) {
1479  $cgui->addItem("imp_page_id[]", $i, ilWikiPage::lookupTitle((int) $i));
1480  }
1481 
1482  $tpl->setContent($cgui->getHTML());
1483  }
1484  }
1485 
1486  public function removeImportantPagesObject(): void
1487  {
1488  $ilCtrl = $this->ctrl;
1489  $lng = $this->lng;
1490 
1491  $this->checkPermission("edit_wiki_navigation");
1492 
1493  $imp_page_ids = $this->edit_request->getImportantPageIds();
1494  foreach ($imp_page_ids as $i) {
1495  $this->imp_pages->removeImportantPage($i);
1496  }
1497  $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_removed_imp_pages"), true);
1498  $ilCtrl->redirect($this, "editImportantPages");
1499  }
1500 
1501  public function saveOrderingAndIndentObject(): void
1502  {
1503  $ilCtrl = $this->ctrl;
1504  $lng = $this->lng;
1505 
1506  $this->checkPermission("edit_wiki_navigation");
1507 
1508  $ordering = $this->edit_request->getImportantPageOrdering();
1509  $indentation = $this->edit_request->getImportantPageIndentation();
1510  $this->imp_pages->saveOrderingAndIndentation($ordering, $indentation);
1511  $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_ordering_and_indent_saved"), true);
1512  $ilCtrl->redirect($this, "editImportantPages");
1513  }
1514 
1515  public function setAsStartPageObject(): void
1516  {
1517  $ilCtrl = $this->ctrl;
1518  $lng = $this->lng;
1519 
1520  $this->checkPermission("edit_wiki_navigation");
1521 
1522  $imp_page_ids = $this->edit_request->getImportantPageIds();
1523  if (count($imp_page_ids) !== 1) {
1524  $this->tpl->setOnScreenMessage('info', $lng->txt("wiki_select_one_item"), true);
1525  } else {
1526  $this->imp_pages->removeImportantPage($imp_page_ids[0]);
1527  $this->object->setStartPage(ilWikiPage::lookupTitle($imp_page_ids[0]));
1528  $this->object->update();
1529  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1530  }
1531  $ilCtrl->redirect($this, "editImportantPages");
1532  }
1533 
1534 
1540  public function exportHTML(): void
1541  {
1543  $wiki = $this->object;
1544  $cont_exp = new Export\WikiHtmlExport($wiki);
1545 
1546  $format = explode("_", $this->edit_request->getFormat());
1547  if (($format[1] ?? "") === "comments") {
1548  $cont_exp->setMode(Export\WikiHtmlExport::MODE_COMMENTS);
1549  }
1550 
1551  $cont_exp->buildExportFile();
1552  }
1553 
1557  public static function lookupSubObjectTitle(
1558  int $a_wiki_id,
1559  string $a_page_id
1560  ): string {
1561  $page = new ilWikiPage($a_page_id);
1562  if ($page->getWikiId() === $a_wiki_id) {
1563  return $page->getTitle();
1564  }
1565  return "";
1566  }
1567 
1571  public function getSubObjectTitle(
1572  int $a_id,
1573  string $a_type
1574  ): string {
1575  return ilWikiPage::lookupTitle($a_id);
1576  }
1577 
1578  public function showTemplateSelectionObject(): void
1579  {
1580  $lng = $this->lng;
1581  $tpl = $this->tpl;
1582  $ilTabs = $this->tabs;
1583  $ilCtrl = $this->ctrl;
1584 
1585  $ilCtrl->setParameterByClass(
1586  "ilobjwikigui",
1587  "from_page",
1588  ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1589  );
1590  $ilTabs->clearTargets();
1591  $this->tpl->setOnScreenMessage('info', $lng->txt("wiki_page_not_exist_select_templ"));
1592 
1593  $form = $this->initTemplateSelectionForm();
1594  $tpl->setContent($form->getHTML());
1595  }
1596 
1598  {
1599  $lng = $this->lng;
1600  $ilCtrl = $this->ctrl;
1601 
1602  $form = new ilPropertyFormGUI();
1603 
1604  // page name
1605  $hi = new ilHiddenInputGUI("page");
1606  $hi->setValue($this->requested_page);
1607  $form->addItem($hi);
1608 
1609  // page template
1610  $radg = new ilRadioGroupInputGUI($lng->txt("wiki_page_template"), "page_templ");
1611  $radg->setRequired(true);
1612 
1613  if ($this->object->getEmptyPageTemplate()) {
1614  $op1 = new ilRadioOption($lng->txt("wiki_empty_page"), 0);
1615  $radg->addOption($op1);
1616  }
1617 
1618  $wt = new ilWikiPageTemplate($this->object->getId());
1619  $ts = $wt->getAllInfo(ilWikiPageTemplate::TYPE_NEW_PAGES, $this->edit_request->getTranslation());
1620  foreach ($ts as $t) {
1621  $op = new ilRadioOption($t["title"], $t["wpage_id"]);
1622  $radg->addOption($op);
1623  }
1624 
1625  $form->addItem($radg);
1626 
1627  // save and cancel commands
1628  $form->addCommandButton("createPageUsingTemplate", $lng->txt("wiki_create_page"));
1629  $form->addCommandButton("cancelCreationPageUsingTemplate", $lng->txt("cancel"));
1630 
1631  $form->setTitle($lng->txt("wiki_new_page") . ": " . $this->requested_page);
1632  $form->setFormAction($ilCtrl->getFormAction($this));
1633 
1634  return $form;
1635  }
1636 
1637  public function createPageUsingTemplateObject(): void
1638  {
1639  $tpl = $this->tpl;
1640  $lng = $this->lng;
1641  $ilCtrl = $this->ctrl;
1642 
1643  $form = $this->initTemplateSelectionForm();
1644  if ($form->checkInput()) {
1645  $a_page = $this->edit_request->getPage();
1646  $this->pm->createWikiPage(
1647  $a_page,
1648  0,
1649  $this->edit_request->getTranslation(),
1650  $this->edit_request->getPageTemplateId()
1651  );
1652 
1653  // redirect to newly created page
1654  $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1655  $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1656 
1657  $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1658  $ilCtrl->redirect($this, "");
1659  } else {
1660  $form->setValuesByPost();
1661  $tpl->setContent($form->getHTML());
1662  }
1663  }
1664 
1666  {
1667  $ilCtrl = $this->ctrl;
1668 
1669  // redirect to newly created page
1670  $ilCtrl->setParameterByClass(
1671  "ilwikipagegui",
1672  "page",
1673  ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1674  );
1675  $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1676  }
1677 
1678  protected function checkPermissionBool(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): bool
1679  {
1680  if ($perm === "create") {
1681  return parent::checkPermissionBool($perm, $cmd, $type, $ref_id);
1682  } else {
1683  if (!$ref_id) {
1684  $ref_id = $this->object->getRefId();
1685  }
1686  return ilWikiPerm::check($perm, $ref_id, $cmd);
1687  }
1688  }
1689 
1690 
1691  //
1692  // User HTML Export
1693  //
1710  public function initUserHTMLExportObject(): void
1711  {
1712  $this->log->debug("init: " . $this->req_with_comments);
1713  $this->checkPermission("wiki_html_export");
1714  $this->object->initUserHTMLExport($this->req_with_comments);
1715  }
1716 
1720  public function startUserHTMLExportObject(): void
1721  {
1722  $this->log->debug("start: " . $this->req_with_comments);
1723  $this->checkPermission("wiki_html_export");
1724  $this->object->startUserHTMLExport($this->req_with_comments);
1725  }
1726 
1730  public function getUserHTMLExportProgressObject(): void
1731  {
1732  $this->log->debug("get progress: " . $this->req_with_comments);
1733  $this->checkPermission("wiki_html_export");
1734  $p = $this->object->getUserHTMLExportProgress($this->req_with_comments);
1735 
1737  $pb->setCurrent($p["progress"]);
1738 
1739  $r = new stdClass();
1740  $r->progressBar = $pb->render();
1741  $r->status = $p["status"];
1742  $this->log->debug("status: " . $r->status);
1743  echo(json_encode($r, JSON_THROW_ON_ERROR));
1744  exit;
1745  }
1746 
1747  public function downloadUserHTMLExportObject(): void
1748  {
1749  $this->log->debug("download");
1750  $this->checkPermission("wiki_html_export");
1751  $this->object->deliverUserHTMLExport();
1752  }
1753 
1755  {
1756  $this->log->debug("download");
1757  $this->checkPermission("wiki_html_export");
1758  $this->object->deliverUserHTMLExport(true);
1759  }
1760 
1761  protected function triggerAssignmentTool(): void
1762  {
1763  if (!is_object($this->object)) {
1764  return;
1765  }
1766  $ass_info = ilExcRepoObjAssignment::getInstance()->getAssignmentInfoOfObj(
1767  $this->object->getRefId(),
1768  $this->user->getId()
1769  );
1770  if (count($ass_info) > 0) {
1771  $ass_ids = array_map(static function ($i): int {
1772  return $i->getId();
1773  }, $ass_info);
1774  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
1775  $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
1776  $this->tool_context->current()->addAdditionalData(
1778  $this->getAssignmentButtons()
1779  );
1780  }
1781  }
1782 
1786  protected function getAssignmentButtons(): array
1787  {
1788  $ilCtrl = $this->ctrl;
1789  $ui = $this->ui;
1790  $lng = $this->lng;
1791 
1792  $ass_info = ilExcRepoObjAssignment::getInstance()->getAssignmentInfoOfObj(
1793  $this->object->getRefId(),
1794  $this->user->getId()
1795  );
1796  $buttons = [];
1797  foreach ($ass_info as $i) { // should be only one
1798  $ass = new ilExAssignment($i->getId());
1799  $times_up = $ass->afterDeadlineStrict();
1800 
1801  // submit button
1802  if (!$times_up) {
1803  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", $ass->getId());
1804  $submit_link = $ilCtrl->getLinkTargetByClass("ilwikipagegui", "finalizeAssignment");
1805  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", "");
1806 
1807  $buttons[$i->getId()][] = $ui->factory()->button()->primary($lng->txt("wiki_finalize_wiki"), $submit_link);
1808  }
1809 
1810  // submitted files
1811  $submission = new ilExSubmission($ass, $this->user->getId());
1812  if ($submission->hasSubmitted()) {
1813  $submitted = $submission->getSelectedObject();
1814  if ($submitted?->getTimestamp() != "") {
1815  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", $ass->getId());
1816  }
1817  $dl_link = $ilCtrl->getLinkTargetByClass("ilwikipagegui", "downloadExcSubFile");
1818  $ilCtrl->setParameterByClass("ilwikipagegui", "ass", "");
1819  $buttons[$i->getId()][] = $ui->factory()->button()->standard($lng->txt("wiki_download_submission"), $dl_link);
1820  }
1821  }
1822  return $buttons;
1823  }
1824 }
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...
WikiGUIRequest $edit_request
Class ilObjectMetaDataGUI.
ILIAS Style Content Object ObjectFacade $content_style_domain
ILIAS Wiki Page PageManager $pm
ILIAS HTTP Services $http
static _lookupComment(int $a_usr_id, int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getUserHTMLExportProgressObject()
Get user html export progress.
Exercise assignment.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
const IL_WIKI_POPULAR_PAGES
static getLogger(string $a_component_id)
Get component logger.
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...
Wiki page template gui class.
GUI class for the workflow of copying objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ROOT_FOLDER_ID
Definition: constants.php:32
prepareOutput(bool $show_sub_objects=true)
static _writeStatus(int $a_obj_id, int $a_user_id, int $a_status)
ILIAS DI UIServices $ui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer Contains several chained tasks and infos about them.
Wiki statistics GUI class.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static _getAllReferences(int $id)
get all reference ids for object ID
Help GUI class.
static renderSideBlock(int $a_wpg_id, int $a_wiki_ref_id, ?ilWikiPage $a_wp=null)
static lookupTitle(int $a_page_id, string $lang="-")
afterDeadlineStrict(bool $a_include_personal=true)
ILIAS Style Content GUIService $content_style_gui
infoScreenObject()
this one is called from the info button in the repository
initCreateForm(string $new_type)
static _gotoRepositoryNode(int $ref_id, string $cmd="")
TableGUI class for wiki pages table.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
static _performSearch(int $a_wiki_id, string $a_searchterm)
Search in Wiki.
getSubObjectTitle(int $a_id, string $a_type)
Used for rating export.
loadLanguageModule(string $a_module)
Load language module.
setOptions(array $a_options)
static _lookupRatingCategories(int $a_wiki_id)
Lookup whether rating categories are activated.
static lookupWikiId(int $a_page_id)
downloadUserHTMLExportWithCommentsObject()
static lookupSubObjectTitle(int $a_wiki_id, string $a_page_id)
Get title for wiki page (used in ilNotesGUI)
getAllInfo(int $a_type=self::TYPE_ALL, string $lang="-")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Wiki Content GUIService $content_gui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setHeaderActionMenu(string $a_header)
Set header action menu.
startUserHTMLExportObject()
Export html (as user)
static _lookupRating(int $a_wiki_id)
Lookup whether rating is activated.
static _lookupStatus(int $a_obj_id, int $a_user_id)
Lookup current success status (STATUS_NOT_GRADED|STATUS_PASSED|STATUS_FAILED)
static strLen(string $a_string)
Definition: class.ilStr.php:63
$provider
Definition: ltitoken.php:80
ilLanguage $lng
ContextServices $tool_context
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...
ilObjectTranslation $ot
GUI class for public user profile presentation.
static http()
Fetches the global http state from ILIAS.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
static _lookupTitle(int $obj_id)
setContent(string $a_html)
Sets content for standard template.
$GLOBALS["DIC"]
Definition: wac.php:30
getPrintView(bool $export=false)
GUI class for LTI provider object settings.
__construct( $a_data, int $a_id, bool $a_call_by_reference, bool $a_prepare_output=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 lookupAdvancedMetadataHidden(int $a_page_id)
global $DIC
Definition: shib_login.php:25
initUserHTMLExportObject()
Current process:
getAssignmentButtons()
Get assignment buttons.
ilToolbarGUI $toolbar
$comments
ILIAS Wiki Navigation ImportantPageManager $imp_pages
static getRandomPage(int $a_wiki_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupStartPage(int $a_wiki_id)
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
static getGotoLink(int $a_ref_id, string $a_page="", string $lang="-")
ILIAS Wiki InternalGUIService $gui
setRequired(bool $a_required)
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
ilPropertyFormGUI $form_gui
setCustomRolesForSelection(array $a_roles)
Set custom roles for mapping to LTI roles.
setSettingsSubTabs(string $a_active)
static redirect(string $a_script)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static _lookupMark(int $a_usr_id, int $a_obj_id)
const IL_WIKI_ALL_PAGES
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static makeUrlTitle(string $a_par)
static makeDbTitle(string $a_par)
static getPageIdForTitle(int $a_wiki_id, string $a_title, string $lang="-")
Get wiki page object for id and title.
static _wikiPageExists(int $a_wiki_id, string $a_title, string $lang="-")
__construct(Container $dic, ilPlugin $plugin)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_WIKI_ORPHANED_PAGES
ilAccessHandler $access
ILIAS Wiki InternalDomainService $domain
setRightContent(string $a_html)
Sets content of right column.
afterSave(ilObject $new_object)
static check(string $a_perm, int $a_ref_id, string $a_cmd="")
Exercise submission //TODO: This class has many static methods related to delivered "files"...
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSideBlock(int $a_wpg_id=0)
addHeaderAction()
Add header action menu.
ilLocatorGUI $locator
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
GUI class for object translation handling.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
gotoPageObject(string $a_page="")
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
static _goto(string $a_target)
$r
const IL_WIKI_NEW_PAGES