ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 " ) VALUES (" .
159 $ilDB->quote($this->getId(), "integer")
160 . "," . $ilDB->quote($this->getTitle(), "text")
161 . "," . $ilDB->quote($this->getWikiId(), "integer")
162 . "," . $ilDB->quote((int) $this->getBlocked(), "integer")
163 . "," . $ilDB->quote((int) $this->getRating(), "integer")
164 . "," . $ilDB->quote((int) $this->isAdvancedMetadataHidden(), "integer")
165 . "," . $ilDB->quote($this->getLanguage(), "text")
166 . ")";
167 $this->wiki_log->debug($query);
168 $ilDB->manipulate($query);
169
170 // create page object
171 if (!$a_import) {
172 parent::create($a_import);
173 $this->saveInternalLinks($this->getDomDoc());
174
176 $this->getNotificationGUI()->send(
177 "new",
179 $this->getWikiRefId(),
180 $this->getId(),
181 null,
182 $this->getLanguage()
183 );
184 }
185
186 $this->updateNews();
187 }
188
189 public function afterUpdate(
190 DOMDocument $domdoc,
191 string $xml
192 ): void {
193 // internal == wiki links
194
195 $this->wiki_log->debug("collect internal links");
196 $int_links = count(ilWikiUtil::collectInternalLinks($xml, $this->getWikiId(), true));
197
198 $xpath = new DOMXPath($domdoc);
199
200 // external = internal + external links
201 $ext_links = count($xpath->query('//IntLink'));
202 $ext_links += count($xpath->query('//ExtLink'));
203
204 $footnotes = count($xpath->query('//Footnote'));
205
206
207 // words/characters (xml)
208
209 $xml = strip_tags($xml);
210
211 $num_chars = ilStr::strLen($xml);
212 $num_words = count(explode(" ", $xml));
213
214 $page_data = array(
215 "int_links" => $int_links,
216 "ext_links" => $ext_links,
217 "footnotes" => $footnotes,
218 "num_words" => $num_words,
219 "num_chars" => $num_chars
220 );
221 $this->wiki_log->debug("handle stats");
223 }
224
229 public function update(
230 bool $a_validate = true,
231 bool $a_no_history = false
232 ) {
233 $ilDB = $this->db;
234 $this->wiki_log->debug("start...");
235 // update wiki page data
236 $query = "UPDATE il_wiki_page SET " .
237 " title = " . $ilDB->quote($this->getTitle(), "text") .
238 ",wiki_id = " . $ilDB->quote($this->getWikiId(), "integer") .
239 ",blocked = " . $ilDB->quote((int) $this->getBlocked(), "integer") .
240 ",rating = " . $ilDB->quote((int) $this->getRating(), "integer") .
241 ",hide_adv_md = " . $ilDB->quote((int) $this->isAdvancedMetadataHidden(), "integer") .
242 " WHERE id = " . $ilDB->quote($this->getId(), "integer") .
243 " AND lang = " . $ilDB->quote($this->getLanguage(), "text");
244 $ilDB->manipulate($query);
245 $updated = parent::update($a_validate, $a_no_history);
246 if ($updated === true) {
247 $this->wiki_log->debug("send notification");
248 $this->getNotificationGUI()->send(
249 "update",
251 $this->getWikiRefId(),
252 $this->getId(),
253 null,
254 $this->getLanguage()
255 );
256
257 $this->wiki_log->debug("update news");
258 ilObjectSearch::raiseContentChanged($this->getWikiId());
259 $this->updateNews(true);
260 } else {
261 return $updated;
262 }
263
264 return true;
265 }
266
267 public function read(
268 bool $a_omit_page_read = false
269 ): void {
270 $ilDB = $this->db;
271
272 $query = "SELECT * FROM il_wiki_page WHERE id = " .
273 $ilDB->quote($this->getId(), "integer") .
274 " AND lang = " . $ilDB->quote($this->getLanguage(), "text");
275
276 $set = $ilDB->query($query);
277 $rec = $ilDB->fetchAssoc($set);
278
279 $this->setTitle($rec["title"]);
280 $this->setWikiId((int) $rec["wiki_id"]);
281 $this->setBlocked((bool) $rec["blocked"]);
282 $this->setRating((bool) $rec["rating"]);
283 $this->hideAdvancedMetadata((bool) $rec["hide_adv_md"]);
284
285 // get co page
286 if (!$a_omit_page_read) {
287 parent::read();
288 }
289 }
290
291
292 public function delete(): void
293 {
294 $imp_pages = $this->service->domain()->importantPage($this->getWikiRefId());
295
296 $ilDB = $this->db;
297
298 // get other pages that link to this page
299 $linking_pages = self::getLinksToPage(
300 $this->getWikiId(),
301 $this->getId()
302 );
303
304 // delete important page
305 // note: the wiki might be already deleted here
306 if (!$this->isTranslationPage()) {
307 if ($imp_pages->isImportantPage($this->getId())) {
308 $imp_pages->removeImportantPage($this->getId());
309 }
310 }
311
312 // delete internal links information to this page
314
316
317 $this->getNotificationGUI()->send(
318 "delete",
320 $this->getWikiRefId(),
321 $this->getId(),
322 null,
323 $this->getLanguage()
324 );
325
326 // remove all notifications
328
329 // delete record of table il_wiki_data
330 $this->repo->delete($this->getId(), $this->getLanguage());
331
332 // delete co page
333 parent::delete();
334
335 // make links of other pages to this page a missing link
336 $missing_page_repo = $this->service->repo()->missingPage();
337 foreach ($linking_pages as $lp) {
338 $missing_page_repo->save(
339 $this->getWikiId(),
340 $lp["id"],
341 $this->getTitle(),
342 $this->getLanguage()
343 );
344 }
345 }
346
347 public static function deleteAllPagesOfWiki(int $a_wiki_id): void
348 {
349 global $DIC;
350
351 $ilDB = $DIC->database();
352
353 // delete record of table il_wiki_data
354 $query = "SELECT * FROM il_wiki_page" .
355 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer");
356 $set = $ilDB->query($query);
357
358 while ($rec = $ilDB->fetchAssoc($set)) {
359 $wiki_page = new ilWikiPage($rec["id"], 0, $rec["lang"]);
360 $wiki_page->delete();
361 }
362 }
363
367 public static function exists(
368 int $a_wiki_id,
369 string $a_title,
370 string $lang = "-"
371 ): bool {
372 global $DIC;
373
374 $ilDB = $DIC->database();
375
376 $a_title = ilWikiUtil::makeDbTitle($a_title);
377
378 $query = "SELECT id FROM il_wiki_page" .
379 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
380 " AND title = " . $ilDB->quote($a_title, "text") .
381 " AND lang = " . $ilDB->quote($lang, "text");
382 $set = $ilDB->query($query);
383 if ($rec = $ilDB->fetchAssoc($set)) {
384 return true;
385 }
386
387 return false;
388 }
389
390
394 public static function getPageIdForTitle(
395 int $a_wiki_id,
396 string $a_title,
397 string $lang = "-"
398 ): ?int {
399 global $DIC;
400
401 if ($lang === "") {
402 $lang = "-";
403 }
404
405 $ilDB = $DIC->database();
406
407 $a_title = ilWikiUtil::makeDbTitle($a_title);
408
409 $query = "SELECT * FROM il_wiki_page" .
410 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
411 " AND title = " . $ilDB->quote($a_title, "text") .
412 " AND lang = " . $ilDB->quote($lang, "text");
413 $set = $ilDB->query($query);
414 if ($rec = $ilDB->fetchAssoc($set)) {
415 return (int) $rec["id"];
416 }
417
418 return null;
419 }
420
421 public static function lookupTitle(int $a_page_id, string $lang = "-"): ?string
422 {
423 global $DIC;
424
425 $ilDB = $DIC->database();
426
427 $query = "SELECT * FROM il_wiki_page" .
428 " WHERE id = " . $ilDB->quote($a_page_id, "integer") .
429 " AND lang = " . $ilDB->quote($lang, "text");
430 $set = $ilDB->query($query);
431 if ($rec = $ilDB->fetchAssoc($set)) {
432 return (string) $rec["title"];
433 }
434 return null;
435 }
436
437 public static function lookupWikiId(
438 int $a_page_id
439 ): ?int {
440 global $DIC;
441
442 $ilDB = $DIC->database();
443
444 $query = "SELECT wiki_id FROM il_wiki_page" .
445 " WHERE id = " . $ilDB->quote($a_page_id, "integer");
446 $set = $ilDB->query($query);
447 if ($rec = $ilDB->fetchAssoc($set)) {
448 return (int) $rec["wiki_id"];
449 }
450
451 return null;
452 }
453
454 public static function getAllWikiPages(
455 int $a_wiki_id,
456 string $lang = "-"
457 ): array {
458 global $DIC;
459
460 $ilDB = $DIC->database();
461
462 $pages = parent::getAllPages("wpg", $a_wiki_id);
463
464 $query = "SELECT * FROM il_wiki_page" .
465 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
466 " AND lang = " . $ilDB->quote($lang, "text") .
467 " ORDER BY title";
468 $set = $ilDB->query($query);
469
470 $pg = array();
471 while ($rec = $ilDB->fetchAssoc($set)) {
472 if (isset($pages[$rec["id"]])) {
473 $pg[$rec["id"]] = $pages[$rec["id"]];
474 $pg[$rec["id"]]["title"] = $rec["title"];
475 }
476 }
477
478 return $pg;
479 }
480
481 public static function getLinksToPage(
482 int $a_wiki_id,
483 int $a_page_id,
484 string $lang = "-"
485 ): array {
486 global $DIC;
487
488 if ($lang === "") {
489 $lang = "-";
490 }
491 $ilDB = $DIC->database();
492
493 $sources = ilInternalLink::_getSourcesOfTarget("wpg", $a_page_id, 0);
494 $ids = array();
495 foreach ($sources as $source) {
496 if ($source["type"] === "wpg:pg" && $source["lang"] === $lang) {
497 $ids[] = $source["id"];
498 }
499 }
500
501 // get wiki page record
502 $query = "SELECT * FROM il_wiki_page wp, page_object p" .
503 " WHERE " . $ilDB->in("wp.id", $ids, false, "integer") .
504 " AND wp.id = p.page_id AND wp.lang = p.lang AND p.parent_type = " . $ilDB->quote("wpg", "text") .
505 " AND wp.wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
506 " AND wp.lang = " . $ilDB->quote($lang, "text") .
507 " ORDER BY title";
508 $set = $ilDB->query($query);
509
510 $pages = array();
511 while ($rec = $ilDB->fetchAssoc($set)) {
512 $pages[] = array_merge($rec, array("user" => $rec["last_change_user"],
513 "date" => $rec["last_change"]));
514 }
515 return $pages;
516 }
517
518 public static function _wikiPageExists(
519 int $a_wiki_id,
520 string $a_title,
521 string $lang = "-"
522 ): bool {
523 global $DIC;
524
525 if ($lang === "") {
526 $lang = "-";
527 }
528
529 $ilDB = $DIC->database();
530
531 $a_title = ilWikiUtil::makeDbTitle($a_title);
532
533 $query = "SELECT id FROM il_wiki_page" .
534 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
535 " AND title = " . $ilDB->quote($a_title, "text") .
536 " AND lang = " . $ilDB->quote($lang, "text");
537 $set = $ilDB->query($query);
538
539 if ($ilDB->fetchAssoc($set)) {
540 return true;
541 }
542
543 return false;
544 }
545
546 public static function getWikiContributors(
547 int $a_wiki_id
548 ): array {
549 return parent::getParentObjectContributors("wpg", $a_wiki_id);
550 }
551
552 public static function getWikiPageContributors(
553 int $a_page_id
554 ): array {
555 return parent::getPageContributors("wpg", $a_page_id);
556 }
557
558 public function saveInternalLinks(
559 DOMDocument $a_domdoc
560 ): void {
561 parent::saveInternalLinks($a_domdoc);
562
563 if ($this->getWikiRefId() > 0) {
564 $link_manager = $this->service->domain()->links($this->getWikiRefId());
565 $link_manager->saveInternalLinksForPage(
566 $a_domdoc,
567 $this->getId(),
568 $this->getTitle(),
569 $this->getLanguage()
570 );
571 }
572 }
573
577 public static function _getPageIdForWikiTitle(
578 int $a_wiki_id,
579 string $a_title
580 ): ?int {
581 return self::getPageIdForTitle($a_wiki_id, $a_title);
582 }
583
584 public static function getPopularPages(
585 int $a_wiki_id
586 ): array {
587 global $DIC;
588
589 $ilDB = $DIC->database();
590
591 $query = "SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po" .
592 " WHERE wp.wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
593 " AND wp.id = po.page_id " .
594 " AND po.parent_type = " . $ilDB->quote("wpg", "text") . " " .
595 " ORDER BY po.view_cnt";
596 $set = $ilDB->query($query);
597
598 $pages = array();
599 while ($rec = $ilDB->fetchAssoc($set)) {
600 $pages[] = $rec;
601 }
602
603 return $pages;
604 }
605
606 public static function countPages(
607 int $a_wiki_id
608 ): int {
609 global $DIC;
610
611 $ilDB = $DIC->database();
612
613 // delete record of table il_wiki_data
614 $query = "SELECT count(*) as cnt FROM il_wiki_page" .
615 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
616 " WHERE lang = " . $ilDB->quote("-", "text");
617 $s = $ilDB->query($query);
618 $r = $ilDB->fetchAssoc($s);
619
620 return $r["cnt"];
621 }
622
623 public static function getRandomPage(
624 int $a_wiki_id
625 ): string {
626 global $DIC;
627
628 $ilDB = $DIC->database();
629
630 $cnt = self::countPages($a_wiki_id);
631
632 if ($cnt < 1) {
633 return "";
634 }
635
636 $random = new \Random\Randomizer();
637 $rand = $random->getInt(1, $cnt);
638
639 $ilDB->setLimit(1, $rand);
640 $query = "SELECT title FROM il_wiki_page" .
641 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer");
642 $s = $ilDB->query($query);
643 $r = $ilDB->fetchAssoc($s);
644
645 return $r["title"];
646 }
647
648 public static function getNewWikiPages(
649 int $a_wiki_id
650 ): array {
651 $pages = parent::getNewPages("wpg", $a_wiki_id);
652 foreach ($pages as $k => $page) {
653 $pages[$k]["title"] = self::lookupTitle($page["id"]);
654 }
655
656 return $pages;
657 }
658
659
663 public static function lookupObjIdByPage(
664 int $a_page_id
665 ): ?int {
666 global $DIC;
667
668 $ilDB = $DIC->database();
669
670 $query = "SELECT wiki_id FROM il_wiki_page" .
671 " WHERE id = " . $ilDB->quote($a_page_id, "integer");
672 $set = $ilDB->query($query);
673 if ($rec = $ilDB->fetchAssoc($set)) {
674 return (int) $rec["wiki_id"];
675 }
676
677 return null;
678 }
679
683 public function rename(
684 string $a_new_name
685 ): string {
686 $ilDB = $this->db;
687
688 // replace unallowed characters
689 $a_new_name = str_replace(array("<", ">"), '', $a_new_name);
690
691 // replace multiple whitespace characters by one single space
692 $a_new_name = trim(preg_replace('!\s+!', ' ', $a_new_name));
693
694 $page_title = ilWikiUtil::makeDbTitle($a_new_name);
695 $pg_id = self::getPageIdForTitle($this->getWikiId(), $page_title, $this->getLanguage());
696
697 $xml_new_name = str_replace("&", "&amp;", $a_new_name);
698
699 if ($pg_id == 0 || $pg_id == $this->getId()) {
700 $sources = ilInternalLink::_getSourcesOfTarget("wpg", $this->getId(), 0);
701
702 $this->log->debug("nr of pages linking to renamed page: " . count($sources));
703 foreach ($sources as $s) {
704 if ($s["type"] === "wpg:pg" && ilPageObject::_exists("wpg", $s["id"])) {
705 $wpage = new ilWikiPage($s["id"], 0, $s["lang"]);
706 $wpage->setWikiRefId($this->getWikiRefId());
707
708 $wiki_id = ilWikiPage::lookupWikiId($s["id"]);
710 $wpage->getXMLContent(),
711 $wiki_id,
712 false,
714 );
715 $this->log->debug("nr internal links: " . count($col));
716 $new_content = $wpage->getXMLContent();
717 foreach ($col as $c) {
718 // this complicated procedure is needed due to the fact
719 // that depending on the collation e = é is true
720 // in the (mysql) database
721 // see bug http://www.ilias.de/mantis/view.php?id=11227
722 $t1 = ilWikiUtil::makeDbTitle($c["nt"]->mTextform);
723 $t2 = ilWikiUtil::makeDbTitle($this->getTitle());
724
725 // this one replaces C2A0 (&nbsp;) by a usual space
726 // otherwise the comparision will fail, since you
727 // get these characters from tiny if more than one
728 // space is repeated in a string. This may not be
729 // 100% but we do not store $t1 anywhere and only
730 // modify it for the comparison
731 $t1 = preg_replace('/\xC2\xA0/', ' ', $t1);
732 $t2 = preg_replace('/\xC2\xA0/', ' ', $t2);
733
734 $set = $ilDB->query($q = "SELECT " . $ilDB->quote($t1, "text") . " = " . $ilDB->quote($t2, "text") . " isequal");
735 $rec = $ilDB->fetchAssoc($set);
736
737 if ($rec["isequal"]) {
738 $new_content =
739 str_replace(
740 "[[" . $c["nt"]->mTextform . "]]",
741 "[[" . $xml_new_name . "]]",
742 $new_content
743 );
744 if ($c["text"] != "") {
745 $new_content =
746 str_replace(
747 "[[" . $c["text"] . "]]",
748 "[[" . $xml_new_name . "]]",
749 $new_content
750 );
751 }
752 $add = ($c["text"] != "")
753 ? "|" . $c["text"]
754 : "";
755 $new_content =
756 str_replace(
757 "[[" . $c["nt"]->mTextform . $add . "]]",
758 "[[" . $xml_new_name . $add . "]]",
759 $new_content
760 );
761 }
762 }
763 $wpage->setXMLContent($new_content);
764 //echo htmlentities($new_content);
765 $wpage->update();
766 }
767 }
768
769 if (ilObjWiki::_lookupStartPage($this->getWikiId()) === $this->getTitle()) {
770 ilObjWiki::writeStartPage($this->getWikiId(), $a_new_name);
771 }
772
773 $this->setTitle($a_new_name);
774
775 $this->update();
776 }
777
778 return $a_new_name;
779 }
780
781
782 public function updateNews(
783 bool $a_update = false
784 ): void {
785 $ilUser = $this->user;
786
787 $news_set = new ilSetting("news");
788 $default_visibility = ($news_set->get("default_visibility") != "")
789 ? $news_set->get("default_visibility")
790 : "users";
791
792 if (!$a_update) {
793 $news_item = new ilNewsItem();
794 $news_item->setContext(
795 $this->getWikiId(),
796 "wiki",
797 $this->getId(),
798 "wpg"
799 );
800 $news_item->setPriority(NEWS_NOTICE);
801 $news_item->setTitle($this->getTitle());
802 $news_item->setContentTextIsLangVar(true);
803 $news_item->setContent("wiki_news_page_created");
804 $news_item->setUserId($ilUser->getId());
805 $news_item->setVisibility($default_visibility);
806 $news_item->create();
807 } else {
808 // get last news item of the day (if existing)
810 $this->getWikiId(),
811 "wiki",
812 $this->getId(),
813 "wpg",
814 true
815 );
816
817 if ($news_id > 0) {
818 $news_item = new ilNewsItem($news_id);
819 $news_item->setContent("wiki_news_page_changed");
820 $news_item->setUserId($ilUser->getId());
821 $news_item->setTitle($this->getTitle());
822 $news_item->setContentTextIsLangVar(true);
823 $news_item->update(true);
824 } else {
825 $news_item = new ilNewsItem();
826 $news_item->setContext(
827 $this->getWikiId(),
828 "wiki",
829 $this->getId(),
830 "wpg"
831 );
832 $news_item->setPriority(NEWS_NOTICE);
833 $news_item->setTitle($this->getTitle());
834 $news_item->setContentTextIsLangVar(true);
835 $news_item->setContent("wiki_news_page_changed");
836 $news_item->setUserId($ilUser->getId());
837 $news_item->setVisibility($default_visibility);
838 $news_item->create();
839 }
840 }
841 }
842
843 public static function getGotoForWikiPageTarget(
844 string $a_target,
845 bool $a_offline = false
846 ): string {
847 if (!$a_offline) {
848 $href = "./goto.php?target=wiki_wpage_" . $a_target;
849 } else {
850 $href = ILIAS_HTTP_PATH . "/goto.php?target=wiki_wpage_" . $a_target;
851 }
852 return $href;
853 }
854
855
860 public function getContentTemplates(): array
861 {
862 $wt = new ilWikiPageTemplate($this->getWikiId());
863 $templates = array();
864 foreach ($wt->getAllInfo(ilWikiPageTemplate::TYPE_ADD_TO_PAGE, $this->getLanguage()) as $t) {
865 $templates[] = array("id" => $t["wpage_id"], "parent_type" => "wpg", "title" => $t["title"]);
866 }
867 return $templates;
868 }
869
870 public static function getPagesForSearch(
871 int $a_wiki_id,
872 string $a_term
873 ): array {
874 global $DIC;
875
876 $ilDB = $DIC->database();
877
878 $set = $ilDB->query("SELECT DISTINCT title FROM il_wiki_page" .
879 " WHERE wiki_id = " . $ilDB->quote($a_wiki_id, "integer") .
880 " AND " . $ilDB->like("title", "text", "%" . $a_term . "%") .
881 " ORDER by title");
882 $res = array();
883 while ($rec = $ilDB->fetchAssoc($set)) {
884 $res[] = $rec["title"];
885 }
886
887 return $res;
888 }
889
890 public static function lookupAdvancedMetadataHidden(
891 int $a_page_id
892 ): bool {
893 global $DIC;
894
895 $ilDB = $DIC->database();
896
897 $query = "SELECT * FROM il_wiki_page" .
898 " WHERE id = " . $ilDB->quote($a_page_id, "integer");
899 $set = $ilDB->query($query);
900 if ($rec = $ilDB->fetchAssoc($set)) {
901 return (bool) $rec["hide_adv_md"];
902 }
903
904 return false;
905 }
906
907 public function preparePageForCompare(ilPageObject $page): void
908 {
909 $page->setWikiRefId($this->getWikiRefId());
910 }
911
912 protected function setTranslationProperties(ilPageObject $transl_page): void
913 {
914 parent::setTranslationProperties($transl_page);
915 $transl_page->setWikiRefId($this->getWikiRefId());
916 }
917
918 protected function setCopyProperties(ilPageObject $new_page): void
919 {
920 // see #44256
921 if ($new_page->getWikiId() === 0 || $new_page->getWikiId() === $this->getWikiId()) {
922 $new_page->setWikiRefId($this->getWikiRefId());
923 }
924 }
925
926}
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:23
getLanguage()
$lang
Definition: xapiexit.php:25