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;
111 function create($a_prevent_page_creation =
false)
115 $id = $ilDB->nextId(
"il_wiki_page");
117 $query =
"INSERT INTO il_wiki_page (".
123 $ilDB->quote($this->
getId(),
"integer")
124 .
",".$ilDB->quote($this->
getTitle(),
"text")
125 .
",".$ilDB->quote($this->
getWikiId(),
"integer")
126 .
",".$ilDB->quote($this->
getBlocked(),
"integer")
128 $ilDB->manipulate(
$query);
131 if (!$a_prevent_page_creation)
136 include_once
"./Services/Notification/classes/class.ilNotification.php";
149 function update($a_validate =
true, $a_no_history =
false)
154 $query =
"UPDATE il_wiki_page SET ".
155 " title = ".$ilDB->quote($this->
getTitle(),
"text").
156 ",wiki_id = ".$ilDB->quote($this->
getWikiId(),
"integer").
157 ",blocked = ".$ilDB->quote($this->
getBlocked(),
"integer").
158 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
159 $ilDB->manipulate(
$query);
162 include_once
"./Services/Notification/classes/class.ilNotification.php";
177 $query =
"SELECT * FROM il_wiki_page WHERE id = ".
178 $ilDB->quote($this->
getId(),
"integer");
179 $set = $ilDB->query(
$query);
180 $rec = $ilDB->fetchAssoc($set);
205 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
208 include_once
"./Services/Notification/classes/class.ilNotification.php";
212 include_once
"./Services/Notification/classes/class.ilNotification.php";
216 $query =
"DELETE FROM il_wiki_page".
217 " WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
218 $ilDB->manipulate(
$query);
224 foreach($linking_pages as $lp)
226 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page ".
227 " WHERE wiki_id = %s AND source_id = %s AND target_name = %s ",
228 array(
"integer",
"integer",
"text"),
230 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page ".
231 "(wiki_id, source_id, target_name) VALUES ".
233 array(
"integer",
"integer",
"text"),
250 $query =
"SELECT * FROM il_wiki_page".
251 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
252 $set = $ilDB->query(
$query);
254 while($rec = $ilDB->fetchAssoc($set))
257 $wiki_page->delete();
266 static function exists($a_wiki_id, $a_title)
272 $query =
"SELECT id FROM il_wiki_page".
273 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
274 " AND title = ".$ilDB->quote($a_title,
"text");
275 $set = $ilDB->query(
$query);
276 if($rec = $ilDB->fetchAssoc($set))
293 $query =
"SELECT id FROM il_wiki_page".
294 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
295 " AND title = ".$ilDB->quote($a_title,
"text");
296 $set = $ilDB->query(
$query);
297 if($rec = $ilDB->fetchAssoc($set))
314 $query =
"SELECT * FROM il_wiki_page".
315 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
316 " AND title = ".$ilDB->quote($a_title,
"text");
317 $set = $ilDB->query(
$query);
318 if($rec = $ilDB->fetchAssoc($set))
333 $query =
"SELECT * FROM il_wiki_page".
334 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
335 $set = $ilDB->query(
$query);
336 if($rec = $ilDB->fetchAssoc($set))
338 return $rec[
"title"];
351 $query =
"SELECT wiki_id FROM il_wiki_page".
352 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
353 $set = $ilDB->query(
$query);
354 if ($rec = $ilDB->fetchAssoc($set))
356 return $rec[
"wiki_id"];
373 $query =
"SELECT * FROM il_wiki_page".
374 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
376 $set = $ilDB->query(
$query);
379 while($rec = $ilDB->fetchAssoc($set))
381 if (isset($pages[$rec[
"id"]]))
383 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
384 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
398 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
402 foreach ($sources as $source)
404 if ($source[
"type"] ==
"wpg:pg")
406 $ids[] = $source[
"id"];
410 $query =
"SELECT * FROM il_wiki_page wp, page_object p".
411 " WHERE ".$ilDB->in(
"wp.id", $ids,
false,
"integer").
412 " AND wp.id = p.page_id AND p.parent_type = ".$ilDB->quote(
"wpg",
"text").
413 " AND wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
415 $set = $ilDB->query(
$query);
418 while ($rec = $ilDB->fetchAssoc($set))
420 $pages[] = array_merge($rec, array(
"user" => $rec[
"last_change_user"],
421 "date" => $rec[
"last_change"]));
438 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
441 foreach ($pages as $k => $page)
446 foreach ($sources as $source)
448 if ($source[
"type"] ==
"wpg:pg")
450 $ids[] = $source[
"id"];
454 $query =
"SELECT count(*) AS cnt FROM il_wiki_page".
455 " WHERE ".$ilDB->in(
"id", $ids,
false,
"integer").
456 " AND wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
458 $set = $ilDB->query(
$query);
459 $rec = $ilDB->fetchAssoc($set);
460 if ($rec[
"cnt"] == 0 &&
481 $query =
"SELECT id FROM il_wiki_page".
482 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
483 " AND title = ".$ilDB->quote($a_title,
"text");
484 $set = $ilDB->query(
$query);
487 if ($rec = $ilDB->fetchAssoc($set))
506 return $contributors;
520 return $contributors;
543 $set = $ilDB->queryF(
"SELECT * FROM il_wiki_missing_page WHERE ".
544 " wiki_id = %s AND target_name = %s",
545 array(
"integer",
"text"),
547 while ($anmiss = $ilDB->fetchAssoc($set))
555 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
556 " wiki_id = %s AND target_name = %s",
557 array(
"integer",
"text"),
564 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE ".
565 " wiki_id = %s AND source_id = %s",
566 array(
"integer",
"integer"),
570 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
573 foreach($int_wiki_links as $wlink)
584 $ilDB->manipulateF(
"DELETE FROM il_wiki_missing_page WHERE".
585 " wiki_id = %s AND source_id = %s AND target_name = %s",
586 array(
"integer",
"integer",
"text"),
588 $ilDB->manipulateF(
"INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)".
589 " VALUES (%s,%s,%s)",
590 array(
"integer",
"integer",
"text"),
603 $query =
"SELECT id FROM il_wiki_page".
604 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
605 " AND title = ".$ilDB->quote($a_title,
"text");
606 $set = $ilDB->query(
$query);
607 if($rec = $ilDB->fetchAssoc($set))
624 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po".
625 " WHERE wp.wiki_id = ".$ilDB->quote($a_wiki_id,
"integer").
626 " AND wp.id = po.page_id ".
627 " AND po.parent_type = ".$ilDB->quote(
"wpg",
"text").
" ".
628 " ORDER BY po.view_cnt";
629 $set = $ilDB->query(
$query);
632 while($rec = $ilDB->fetchAssoc($set))
650 $query =
"SELECT count(*) as cnt FROM il_wiki_page".
651 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
652 $s = $ilDB->query(
$query);
653 $r = $ilDB->fetchAssoc($s);
674 $rand = rand(1, $cnt);
677 $ilDB->setLimit(1, $rand);
678 $query =
"SELECT title FROM il_wiki_page".
679 " WHERE wiki_id = ".$ilDB->quote($a_wiki_id,
"integer");
680 $s = $ilDB->query(
$query);
681 $r = $ilDB->fetchAssoc($s);
697 foreach($pages as $k => $page)
716 $query =
"SELECT wiki_id FROM il_wiki_page".
717 " WHERE id = ".$ilDB->quote($a_page_id,
"integer");
718 $set = $ilDB->query(
$query);
719 if($rec = $ilDB->fetchAssoc($set))
721 return $rec[
"wiki_id"];
734 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
736 foreach ($sources as $s)
738 if ($s[
"type"] ==
"wpg:pg")
744 $new_content = $wpage->getXmlContent();
751 str_replace(
"[[".$c[
"nt"]->mTextform.
"]]",
752 "[[".$a_new_name.
"]]", $new_content);
753 if ($c[
"text"] !=
"")
756 str_replace(
"[[".$c[
"text"].
"]]",
757 "[[".$a_new_name.
"]]", $new_content);
759 $add = ($c[
"text"] !=
"")
763 str_replace(
"[[".$c[
"nt"]->mTextform.$add.
"]]",
764 "[[".$a_new_name.$add.
"]]", $new_content);
769 $wpage->setXmlContent($new_content);
774 include_once(
"./Modules/Wiki/classes/class.ilObjWiki.php");
795 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
796 ? $news_set->get(
"default_visibility")
799 include_once(
"./Services/News/classes/class.ilNewsItem.php");
803 $news_item->setContext(
805 $this->
getId(),
"wpg");
807 $news_item->setTitle($this->
getTitle());
808 $news_item->setContentTextIsLangVar(
true);
809 $news_item->setContent(
"wiki_news_page_created");
810 $news_item->setUserId($ilUser->getId());
811 $news_item->setVisibility($default_visibility);
812 $news_item->create();
819 $this->
getId(),
"wpg",
true);
824 $news_item->setContent(
"wiki_news_page_changed");
825 $news_item->setUserId($ilUser->getId());
826 $news_item->setTitle($this->
getTitle());
827 $news_item->setContentTextIsLangVar(
true);
828 $news_item->update(
true);
833 $news_item->setContext(
835 $this->
getId(),
"wpg");
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();
852 return "12.1.1: Test User, Max";