ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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
897 if ($ilAccess->checkAccess("read", "", $a_target)) {
898 if ($wpg_id > 0) {
900 "ilobjwikigui",
901 "wpg_id",
902 $wpg_id
903 );
904 } else {
906 "ilobjwikigui",
907 "page",
909 );
910 }
911 if ($lang != "") {
913 "ilobjwikigui",
914 "transl",
915 $lang
916 );
917 }
919 "ilwikihandlergui",
920 "ref_id",
921 $a_target
922 );
923 if ($a_page != "") {
925 ["ilwikihandlergui", "ilobjwikigui"],
926 "viewPage"
927 );
928 } else {
930 ["ilwikihandlergui"],
931 "view"
932 );
933 }
934 } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
935 ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
936 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
937 $main_tpl->setOnScreenMessage('failure', sprintf(
938 $lng->txt("msg_no_perm_read_item"),
940 ), true);
942 }
943
944 throw new ilPermissionException($lng->txt("permission_denied"));
945 }
946
947 public static function getGotoLink(
948 int $a_ref_id,
949 string $a_page = "",
950 string $lang = "-"
951 ): string {
952 if ($a_page === "") {
954 }
955
956 $append = (!in_array($lang, ["", "-"]))
957 ? "&transl=" . $lang
958 : "";
959 $goto = "goto.php?target=wiki_" . $a_ref_id . "_" .
960 ilWikiUtil::makeUrlTitle($a_page) . $append;
961 return $goto;
962 }
963
964 public function viewPageObject(): void
965 {
967 $ilCtrl = $this->ctrl;
968 $tpl = $this->tpl;
969 $ilTabs = $this->tabs;
970 $ilAccess = $this->access;
971
972 $this->checkPermission("read");
973
974 $ilTabs->clearTargets();
975 $tpl->setHeaderActionMenu("");
976
977 $wpage_gui = $this->gui->content()->getCurrentPageGUI();
978
979 // page exists, show it !
980 $ilCtrl->setParameter(
981 $this,
982 "page",
983 ilWikiUtil::makeUrlTitle($wpage_gui->getPageObject()->getTitle())
984 );
985
986 $wpage_gui->setStyleId($this->content_style_domain->getEffectiveStyleId());
987
988 $this->setContentStyleSheet();
989
990 //$wpage_gui->setSideBlock();
991 $ilCtrl->redirectByClass(ilWikiPageGUI::class, "preview");
992 }
993
994 public function allPagesObject(): void
995 {
996 $tpl = $this->tpl;
997
998 $this->checkPermission("read");
999
1000 $this->addPagesSubTabs();
1001
1002 $table_gui = new ilWikiPagesTableGUI(
1003 $this,
1004 "allPages",
1005 $this->object->getId(),
1007 );
1008
1009 //$this->setSideBlock();
1010 $tpl->setContent($table_gui->getHTML());
1011 }
1012
1016 public function popularPagesObject(): void
1017 {
1018 $tpl = $this->tpl;
1019
1020 $this->checkPermission("read");
1021
1022 $this->addPagesSubTabs();
1023
1024 $table_gui = new ilWikiPagesTableGUI(
1025 $this,
1026 "popularPages",
1027 $this->object->getId(),
1029 );
1030
1031 //$this->setSideBlock();
1032 $tpl->setContent($table_gui->getHTML());
1033 }
1034
1038 public function orphanedPagesObject(): void
1039 {
1040 $tpl = $this->tpl;
1041
1042 $this->checkPermission("read");
1043
1044 $this->addPagesSubTabs();
1045
1046 $table_gui = new ilWikiPagesTableGUI(
1047 $this,
1048 "orphanedPages",
1049 $this->object->getId(),
1051 );
1052
1053 //$this->setSideBlock();
1054 $tpl->setContent($table_gui->getHTML());
1055 }
1056
1060 public function gotoPageObject(
1061 string $a_page = ""
1062 ): void {
1063 $ilCtrl = $this->ctrl;
1064
1065 if ($a_page === "") {
1066 $a_page = $this->requested_page;
1067 }
1068
1069 if ($this->pm->existsByTitle(
1070 ilWikiUtil::makeDbTitle($a_page),
1071 $this->edit_request->getTranslation()
1072 )) {
1073 // to do: get rid of this redirect
1074 ilUtil::redirect(self::getGotoLink($this->object->getRefId(), $a_page, $this->edit_request->getTranslation()));
1075 } else {
1076 if (!$this->access->checkAccess("add_pages", "", $this->object->getRefId())) {
1077 $this->tpl->setOnScreenMessage("failure", $this->lng->txt("no_permission"), true);
1078 $from_page_id = $this->pm->getPageIdForTitle($this->edit_request->getFromPage(), $this->edit_request->getTranslation());
1079 ilUtil::redirect($this->pm->getPermaLink($from_page_id, $this->edit_request->getTranslation()));
1080 }
1081 if ($this->isNewTranslatedPage()) {
1082 return;
1083 }
1084 if (!$this->object->getTemplateSelectionOnCreation()) {
1085 // check length
1086 if (ilStr::strLen(ilWikiUtil::makeDbTitle($a_page)) > 200) {
1087 $this->tpl->setOnScreenMessage(
1088 'failure',
1089 $this->lng->txt("wiki_page_title_too_long") . " (" . $a_page . ")",
1090 true
1091 );
1092 $ilCtrl->setParameterByClass(
1093 "ilwikipagegui",
1094 "page",
1095 ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1096 );
1097 $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1098 }
1099
1100 $this->pm->createWikiPage(
1101 $a_page,
1102 0,
1103 $this->edit_request->getTranslation()
1104 );
1105
1106 // redirect to newly created page
1107 $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1108 $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1109 } else {
1110 $ilCtrl->setParameter($this, "page", ilWikiUtil::makeUrlTitle($this->requested_page));
1111 $ilCtrl->setParameter(
1112 $this,
1113 "from_page",
1114 ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1115 );
1116 $ilCtrl->redirect($this, "showTemplateSelection");
1117 }
1118 }
1119 }
1120
1121 protected function isNewTranslatedPage(): bool
1122 {
1123 if (in_array($this->edit_request->getTranslation(), ["-", ""])) {
1124 return false;
1125 }
1126 $page = $this->requested_page;
1128 $this->object->getId(),
1130 $this->edit_request->getTranslation()
1131 )) {
1132 $this->tabs_gui->clearTargets();
1133 $this->tabs_gui->setBackTarget(
1134 $this->lng->txt("back"),
1135 $this->pm->getPermaLink(
1136 $this->pm->getPageIdForTitle(
1137 $this->edit_request->getFromPage(),
1138 $this->edit_request->getTranslation()
1139 ),
1140 $this->edit_request->getTranslation()
1141 )
1142 );
1143 $form = $this->getNewTranslatedPageForm();
1144 $this->tpl->setContent($this->getRenderedTranslationInfo() . $form->render());
1145 return true;
1146 }
1147 return false;
1148 }
1149
1150 protected function getRenderedTranslationInfo(): string
1151 {
1152 $mess = $this->gui->ui()->factory()->messageBox()->info(
1153 $this->lng->txt("wiki_translate_page_master_info")
1154 );
1155 return $this->gui->ui()->renderer()->render($mess);
1156 }
1157
1159 {
1160 $pm = $this->domain->page()->page($this->object->getRefId());
1161 $options = [];
1162 foreach ($pm->getMasterPagesWithoutTranslation($this->edit_request->getTranslation()) as $page) {
1163 $options[$page->getId()] = $page->getTitle();
1164 }
1165 $append = " '" . $this->edit_request->getPage() . "'";
1166 $append .= " (" . $this->lng->txt("meta_l_" . $this->edit_request->getTranslation()) . ")";
1167 $append2 = " (" . $this->lng->txt("meta_l_" . $this->object->getObjectProperties()->getPropertyTranslations()->getBaseLanguage()) . ")";
1168 $form = $this->gui->form([self::class], "createNewTranslatedPage")
1169 ->section("sec", $this->lng->txt("wiki_translation_page") . $append)
1170 ->switch("type", $this->lng->txt("wiki_page_in_master_language") . $append2, "", "existing")
1171 ->group("existing", $this->lng->txt("wiki_master_existing"))
1172 ->select("master_id", $this->lng->txt("wiki_master_title"), $options)
1173 ->required()
1174 ->group("new", $this->lng->txt("wiki_no_master"))
1175 ->text("master_title", $this->lng->txt("wiki_master_title"))
1176 ->end();
1177
1178 if ($this->object->getTemplateSelectionOnCreation($this->edit_request->getTranslation())) {
1179 $form = $form->radio("page_templ", $this->lng->txt("wiki_page_template"), "", "0")->required();
1180 if ($this->object->getEmptyPageTemplate()) {
1181 $form = $form->radioOption("0", $this->lng->txt("wiki_empty_page"));
1182 }
1183 $wt = new ilWikiPageTemplate($this->object->getId());
1184 $ts = $wt->getAllInfo(ilWikiPageTemplate::TYPE_NEW_PAGES, $this->edit_request->getTranslation());
1185 foreach ($ts as $t) {
1186 $form = $form->radioOption($t["wpage_id"], $t["title"]);
1187 }
1188 }
1189
1190 return $form;
1191 }
1192
1193 protected function createNewTranslatedPageObject(): void
1194 {
1195 $form = $this->getNewTranslatedPageForm();
1196 if ($form->isValid()) {
1197 $page_template_id = 0;
1198 if ($this->object->getTemplateSelectionOnCreation($this->edit_request->getTranslation())) {
1199 $page_template_id = (int) $form->getData("page_templ");
1200 }
1201 if ($form->getData("type") === "new") {
1202 $wpg_id = $this->pm->createWikiPage(
1203 $form->getData("master_title")
1204 );
1205 } else {
1206 $wpg_id = $form->getData("master_id");
1207 }
1208 $wpg_id = $this->pm->createWikiPage(
1209 $this->edit_request->getPage(),
1210 $wpg_id,
1211 $this->edit_request->getTranslation(),
1212 $page_template_id
1213 );
1214 }
1215 $this->ctrl->setParameterByClass(ilWikiPageGUI::class, "wpg_id", $wpg_id);
1216 $this->ctrl->redirectByClass(ilWikiPageGUI::class, "preview");
1217 }
1218
1219 public function randomPageObject(): void
1220 {
1221 $this->checkPermission("read");
1222
1223 $page = ilWikiPage::getRandomPage($this->object->getId());
1224 $this->gotoPageObject($page);
1225 }
1226
1227 public function recentChangesObject(): void
1228 {
1229 $tpl = $this->tpl;
1230
1231 $this->checkPermission("read");
1232
1233 $this->addPagesSubTabs();
1234
1235 $table_gui = new ilWikiRecentChangesTableGUI(
1236 $this,
1237 "recentChanges",
1238 $this->object->getId()
1239 );
1240
1241 //$this->setSideBlock();
1242 $tpl->setContent($table_gui->getHTML());
1243 }
1244
1245 public function setSideBlock(int $a_wpg_id = 0): void
1246 {
1247 self::renderSideBlock($a_wpg_id, $this->object->getRefId());
1248 }
1249
1250 public static function renderSideBlock(
1251 int $a_wpg_id,
1252 int $a_wiki_ref_id,
1253 ?ilWikiPage $a_wp = null
1254 ): void {
1255 global $DIC;
1256
1257 $tpl = $DIC["tpl"];
1258 $lng = $DIC->language();
1259 $ilAccess = $DIC->access();
1260 $ilCtrl = $DIC->ctrl();
1261
1262 $debug = false;
1263 if ($debug) {
1264 $tpl->addJavaScript("../components/ILIAS/Wiki/resources/WikiPres.js");
1265 } else {
1266 $tpl->addJavaScript("assets/js/WikiPres.js");
1267 }
1268
1269 // setting asynch to false fixes #0019457, since otherwise ilBlockGUI would act on asynch and output html when side blocks
1270 // being processed during the export. This is a flaw in ilCtrl and/or ilBlockGUI.
1271 $tpl->addOnLoadCode("il.Wiki.Pres.init('" . $ilCtrl->getLinkTargetByClass("ilobjwikigui", "", "", false, false) . "');");
1272
1273 if ($a_wpg_id > 0 && !$a_wp) {
1274 $a_wp = new ilWikiPage($a_wpg_id);
1275 }
1276
1277 // search block
1278 $rcontent = ilRepositoryObjectSearchGUI::getSearchBlockHTML($lng->txt('wiki_search'));
1279
1280
1281 // quick navigation
1282 if ($a_wpg_id > 0) {
1283 // rating
1284 $wiki_id = ilObject::_lookupObjId($a_wiki_ref_id);
1285 if (ilObjWiki::_lookupRating($wiki_id) &&
1286 // ilObjWiki::_lookupRatingAsBlock($wiki_id) &&
1287 $a_wp->getRating()) {
1288 $rgui = new ilRatingGUI();
1289 $rgui->setObject($wiki_id, "wiki", $a_wpg_id, "wpg");
1290 $rgui->enableCategories(ilObjWiki::_lookupRatingCategories($wiki_id));
1291 $rgui->setYourRatingText("#");
1292 $rcontent .= $rgui->getBlockHTML($lng->txt("wiki_rate_page"));
1293 }
1294
1295 // advanced metadata
1297 $cmd = null;
1298 if ($ilAccess->checkAccess("write", "", $a_wiki_ref_id) ||
1299 $ilAccess->checkAccess("edit_page_meta", "", $a_wiki_ref_id)) {
1300 $cmd = array(
1301 "edit" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "editAdvancedMetaData"),
1302 "hide" => $ilCtrl->getLinkTargetByClass("ilwikipagegui", "hideAdvancedMetaData")
1303 );
1304 }
1305 $wiki = new ilObjWiki($a_wiki_ref_id);
1306 $callback = $wiki->getLinkMetadataValues()
1307 ? array($wiki, "decorateAdvMDValue")
1308 : null;
1309 $mdgui = new ilObjectMetaDataGUI($wiki, "wpg", $a_wpg_id);
1310 $rcontent .= $mdgui->getBlockHTML($cmd, $callback); // #17291
1311 }
1312 }
1313
1314 // important pages
1315 $imp_pages_block = new ilWikiImportantPagesBlockGUI();
1316 $rcontent .= $imp_pages_block->getHTML();
1317
1318 // wiki functions block
1319 if ($a_wpg_id > 0) {
1320 $wiki_functions_block = new ilWikiFunctionsBlockGUI();
1321 $wiki_functions_block->setPageObject($a_wp);
1322 $rcontent .= $wiki_functions_block->getHTML();
1323 }
1324
1325 $tpl->setRightContent($rcontent);
1326 }
1327
1328 public function newPagesObject(): void
1329 {
1330 $tpl = $this->tpl;
1331
1332 $this->checkPermission("read");
1333
1334 $this->addPagesSubTabs();
1335
1336 $table_gui = new ilWikiPagesTableGUI(
1337 $this,
1338 "newPages",
1339 $this->object->getId(),
1341 );
1342
1343 //$this->setSideBlock();
1344 $tpl->setContent($table_gui->getHTML());
1345 }
1346
1347 protected function getPrintPageIds(): array
1348 {
1349 $page_ids = [];
1350 $ordering = $this->edit_request->getPrintOrdering();
1351
1352 // multiple ordered page ids
1353 if (count($ordering) > 0) {
1354 asort($ordering);
1355 $page_ids = array_keys($ordering);
1356 }
1357 // single page
1358 elseif ($this->edit_request->getWikiPageId()) {
1359 $page_ids = array($this->edit_request->getWikiPageId());
1360 }
1361 return $page_ids;
1362 }
1363
1364 public function getPrintView(bool $export = false): \ILIAS\Export\PrintProcessGUI
1365 {
1366 $page_ids = $export
1367 ? null
1368 : $this->getPrintPageIds();
1369 $provider = new \ILIAS\Wiki\WikiPrintViewProviderGUI(
1370 $this->lng,
1371 $this->ctrl,
1372 $this->object->getRefId(),
1373 $page_ids
1374 );
1375
1376 return new \ILIAS\Export\PrintProcessGUI(
1377 $provider,
1378 $this->http,
1379 $this->ui,
1380 $this->lng
1381 );
1382 }
1383
1384 public function printViewObject(): void
1385 {
1386 $print_view = $this->getPrintView();
1387 $print_view->sendPrintView();
1388 }
1389
1390 public function performSearchObject(): void
1391 {
1392 $tpl = $this->tpl;
1393 $ilTabs = $this->tabs;
1394 $ilCtrl = $this->ctrl;
1395 $lng = $this->lng;
1396
1397 $this->checkPermission("read");
1398
1399 $ilTabs->setTabActive("wiki_search_results");
1400
1401 if ($this->edit_request->getSearchTerm() === "") {
1402 $this->tpl->setOnScreenMessage('failure', $lng->txt("wiki_please_enter_search_term"), true);
1403 $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1404 }
1405
1406 $search_results = ilObjWiki::_performSearch(
1407 $this->object->getId(),
1408 $this->edit_request->getSearchTerm()
1409 );
1410 $table_gui = new ilWikiSearchResultsTableGUI(
1411 $this,
1412 "performSearch",
1413 $this->object->getId(),
1414 $search_results,
1415 $this->edit_request->getSearchTerm()
1416 );
1417
1418 $this->setSideBlock();
1419 $tpl->setContent($table_gui->getHTML());
1420 }
1421
1422 public function setContentStyleSheet(): void
1423 {
1424 $tpl = $this->tpl;
1425
1426 if ($tpl == null) {
1427 $tpl = $this->tpl;
1428 }
1429
1430 $this->content_style_gui->addCss($tpl, $this->object->getRefId());
1432 }
1433
1434
1435 //
1436 // Important pages
1437 //
1438
1439 public function editImportantPagesObject(): void
1440 {
1441 $tpl = $this->tpl;
1442 $ilToolbar = $this->toolbar;
1443 $ilTabs = $this->tabs;
1444 $lng = $this->lng;
1445 $ilCtrl = $this->ctrl;
1446
1447 $this->checkPermission("edit_wiki_navigation");
1448
1449 $this->tpl->setOnScreenMessage('info', $lng->txt("wiki_navigation_info"));
1450
1451 $ipages_ids = $this->imp_pages->getImportantPageIds();
1452
1453 // list pages
1454 $pages = $this->pm->getAllPagesInfo();
1455 $options = array("" => $lng->txt("please_select"));
1456 foreach ($pages as $p) {
1457 if (!in_array($p->getId(), $ipages_ids)) {
1458 $options[$p->getId()] = ilStr::shortenTextExtended($p->getTitle(), 60, true);
1459 }
1460 }
1461 if (count($options) > 0) {
1462 $si = new ilSelectInputGUI($lng->txt("wiki_pages"), "imp_page_id");
1463 $si->setOptions($options);
1464 $si->setInfo($lng->txt(""));
1465 $ilToolbar->addInputItem($si);
1466 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1467 $ilToolbar->addFormButton($lng->txt("add"), "addImportantPage");
1468 }
1469
1470
1471 $ilTabs->activateTab("settings");
1472 $this->setSettingsSubTabs("imp_pages");
1473
1474 $imp_table = new ilImportantPagesTableGUI($this, "editImportantPages");
1475
1476 $tpl->setContent($imp_table->getHTML());
1477 }
1478
1479 public function addImportantPageObject(): void
1480 {
1481 $ilCtrl = $this->ctrl;
1482 $lng = $this->lng;
1483
1484 $this->checkPermission("edit_wiki_navigation");
1485
1486 $imp_page_id = $this->edit_request->getImportantPageId();
1487 if ($imp_page_id > 0) {
1488 $this->imp_pages->add($imp_page_id);
1489 $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_imp_page_added"), true);
1490 }
1491 $ilCtrl->redirect($this, "editImportantPages");
1492 }
1493
1495 {
1496 $ilCtrl = $this->ctrl;
1497 $tpl = $this->tpl;
1498 $lng = $this->lng;
1499
1500 $imp_page_ids = $this->edit_request->getImportantPageIds();
1501 if (count($imp_page_ids) === 0) {
1502 $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
1503 $ilCtrl->redirect($this, "editImportantPages");
1504 } else {
1505 $cgui = new ilConfirmationGUI();
1506 $cgui->setFormAction($ilCtrl->getFormAction($this));
1507 $cgui->setHeaderText($lng->txt("wiki_sure_remove_imp_pages"));
1508 $cgui->setCancel($lng->txt("cancel"), "editImportantPages");
1509 $cgui->setConfirm($lng->txt("remove"), "removeImportantPages");
1510
1511 foreach ($imp_page_ids as $i) {
1512 $cgui->addItem("imp_page_id[]", $i, ilWikiPage::lookupTitle((int) $i));
1513 }
1514
1515 $tpl->setContent($cgui->getHTML());
1516 }
1517 }
1518
1519 public function removeImportantPagesObject(): void
1520 {
1521 $ilCtrl = $this->ctrl;
1522 $lng = $this->lng;
1523
1524 $this->checkPermission("edit_wiki_navigation");
1525
1526 $imp_page_ids = $this->edit_request->getImportantPageIds();
1527 foreach ($imp_page_ids as $i) {
1528 $this->imp_pages->removeImportantPage($i);
1529 }
1530 $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_removed_imp_pages"), true);
1531 $ilCtrl->redirect($this, "editImportantPages");
1532 }
1533
1534 public function saveOrderingAndIndentObject(): void
1535 {
1536 $ilCtrl = $this->ctrl;
1537 $lng = $this->lng;
1538
1539 $this->checkPermission("edit_wiki_navigation");
1540
1541 $ordering = $this->edit_request->getImportantPageOrdering();
1542 $indentation = $this->edit_request->getImportantPageIndentation();
1543 $this->imp_pages->saveOrderingAndIndentation($ordering, $indentation);
1544 $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_ordering_and_indent_saved"), true);
1545 $ilCtrl->redirect($this, "editImportantPages");
1546 }
1547
1548 public function setAsStartPageObject(): void
1549 {
1550 $ilCtrl = $this->ctrl;
1551 $lng = $this->lng;
1552
1553 $this->checkPermission("edit_wiki_navigation");
1554
1555 $imp_page_ids = $this->edit_request->getImportantPageIds();
1556 if (count($imp_page_ids) !== 1) {
1557 $this->tpl->setOnScreenMessage('info', $lng->txt("wiki_select_one_item"), true);
1558 } else {
1559 $this->imp_pages->removeImportantPage($imp_page_ids[0]);
1560 $this->object->setStartPage(ilWikiPage::lookupTitle($imp_page_ids[0]));
1561 $this->object->update();
1562 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1563 }
1564 $ilCtrl->redirect($this, "editImportantPages");
1565 }
1566
1567
1573 public function exportHTML(): void
1574 {
1576 $wiki = $this->object;
1577 $cont_exp = new Export\WikiHtmlExport($wiki);
1578
1579 $format = explode("_", $this->edit_request->getFormat());
1580 if (($format[1] ?? "") === "comments") {
1581 $cont_exp->setMode(Export\WikiHtmlExport::MODE_COMMENTS);
1582 }
1583
1584 $cont_exp->buildExportFile();
1585 }
1586
1590 public static function lookupSubObjectTitle(
1591 int $a_wiki_id,
1592 string $a_page_id
1593 ): string {
1594 $page = new ilWikiPage($a_page_id);
1595 if ($page->getWikiId() === $a_wiki_id) {
1596 return $page->getTitle();
1597 }
1598 return "";
1599 }
1600
1604 public function getSubObjectTitle(
1605 int $a_id,
1606 string $a_type
1607 ): string {
1608 return ilWikiPage::lookupTitle($a_id);
1609 }
1610
1611 public function showTemplateSelectionObject(): void
1612 {
1613 $lng = $this->lng;
1614 $tpl = $this->tpl;
1615 $ilTabs = $this->tabs;
1616 $ilCtrl = $this->ctrl;
1617
1618 $ilCtrl->setParameterByClass(
1619 "ilobjwikigui",
1620 "from_page",
1621 ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1622 );
1623 $ilTabs->clearTargets();
1624 $this->tpl->setOnScreenMessage('info', $lng->txt("wiki_page_not_exist_select_templ"));
1625
1626 $form = $this->initTemplateSelectionForm();
1627 $tpl->setContent($form->getHTML());
1628 }
1629
1631 {
1632 $lng = $this->lng;
1633 $ilCtrl = $this->ctrl;
1634
1635 $form = new ilPropertyFormGUI();
1636
1637 // page name
1638 $hi = new ilHiddenInputGUI("page");
1639 $hi->setValue($this->requested_page);
1640 $form->addItem($hi);
1641
1642 // page template
1643 $radg = new ilRadioGroupInputGUI($lng->txt("wiki_page_template"), "page_templ");
1644 $radg->setRequired(true);
1645
1646 if ($this->object->getEmptyPageTemplate()) {
1647 $op1 = new ilRadioOption($lng->txt("wiki_empty_page"), 0);
1648 $radg->addOption($op1);
1649 }
1650
1651 $wt = new ilWikiPageTemplate($this->object->getId());
1652 $ts = $wt->getAllInfo(ilWikiPageTemplate::TYPE_NEW_PAGES, $this->edit_request->getTranslation());
1653 foreach ($ts as $t) {
1654 $op = new ilRadioOption($t["title"], $t["wpage_id"]);
1655 $radg->addOption($op);
1656 }
1657
1658 $form->addItem($radg);
1659
1660 // save and cancel commands
1661 $form->addCommandButton("createPageUsingTemplate", $lng->txt("wiki_create_page"));
1662 $form->addCommandButton("cancelCreationPageUsingTemplate", $lng->txt("cancel"));
1663
1664 $form->setTitle($lng->txt("wiki_new_page") . ": " . $this->requested_page);
1665 $form->setFormAction($ilCtrl->getFormAction($this));
1666
1667 return $form;
1668 }
1669
1670 public function createPageUsingTemplateObject(): void
1671 {
1672 $tpl = $this->tpl;
1673 $lng = $this->lng;
1674 $ilCtrl = $this->ctrl;
1675
1676 $form = $this->initTemplateSelectionForm();
1677 if ($form->checkInput()) {
1678 $a_page = $this->edit_request->getPage();
1679 $this->pm->createWikiPage(
1680 $a_page,
1681 0,
1682 $this->edit_request->getTranslation(),
1683 $this->edit_request->getPageTemplateId()
1684 );
1685
1686 // redirect to newly created page
1687 $ilCtrl->setParameterByClass("ilwikipagegui", "page", ilWikiUtil::makeUrlTitle(($a_page)));
1688 $ilCtrl->redirectByClass("ilwikipagegui", "edit");
1689
1690 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1691 $ilCtrl->redirect($this, "");
1692 } else {
1693 $form->setValuesByPost();
1694 $tpl->setContent($form->getHTML());
1695 }
1696 }
1697
1699 {
1700 $ilCtrl = $this->ctrl;
1701
1702 // redirect to newly created page
1703 $ilCtrl->setParameterByClass(
1704 "ilwikipagegui",
1705 "page",
1706 ilWikiUtil::makeUrlTitle($this->edit_request->getFromPage())
1707 );
1708 $ilCtrl->redirectByClass("ilwikipagegui", "preview");
1709 }
1710
1711 protected function checkPermissionBool(string $perm, string $cmd = "", string $type = "", ?int $ref_id = null): bool
1712 {
1713 if ($perm === "create") {
1714 return parent::checkPermissionBool($perm, $cmd, $type, $ref_id);
1715 } else {
1716 if (!$ref_id) {
1717 $ref_id = $this->object->getRefId();
1718 }
1719 return ilWikiPerm::check($perm, $ref_id, $cmd);
1720 }
1721 }
1722
1723
1724 //
1725 // User HTML Export
1726 //
1743 public function initUserHTMLExportObject(): void
1744 {
1745 $this->log->debug("init: " . $this->req_with_comments);
1746 $this->checkPermission("wiki_html_export");
1747 $this->object->initUserHTMLExport($this->req_with_comments);
1748 }
1749
1753 public function startUserHTMLExportObject(): void
1754 {
1755 $this->log->debug("start: " . $this->req_with_comments);
1756 $this->checkPermission("wiki_html_export");
1757 $this->object->startUserHTMLExport($this->req_with_comments);
1758 }
1759
1763 public function getUserHTMLExportProgressObject(): void
1764 {
1765 $this->log->debug("get progress: " . $this->req_with_comments);
1766 $this->checkPermission("wiki_html_export");
1767 $p = $this->object->getUserHTMLExportProgress($this->req_with_comments);
1768
1770 $pb->setCurrent($p["progress"]);
1771
1772 $r = new stdClass();
1773 $r->progressBar = $pb->render();
1774 $r->status = $p["status"];
1775 $this->log->debug("status: " . $r->status);
1776 echo(json_encode($r, JSON_THROW_ON_ERROR));
1777 exit;
1778 }
1779
1780 public function downloadUserHTMLExportObject(): void
1781 {
1782 $this->log->debug("download");
1783 $this->checkPermission("wiki_html_export");
1784 $this->object->deliverUserHTMLExport();
1785 }
1786
1788 {
1789 $this->log->debug("download");
1790 $this->checkPermission("wiki_html_export");
1791 $this->object->deliverUserHTMLExport(true);
1792 }
1793
1794 protected function triggerAssignmentTool(): void
1795 {
1796 if (!is_object($this->object)) {
1797 return;
1798 }
1799 $ass_info = ilExcRepoObjAssignment::getInstance()->getAssignmentInfoOfObj(
1800 $this->object->getRefId(),
1801 $this->user->getId()
1802 );
1803 if (count($ass_info) > 0) {
1804 $ass_ids = array_map(static function ($i): int {
1805 return $i->getId();
1806 }, $ass_info);
1807 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
1808 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
1809 $this->tool_context->current()->addAdditionalData(
1811 $this->getAssignmentButtons()
1812 );
1813 }
1814 }
1815
1819 protected function getAssignmentButtons(): array
1820 {
1821 $ilCtrl = $this->ctrl;
1822 $ui = $this->ui;
1823 $lng = $this->lng;
1824
1825 $ass_info = ilExcRepoObjAssignment::getInstance()->getAssignmentInfoOfObj(
1826 $this->object->getRefId(),
1827 $this->user->getId()
1828 );
1829 $buttons = [];
1830 foreach ($ass_info as $i) { // should be only one
1831 $ass = new ilExAssignment($i->getId());
1832 $times_up = $ass->afterDeadlineStrict();
1833
1834 // submit button
1835 if (!$times_up) {
1836 $ilCtrl->setParameterByClass("ilwikipagegui", "ass", $ass->getId());
1837 $submit_link = $ilCtrl->getLinkTargetByClass("ilwikipagegui", "finalizeAssignment");
1838 $ilCtrl->setParameterByClass("ilwikipagegui", "ass", "");
1839
1840 $buttons[$i->getId()][] = $ui->factory()->button()->primary($lng->txt("wiki_finalize_wiki"), $submit_link);
1841 }
1842
1843 // submitted files
1844 $submission = new ilExSubmission($ass, $this->user->getId());
1845 if ($submission->hasSubmitted()) {
1846 $submitted = $submission->getSelectedObject();
1847 if ($submitted?->getTimestamp() != "") {
1848 $ilCtrl->setParameterByClass("ilwikipagegui", "ass", $ass->getId());
1849 }
1850 $dl_link = $ilCtrl->getLinkTargetByClass("ilwikipagegui", "downloadExcSubFile");
1851 $ilCtrl->setParameterByClass("ilwikipagegui", "ass", "");
1852 $buttons[$i->getId()][] = $ui->factory()->button()->standard($lng->txt("wiki_download_submission"), $dl_link);
1853 }
1854 }
1855 return $buttons;
1856 }
1857}
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:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$comments
$GLOBALS["DIC"]
Definition: wac.php:54