ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilWikiPage.php
Go to the documentation of this file.
1<?php
2
25{
26 protected \ILIAS\Wiki\Page\PageDBRepository $repo;
28 protected \ILIAS\Wiki\InternalService $service;
29 protected int $parent_ref_id = 0;
30 protected string $title = "";
31 protected bool $blocked = false;
32 protected bool $rating = false;
33 protected bool $hide_adv_md = false;
34
35 public function getParentType(): string
36 {
37 return "wpg";
38 }
39
40 public function afterConstructor(): void
41 {
42 global $DIC;
43 $this->service = $DIC->wiki()->internal();
44 $this->getPageConfig()->configureByObjectId($this->getParentId());
45 $this->wiki_log = $this->service->domain()->log();
46 $this->repo = $this->service->repo()->page();
47 }
48
53 protected function getNotificationGUI(): \ILIAS\Wiki\Notification\NotificationGUI
54 {
55 return $this->service->gui()->notification();
56 }
57
58 public function setTitle(string $a_title): void
59 {
60 $this->title = ilWikiUtil::makeDbTitle($a_title);
61 }
62
63 public function getTitle(): string
64 {
65 return $this->title;
66 }
67
68 public function setWikiId(int $a_wikiid): void
69 {
70 $this->setParentId($a_wikiid);
71 }
72
73 public function getWikiId(): int
74 {
75 return $this->getParentId();
76 }
77
78 public function setWikiRefId(int $a_wiki_ref_id): void
79 {
80 $this->parent_ref_id = $a_wiki_ref_id;
81 }
82
83 public function getWikiRefId(): int
84 {
86 }
87
88 public function setBlocked(bool $a_val): void
89 {
90 $this->blocked = $a_val;
91 }
92
93 public function getBlocked(): bool
94 {
95 return $this->blocked;
96 }
97
98 public function setRating(bool $a_val): void
99 {
100 $this->rating = $a_val;
101 }
102
103 public function getRating(): bool
104 {
105 return $this->rating;
106 }
107
108 public function hideAdvancedMetadata(bool $a_val): void
109 {
110 $this->hide_adv_md = $a_val;
111 }
112
113 public function isAdvancedMetadataHidden(): bool
114 {
115 return $this->hide_adv_md;
116 }
117
118 public function createFromXML(): void
119 {
121
122 // ilWikiDataset creates wiki pages without copage objects
123 // (see create function in this class, parameter $a_prevent_page_creation)
124 // The ilCOPageImporter will call createFromXML without running through the read
125 // method -> we will miss the important wiki id, thus we read it now
126 // see also bug #12224
127 $set = $ilDB->query(
128 "SELECT id FROM il_wiki_page " .
129 " WHERE id = " . $ilDB->quote($this->getId(), "integer") .
130 " AND lang = " . $ilDB->quote($this->getLanguage(), "text")
131 );
132 if ($rec = $ilDB->fetchAssoc($set)) {
133 $this->read(true);
134 }
135
136 parent::createFromXML();
137 }
138
139 public function create(
140 bool $a_import = false
141 ): void {
142 $ilDB = $this->db;
143
144 // get new id, if not a translation page
145 if (in_array($this->getLanguage(), ["-", ""]) && $this->getId() == 0) {
146 $id = $ilDB->nextId("il_wiki_page");
147 $this->setId($id);
148 }
149
150 $query = "INSERT INTO il_wiki_page (" .
151 "id" .
152 ", title" .
153 ", wiki_id" .
154 ", blocked" .
155 ", rating" .
156 ", hide_adv_md" .
157 ", lang" .
158 ", create_date" .
159 " ) VALUES (" .
160 $ilDB->quote($this->getId(), "integer")
161 . "," . $ilDB->quote($this->getTitle(), "text")
162 . "," . $ilDB->quote($this->getWikiId(), "integer")
163 . "," . $ilDB->quote((int) $this->getBlocked(), "integer")
164 . "," . $ilDB->quote((int) $this->getRating(), "integer")
165 . "," . $ilDB->quote((int) $this->isAdvancedMetadataHidden(), "integer")
166 . "," . $ilDB->quote($this->getLanguage(), "text")
167 . "," . $ilDB->now()
168 . ")";
169 $this->wiki_log->debug($query);
170 $ilDB->manipulate($query);
171
172 // create page object
173 if (!$a_import) {
174 parent::create($a_import);
175 $this->saveInternalLinks($this->getDomDoc());
176
178 $this->getNotificationGUI()->send(
179 "new",
181 $this->getWikiRefId(),
182 $this->getId(),
183 null,
184 $this->getLanguage()
185 );
186 }
187
188 $this->updateNews();
189 }
190
191 public function afterUpdate(
192 DOMDocument $domdoc,
193 string $xml
194 ): void {
195 // internal == wiki links
196
197 $this->wiki_log->debug("collect internal links");
198 $int_links = count(ilWikiUtil::collectInternalLinks($xml, $this->getWikiId(), true));
199
200 $xpath = new DOMXPath($domdoc);
201
202 // external = internal + external links
203 $ext_links = count($xpath->query('//IntLink'));
204 $ext_links += count($xpath->query('//ExtLink'));
205
206 $footnotes = count($xpath->query('//Footnote'));
207
208
209 // words/characters (xml)
210
211 $xml = strip_tags($xml);
212
213 $num_chars = ilStr::strLen($xml);
214 $num_words = count(explode(" ", $xml));
215
216 $page_data = array(
217 "int_links" => $int_links,
218 "ext_links" => $ext_links,
219 "footnotes" => $footnotes,
220 "num_words" => $num_words,
221 "num_chars" => $num_chars
222 );
223 $this->wiki_log->debug("handle stats");
225 }
226
231 public function update(
232 bool $a_validate = true,
233 bool $a_no_history = false
234 ): array|bool {
235 $ilDB = $this->db;
236 $this->wiki_log->debug("start...");
237 // update wiki page data
238 $query = "UPDATE il_wiki_page SET " .
239 " title = " . $ilDB->quote($this->getTitle(), "text") .
240 ",wiki_id = " . $ilDB->quote($this->getWikiId(), "integer") .
241 ",blocked = " . $ilDB->quote((int) $this->getBlocked(), "integer") .
242 ",rating = " . $ilDB->quote((int) $this->getRating(), "integer") .
243 ",hide_adv_md = " . $ilDB->quote((int) $this->isAdvancedMetadataHidden(), "integer") .
244 " WHERE id = " . $ilDB->quote($this->getId(), "integer") .
245 " AND lang = " . $ilDB->quote($this->getLanguage(), "text");
246 $ilDB->manipulate($query);
247 $updated = parent::update($a_validate, $a_no_history);
248 if ($updated === true) {
249 $this->wiki_log->debug("send notification");
250 $this->getNotificationGUI()->send(
251 "update",
253 $this->getWikiRefId(),
254 $this->getId(),
255 null,
256 $this->getLanguage()
257 );
258
259 $this->wiki_log->debug("update news");
260 ilObjectSearch::raiseContentChanged($this->getWikiId());
261 $this->updateNews(true);
262 } else {
263 return $updated;
264 }
265
266 return true;
267 }
268
269 public function read(
270 bool $a_omit_page_read = false
271 ): void {
272 $ilDB = $this->db;
273
274 $query = "SELECT * FROM il_wiki_page WHERE id = " .
275 $ilDB->quote($this->getId(), "integer") .
276 " AND lang = " . $ilDB->quote($this->getLanguage(), "text");
277
278 $set = $ilDB->query($query);
279 $rec = $ilDB->fetchAssoc($set);
280
281 $this->setTitle($rec["title"]);
282 $this->setWikiId((int) $rec["wiki_id"]);
283 $this->setBlocked((bool) $rec["blocked"]);
284 $this->setRating((bool) $rec["rating"]);
285 $this->hideAdvancedMetadata((bool) $rec["hide_adv_md"]);
286
287 // get co page
288 if (!$a_omit_page_read) {
289 parent::read();
290 }
291 }
292
293
294 public function delete(): void
295 {
296 $imp_pages = $this->service->domain()->importantPage($this->getWikiRefId());
297
298 $ilDB = $this->db;
299
300 // get other pages that link to this page
301 $linking_pages = self::getLinksToPage(
302 $this->getWikiId(),
303 $this->getId()
304 );
305
306 // delete important page
307 // note: the wiki might be already deleted here
308 if (!$this->isTranslationPage()) {
309 if ($imp_pages->isImportantPage($this->getId())) {
310 $imp_pages->removeImportantPage($this->getId());
311 }
312 }
313
314 // delete internal links information to this page
316
318
319 $this->getNotificationGUI()->send(
320 "delete",
322 $this->getWikiRefId(),
323 $this->getId(),
324 null,
325 $this->getLanguage()
326 );
327
328 // remove all notifications
330
331 // delete record of table il_wiki_data
332 $this->repo->delete($this->getId(), $this->getLanguage());
333
334 // delete co page
335 parent::delete();
336
337 // make links of other pages to this page a missing link
338 $missing_page_repo = $this->service->repo()->missingPage();
339 foreach ($linking_pages as $lp) {
340 $missing_page_repo->save(
341 $this->getWikiId(),
342 $lp["id"],
343 $this->getTitle(),
344 $this->getLanguage()
345 );
346 }
347 }
348
349 public static function deleteAllPagesOfWiki(int $a_wiki_id): void
350 {
351 global $DIC;
352
353 $ilDB = $DIC->database();
354
355 // delete record of table il_wiki_data
356 $query = "SELECT * FROM il_wiki_page" .
357 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer");
358 $set = $ilDB->query($query);
359
360 while ($rec = $ilDB->fetchAssoc($set)) {
361 if (ilWikiPage::_exists("wpg", $rec["id"], 0, $rec["lang"])) {
362 $wiki_page = new ilWikiPage($rec["id"], 0, $rec["lang"]);
363 $wiki_page->delete();
364 }
365 }
366 }
367
371 public static function exists(
372 int $a_wiki_id,
373 string $a_title,
374 string $lang = "-"
375 ): bool {
376 global $DIC;
377
378 $ilDB = $DIC->database();
379
380 $a_title = ilWikiUtil::makeDbTitle($a_title);
381
382 $query = "SELECT id FROM il_wiki_page" .
383 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
384 " AND title = " . $ilDB->quote($a_title, "text") .
385 " AND lang = " . $ilDB->quote($lang, "text");
386 $set = $ilDB->query($query);
387 if ($rec = $ilDB->fetchAssoc($set)) {
388 return true;
389 }
390
391 return false;
392 }
393
394
398 public static function getPageIdForTitle(
399 int $a_wiki_id,
400 string $a_title,
401 string $lang = "-"
402 ): ?int {
403 global $DIC;
404
405 if ($lang === "") {
406 $lang = "-";
407 }
408
409 $ilDB = $DIC->database();
410
411 $a_title = ilWikiUtil::makeDbTitle($a_title);
412
413 $query = "SELECT * FROM il_wiki_page" .
414 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
415 " AND title = " . $ilDB->quote($a_title, "text") .
416 " AND lang = " . $ilDB->quote($lang, "text");
417 $set = $ilDB->query($query);
418 if ($rec = $ilDB->fetchAssoc($set)) {
419 return (int) $rec["id"];
420 }
421
422 return null;
423 }
424
425 public static function lookupTitle(int $a_page_id, string $lang = "-"): ?string
426 {
427 global $DIC;
428
429 $ilDB = $DIC->database();
430
431 $query = "SELECT * FROM il_wiki_page" .
432 " WHERE id = " . $ilDB->quote($a_page_id, "integer") .
433 " AND lang = " . $ilDB->quote($lang, "text");
434 $set = $ilDB->query($query);
435 if ($rec = $ilDB->fetchAssoc($set)) {
436 return (string) $rec["title"];
437 }
438 return null;
439 }
440
441 public static function lookupWikiId(
442 int $a_page_id
443 ): ?int {
444 global $DIC;
445
446 $ilDB = $DIC->database();
447
448 $query = "SELECT wiki_id FROM il_wiki_page" .
449 " WHERE id = " . $ilDB->quote($a_page_id, "integer");
450 $set = $ilDB->query($query);
451 if ($rec = $ilDB->fetchAssoc($set)) {
452 return (int) $rec["wiki_id"];
453 }
454
455 return null;
456 }
457
458 public static function getAllWikiPages(
459 int $a_wiki_id,
460 string $lang = "-"
461 ): array {
462 global $DIC;
463
464 $ilDB = $DIC->database();
465
466 $pages = parent::getAllPages("wpg", $a_wiki_id);
467
468 $query = "SELECT * FROM il_wiki_page" .
469 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
470 " AND lang = " . $ilDB->quote($lang, "text") .
471 " ORDER BY title";
472 $set = $ilDB->query($query);
473
474 $pg = array();
475 while ($rec = $ilDB->fetchAssoc($set)) {
476 if (isset($pages[$rec["id"]])) {
477 $pg[$rec["id"]] = $pages[$rec["id"]];
478 $pg[$rec["id"]]["title"] = $rec["title"];
479 }
480 }
481
482 return $pg;
483 }
484
485 public static function getLinksToPage(
486 int $a_wiki_id,
487 int $a_page_id,
488 string $lang = "-"
489 ): array {
490 global $DIC;
491
492 if ($lang === "") {
493 $lang = "-";
494 }
495 $ilDB = $DIC->database();
496
497 $sources = ilInternalLink::_getSourcesOfTarget("wpg", $a_page_id, 0);
498 $ids = array();
499 foreach ($sources as $source) {
500 if ($source["type"] === "wpg:pg" && $source["lang"] === $lang) {
501 $ids[] = $source["id"];
502 }
503 }
504
505 // get wiki page record
506 $query = "SELECT * FROM il_wiki_page wp, page_object p" .
507 " WHERE " . $ilDB->in("wp.id", $ids, false, "integer") .
508 " AND wp.id = p.page_id AND wp.lang = p.lang AND p.parent_type = " . $ilDB->quote("wpg", "text") .
509 " AND wp.wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
510 " AND wp.lang = " . $ilDB->quote($lang, "text") .
511 " ORDER BY title";
512 $set = $ilDB->query($query);
513
514 $pages = array();
515 while ($rec = $ilDB->fetchAssoc($set)) {
516 $pages[] = array_merge($rec, array("user" => $rec["last_change_user"],
517 "date" => $rec["last_change"]));
518 }
519 return $pages;
520 }
521
522 public static function _wikiPageExists(
523 int $a_wiki_id,
524 string $a_title,
525 string $lang = "-"
526 ): bool {
527 global $DIC;
528
529 if ($lang === "") {
530 $lang = "-";
531 }
532
533 $ilDB = $DIC->database();
534
535 $a_title = ilWikiUtil::makeDbTitle($a_title);
536
537 $query = "SELECT id FROM il_wiki_page" .
538 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
539 " AND title = " . $ilDB->quote($a_title, "text") .
540 " AND lang = " . $ilDB->quote($lang, "text");
541 $set = $ilDB->query($query);
542
543 if ($ilDB->fetchAssoc($set)) {
544 return true;
545 }
546
547 return false;
548 }
549
550 public static function getWikiContributors(
551 int $a_wiki_id
552 ): array {
553 return parent::getParentObjectContributors("wpg", $a_wiki_id);
554 }
555
556 public static function getWikiPageContributors(
557 int $a_page_id
558 ): array {
559 return parent::getPageContributors("wpg", $a_page_id);
560 }
561
562 public function saveInternalLinks(
563 DOMDocument $a_domdoc
564 ): void {
565 parent::saveInternalLinks($a_domdoc);
566
567 if ($this->getWikiRefId() > 0) {
568 $link_manager = $this->service->domain()->links($this->getWikiRefId());
569 $link_manager->saveInternalLinksForPage(
570 $a_domdoc,
571 $this->getId(),
572 $this->getTitle(),
573 $this->getLanguage()
574 );
575 }
576 }
577
581 public static function _getPageIdForWikiTitle(
582 int $a_wiki_id,
583 string $a_title
584 ): ?int {
585 return self::getPageIdForTitle($a_wiki_id, $a_title);
586 }
587
588 public static function getPopularPages(
589 int $a_wiki_id
590 ): array {
591 global $DIC;
592
593 $ilDB = $DIC->database();
594
595 $query = "SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po" .
596 " WHERE wp.wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
597 " AND wp.id = po.page_id " .
598 " AND po.parent_type = " . $ilDB->quote("wpg", "text") . " " .
599 " ORDER BY po.view_cnt";
600 $set = $ilDB->query($query);
601
602 $pages = array();
603 while ($rec = $ilDB->fetchAssoc($set)) {
604 $pages[] = $rec;
605 }
606
607 return $pages;
608 }
609
610 public static function countPages(
611 int $a_wiki_id
612 ): int {
613 global $DIC;
614
615 $ilDB = $DIC->database();
616
617 // delete record of table il_wiki_data
618 $query = "SELECT count(*) as cnt FROM il_wiki_page" .
619 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
620 " WHERE lang = " . $ilDB->quote("-", "text");
621 $s = $ilDB->query($query);
622 $r = $ilDB->fetchAssoc($s);
623
624 return $r["cnt"];
625 }
626
627 public static function getRandomPage(
628 int $a_wiki_id
629 ): string {
630 global $DIC;
631
632 $ilDB = $DIC->database();
633
634 $cnt = self::countPages($a_wiki_id);
635
636 if ($cnt < 1) {
637 return "";
638 }
639
640 $random = new \Random\Randomizer();
641 $rand = $random->getInt(1, $cnt);
642
643 $ilDB->setLimit(1, $rand);
644 $query = "SELECT title FROM il_wiki_page" .
645 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer");
646 $s = $ilDB->query($query);
647 $r = $ilDB->fetchAssoc($s);
648
649 return $r["title"];
650 }
651
652 public static function getNewWikiPages(
653 int $a_wiki_id
654 ): array {
655 $pages = parent::getNewPages("wpg", $a_wiki_id);
656 foreach ($pages as $k => $page) {
657 $pages[$k]["title"] = self::lookupTitle($page["id"]);
658 }
659
660 return $pages;
661 }
662
663
667 public static function lookupObjIdByPage(
668 int $a_page_id
669 ): ?int {
670 global $DIC;
671
672 $ilDB = $DIC->database();
673
674 $query = "SELECT wiki_id FROM il_wiki_page" .
675 " WHERE id = " . $ilDB->quote($a_page_id, "integer");
676 $set = $ilDB->query($query);
677 if ($rec = $ilDB->fetchAssoc($set)) {
678 return (int) $rec["wiki_id"];
679 }
680
681 return null;
682 }
683
687 public function rename(
688 string $a_new_name
689 ): string {
690 $ilDB = $this->db;
691
692 // replace unallowed characters
693 $a_new_name = str_replace(array("<", ">"), '', $a_new_name);
694
695 // replace multiple whitespace characters by one single space
696 $a_new_name = trim(preg_replace('!\s+!', ' ', $a_new_name));
697
698 $page_title = ilWikiUtil::makeDbTitle($a_new_name);
699 $pg_id = self::getPageIdForTitle($this->getWikiId(), $page_title, $this->getLanguage());
700
701 $xml_new_name = str_replace("&", "&amp;", $a_new_name);
702
703 if ($pg_id == 0 || $pg_id == $this->getId()) {
704 $sources = ilInternalLink::_getSourcesOfTarget("wpg", $this->getId(), 0);
705
706 $this->log->debug("nr of pages linking to renamed page: " . count($sources));
707 foreach ($sources as $s) {
708 if ($s["type"] === "wpg:pg" && ilPageObject::_exists("wpg", $s["id"])) {
709 $wpage = new ilWikiPage($s["id"], 0, $s["lang"]);
710 $wpage->setWikiRefId($this->getWikiRefId());
711
712 $wiki_id = ilWikiPage::lookupWikiId($s["id"]);
714 $wpage->getXMLContent(),
715 $wiki_id,
716 false,
718 );
719 $this->log->debug("nr internal links: " . count($col));
720 $new_content = $wpage->getXMLContent();
721 foreach ($col as $c) {
722 // this complicated procedure is needed due to the fact
723 // that depending on the collation e = é is true
724 // in the (mysql) database
725 // see bug http://www.ilias.de/mantis/view.php?id=11227
726 $t1 = ilWikiUtil::makeDbTitle($c["nt"]->mTextform);
727 $t2 = ilWikiUtil::makeDbTitle($this->getTitle());
728
729 // this one replaces C2A0 (&nbsp;) by a usual space
730 // otherwise the comparision will fail, since you
731 // get these characters from tiny if more than one
732 // space is repeated in a string. This may not be
733 // 100% but we do not store $t1 anywhere and only
734 // modify it for the comparison
735 $t1 = preg_replace('/\xC2\xA0/', ' ', $t1);
736 $t2 = preg_replace('/\xC2\xA0/', ' ', $t2);
737
738 $set = $ilDB->query($q = "SELECT " . $ilDB->quote($t1, "text") . " = " . $ilDB->quote($t2, "text") . " isequal");
739 $rec = $ilDB->fetchAssoc($set);
740
741 if ($rec["isequal"]) {
742 $new_content =
743 str_replace(
744 "[[" . $c["nt"]->mTextform . "]]",
745 "[[" . $xml_new_name . "]]",
746 $new_content
747 );
748 if ($c["text"] != "") {
749 $new_content =
750 str_replace(
751 "[[" . $c["text"] . "]]",
752 "[[" . $xml_new_name . "]]",
753 $new_content
754 );
755 }
756 $add = ($c["text"] != "")
757 ? "|" . $c["text"]
758 : "";
759 $new_content =
760 str_replace(
761 "[[" . $c["nt"]->mTextform . $add . "]]",
762 "[[" . $xml_new_name . $add . "]]",
763 $new_content
764 );
765 }
766 }
767 $wpage->setXMLContent($new_content);
768 //echo htmlentities($new_content);
769 $wpage->update();
770 }
771 }
772
773 if (ilObjWiki::_lookupStartPage($this->getWikiId()) === $this->getTitle()) {
774 ilObjWiki::writeStartPage($this->getWikiId(), $a_new_name);
775 }
776
777 $this->setTitle($a_new_name);
778
779 $this->update();
780 }
781
782 return $a_new_name;
783 }
784
785
786 public function updateNews(
787 bool $a_update = false
788 ): void {
789 $ilUser = $this->user;
790
791 $news_set = new ilSetting("news");
792 $default_visibility = ($news_set->get("default_visibility") != "")
793 ? $news_set->get("default_visibility")
794 : "users";
795
796 if (!$a_update) {
797 $news_item = new ilNewsItem();
798 $news_item->setContext(
799 $this->getWikiId(),
800 "wiki",
801 $this->getId(),
802 "wpg"
803 );
804 $news_item->setPriority(NEWS_NOTICE);
805 $news_item->setTitle($this->getTitle());
806 $news_item->setContentTextIsLangVar(true);
807 $news_item->setContent("wiki_news_page_created");
808 $news_item->setUserId($ilUser->getId());
809 $news_item->setVisibility($default_visibility);
810 $news_item->create();
811 } else {
812 // get last news item of the day (if existing)
814 $this->getWikiId(),
815 "wiki",
816 $this->getId(),
817 "wpg",
818 true
819 );
820
821 if ($news_id > 0) {
822 $news_item = new ilNewsItem($news_id);
823 $news_item->setContent("wiki_news_page_changed");
824 $news_item->setUserId($ilUser->getId());
825 $news_item->setTitle($this->getTitle());
826 $news_item->setContentTextIsLangVar(true);
827 $news_item->update(true);
828 } else {
829 $news_item = new ilNewsItem();
830 $news_item->setContext(
831 $this->getWikiId(),
832 "wiki",
833 $this->getId(),
834 "wpg"
835 );
836 $news_item->setPriority(NEWS_NOTICE);
837 $news_item->setTitle($this->getTitle());
838 $news_item->setContentTextIsLangVar(true);
839 $news_item->setContent("wiki_news_page_changed");
840 $news_item->setUserId($ilUser->getId());
841 $news_item->setVisibility($default_visibility);
842 $news_item->create();
843 }
844 }
845 }
846
847 public static function getGotoForWikiPageTarget(
848 string $a_target,
849 bool $a_offline = false
850 ): string {
851 if (!$a_offline) {
852 $href = "./goto.php?target=wiki_wpage_" . $a_target;
853 } else {
854 $href = ILIAS_HTTP_PATH . "/goto.php?target=wiki_wpage_" . $a_target;
855 }
856 return $href;
857 }
858
859
864 public function getContentTemplates(): array
865 {
866 $wt = new ilWikiPageTemplate($this->getWikiId());
867 $templates = array();
868 foreach ($wt->getAllInfo(ilWikiPageTemplate::TYPE_ADD_TO_PAGE, $this->getLanguage()) as $t) {
869 $templates[] = array("id" => $t["wpage_id"], "parent_type" => "wpg", "title" => $t["title"]);
870 }
871 return $templates;
872 }
873
874 public static function getPagesForSearch(
875 int $a_wiki_id,
876 string $a_term
877 ): array {
878 global $DIC;
879
880 $ilDB = $DIC->database();
881
882 $set = $ilDB->query("SELECT DISTINCT title FROM il_wiki_page" .
883 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
884 " AND " . $ilDB->like("title", "text", "%" . $a_term . "%") .
885 " ORDER by title");
886 $res = array();
887 while ($rec = $ilDB->fetchAssoc($set)) {
888 $res[] = $rec["title"];
889 }
890
891 return $res;
892 }
893
894 public static function lookupAdvancedMetadataHidden(
895 int $a_page_id
896 ): bool {
897 global $DIC;
898
899 $ilDB = $DIC->database();
900
901 $query = "SELECT * FROM il_wiki_page" .
902 " WHERE id = " . $ilDB->quote($a_page_id, "integer");
903 $set = $ilDB->query($query);
904 if ($rec = $ilDB->fetchAssoc($set)) {
905 return (bool) $rec["hide_adv_md"];
906 }
907
908 return false;
909 }
910
911 public function preparePageForCompare(ilPageObject $page): void
912 {
913 $page->setWikiRefId($this->getWikiRefId());
914 }
915
916 protected function setTranslationProperties(ilPageObject $transl_page): void
917 {
918 parent::setTranslationProperties($transl_page);
919 $transl_page->setWikiRefId($this->getWikiRefId());
920 }
921
922 protected function setCopyProperties(ilPageObject $new_page): void
923 {
924 // see #44256
925 if ($new_page->getWikiId() === 0 || $new_page->getWikiId() === $this->getWikiId()) {
926 $new_page->setWikiRefId($this->getWikiRefId());
927 }
928 }
929
930}
const NEWS_NOTICE
const IL_WIKI_MODE_EXT_COLLECT
Component logger with individual log levels by component id.
A news item can be created by different sources.
static getLastNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="", bool $a_only_today=false)
Get last news id of news set related to a certain context.
static removeForObject(int $type, int $id)
Remove all notifications for given object.
static writeStartPage(int $a_id, string $a_name)
static _lookupStartPage(int $a_wiki_id)
static raiseContentChanged(int $obj_id)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
read()
Read page data.
ilDBInterface $db
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
getDomDoc()
Get dom doc (DOMDocument)
setParentId(int $a_id)
ILIAS Setting Class.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTranslationProperties(ilPageObject $transl_page)
updateNews(bool $a_update=false)
static exists(int $a_wiki_id, string $a_title, string $lang="-")
Checks whether a page with given title exists.
create(bool $a_import=false)
create new page (with current xml data)
getContentTemplates()
Get content templates.
static lookupObjIdByPage(int $a_page_id)
returns the wiki/object id to a given page id
static getPagesForSearch(int $a_wiki_id, string $a_term)
static getPageIdForTitle(int $a_wiki_id, string $a_title, string $lang="-")
Get wiki page object for id and title.
setWikiRefId(int $a_wiki_ref_id)
setCopyProperties(ilPageObject $new_page)
setRating(bool $a_val)
getNotificationGUI()
This currently violates the layer model, since notifications render the abstracts with a GUI class.
update(bool $a_validate=true, bool $a_no_history=false)
static getWikiPageContributors(int $a_page_id)
static lookupWikiId(int $a_page_id)
ILIAS Wiki InternalService $service
createFromXML()
Create new page object with current xml content.
preparePageForCompare(ilPageObject $page)
afterUpdate(DOMDocument $domdoc, string $xml)
After update.
static getLinksToPage(int $a_wiki_id, int $a_page_id, string $lang="-")
setBlocked(bool $a_val)
hideAdvancedMetadata(bool $a_val)
static lookupAdvancedMetadataHidden(int $a_page_id)
setWikiId(int $a_wikiid)
setTitle(string $a_title)
static lookupTitle(int $a_page_id, string $lang="-")
saveInternalLinks(DOMDocument $a_domdoc)
save internal links of page
static getWikiContributors(int $a_wiki_id)
read(bool $a_omit_page_read=false)
ILIAS Wiki Page PageDBRepository $repo
static _wikiPageExists(int $a_wiki_id, string $a_title, string $lang="-")
rename(string $a_new_name)
Rename page.
static getPopularPages(int $a_wiki_id)
static countPages(int $a_wiki_id)
static getNewWikiPages(int $a_wiki_id)
static getGotoForWikiPageTarget(string $a_target, bool $a_offline=false)
static deleteAllPagesOfWiki(int $a_wiki_id)
ilLogger $wiki_log
static getAllWikiPages(int $a_wiki_id, string $lang="-")
static getRandomPage(int $a_wiki_id)
static _getPageIdForWikiTitle(int $a_wiki_id, string $a_title)
const EVENT_PAGE_UPDATED
static handleEvent(int $a_event, ilWikiPage $a_page_obj, ?int $a_user_id=null, ?array $a_additional_data=null)
Handle wiki page event.
const EVENT_PAGE_CREATED
const EVENT_PAGE_DELETED
static collectInternalLinks(string $s, int $a_wiki_id, bool $a_collect_non_ex=false, string $mode=IL_WIKI_MODE_COLLECT)
Collect internal wiki links of a string.
static makeDbTitle(string $a_par)
$c
Definition: deliver.php:25
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:25
getLanguage()