4 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
5 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
75 $this->parent_ref_id = $a_wiki_ref_id;
85 return $this->parent_ref_id;
95 $this->blocked = $a_val;
115 $this->rating = (bool)$a_val;
125 return $this->rating;
131 function create($a_prevent_page_creation =
false)
135 $id = $ilDB->nextId(
"il_wiki_page");
137 $query =
"INSERT INTO il_wiki_page (".
144 $ilDB->quote($this->
getId(),
"integer")
145 .
",".$ilDB->quote($this->
getTitle(),
"text")
146 .
",".$ilDB->quote((
int) $this->
getWikiId(),
"integer")
147 .
",".$ilDB->quote((
int) $this->
getBlocked(),
"integer")
148 .
",".$ilDB->quote((
int) $this->
getRating(),
"integer")
150 $ilDB->manipulate(
$query);
153 if (!$a_prevent_page_creation)
158 include_once
"./Services/Notification/classes/class.ilNotification.php";
171 function update($a_validate =
true, $a_no_history =
false)
176 $query =
"UPDATE il_wiki_page SET ".
177 " title = ".$ilDB->quote($this->
getTitle(),
"text").
178 ",wiki_id = ".$ilDB->quote((
int) $this->
getWikiId(),
"integer").
179 ",blocked = ".$ilDB->quote((
int) $this->
getBlocked(),
"integer").
180 ",rating = ".$ilDB->quote((
int) $this->
getRating(),
"integer").
181 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
182 $ilDB->manipulate(
$query);
185 include_once
"./Services/Notification/classes/class.ilNotification.php";
200 $query =
"SELECT * FROM il_wiki_page WHERE id = ".
201 $ilDB->quote($this->
getId(),
"integer");
202 $set = $ilDB->query(
$query);
203 $rec = $ilDB->fetchAssoc($set);
229 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
232 include_once
"./Services/Notification/classes/class.ilNotification.php";
236 include_once
"./Services/Notification/classes/class.ilNotification.php";
240 $query =
"DELETE FROM il_wiki_page".
241 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
242 $ilDB->manipulate(
$query);
248 foreach($linking_pages as $lp)
250 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page ".
251 " WHERE wiki_id = %s AND source_id = %s AND target_name = %s ",
252 array(
"integer",
"integer",
"text"),
254 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page ".
255 "(wiki_id, source_id, target_name) VALUES ".
257 array(
"integer",
"integer",
"text"),
274 $query =
"SELECT * FROM il_wiki_page".
275 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
276 $set = $ilDB->query(
$query);
278 while($rec = $ilDB->fetchAssoc($set))
281 $wiki_page->delete();
290 static function exists($a_wiki_id, $a_title)
296 $query =
"SELECT id FROM il_wiki_page".
297 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
298 " AND title = ".$ilDB->quote($a_title,
"text");
299 $set = $ilDB->query(
$query);
300 if($rec = $ilDB->fetchAssoc($set))
317 $query =
"SELECT id FROM il_wiki_page".
318 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
319 " AND title = ".$ilDB->quote($a_title,
"text");
320 $set = $ilDB->query(
$query);
321 if($rec = $ilDB->fetchAssoc($set))
338 $query =
"SELECT * FROM il_wiki_page".
339 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
340 " AND title = ".$ilDB->quote($a_title,
"text");
341 $set = $ilDB->query(
$query);
342 if($rec = $ilDB->fetchAssoc($set))
357 $query =
"SELECT * FROM il_wiki_page".
358 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
359 $set = $ilDB->query(
$query);
360 if($rec = $ilDB->fetchAssoc($set))
362 return $rec[
"title"];
375 $query =
"SELECT wiki_id FROM il_wiki_page".
376 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
377 $set = $ilDB->query(
$query);
378 if ($rec = $ilDB->fetchAssoc($set))
380 return $rec[
"wiki_id"];
397 $query =
"SELECT * FROM il_wiki_page".
398 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
400 $set = $ilDB->query(
$query);
403 while($rec = $ilDB->fetchAssoc($set))
405 if (isset($pages[$rec[
"id"]]))
407 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
408 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
422 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
426 foreach ($sources as $source)
428 if ($source[
"type"] ==
"wpg:pg")
430 $ids[] = $source[
"id"];
434 $query =
"SELECT * FROM il_wiki_page wp, page_object p".
435 " WHERE ".$ilDB->in(
"wp.id", $ids,
false,
"integer").
436 " AND wp.id = p.page_id AND p.parent_type = ".$ilDB->quote(
"wpg",
"text").
437 " AND wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
439 $set = $ilDB->query(
$query);
442 while ($rec = $ilDB->fetchAssoc($set))
444 $pages[] = array_merge($rec, array(
"user" => $rec[
"last_change_user"],
445 "date" => $rec[
"last_change"]));
462 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
465 foreach ($pages as $k => $page)
470 foreach ($sources as $source)
472 if ($source[
"type"] ==
"wpg:pg")
474 $ids[] = $source[
"id"];
477 $query =
"SELECT count(*) cnt FROM il_wiki_page".
478 " WHERE ".$ilDB->in(
"id", $ids,
false,
"integer").
479 " AND wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
481 $set = $ilDB->query(
$query);
482 $rec = $ilDB->fetchAssoc($set);
483 if ($rec[
"cnt"] == 0 &&
504 $query =
"SELECT id FROM il_wiki_page".
505 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
506 " AND title = ".$ilDB->quote($a_title,
"text");
507 $set = $ilDB->query(
$query);
510 if ($rec = $ilDB->fetchAssoc($set))
529 return $contributors;
543 return $contributors;
566 $set = $ilDB->queryF(
"SELECT * FROM il_wiki_missing_page WHERE ".
567 " wiki_id = %s AND target_name = %s",
568 array(
"integer",
"text"),
570 while ($anmiss = $ilDB->fetchAssoc($set))
578 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
579 " wiki_id = %s AND target_name = %s",
580 array(
"integer",
"text"),
587 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
588 " wiki_id = %s AND source_id = %s",
589 array(
"integer",
"integer"),
593 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
596 foreach($int_wiki_links as $wlink)
607 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE".
608 " wiki_id = %s AND source_id = %s AND target_name = %s",
609 array(
"integer",
"integer",
"text"),
611 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)".
612 " VALUES (%s,%s,%s)",
613 array(
"integer",
"integer",
"text"),
626 $query =
"SELECT id FROM il_wiki_page".
627 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
628 " AND title = ".$ilDB->quote($a_title,
"text");
629 $set = $ilDB->query(
$query);
630 if($rec = $ilDB->fetchAssoc($set))
647 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po".
648 " WHERE wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
649 " AND wp.id = po.page_id ".
650 " AND po.parent_type = ".$ilDB->quote(
"wpg",
"text").
" ".
651 " ORDER BY po.view_cnt";
652 $set = $ilDB->query(
$query);
655 while($rec = $ilDB->fetchAssoc($set))
673 $query =
"SELECT count(*) as cnt FROM il_wiki_page".
674 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
675 $s = $ilDB->query(
$query);
676 $r = $ilDB->fetchAssoc($s);
697 $rand = rand(1, $cnt);
700 $ilDB->setLimit(1, $rand);
701 $query =
"SELECT title FROM il_wiki_page".
702 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
703 $s = $ilDB->query(
$query);
704 $r = $ilDB->fetchAssoc($s);
720 foreach($pages as $k => $page)
739 $query =
"SELECT wiki_id FROM il_wiki_page".
740 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
741 $set = $ilDB->query(
$query);
742 if($rec = $ilDB->fetchAssoc($set))
744 return $rec[
"wiki_id"];
758 $a_new_name = str_replace(array(
"<",
">"),
'', $a_new_name);
761 $a_new_name = trim(preg_replace(
'!\s+!',
' ', $a_new_name));
766 $xml_new_name = str_replace(
"&",
"&", $a_new_name);
768 if ($pg_id == 0 || $pg_id == $this->
getId())
770 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
773 foreach ($sources as $s)
781 $new_content = $wpage->getXmlContent();
798 $t1 = preg_replace(
'/\xC2\xA0/',
' ', $t1);
799 $t2 = preg_replace(
'/\xC2\xA0/',
' ', $t2);
801 $set = $ilDB->query($q =
"SELECT ".$ilDB->quote($t1,
"text").
" = ".$ilDB->quote($t2,
"text").
" isequal");
802 $rec = $ilDB->fetchAssoc($set);
807 str_replace(
"[[".$c[
"nt"]->mTextform.
"]]",
808 "[[".$xml_new_name.
"]]", $new_content);
809 if ($c[
"text"] !=
"")
812 str_replace(
"[[".$c[
"text"].
"]]",
813 "[[".$xml_new_name.
"]]", $new_content);
815 $add = ($c[
"text"] !=
"")
819 str_replace(
"[[".$c[
"nt"]->mTextform.$add.
"]]",
820 "[[".$xml_new_name.$add.
"]]", $new_content);
823 $wpage->setXmlContent($new_content);
829 include_once(
"./Modules/Wiki/classes/class.ilObjWiki.php");
852 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
853 ? $news_set->get(
"default_visibility")
856 include_once(
"./Services/News/classes/class.ilNewsItem.php");
860 $news_item->setContext(
862 $this->
getId(),
"wpg");
864 $news_item->setTitle($this->
getTitle());
865 $news_item->setContentTextIsLangVar(
true);
866 $news_item->setContent(
"wiki_news_page_created");
867 $news_item->setUserId($ilUser->getId());
868 $news_item->setVisibility($default_visibility);
869 $news_item->create();
876 $this->
getId(),
"wpg",
true);
881 $news_item->setContent(
"wiki_news_page_changed");
882 $news_item->setUserId($ilUser->getId());
883 $news_item->setTitle($this->
getTitle());
884 $news_item->setContentTextIsLangVar(
true);
885 $news_item->update(
true);
890 $news_item->setContext(
892 $this->
getId(),
"wpg");
894 $news_item->setTitle($this->
getTitle());
895 $news_item->setContentTextIsLangVar(
true);
896 $news_item->setContent(
"wiki_news_page_changed");
897 $news_item->setUserId($ilUser->getId());
898 $news_item->setVisibility($default_visibility);
899 $news_item->create();
909 return "12.1.1: Test User, Max";