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