ILIAS  release_8 Revision v8.24
class.ilWikiPageGUI.php
Go to the documentation of this file.
1<?php
2
30{
31 protected \ILIAS\Notes\Service $notes;
32 protected \ILIAS\HTTP\Services $http;
33 protected \ILIAS\Wiki\Editing\EditingGUIRequest $wiki_request;
35 protected bool $fill_on_load_code = false;
36 protected int $wiki_ref_id = 0;
38 protected ilObjWiki $wiki;
39
40 public function __construct(
41 int $a_id = 0,
42 int $a_old_nr = 0,
43 int $a_wiki_ref_id = 0
44 ) {
45 global $DIC;
46
47 $this->settings = $DIC->settings();
48 $this->http = $DIC->http();
49
50 // needed for notifications
51 $this->setWikiRefId($a_wiki_ref_id);
52
53 parent::__construct("wpg", $a_id, $a_old_nr);
54 $this->getPageObject()->setWikiRefId($this->getWikiRefId());
55
56 // content style
57 $this->tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
58 $this->wiki_request = $DIC
59 ->wiki()
60 ->internal()
61 ->gui()
62 ->editing()
63 ->request();
64 $this->notes = $DIC->notes();
65 }
66
67 public function setScreenIdComponent(): void
68 {
69 $ilHelp = $this->help;
70 $ilHelp->setScreenIdComponent("copgwpg");
71 }
72
73 public function setWikiRefId(int $a_ref_id): void
74 {
75 $this->wiki_ref_id = $a_ref_id;
76 }
77
78 public function getWikiRefId(): int
79 {
80 return $this->wiki_ref_id;
81 }
82
83 public function setWiki(ilObjWiki $a_val): void
84 {
85 $this->wiki = $a_val;
86 }
87
88 public function getWiki(): ilObjWiki
89 {
90 return $this->wiki;
91 }
92
96 public function executeCommand(): string
97 {
98 $ilCtrl = $this->ctrl;
99 $ilTabs = $this->tabs_gui;
101 $ilAccess = $this->access;
104
105 $next_class = $this->ctrl->getNextClass($this);
106
107 $head_title = ilObject::_lookupTitle(ilObject::_lookupObjId($this->requested_ref_id)) .
108 ": " . $this->getWikiPage()->getTitle();
109 $tpl->setHeaderPageTitle($head_title);
110 // see #13804
111 if ($this->wiki_request->getPage() !== "") {
113 "wiki",
114 null,
115 "wpage_" . $this->getPageObject()->getId() . "_" . $this->requested_ref_id,
116 "",
117 $head_title
118 );
119 } else {
120 $tpl->setPermanentLink("wiki", $this->requested_ref_id);
121 }
122
123
124 switch ($next_class) {
125 case "ilnotegui":
126 $this->getTabs();
127 $ilTabs->setTabActive("pg");
128 return $this->preview();
129
130 case "ilratinggui":
131 // for rating side block
132 $rating_gui = new ilRatingGUI();
133 $rating_gui->setObject(
134 $this->getPageObject()->getParentId(),
135 "wiki",
136 $this->getPageObject()->getId(),
137 "wpg"
138 );
139 $rating_gui->setUpdateCallback(array($this, "updateStatsRating"));
140 $this->ctrl->forwardCommand($rating_gui);
141 $ilCtrl->redirect($this, "preview");
142 break;
143
144 case "ilcommonactiondispatchergui":
146 if (!is_null($gui)) {
147 $gui->enableCommentsSettings(false);
148 $gui->setRatingCallback(
149 $this,
150 "preview"
151 );
152 $this->ctrl->forwardCommand($gui);
153 }
154 break;
155
156 case "ilwikistatgui":
157 if ($ilAccess->checkAccess("statistics_read", "", $this->wiki_ref_id)) {
158 $this->tabs_gui->clearTargets(); // see ilObjWikiGUI::getTabs()
159 $this->getTabs("statistics");
160
161 $gui = new ilWikiStatGUI(
162 $this->getPageObject()->getParentId(),
163 $this->getPageObject()->getId()
164 );
165 $this->ctrl->forwardCommand($gui);
166 }
167 break;
168 case 'ilobjectmetadatagui':
169
170 if (!$ilAccess->checkAccess("write", "", $this->wiki_ref_id)) {
171 $this->tpl->setOnScreenMessage('failure', $lng->txt("permission_denied"), true);
172 $ilCtrl->redirect($this, "preview");
173 }
174 return parent::executeCommand();
175
176 case "ilpropertyformgui":
177 // only case is currently adv metadata internal link in info settings, see #24497
179 $ilCtrl->forwardCommand($form);
180 break;
181
182 default:
183
184 if (strtolower($ilCtrl->getNextClass()) === "ilpageeditorgui") {
185 self::initEditingJS($this->tpl);
186 }
187
188 if ($this->wiki_request->getNotification() > 0
189 && $ilUser->getId() !== ANONYMOUS_USER_ID) {
190 switch ($this->wiki_request->getNotification()) {
191 case 1:
192 ilNotification::setNotification(ilNotification::TYPE_WIKI, $ilUser->getId(), $this->getPageObject()->getParentId(), false);
193 break;
194
195 case 2:
196 // remove all page notifications here?
197 ilNotification::setNotification(ilNotification::TYPE_WIKI, $ilUser->getId(), $this->getPageObject()->getParentId(), true);
198 break;
199
200 case 3:
201 ilNotification::setNotification(ilNotification::TYPE_WIKI_PAGE, $ilUser->getId(), $this->getPageObject()->getId(), false);
202 break;
203
204 case 4:
205 ilNotification::setNotification(ilNotification::TYPE_WIKI_PAGE, $ilUser->getId(), $this->getPageObject()->getId(), true);
206 break;
207 }
208 $ilCtrl->redirect($this, "preview");
209 }
210
211 $this->setPresentationTitle($this->getWikiPage()->getTitle());
212 return parent::executeCommand();
213 }
214 return "";
215 }
216
217 public function setWikiPage(ilWikiPage $a_wikipage): void
218 {
219 $this->setPageObject($a_wikipage);
220 }
221
222 public function getWikiPage(): ilWikiPage
223 {
226 return $this->getPageObject();
227 }
228
232 public static function getGUIForTitle(
233 int $a_wiki_id,
234 string $a_title,
235 int $a_old_nr = 0,
236 int $a_wiki_ref_id = 0
237 ): ilWikiPageGUI {
238 $id = ilWikiPage::getPageIdForTitle($a_wiki_id, $a_title);
239 return new ilWikiPageGUI($id, $a_old_nr, $a_wiki_ref_id);
240 }
241
242 public function setSideBlock(): void
243 {
245 $this->getWikiPage()->getId(),
246 $this->wiki_ref_id,
247 $this->getWikiPage()
248 );
249 }
250
251 public function addHeaderAction(
252 bool $a_redraw = false
253 ): string {
254 $ilUser = $this->user;
255 $ilAccess = $this->access;
256
257 $wiki_id = $this->getPageObject()->getParentId();
258 $page_id = $this->getPageObject()->getId();
259
260 $dispatcher = new ilCommonActionDispatcherGUI(
262 $ilAccess,
263 "wiki",
264 $this->requested_ref_id,
265 $wiki_id
266 );
267
268 // see #33422
269 $dispatcher->setSubObject("wpg", $page_id);
270
272 $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
273 "",
274 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
275 );
276
277 $lg = $dispatcher->initHeaderAction();
278 $lg->enableNotes(true);
279 $lg->enableComments(ilObjWiki::_lookupPublicNotes($wiki_id), false);
280
281 // rating
282 if (ilObjWiki::_lookupRatingOverall($wiki_id)) {
283 $lg->enableRating(
284 true,
285 $this->lng->txt("wiki_rate_overall"),
286 false,
287 // so ilCtrl does not use the shortcut via ilWikiGUI
288 array("ilcommonactiondispatchergui", "ilratinggui"),
289 true
290 );
291 }
292
293 // notification
294 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
296 $this->ctrl->setParameter($this, "ntf", 1);
297 if (ilNotification::hasOptOut($wiki_id)) {
298 $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "wiki_notification_deactivate_wiki");
299 }
300
301 $lg->addHeaderIcon(
302 "not_icon",
303 ilUtil::getImagePath("notification_on.svg"),
304 $this->lng->txt("wiki_notification_activated")
305 );
306 } else {
307 $this->ctrl->setParameter($this, "ntf", 2);
308 $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "wiki_notification_activate_wiki");
309
311 $this->ctrl->setParameter($this, "ntf", 3);
312 $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "wiki_notification_deactivate_page");
313
314 $lg->addHeaderIcon(
315 "not_icon",
316 ilUtil::getImagePath("notification_on.svg"),
317 $this->lng->txt("wiki_page_notification_activated")
318 );
319 } else {
320 $this->ctrl->setParameter($this, "ntf", 4);
321 $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "wiki_notification_activate_page");
322
323 $lg->addHeaderIcon(
324 "not_icon",
325 ilUtil::getImagePath("notification_off.svg"),
326 $this->lng->txt("wiki_notification_deactivated")
327 );
328 }
329 }
330 $this->ctrl->setParameter($this, "ntf", "");
331 }
332
333 if (!$a_redraw) {
334 $this->tpl->setHeaderActionMenu($lg->getHeaderAction());
335 } else {
336 // we need to add onload code manually (rating, comments, etc.)
337 return $lg->getHeaderAction() .
338 $this->tpl->getOnLoadCodeForAsynch();
339 }
340 return "";
341 }
342
343 public function redrawHeaderAction(): void
344 {
345 echo $this->addHeaderAction(true);
346 exit;
347 }
348
349 public function preview(): string
350 {
351 $ilCtrl = $this->ctrl;
352 $ilAccess = $this->access;
355 $ilUser = $this->user;
357 $append = "";
358 $message = "";
359
360
361 // block/unblock
362 if ($this->getPageObject()->getBlocked()) {
363 $this->tpl->setOnScreenMessage('info', $lng->txt("wiki_page_status_blocked"));
364 }
365
366
367 $this->increaseViewCount();
368
369 $this->addHeaderAction();
370
371 // content
372 if ($ilCtrl->getNextClass() !== "ilnotegui") {
373 $this->setSideBlock();
374 }
375
376 $wtpl = new ilTemplate(
377 "tpl.wiki_page_view_main_column.html",
378 true,
379 true,
380 "Modules/Wiki"
381 );
382
383 $callback = array($this, "observeNoteAction");
384 // notes
385 if (!$ilSetting->get("disable_comments") &&
386 ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId())) {
387 $may_delete = ($ilSetting->get("comments_del_tutor", '1') &&
388 $ilAccess->checkAccess("write", "", $this->requested_ref_id));
389 $wtpl->setVariable("NOTES", $this->getNotesHTML(
390 $this->getPageObject(),
391 true,
392 ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()),
393 $may_delete,
394 $callback
395 ));
396 }
397
398
399 // page content
400 $this->setOutputMode(ilPageObjectGUI::PRESENTATION);
401 $this->showEditToolbar();
402 $this->setRenderPageContainer(true);
403 $wtpl->setVariable("PAGE", $this->showPage());
404
405 $tpl->setLoginTargetPar("wiki_" . $this->requested_ref_id . $append);
406
407 // last edited info
408 $wtpl->setVariable(
409 "LAST_EDITED_INFO",
410 $lng->txt("wiki_last_edited") . ": " .
412 new ilDateTime($this->getPageObject()->getLastChange(), IL_CAL_DATETIME)
413 ) . ", " .
415 $this->getPageObject()->getLastChangeUser(),
416 false,
417 true,
418 $ilCtrl->getLinkTarget($this, "preview")
419 )
420 );
421
422 $tpl->setLoginTargetPar("wiki_" . $this->requested_ref_id . $append);
423
424 //highlighting
425 if ($this->wiki_request->getSearchString()) {
426 $cache = ilUserSearchCache::_getInstance($ilUser->getId());
427 $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
428 $search_string = $cache->getQuery();
429
430 // advanced search?
431 if (is_array($search_string)) {
432 $search_string = $search_string["lom_content"];
433 }
434
435 $p = new ilQueryParser($search_string);
436 $p->parse();
437
438 $words = $p->getQuotedWords();
439 if (is_array($words)) {
440 foreach ($words as $w) {
441 ilTextHighlighterGUI::highlight("ilCOPageContent", $w, $tpl);
442 }
443 }
444 $this->fill_on_load_code = true;
445 }
446
447 return $message . $wtpl->get();
448 }
449
450 public function showPage(): string
451 {
452 if ($this->getOutputMode() === ilPageObjectGUI::PRESENTATION) {
453 $this->initToolbar();
454 }
455 $this->setTemplateOutput(false);
456
457 if (!$this->getAbstractOnly()) {
458 $this->setPresentationTitle($this->getWikiPage()->getTitle());
459
460 // wiki stats clean up
461 // $this->increaseViewCount();
462 }
463
464 return parent::showPage();
465 }
466
467 protected function initToolbar(): void
468 {
469 $toolbar = $this->toolbar;
470
471 $print_view = $this->getPrintView();
472 $modal_elements = $print_view->getModalElements($this->ctrl->getLinkTarget(
473 $this,
474 "printViewSelection"
475 ));
476 $toolbar->addComponent($modal_elements->button);
477 $toolbar->addComponent($modal_elements->modal);
478 }
479
480 protected function getPrintView(): \ILIAS\Export\PrintProcessGUI
481 {
482 $provider = new \ILIAS\Wiki\WikiPrintViewProviderGUI(
483 $this->lng,
484 $this->ctrl,
485 $this->getWikiPage()->getWikiRefId(),
486 []
487 );
488
489 return new \ILIAS\Export\PrintProcessGUI(
490 $provider,
491 $this->http,
492 $this->ui,
493 $this->lng
494 );
495 }
496
497 protected function increaseViewCount(): void
498 {
499 $ilUser = $this->user;
500
501 $this->getWikiPage()->increaseViewCnt();
502
503 // enable object statistics
505 "wiki",
506 $this->getWikiPage()->getWikiRefId(),
507 $this->getWikiPage()->getWikiId(),
508 $ilUser->getId()
509 );
510
512 }
513
514 public function postOutputProcessing(string $a_output): string
515 {
516 $ilCtrl = $this->ctrl;
517
518 $ilCtrl->setParameterByClass(
519 "ilobjwikigui",
520 "from_page",
521 ilWikiUtil::makeUrlTitle($this->wiki_request->getPage())
522 );
523 if ($this->getEnabledHref() && $this->getOutputMode() !== self::EDIT) {
525 $a_output,
526 $this->getWikiPage()->getWikiId(),
527 ($this->getOutputMode() === "offline")
528 );
529 } else {
530 $output = $a_output;
531 }
532 $ilCtrl->setParameterByClass(
533 "ilobjwikigui",
534 "from_page",
535 $this->wiki_request->getFromPage()
536 );
537
538
539 // metadata in print view
540 if ($this->getOutputMode() === "print" && $this->wiki instanceof ilObjWiki) {
541 $mdgui = new ilObjectMetaDataGUI($this->wiki, "wpg", $this->getId());
542 $md = $mdgui->getKeyValueList();
543 if ($md !== "") {
544 $output = str_replace("<!--COPage-PageTop-->", "<p>" . $md . "</p>", $output);
545 }
546 }
547
548
549 return $output;
550 }
551
552 public function whatLinksHere(): void
553 {
555
556 $this->setSideBlock();
557 $table_gui = new ilWikiPagesTableGUI(
558 $this,
559 "whatLinksHere",
560 $this->getWikiPage()->getWikiId(),
562 $this->wiki_request->getWikiPageId()
563 );
564
565 $tpl->setContent($table_gui->getHTML());
566 }
567
568 public function getTabs(
569 string $a_activate = ""
570 ): void {
571 $ilTabs = $this->tabs_gui;
572 $ilCtrl = $this->ctrl;
573 $ilAccess = $this->access;
574
575 parent::getTabs($a_activate);
576
577 if ($ilAccess->checkAccess("statistics_read", "", $this->requested_ref_id)) {
578 $ilTabs->addTarget(
579 "statistics",
580 $this->ctrl->getLinkTargetByClass(
581 array("ilwikipagegui", "ilwikistatgui"),
582 "initial"
583 ),
584 "",
585 "ilwikistatgui"
586 );
587 }
588
589 $ilCtrl->setParameterByClass(
590 "ilobjwikigui",
591 "wpg_id",
593 $this->getPageObject()->getParentId(),
594 ilWikiUtil::makeDbTitle($this->wiki_request->getPage())
595 )
596 );
597 $ilCtrl->setParameterByClass(
598 "ilobjwikigui",
599 "page",
600 ilWikiUtil::makeUrlTitle($this->wiki_request->getPage())
601 );
602
603 $ilTabs->addTarget(
604 "wiki_what_links_here",
605 $this->ctrl->getLinkTargetByClass(
606 "ilwikipagegui",
607 "whatLinksHere"
608 ),
609 "whatLinksHere"
610 );
611 }
612
613 public function deleteWikiPageConfirmationScreen(): void
614 {
616 $ilCtrl = $this->ctrl;
618
619 if (ilWikiPerm::check("delete_wiki_pages", $this->requested_ref_id)) {
620 $confirmation_gui = new ilConfirmationGUI();
621 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
622 $confirmation_gui->setHeaderText($lng->txt("wiki_page_deletion_confirmation"));
623 $confirmation_gui->setCancel($lng->txt("cancel"), "cancelWikiPageDeletion");
624 $confirmation_gui->setConfirm($lng->txt("delete"), "confirmWikiPageDeletion");
625
626 $dtpl = new ilTemplate(
627 "tpl.wiki_page_deletion_confirmation.html",
628 true,
629 true,
630 "Modules/Wiki"
631 );
632
633 $dtpl->setVariable("PAGE_TITLE", $this->getWikiPage()->getTitle());
634
635 // other pages that link to this page
636 $dtpl->setVariable("TXT_OTHER_PAGES", $lng->txt("wiki_other_pages_linking"));
638 $this->getWikiPage()->getWikiId(),
639 $this->getWikiPage()->getId()
640 );
641 if (count($pages) > 0) {
642 foreach ($pages as $page) {
643 $dtpl->setCurrentBlock("lpage");
644 $dtpl->setVariable("TXT_LINKING_PAGE", $page["title"]);
645 $dtpl->parseCurrentBlock();
646 }
647 } else {
648 $dtpl->setCurrentBlock("lpage");
649 $dtpl->setVariable("TXT_LINKING_PAGE", "-");
650 $dtpl->parseCurrentBlock();
651 }
652
653 // contributors
654 $dtpl->setVariable("TXT_CONTRIBUTORS", $lng->txt("wiki_contributors"));
655 $contributors = ilWikiPage::getWikiPageContributors($this->getWikiPage()->getId());
656 foreach ($contributors as $contributor) {
657 $dtpl->setCurrentBlock("contributor");
658 $dtpl->setVariable(
659 "TXT_CONTRIBUTOR",
660 $contributor["lastname"] . ", " . $contributor["firstname"]
661 );
662 $dtpl->parseCurrentBlock();
663 }
664
665 // notes/comments
666 $cnt_note_users = $this->notes->domain()->getUserCount(
667 $this->getPageObject()->getParentId(),
668 $this->getPageObject()->getId(),
669 "wpg"
670 );
671 $dtpl->setVariable(
672 "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
673 $lng->txt("wiki_number_users_notes_or_comments")
674 );
675 $dtpl->setVariable("TXT_NR_NOTES_COMMENTS", $cnt_note_users);
676
677 $confirmation_gui->addItem("", "", $dtpl->get());
678
679 $tpl->setContent($confirmation_gui->getHTML());
680 }
681 }
682
683 public function cancelWikiPageDeletion(): void
684 {
685 $ilCtrl = $this->ctrl;
686
687 $ilCtrl->redirect($this, "preview");
688 }
689
690 public function confirmWikiPageDeletion(): void
691 {
692 $ilCtrl = $this->ctrl;
694
695 if (ilWikiPerm::check("delete_wiki_pages", $this->requested_ref_id)) {
696 $this->getPageObject()->delete();
697
698 $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_page_deleted"), true);
699 }
700
701 $ilCtrl->redirectByClass("ilobjwikigui", "allPages");
702 }
703
707
708 public function printViewSelection(): void
709 {
710 $view = $this->getPrintView();
711 $view->sendForm();
712 }
713
714 public function printViewOrder(): void
715 {
716 $this->printViewOrderList();
717 }
718
719 protected function printViewOrderList(
720 ): void {
721 $ilTabs = $this->tabs_gui;
722
723 $pg_ids = $all_pages = array();
724
725 // coming from type selection
726 $ordering = $this->wiki_request->getPrintOrdering();
727 if (count($ordering) === 0) {
728 switch ($this->wiki_request->getSelectedPrintType()) {
729 case "wiki":
730 $all_pages = ilWikiPage::getAllWikiPages($this->getPageObject()->getWikiId());
731 foreach ($all_pages as $p) {
732 $pg_ids[] = $p["id"];
733 }
734 break;
735
736 case "selection":
737 $pg_ids = $this->wiki_request->getWikiPageIds();
738 if (count($pg_ids) === 0) {
739 $pg_ids = [$this->wiki_request->getWikiPageId()];
740 }
741 if (count($pg_ids) > 1) {
742 break;
743 } else {
744 $wiki_page_id = array_pop($pg_ids);
745 }
746 $this->ctrl->setParameterByClass(
747 "ilObjWikiGUI",
748 "wpg_id",
749 $wiki_page_id
750 );
751 $this->ctrl->redirectByClass("ilObjWikiGUI", "printView");
752 break;
753
754 default:
755 $this->ctrl->setParameterByClass(
756 "ilObjWikiGUI",
757 "wpg_id",
758 $this->wiki_request->getWikiPageId()
759 );
760 $this->ctrl->redirectByClass("ilObjWikiGUI", "printView");
761 break;
762 }
763 }
764 // refresh sorting
765 else {
766 asort($ordering);
767 $pg_ids = array_keys($ordering);
768 }
769
770 $ilTabs->clearTargets();
771 $ilTabs->setBackTarget(
772 $this->lng->txt("back"),
773 $this->ctrl->getLinkTarget($this, "preview")
774 );
775
776 if (!count($all_pages)) {
777 $all_pages = ilWikiPage::getAllWikiPages($this->getPageObject()->getWikiId());
778 }
779
780 $tbl = new ilWikiExportOrderTableGUI(
781 $this,
782 "printViewOrderList",
783 $all_pages,
784 $pg_ids
785 );
786 $this->tpl->setContent($tbl->getHTML());
787 }
788
789
793
794 public function blockWikiPage(): void
795 {
796 $ilCtrl = $this->ctrl;
798
799 if (ilWikiPerm::check("activate_wiki_protection", $this->requested_ref_id)) {
800 $this->getPageObject()->setBlocked(true);
801 $this->getPageObject()->update();
802
803 $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_page_blocked"), true);
804 }
805
806 $ilCtrl->redirect($this, "preview");
807 }
808
809 public function unblockWikiPage(): void
810 {
811 $ilCtrl = $this->ctrl;
813
814 if (ilWikiPerm::check("activate_wiki_protection", $this->requested_ref_id)) {
815 $this->getPageObject()->setBlocked(false);
816 $this->getPageObject()->update();
817
818 $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_page_unblocked"), true);
819 }
820
821 $ilCtrl->redirect($this, "preview");
822 }
823
824
828
829 public function renameWikiPage(): void
830 {
831 $ilAccess = $this->access;
833
834 if (($ilAccess->checkAccess(
835 "edit_content",
836 "",
837 $this->requested_ref_id
838 ) && !$this->getPageObject()->getBlocked())
839 || $ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
840 $this->initRenameForm();
841 $tpl->setContent($this->form->getHTML());
842 }
843 }
844
845 protected function initRenameForm(): void
846 {
848 $ilCtrl = $this->ctrl;
849
850 $this->form = new ilPropertyFormGUI();
851
852 // new name
853 $ti = new ilTextInputGUI($lng->txt("wiki_new_page_name"), "new_page_name");
854 $ti->setMaxLength(200);
855 $ti->setSize(50);
856 $ti->setValue($this->getPageObject()->getTitle());
857 $ti->setRequired(true);
858 $this->form->addItem($ti);
859
860 $this->form->addCommandButton("renamePage", $lng->txt("wiki_rename"));
861 $this->form->addCommandButton("preview", $lng->txt("cancel"));
862
863 $this->form->setTitle($lng->txt("wiki_rename_page"));
864 $this->form->setFormAction($ilCtrl->getFormAction($this));
865 }
866
867 public function renamePage(): void
868 {
871 $ilCtrl = $this->ctrl;
872 $ilAccess = $this->access;
873
874 $this->initRenameForm();
875 if ($this->form->checkInput()) {
876 if (($ilAccess->checkAccess("edit_content", "", $this->requested_ref_id) && !$this->getPageObject()->getBlocked())
877 || $ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
878 $new_name = $this->form->getInput("new_page_name");
879
880 $page_title = ilWikiUtil::makeDbTitle($new_name);
881 $pg_id = ilWikiPage::_getPageIdForWikiTitle($this->getPageObject()->getWikiId(), $page_title);
882
883 // we might get the same page id back here, if the page
884 // name only differs in diacritics
885 // see bug http://www.ilias.de/mantis/view.php?id=11226
886 if ($pg_id > 0 && $pg_id != $this->getPageObject()->getId()) {
887 $this->tpl->setOnScreenMessage('failure', $lng->txt("wiki_page_already_exists"));
888 } else {
889 $new_name = $this->getPageObject()->rename($new_name);
890 $ilCtrl->setParameterByClass("ilobjwikigui", "page", ilWikiUtil::makeUrlTitle($new_name));
891 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
892 $ilCtrl->redirect($this, "preview");
893 }
894 }
895 }
896
897 $this->form->setValuesByPost();
898 $tpl->setContent($this->form->getHTML());
899 }
900
904
905 public function activateWikiPageRating(): void
906 {
908 $ilCtrl = $this->ctrl;
909
910 $this->getPageObject()->setRating(true);
911 $this->getPageObject()->update();
912
913 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
914 $ilCtrl->redirect($this, "preview");
915 }
916
917 public function deactivateWikiPageRating(): void
918 {
920 $ilCtrl = $this->ctrl;
921
922 $this->getPageObject()->setRating(false);
923 $this->getPageObject()->update();
924
925 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
926 $ilCtrl->redirect($this, "preview");
927 }
928
929
930 public function observeNoteAction(
931 int $a_wiki_id,
932 int $a_page_id,
933 string $a_type,
934 string $a_action,
935 int $a_note_id
936 ): void {
937
938 // #10040 - get note text
939 $note = $this->notes->domain()->getById($a_note_id);
940 $text = $note->getText();
941
942 ilWikiUtil::sendNotification("comment", ilNotification::TYPE_WIKI_PAGE, $this->getWikiRefId(), $a_page_id, $text);
943 }
944
945 public function updateStatsRating(
946 int $a_wiki_id,
947 string $a_wiki_type,
948 int $a_page_id,
949 string $a_page_type
950 ): void {
951 ilWikiStat::handleEvent(ilWikiStat::EVENT_PAGE_RATING, $this->getWikiPage());
952 }
953
954
955 //
956 // advanced meta data
957 //
958
960 {
961 $ilCtrl = $this->ctrl;
963
964 $page = $this->getWikiPage();
965
966 $form = new ilPropertyFormGUI();
967 $form->setFormAction($ilCtrl->getFormAction($this, "updateAdvancedMetaData"));
968
969 // :TODO:
970 $form->setTitle($lng->txt("wiki_advmd_block_title") . ": " . $page->getTitle());
971
972 $this->record_gui = new ilAdvancedMDRecordGUI(
974 'wiki',
975 $page->getWikiId(),
976 'wpg',
977 $page->getId()
978 );
979 $this->record_gui->setPropertyForm($form);
980 $this->record_gui->parse();
981
982 $form->addCommandButton("updateAdvancedMetaData", $lng->txt("save"));
983 $form->addCommandButton("preview", $lng->txt("cancel"));
984
985 return $form;
986 }
987
988 public function editAdvancedMetaData(
989 ilPropertyFormGUI $a_form = null
990 ): void {
991 $ilTabs = $this->tabs_gui;
993 $ilCtrl = $this->ctrl;
995 $ilAccess = $this->access;
996
997 if (!$ilAccess->checkAccess("write", "", $this->wiki_ref_id) &&
998 !$ilAccess->checkAccess("edit_page_meta", "", $this->wiki_ref_id)) {
999 return;
1000 }
1001
1002
1003 $ilTabs->clearTargets();
1004 $ilTabs->setBackTarget(
1005 $lng->txt("back"),
1006 $ilCtrl->getLinkTarget($this, "preview")
1007 );
1008
1009 if (!$a_form) {
1010 $a_form = $this->initAdvancedMetaDataForm();
1011 }
1012
1013 $tpl->setContent($a_form->getHTML());
1014 }
1015
1016 public function updateAdvancedMetaData(): void
1017 {
1018 $ilCtrl = $this->ctrl;
1019 $lng = $this->lng;
1020 $ilAccess = $this->access;
1021
1022 if (!$ilAccess->checkAccess("write", "", $this->wiki_ref_id) &&
1023 !$ilAccess->checkAccess("edit_page_meta", "", $this->wiki_ref_id)) {
1024 return;
1025 }
1026
1027 $form = $this->initAdvancedMetaDataForm();
1028
1029 // needed for proper advanced MD validation
1030 $form->checkInput();
1031 if (!$this->record_gui->importEditFormPostValues()) {
1032 $this->editAdvancedMetaData($form); // #16470
1033 return;
1034 }
1035
1036 if ($this->record_gui->writeEditForm()) {
1037 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
1038 }
1039 $ilCtrl->redirect($this, "preview");
1040 }
1041
1042 public function hideAdvancedMetaData(): void
1043 {
1044 $ilCtrl = $this->ctrl;
1045 $lng = $this->lng;
1046 $ilAccess = $this->access;
1047
1048 if (!$ilAccess->checkAccess("write", "", $this->wiki_ref_id) &&
1049 !$ilAccess->checkAccess("edit_page_meta", "", $this->wiki_ref_id)) {
1050 return;
1051 }
1052
1053 $this->getPageObject()->hideAdvancedMetadata(true);
1054 $this->getPageObject()->update();
1055
1056 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
1057 $ilCtrl->redirect($this, "preview");
1058 }
1059
1060 public function unhideAdvancedMetaData(): void
1061 {
1062 $ilCtrl = $this->ctrl;
1063 $lng = $this->lng;
1064 $ilAccess = $this->access;
1065
1066 if (!$ilAccess->checkAccess("write", "", $this->wiki_ref_id) &&
1067 !$ilAccess->checkAccess("edit_page_meta", "", $this->wiki_ref_id)) {
1068 return;
1069 }
1070
1071 $this->getPageObject()->hideAdvancedMetadata(false);
1072 $this->getPageObject()->update();
1073
1074 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
1075 $ilCtrl->redirect($this, "preview");
1076 }
1077
1078 public function edit(): string
1079 {
1080 $tpl = $this->tpl;
1081 $lng = $this->lng;
1082
1083 self::initEditingJS($tpl);
1084
1085 return parent::edit();
1086 }
1087
1088 public static function initEditingJS(ilGlobalTemplateInterface $a_tpl): void
1089 {
1090 global $DIC;
1091
1092 $lng = $DIC->language();
1093
1094 $a_tpl->addJavaScript("./Modules/Wiki/js/WikiEdit.js");
1095 $a_tpl->addOnLoadCode("il.Wiki.Edit.txt.page_exists = '" . $lng->txt("wiki_page_exists") . "';");
1096 $a_tpl->addOnLoadCode("il.Wiki.Edit.txt.new_page = '" . $lng->txt("wiki_new_page") . "';");
1097 }
1098
1099
1103 public function insertWikiLink(): void
1104 {
1105 $lng = $this->lng;
1106 $ilCtrl = $this->ctrl;
1107
1108 $form = new ilPropertyFormGUI();
1109 $form->addCommandButton("addWikiLink", $lng->txt("wiki_add_link"));
1110 $form->addCommandButton("searchWikiLink", $lng->txt("search"));
1111
1112 // Target page
1113 $tp = new ilTextInputGUI($this->lng->txt("wiki_target_page"), "target_page");
1114 $tp->setSize(18);
1115 $tp->setRequired(true);
1116 $tp->setInfo("...");
1117 $tp->setDataSource($ilCtrl->getLinkTarget($this, "insertWikiLinkAC", "", true));
1118 $form->addItem($tp);
1119
1120 // Link text
1121 $lt = new ilTextInputGUI($this->lng->txt("wiki_link_text"), "link_text");
1122 $lt->setSize(18);
1123 $form->addItem($lt);
1124
1125 //$form->setTitle($lng->txt("wiki_link"));
1126
1127 echo $form->getHTML();
1128 exit;
1129 }
1130
1134 public function insertWikiLinkAC(): void
1135 {
1136 $result = array();
1137
1138 $term = $this->wiki_request->getTerm();
1139
1140 // if page exists, make it first entry
1141 if (ilWikiPage::_wikiPageExists($this->getPageObject()->getParentId(), $term)) {
1142 $entry = new stdClass();
1143 $entry->value = $term;
1144 $entry->label = $term;
1145 $result[] = $entry;
1146 }
1147
1148 $res = ilWikiPage::getPagesForSearch($this->getPageObject()->getParentId(), $term);
1149
1150 $cnt = 0;
1151 foreach ($res as $r) {
1152 if ($result[0]->value == $r) {
1153 continue;
1154 }
1155 if ($cnt++ > 19) {
1156 continue;
1157 }
1158 $entry = new stdClass();
1159 $entry->value = $r;
1160 $entry->label = $r;
1161 $result[] = $entry;
1162 }
1163
1164 echo json_encode($result, JSON_THROW_ON_ERROR);
1165 exit;
1166 }
1167
1171 public function searchWikiLinkAC(): void
1172 {
1173 $lng = $this->lng;
1174
1175 $lng->loadLanguageModule("wiki");
1176
1177 $tpl = new ilTemplate("tpl.wiki_ac_search_result.html", true, true, "Modules/Wiki");
1178 $term = $this->wiki_request->getTerm();
1179
1180 $pages = ilObjWiki::_performSearch($this->getPageObject()->getParentId(), $term);
1181
1182 $found = array();
1183 foreach ($pages as $page) {
1184 $found[] = array("page_id" => $page["page_id"], "title" => ilWikiPage::lookupTitle($page["page_id"]));
1185 }
1186
1187 // sort if all pages are listed
1188 if ($term === "") {
1189 $found = ilArrayUtil::sortArray($found, "title", "asc");
1190 }
1191
1192 foreach ($found as $f) {
1193 $tpl->setCurrentBlock("item");
1194 $tpl->setVariable("WIKI_TITLE", $f["title"]);
1195 $tpl->parseCurrentBlock();
1196 }
1197
1198 if (count($pages) === 0) {
1199 $tpl->setVariable("INFOTEXT", str_replace("$1", $term, $lng->txt("wiki_no_page_found")));
1200 } elseif ($term === '') {
1201 $tpl->setVariable("INFOTEXT", $lng->txt("wiki_no_search_term"));
1202 } else {
1203 $tpl->setVariable("INFOTEXT", str_replace("$1", $term, $lng->txt("wiki_pages_found")));
1204 }
1205
1206 $tpl->setVariable("TXT_BACK", $lng->txt("back"));
1207 echo $tpl->get();
1208 exit;
1209 }
1210
1211 //
1212 // exercise assignment
1213 //
1214
1218 protected function finalizeAssignment(): void
1219 {
1220 $ilCtrl = $this->ctrl;
1221 $lng = $this->lng;
1222
1224
1225 $ass_id = $this->wiki_request->getAssignmentId();
1226 $wiki_ass->submitWiki($ass_id, $this->user->getId(), $this->getWikiRefId());
1227
1228 $this->tpl->setOnScreenMessage('success', $lng->txt("wiki_finalized"), true);
1229 $ilCtrl->redirectByClass("ilObjWikiGUI", "gotoStartPage");
1230 }
1231
1232 protected function downloadExcSubFile(): void
1233 {
1234 $ilUser = $this->user;
1235
1236 $ass_id = $this->wiki_request->getAssignmentId();
1237 $ass = new ilExAssignment($ass_id);
1238 $submission = new ilExSubmission($ass, $ilUser->getId());
1239 $submitted = $submission->getFiles();
1240 if (count($submitted) > 0) {
1241 $submitted = array_pop($submitted);
1242
1243 $user_data = ilObjUser::_lookupName($submitted["user_id"]);
1244 $title = ilObject::_lookupTitle($submitted["obj_id"]) . " - " .
1245 $ass->getTitle() . " (Team " . $submission->getTeam()->getId() . ").zip";
1246
1247 ilFileDelivery::deliverFileLegacy($submitted["filename"], $title);
1248 }
1249 }
1250
1251 public function getCommentsHTMLExport(): string
1252 {
1253 return $this->getNotesHTML(
1254 $this->getPageObject(),
1255 false,
1256 ilObjWiki::_lookupPublicNotes($this->getPageObject()->getParentId()),
1257 false,
1258 null,
1259 true
1260 );
1261 }
1262}
const IL_CAL_DATETIME
const IL_WIKI_WHAT_LINKS_HERE
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
Exercise assignment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
setScreenIdComponent(string $a_comp)
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 hasOptOut(int $obj_id)
Is opt out (disable notification) allowed?
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
static _lookupName(int $a_user_id)
lookup user name
static renderSideBlock(int $a_wpg_id, int $a_wiki_ref_id, ?ilWikiPage $a_wp=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _performSearch(int $a_wiki_id, string $a_searchterm)
Search in Wiki.
static _lookupPublicNotes(int $a_wiki_id)
Lookup whether public notes are activated.
static _lookupRatingOverall(int $a_wiki_id)
Lookup whether rating is activated for whole object.
static prepareJsLinks(string $redraw_url, string $notes_url, string $tags_url, ilGlobalTemplateInterface $tpl=null)
Insert js/ajax links into template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
Class ilPageObjectGUI.
setPresentationTitle(string $a_title="")
ilAccessHandler $access
ilPropertyFormGUI $form
ilGlobalTemplateInterface $tpl
setPageObject(ilPageObject $a_pg_obj)
This class represents a property form user interface.
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...
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static _getInstance(int $a_usr_id)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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 initEditingJS(ilGlobalTemplateInterface $a_tpl)
updateStatsRating(int $a_wiki_id, string $a_wiki_type, int $a_page_id, string $a_page_type)
__construct(int $a_id=0, int $a_old_nr=0, int $a_wiki_ref_id=0)
activateWikiPageRating()
Rating /.
setWikiPage(ilWikiPage $a_wikipage)
getTabs(string $a_activate="")
showPage()
display content of page
ILIAS HTTP Services $http
setWikiRefId(int $a_ref_id)
insertWikiLink()
Returns form to insert a wiki link per ajax.
ilAdvancedMDRecordGUI $record_gui
editAdvancedMetaData(ilPropertyFormGUI $a_form=null)
addHeaderAction(bool $a_redraw=false)
finalizeAssignment()
Finalize and submit blog to exercise.
observeNoteAction(int $a_wiki_id, int $a_page_id, string $a_type, string $a_action, int $a_note_id)
insertWikiLinkAC()
Auto complete for insert wiki link.
searchWikiLinkAC()
Search wiki link list.
ILIAS Notes Service $notes
postOutputProcessing(string $a_output)
Finalizing output processing.
setWiki(ilObjWiki $a_val)
static getGUIForTitle(int $a_wiki_id, string $a_title, int $a_old_nr=0, int $a_wiki_ref_id=0)
Get wiki page gui for id and title.
ILIAS Wiki Editing EditingGUIRequest $wiki_request
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllWikiPages(int $a_wiki_id)
static getPagesForSearch(int $a_wiki_id, string $a_term)
static getWikiPageContributors(int $a_page_id)
static getLinksToPage(int $a_wiki_id, int $a_page_id)
static getPageIdForTitle(int $a_wiki_id, string $a_title)
Get wiki page object for id and title.
static _wikiPageExists(int $a_wiki_id, string $a_title)
static lookupTitle(int $a_page_id)
static _getPageIdForWikiTitle(int $a_wiki_id, string $a_title)
TableGUI class for wiki pages table.
static check(string $a_perm, int $a_ref_id, string $a_cmd="")
Wiki statistics GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const EVENT_PAGE_READ
static handleEvent(int $a_event, ilWikiPage $a_page_obj, ?int $a_user_id=null, array $a_additional_data=null)
Handle wiki page event.
static makeUrlTitle(string $a_par)
static replaceInternalLinks(string $s, int $a_wiki_id, bool $a_offline=false)
This one is based on Mediawiki Parser->replaceInternalLinks since we display images in another way,...
static sendNotification(string $a_action, int $a_type, int $a_wiki_ref_id, int $a_page_id, ?string $a_comment=null)
static makeDbTitle(string $a_par)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
setPermanentLink(string $a_type, ?int $a_id, string $a_append="", string $a_target="", string $a_title="")
Generates and sets a permanent ilias link.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
setHeaderPageTitle(string $a_title)
Sets the title of the page (for browser window).
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
exit
Definition: login.php:28
$res
Definition: ltiservices.php:69
$provider
Definition: ltitoken.php:83
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
form( $class_path, string $cmd)
Class ChatMainBarProvider \MainMenu\Provider.
global $ilSetting
Definition: privfeed.php:17
$lng
$message
Definition: xapiexit.php:32