4 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
5 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
86 $this->parent_ref_id = $a_wiki_ref_id;
96 return $this->parent_ref_id;
106 $this->blocked = $a_val;
126 $this->rating = (bool)$a_val;
136 return $this->rating;
151 $set = $ilDB->query(
"SELECT id FROM il_wiki_page ".
152 " WHERE id = ".$ilDB->quote($this->getId(),
"integer")
154 if ($rec = $ilDB->fetchAssoc($set))
165 function create($a_prevent_page_creation =
false)
169 $id = $ilDB->nextId(
"il_wiki_page");
171 $query =
"INSERT INTO il_wiki_page (".
178 $ilDB->quote($this->
getId(),
"integer")
179 .
",".$ilDB->quote($this->
getTitle(),
"text")
180 .
",".$ilDB->quote((
int) $this->
getWikiId(),
"integer")
181 .
",".$ilDB->quote((
int) $this->
getBlocked(),
"integer")
182 .
",".$ilDB->quote((
int) $this->
getRating(),
"integer")
184 $ilDB->manipulate(
$query);
187 if (!$a_prevent_page_creation)
192 include_once
"./Services/Notification/classes/class.ilNotification.php";
205 function update($a_validate =
true, $a_no_history =
false)
210 $query =
"UPDATE il_wiki_page SET ".
211 " title = ".$ilDB->quote($this->
getTitle(),
"text").
212 ",wiki_id = ".$ilDB->quote((
int) $this->
getWikiId(),
"integer").
213 ",blocked = ".$ilDB->quote((
int) $this->
getBlocked(),
"integer").
214 ",rating = ".$ilDB->quote((
int) $this->
getRating(),
"integer").
215 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
216 $ilDB->manipulate(
$query);
219 if ($updated ===
true)
221 include_once
"./Services/Notification/classes/class.ilNotification.php";
236 function read($a_omit_page_read =
false)
240 $query =
"SELECT * FROM il_wiki_page WHERE id = ".
241 $ilDB->quote($this->
getId(),
"integer");
242 $set = $ilDB->query(
$query);
243 $rec = $ilDB->fetchAssoc($set);
251 if (!$a_omit_page_read)
272 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
275 include_once
"./Services/Notification/classes/class.ilNotification.php";
279 include_once
"./Services/Notification/classes/class.ilNotification.php";
283 $query =
"DELETE FROM il_wiki_page".
284 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
285 $ilDB->manipulate(
$query);
291 foreach($linking_pages as $lp)
293 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page ".
294 " WHERE wiki_id = %s AND source_id = %s AND target_name = %s ",
295 array(
"integer",
"integer",
"text"),
297 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page ".
298 "(wiki_id, source_id, target_name) VALUES ".
300 array(
"integer",
"integer",
"text"),
317 $query =
"SELECT * FROM il_wiki_page".
318 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
319 $set = $ilDB->query(
$query);
321 while($rec = $ilDB->fetchAssoc($set))
324 $wiki_page->delete();
333 static function exists($a_wiki_id, $a_title)
339 $query =
"SELECT id FROM il_wiki_page".
340 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
341 " AND title = ".$ilDB->quote($a_title,
"text");
342 $set = $ilDB->query(
$query);
343 if($rec = $ilDB->fetchAssoc($set))
360 $query =
"SELECT id FROM il_wiki_page".
361 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
362 " AND title = ".$ilDB->quote($a_title,
"text");
363 $set = $ilDB->query(
$query);
364 if($rec = $ilDB->fetchAssoc($set))
381 $query =
"SELECT * FROM il_wiki_page".
382 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
383 " AND title = ".$ilDB->quote($a_title,
"text");
384 $set = $ilDB->query(
$query);
385 if($rec = $ilDB->fetchAssoc($set))
400 $query =
"SELECT * FROM il_wiki_page".
401 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
402 $set = $ilDB->query(
$query);
403 if($rec = $ilDB->fetchAssoc($set))
405 return $rec[
"title"];
418 $query =
"SELECT wiki_id FROM il_wiki_page".
419 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
420 $set = $ilDB->query(
$query);
421 if ($rec = $ilDB->fetchAssoc($set))
423 return $rec[
"wiki_id"];
440 $query =
"SELECT * FROM il_wiki_page".
441 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
443 $set = $ilDB->query(
$query);
446 while($rec = $ilDB->fetchAssoc($set))
448 if (isset($pages[$rec[
"id"]]))
450 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
451 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
465 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
469 foreach ($sources as $source)
471 if ($source[
"type"] ==
"wpg:pg")
473 $ids[] = $source[
"id"];
477 $query =
"SELECT * FROM il_wiki_page wp, page_object p".
478 " WHERE ".$ilDB->in(
"wp.id", $ids,
false,
"integer").
479 " AND wp.id = p.page_id AND p.parent_type = ".$ilDB->quote(
"wpg",
"text").
480 " AND wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
482 $set = $ilDB->query(
$query);
485 while ($rec = $ilDB->fetchAssoc($set))
487 $pages[] = array_merge($rec, array(
"user" => $rec[
"last_change_user"],
488 "date" => $rec[
"last_change"]));
505 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
508 foreach ($pages as $k => $page)
513 foreach ($sources as $source)
515 if ($source[
"type"] ==
"wpg:pg")
517 $ids[] = $source[
"id"];
520 $query =
"SELECT count(*) cnt FROM il_wiki_page".
521 " WHERE ".$ilDB->in(
"id", $ids,
false,
"integer").
522 " AND wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
524 $set = $ilDB->query(
$query);
525 $rec = $ilDB->fetchAssoc($set);
526 if ($rec[
"cnt"] == 0 &&
547 $query =
"SELECT id FROM il_wiki_page".
548 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
549 " AND title = ".$ilDB->quote($a_title,
"text");
550 $set = $ilDB->query(
$query);
553 if ($rec = $ilDB->fetchAssoc($set))
572 return $contributors;
586 return $contributors;
609 $set = $ilDB->queryF(
"SELECT * FROM il_wiki_missing_page WHERE ".
610 " wiki_id = %s AND target_name = %s",
611 array(
"integer",
"text"),
613 while ($anmiss = $ilDB->fetchAssoc($set))
621 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
622 " wiki_id = %s AND target_name = %s",
623 array(
"integer",
"text"),
630 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
631 " wiki_id = %s AND source_id = %s",
632 array(
"integer",
"integer"),
636 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
637 $xml = $a_domdoc->saveXML();
639 foreach($int_wiki_links as $wlink)
650 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE".
651 " wiki_id = %s AND source_id = %s AND target_name = %s",
652 array(
"integer",
"integer",
"text"),
654 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)".
655 " VALUES (%s,%s,%s)",
656 array(
"integer",
"integer",
"text"),
669 $query =
"SELECT id FROM il_wiki_page".
670 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
671 " AND title = ".$ilDB->quote($a_title,
"text");
672 $set = $ilDB->query(
$query);
673 if($rec = $ilDB->fetchAssoc($set))
690 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po".
691 " WHERE wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
692 " AND wp.id = po.page_id ".
693 " AND po.parent_type = ".$ilDB->quote(
"wpg",
"text").
" ".
694 " ORDER BY po.view_cnt";
695 $set = $ilDB->query(
$query);
698 while($rec = $ilDB->fetchAssoc($set))
716 $query =
"SELECT count(*) as cnt FROM il_wiki_page".
717 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
718 $s = $ilDB->query(
$query);
719 $r = $ilDB->fetchAssoc($s);
740 $rand = rand(1, $cnt);
743 $ilDB->setLimit(1, $rand);
744 $query =
"SELECT title FROM il_wiki_page".
745 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
746 $s = $ilDB->query(
$query);
747 $r = $ilDB->fetchAssoc($s);
763 foreach($pages as $k => $page)
782 $query =
"SELECT wiki_id FROM il_wiki_page".
783 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
784 $set = $ilDB->query(
$query);
785 if($rec = $ilDB->fetchAssoc($set))
787 return $rec[
"wiki_id"];
801 $a_new_name = str_replace(array(
"<",
">"),
'', $a_new_name);
804 $a_new_name = trim(preg_replace(
'!\s+!',
' ', $a_new_name));
809 $xml_new_name = str_replace(
"&",
"&", $a_new_name);
811 if ($pg_id == 0 || $pg_id == $this->
getId())
813 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
816 foreach ($sources as $s)
824 $new_content = $wpage->getXmlContent();
841 $t1 = preg_replace(
'/\xC2\xA0/',
' ', $t1);
842 $t2 = preg_replace(
'/\xC2\xA0/',
' ', $t2);
844 $set = $ilDB->query($q =
"SELECT ".$ilDB->quote($t1,
"text").
" = ".$ilDB->quote($t2,
"text").
" isequal");
845 $rec = $ilDB->fetchAssoc($set);
850 str_replace(
"[[".$c[
"nt"]->mTextform.
"]]",
851 "[[".$xml_new_name.
"]]", $new_content);
852 if ($c[
"text"] !=
"")
855 str_replace(
"[[".$c[
"text"].
"]]",
856 "[[".$xml_new_name.
"]]", $new_content);
858 $add = ($c[
"text"] !=
"")
862 str_replace(
"[[".$c[
"nt"]->mTextform.$add.
"]]",
863 "[[".$xml_new_name.$add.
"]]", $new_content);
866 $wpage->setXmlContent($new_content);
872 include_once(
"./Modules/Wiki/classes/class.ilObjWiki.php");
895 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
896 ? $news_set->get(
"default_visibility")
899 include_once(
"./Services/News/classes/class.ilNewsItem.php");
903 $news_item->setContext(
905 $this->
getId(),
"wpg");
907 $news_item->setTitle($this->
getTitle());
908 $news_item->setContentTextIsLangVar(
true);
909 $news_item->setContent(
"wiki_news_page_created");
910 $news_item->setUserId($ilUser->getId());
911 $news_item->setVisibility($default_visibility);
912 $news_item->create();
919 $this->
getId(),
"wpg",
true);
924 $news_item->setContent(
"wiki_news_page_changed");
925 $news_item->setUserId($ilUser->getId());
926 $news_item->setTitle($this->
getTitle());
927 $news_item->setContentTextIsLangVar(
true);
928 $news_item->update(
true);
933 $news_item->setContext(
935 $this->
getId(),
"wpg");
937 $news_item->setTitle($this->
getTitle());
938 $news_item->setContentTextIsLangVar(
true);
939 $news_item->setContent(
"wiki_news_page_changed");
940 $news_item->setUserId($ilUser->getId());
941 $news_item->setVisibility($default_visibility);
942 $news_item->create();
952 return "12.1.1: Test User, Max";
965 $href =
"./goto.php?target=wiki_wpage_".$a_target;
969 $href = ILIAS_HTTP_PATH.
"/goto.php?target=wiki_wpage_".$a_target;