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