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