4 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
5 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
88 $this->parent_ref_id = $a_wiki_ref_id;
98 return $this->parent_ref_id;
108 $this->blocked = $a_val;
128 $this->rating = (bool)$a_val;
148 $this->hide_adv_md = (bool)$a_val;
173 $set = $ilDB->query(
"SELECT id FROM il_wiki_page ".
174 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
176 if ($rec = $ilDB->fetchAssoc($set))
187 function create($a_prevent_page_creation =
false)
191 $id = $ilDB->nextId(
"il_wiki_page");
193 $query =
"INSERT INTO il_wiki_page (".
201 $ilDB->quote($this->
getId(),
"integer")
202 .
",".$ilDB->quote($this->
getTitle(),
"text")
203 .
",".$ilDB->quote((
int) $this->
getWikiId(),
"integer")
204 .
",".$ilDB->quote((
int) $this->
getBlocked(),
"integer")
205 .
",".$ilDB->quote((
int) $this->
getRating(),
"integer")
208 $ilDB->manipulate(
$query);
211 if (!$a_prevent_page_creation)
216 include_once
"./Modules/Wiki/classes/class.ilWikiStat.php";
219 include_once
"./Services/Notification/classes/class.ilNotification.php";
229 include_once
"Modules/Wiki/classes/class.ilWikiUtil.php";
232 $xpath =
new DOMXPath($a_domdoc);
235 $ext_links =
sizeof($xpath->query(
'//IntLink'));
236 $ext_links +=
sizeof($xpath->query(
'//ExtLink'));
238 $footnotes =
sizeof($xpath->query(
'//Footnote'));
243 $xml = strip_tags($a_xml);
245 include_once
"Services/Utilities/classes/class.ilStr.php";
247 $num_words =
sizeof(explode(
" ",
$xml));
250 "int_links" => $int_links,
251 "ext_links" => $ext_links,
252 "footnotes" => $footnotes,
253 "num_words" => $num_words,
254 "num_chars" => $num_chars
257 include_once
"./Modules/Wiki/classes/class.ilWikiStat.php";
267 function update($a_validate =
true, $a_no_history =
false)
272 $query =
"UPDATE il_wiki_page SET ".
273 " title = ".$ilDB->quote($this->
getTitle(),
"text").
274 ",wiki_id = ".$ilDB->quote((
int) $this->
getWikiId(),
"integer").
275 ",blocked = ".$ilDB->quote((
int) $this->
getBlocked(),
"integer").
276 ",rating = ".$ilDB->quote((
int) $this->
getRating(),
"integer").
278 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
279 $ilDB->manipulate(
$query);
282 if ($updated ===
true)
284 include_once
"./Services/Notification/classes/class.ilNotification.php";
300 function read($a_omit_page_read =
false)
304 $query =
"SELECT * FROM il_wiki_page WHERE id = ".
305 $ilDB->quote($this->
getId(),
"integer");
306 $set = $ilDB->query(
$query);
307 $rec = $ilDB->fetchAssoc($set);
316 if (!$a_omit_page_read)
337 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
340 include_once
"./Modules/Wiki/classes/class.ilWikiStat.php";
343 include_once
"./Services/Notification/classes/class.ilNotification.php";
347 include_once
"./Services/Notification/classes/class.ilNotification.php";
351 $query =
"DELETE FROM il_wiki_page".
352 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
353 $ilDB->manipulate(
$query);
359 foreach($linking_pages as $lp)
361 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page ".
362 " WHERE wiki_id = %s AND source_id = %s AND target_name = %s ",
363 array(
"integer",
"integer",
"text"),
365 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page ".
366 "(wiki_id, source_id, target_name) VALUES ".
368 array(
"integer",
"integer",
"text"),
385 $query =
"SELECT * FROM il_wiki_page".
386 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
387 $set = $ilDB->query(
$query);
389 while($rec = $ilDB->fetchAssoc($set))
392 $wiki_page->delete();
401 static function exists($a_wiki_id, $a_title)
407 $query =
"SELECT id FROM il_wiki_page".
408 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
409 " AND title = ".$ilDB->quote($a_title,
"text");
410 $set = $ilDB->query(
$query);
411 if($rec = $ilDB->fetchAssoc($set))
428 $query =
"SELECT id FROM il_wiki_page".
429 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
430 " AND title = ".$ilDB->quote($a_title,
"text");
431 $set = $ilDB->query(
$query);
432 if($rec = $ilDB->fetchAssoc($set))
449 $query =
"SELECT * FROM il_wiki_page".
450 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
451 " AND title = ".$ilDB->quote($a_title,
"text");
452 $set = $ilDB->query(
$query);
453 if($rec = $ilDB->fetchAssoc($set))
468 $query =
"SELECT * FROM il_wiki_page".
469 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
470 $set = $ilDB->query(
$query);
471 if($rec = $ilDB->fetchAssoc($set))
473 return $rec[
"title"];
486 $query =
"SELECT wiki_id FROM il_wiki_page".
487 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
488 $set = $ilDB->query(
$query);
489 if ($rec = $ilDB->fetchAssoc($set))
491 return $rec[
"wiki_id"];
508 $query =
"SELECT * FROM il_wiki_page".
509 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
511 $set = $ilDB->query(
$query);
514 while($rec = $ilDB->fetchAssoc($set))
516 if (isset($pages[$rec[
"id"]]))
518 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
519 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
533 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
537 foreach ($sources as $source)
539 if ($source[
"type"] ==
"wpg:pg")
541 $ids[] = $source[
"id"];
545 $query =
"SELECT * FROM il_wiki_page wp, page_object p".
546 " WHERE ".$ilDB->in(
"wp.id", $ids,
false,
"integer").
547 " AND wp.id = p.page_id AND p.parent_type = ".$ilDB->quote(
"wpg",
"text").
548 " AND wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
550 $set = $ilDB->query(
$query);
553 while ($rec = $ilDB->fetchAssoc($set))
555 $pages[] = array_merge($rec, array(
"user" => $rec[
"last_change_user"],
556 "date" => $rec[
"last_change"]));
573 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
576 foreach ($pages as $k => $page)
581 foreach ($sources as $source)
583 if ($source[
"type"] ==
"wpg:pg")
585 $ids[] = $source[
"id"];
588 $query =
"SELECT count(*) cnt FROM il_wiki_page".
589 " WHERE ".$ilDB->in(
"id", $ids,
false,
"integer").
590 " AND wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
592 $set = $ilDB->query(
$query);
593 $rec = $ilDB->fetchAssoc($set);
594 if ($rec[
"cnt"] == 0 &&
615 $query =
"SELECT id FROM il_wiki_page".
616 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
617 " AND title = ".$ilDB->quote($a_title,
"text");
618 $set = $ilDB->query(
$query);
621 if ($rec = $ilDB->fetchAssoc($set))
640 return $contributors;
654 return $contributors;
677 $set = $ilDB->queryF(
"SELECT * FROM il_wiki_missing_page WHERE ".
678 " wiki_id = %s AND target_name = %s",
679 array(
"integer",
"text"),
681 while ($anmiss = $ilDB->fetchAssoc($set))
689 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
690 " wiki_id = %s AND target_name = %s",
691 array(
"integer",
"text"),
698 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
699 " wiki_id = %s AND source_id = %s",
700 array(
"integer",
"integer"),
704 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
705 $xml = $a_domdoc->saveXML();
707 foreach($int_wiki_links as $wlink)
718 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE".
719 " wiki_id = %s AND source_id = %s AND target_name = %s",
720 array(
"integer",
"integer",
"text"),
722 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)".
723 " VALUES (%s,%s,%s)",
724 array(
"integer",
"integer",
"text"),
737 $query =
"SELECT id FROM il_wiki_page".
738 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
739 " AND title = ".$ilDB->quote($a_title,
"text");
740 $set = $ilDB->query(
$query);
741 if($rec = $ilDB->fetchAssoc($set))
758 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po".
759 " WHERE wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
760 " AND wp.id = po.page_id ".
761 " AND po.parent_type = ".$ilDB->quote(
"wpg",
"text").
" ".
762 " ORDER BY po.view_cnt";
763 $set = $ilDB->query(
$query);
766 while($rec = $ilDB->fetchAssoc($set))
784 $query =
"SELECT count(*) as cnt FROM il_wiki_page".
785 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
786 $s = $ilDB->query(
$query);
787 $r = $ilDB->fetchAssoc($s);
808 $rand = rand(1, $cnt);
811 $ilDB->setLimit(1, $rand);
812 $query =
"SELECT title FROM il_wiki_page".
813 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
814 $s = $ilDB->query(
$query);
815 $r = $ilDB->fetchAssoc($s);
831 foreach($pages as $k => $page)
850 $query =
"SELECT wiki_id FROM il_wiki_page".
851 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
852 $set = $ilDB->query(
$query);
853 if($rec = $ilDB->fetchAssoc($set))
855 return $rec[
"wiki_id"];
869 $a_new_name = str_replace(array(
"<",
">"),
'', $a_new_name);
872 $a_new_name = trim(preg_replace(
'!\s+!',
' ', $a_new_name));
877 $xml_new_name = str_replace(
"&",
"&", $a_new_name);
879 if ($pg_id == 0 || $pg_id == $this->
getId())
881 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
884 foreach ($sources as $s)
892 $new_content = $wpage->getXmlContent();
909 $t1 = preg_replace(
'/\xC2\xA0/',
' ', $t1);
910 $t2 = preg_replace(
'/\xC2\xA0/',
' ', $t2);
912 $set = $ilDB->query($q =
"SELECT ".$ilDB->quote($t1,
"text").
" = ".$ilDB->quote($t2,
"text").
" isequal");
913 $rec = $ilDB->fetchAssoc($set);
918 str_replace(
"[[".$c[
"nt"]->mTextform.
"]]",
919 "[[".$xml_new_name.
"]]", $new_content);
920 if ($c[
"text"] !=
"")
923 str_replace(
"[[".$c[
"text"].
"]]",
924 "[[".$xml_new_name.
"]]", $new_content);
926 $add = ($c[
"text"] !=
"")
930 str_replace(
"[[".$c[
"nt"]->mTextform.$add.
"]]",
931 "[[".$xml_new_name.$add.
"]]", $new_content);
934 $wpage->setXmlContent($new_content);
940 include_once(
"./Modules/Wiki/classes/class.ilObjWiki.php");
963 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
964 ? $news_set->get(
"default_visibility")
967 include_once(
"./Services/News/classes/class.ilNewsItem.php");
971 $news_item->setContext(
973 $this->
getId(),
"wpg");
975 $news_item->setTitle($this->
getTitle());
976 $news_item->setContentTextIsLangVar(
true);
977 $news_item->setContent(
"wiki_news_page_created");
978 $news_item->setUserId($ilUser->getId());
979 $news_item->setVisibility($default_visibility);
980 $news_item->create();
987 $this->
getId(),
"wpg",
true);
992 $news_item->setContent(
"wiki_news_page_changed");
993 $news_item->setUserId($ilUser->getId());
994 $news_item->setTitle($this->
getTitle());
995 $news_item->setContentTextIsLangVar(
true);
996 $news_item->update(
true);
1001 $news_item->setContext(
1003 $this->
getId(),
"wpg");
1005 $news_item->setTitle($this->
getTitle());
1006 $news_item->setContentTextIsLangVar(
true);
1007 $news_item->setContent(
"wiki_news_page_changed");
1008 $news_item->setUserId($ilUser->getId());
1009 $news_item->setVisibility($default_visibility);
1010 $news_item->create();
1020 return "12.1.1: Test User, Max";
1033 $href =
"./goto.php?target=wiki_wpage_".$a_target;
1037 $href = ILIAS_HTTP_PATH.
"/goto.php?target=wiki_wpage_".$a_target;
1050 include_once(
"./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
1052 $templates = array();
1055 $templates[] = array(
"id" =>
$t[
"wpage_id"],
"parent_type" =>
"wpg",
"title" =>
$t[
"title"]);
1070 $set = $ilDB->query(
"SELECT DISTINCT title FROM il_wiki_page".
1071 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
1072 " AND ".$ilDB->like(
"title",
"text",
"%".$a_term.
"%").
1075 while ($rec = $ilDB->fetchAssoc($set))
1077 $res[] = $rec[
"title"];
1087 $query =
"SELECT * FROM il_wiki_page".
1088 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
1089 $set = $ilDB->query(
$query);
1090 if($rec = $ilDB->fetchAssoc($set))
1092 return (
bool)$rec[
"hide_adv_md"];