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;
174 "SELECT id FROM il_wiki_page " .
175 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
177 if ($rec =
$ilDB->fetchAssoc($set)) {
181 parent::createFromXML();
187 public function create($a_prevent_page_creation =
false)
191 $id =
$ilDB->nextId(
"il_wiki_page");
193 $query =
"INSERT INTO il_wiki_page (" .
211 if (!$a_prevent_page_creation) {
215 include_once
"./Modules/Wiki/classes/class.ilWikiStat.php";
218 include_once
"./Services/Notification/classes/class.ilNotification.php";
228 include_once
"Modules/Wiki/classes/class.ilWikiUtil.php";
229 $this->log->debug(
"collect internal links");
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";
258 $this->log->debug(
"handle stats");
268 public function update($a_validate =
true, $a_no_history =
false)
271 $this->log->debug(
"start...");
273 $query =
"UPDATE il_wiki_page SET " .
275 ",wiki_id = " .
$ilDB->quote((
int) $this->
getWikiId(),
"integer") .
277 ",rating = " .
$ilDB->quote((
int) $this->
getRating(),
"integer") .
279 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
281 $updated = parent::update($a_validate, $a_no_history);
283 if ($updated ===
true) {
284 include_once
"./Services/Notification/classes/class.ilNotification.php";
285 $this->log->debug(
"send notification");
288 $this->log->debug(
"update news");
300 public function read($a_omit_page_read =
false)
304 $query =
"SELECT * FROM il_wiki_page WHERE id = " .
307 $rec =
$ilDB->fetchAssoc($set);
316 if (!$a_omit_page_read) {
327 public function delete()
341 if ($wiki->isImportantPage($this->getId())) {
342 $wiki->removeImportantPage($this->
getId());
347 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
350 include_once
"./Modules/Wiki/classes/class.ilWikiStat.php";
353 include_once
"./Services/Notification/classes/class.ilNotification.php";
357 include_once
"./Services/Notification/classes/class.ilNotification.php";
361 $query =
"DELETE FROM il_wiki_page" .
362 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
369 foreach ($linking_pages as $lp) {
371 "DELETE FROM il_wiki_missing_page " .
372 " WHERE wiki_id = %s AND source_id = %s AND target_name = %s ",
373 array(
"integer",
"integer",
"text"),
377 "INSERT INTO il_wiki_missing_page " .
378 "(wiki_id, source_id, target_name) VALUES " .
380 array(
"integer",
"integer",
"text"),
397 $ilDB = $DIC->database();
400 $query =
"SELECT * FROM il_wiki_page" .
401 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
404 while ($rec =
$ilDB->fetchAssoc($set)) {
406 $wiki_page->delete();
413 public static function exists($a_wiki_id, $a_title)
417 $ilDB = $DIC->database();
421 $query =
"SELECT id FROM il_wiki_page" .
422 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
423 " AND title = " .
$ilDB->quote($a_title,
"text");
425 if ($rec =
$ilDB->fetchAssoc($set)) {
439 $ilDB = $DIC->database();
443 $query =
"SELECT id FROM il_wiki_page" .
444 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
445 " AND title = " .
$ilDB->quote($a_title,
"text");
447 if ($rec =
$ilDB->fetchAssoc($set)) {
461 $ilDB = $DIC->database();
465 $query =
"SELECT * FROM il_wiki_page" .
466 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
467 " AND title = " .
$ilDB->quote($a_title,
"text");
469 if ($rec =
$ilDB->fetchAssoc($set)) {
483 $ilDB = $DIC->database();
485 $query =
"SELECT * FROM il_wiki_page" .
486 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
488 if ($rec =
$ilDB->fetchAssoc($set)) {
489 return $rec[
"title"];
502 $ilDB = $DIC->database();
504 $query =
"SELECT wiki_id FROM il_wiki_page" .
505 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
507 if ($rec =
$ilDB->fetchAssoc($set)) {
508 return $rec[
"wiki_id"];
523 $ilDB = $DIC->database();
525 $pages = parent::getAllPages(
"wpg", $a_wiki_id);
527 $query =
"SELECT * FROM il_wiki_page" .
528 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
533 while ($rec =
$ilDB->fetchAssoc($set)) {
534 if (isset($pages[$rec[
"id"]])) {
535 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
536 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
550 $ilDB = $DIC->database();
552 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
556 foreach ($sources as
$source) {
557 if ($source[
"type"] ==
"wpg:pg") {
558 $ids[] = $source[
"id"];
562 $query =
"SELECT * FROM il_wiki_page wp, page_object p" .
563 " WHERE " .
$ilDB->in(
"wp.id", $ids,
false,
"integer") .
564 " AND wp.id = p.page_id AND p.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
565 " AND wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
570 while ($rec =
$ilDB->fetchAssoc($set)) {
571 $pages[] = array_merge($rec, array(
"user" => $rec[
"last_change_user"],
572 "date" => $rec[
"last_change"]));
587 $ilDB = $DIC->database();
591 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
594 foreach ($pages as $k => $page) {
598 foreach ($sources as
$source) {
599 if ($source[
"type"] ==
"wpg:pg") {
600 $ids[] = $source[
"id"];
603 $query =
"SELECT count(*) cnt FROM il_wiki_page" .
604 " WHERE " .
$ilDB->in(
"id", $ids,
false,
"integer") .
605 " AND wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
608 $rec =
$ilDB->fetchAssoc($set);
609 if ($rec[
"cnt"] == 0 &&
627 $ilDB = $DIC->database();
631 $query =
"SELECT id FROM il_wiki_page" .
632 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
633 " AND title = " .
$ilDB->quote($a_title,
"text");
637 if ($rec =
$ilDB->fetchAssoc($set)) {
653 $ilDB = $DIC->database();
655 $contributors = parent::getParentObjectContributors(
"wpg", $a_wiki_id);
657 return $contributors;
669 $ilDB = $DIC->database();
671 $contributors = parent::getPageContributors(
"wpg", $a_page_id);
673 return $contributors;
686 $this->log->debug(
"start...");
689 parent::saveInternalLinks($a_domdoc);
696 $set =
$ilDB->queryF(
697 "SELECT * FROM il_wiki_missing_page WHERE " .
698 " wiki_id = %s AND target_name = %s",
699 array(
"integer",
"text"),
702 while ($anmiss =
$ilDB->fetchAssoc($set)) {
706 $anmiss[
"source_id"],
715 "DELETE FROM il_wiki_missing_page WHERE " .
716 " wiki_id = %s AND target_name = %s",
717 array(
"integer",
"text"),
726 "DELETE FROM il_wiki_missing_page WHERE " .
727 " wiki_id = %s AND source_id = %s",
728 array(
"integer",
"integer"),
733 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
734 $xml = $a_domdoc->saveXML();
736 foreach ($int_wiki_links as $wlink) {
749 "DELETE FROM il_wiki_missing_page WHERE" .
750 " wiki_id = %s AND source_id = %s AND target_name = %s",
751 array(
"integer",
"integer",
"text"),
755 "INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)" .
756 " VALUES (%s,%s,%s)",
757 array(
"integer",
"integer",
"text"),
762 $this->log->debug(
"...end");
772 $ilDB = $DIC->database();
774 $query =
"SELECT id FROM il_wiki_page" .
775 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
776 " AND title = " .
$ilDB->quote($a_title,
"text");
778 if ($rec =
$ilDB->fetchAssoc($set)) {
794 $ilDB = $DIC->database();
796 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po" .
797 " WHERE wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
798 " AND wp.id = po.page_id " .
799 " AND po.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
" " .
800 " ORDER BY po.view_cnt";
804 while ($rec =
$ilDB->fetchAssoc($set)) {
820 $ilDB = $DIC->database();
823 $query =
"SELECT count(*) as cnt FROM il_wiki_page" .
824 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
826 $r =
$ilDB->fetchAssoc($s);
840 $ilDB = $DIC->database();
848 $random = new \ilRandom();
849 $rand = $random->int(1, $cnt);
852 $ilDB->setLimit(1, $rand);
853 $query =
"SELECT title FROM il_wiki_page" .
854 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
856 $r =
$ilDB->fetchAssoc($s);
870 $ilDB = $DIC->database();
872 $pages = parent::getNewPages(
"wpg", $a_wiki_id);
874 foreach ($pages as $k => $page) {
892 $ilDB = $DIC->database();
894 $query =
"SELECT wiki_id FROM il_wiki_page" .
895 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
897 if ($rec =
$ilDB->fetchAssoc($set)) {
898 return $rec[
"wiki_id"];
912 $a_new_name = str_replace(array(
"<",
">"),
'', $a_new_name);
915 $a_new_name = trim(preg_replace(
'!\s+!',
' ', $a_new_name));
920 $xml_new_name = str_replace(
"&",
"&", $a_new_name);
922 if ($pg_id == 0 || $pg_id == $this->
getId()) {
923 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
926 foreach ($sources as $s) {
931 $wpage->getXmlContent(),
935 $new_content = $wpage->getXmlContent();
936 foreach ($col as
$c) {
951 $t1 = preg_replace(
'/\xC2\xA0/',
' ', $t1);
952 $t2 = preg_replace(
'/\xC2\xA0/',
' ', $t2);
954 $set =
$ilDB->query($q =
"SELECT " .
$ilDB->quote($t1,
"text") .
" = " .
$ilDB->quote($t2,
"text") .
" isequal");
955 $rec =
$ilDB->fetchAssoc($set);
957 if ($rec[
"isequal"]) {
960 "[[" . $c[
"nt"]->mTextform .
"]]",
961 "[[" . $xml_new_name .
"]]",
964 if ($c[
"text"] !=
"") {
967 "[[" . $c[
"text"] .
"]]",
968 "[[" . $xml_new_name .
"]]",
972 $add = ($c[
"text"] !=
"")
977 "[[" . $c[
"nt"]->mTextform . $add .
"]]",
978 "[[" . $xml_new_name . $add .
"]]",
983 $wpage->setXmlContent($new_content);
989 include_once(
"./Modules/Wiki/classes/class.ilObjWiki.php");
1011 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
1012 ? $news_set->get(
"default_visibility")
1015 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1018 $news_item->setContext(
1025 $news_item->setTitle($this->
getTitle());
1026 $news_item->setContentTextIsLangVar(
true);
1027 $news_item->setContent(
"wiki_news_page_created");
1028 $news_item->setUserId(
$ilUser->getId());
1029 $news_item->setVisibility($default_visibility);
1030 $news_item->create();
1043 $news_item->setContent(
"wiki_news_page_changed");
1044 $news_item->setUserId(
$ilUser->getId());
1045 $news_item->setTitle($this->
getTitle());
1046 $news_item->setContentTextIsLangVar(
true);
1047 $news_item->update(
true);
1050 $news_item->setContext(
1057 $news_item->setTitle($this->
getTitle());
1058 $news_item->setContentTextIsLangVar(
true);
1059 $news_item->setContent(
"wiki_news_page_changed");
1060 $news_item->setUserId(
$ilUser->getId());
1061 $news_item->setVisibility($default_visibility);
1062 $news_item->create();
1072 return "12.1.1: Test User, Max";
1084 $href =
"./goto.php?target=wiki_wpage_" . $a_target;
1086 $href = ILIAS_HTTP_PATH .
"/goto.php?target=wiki_wpage_" . $a_target;
1099 include_once(
"./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
1101 $templates = array();
1103 $templates[] = array(
"id" => $t[
"wpage_id"],
"parent_type" =>
"wpg",
"title" => $t[
"title"]);
1118 $ilDB = $DIC->database();
1120 $set =
$ilDB->query(
"SELECT DISTINCT title FROM il_wiki_page" .
1121 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
1122 " AND " .
$ilDB->like(
"title",
"text",
"%" . $a_term .
"%") .
1125 while ($rec =
$ilDB->fetchAssoc($set)) {
1126 $res[] = $rec[
"title"];
1136 $ilDB = $DIC->database();
1138 $query =
"SELECT * FROM il_wiki_page" .
1139 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
1141 if ($rec =
$ilDB->fetchAssoc($set)) {
1142 return (
bool) $rec[
"hide_adv_md"];
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
setTitle($a_title)
Set Title.
static removeForObject($type, $id)
Remove all notifications for given object.
updateNews($a_update=false)
Create.
getWikiId()
Get Wiki Object Id.
afterUpdate($a_domdoc=null, $a_xml="")
getWikiRefId()
Get Wiki Ref Id.
getNewsContent()
Get content for a wiki news item.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
isAdvancedMetadataHidden()
Get adv md visibility status.
static getNewWikiPages($a_wiki_id)
Get all pages of wiki.
static _lookupStartPage($a_wiki_id)
Lookup start page.
static getPopularPages($a_wiki_id)
Get popular pages of wiki.
getParentType()
Get parent type.
getContentTemplates()
Get content templates.
getDomDoc()
Get dom doc (php5 dom document)
static collectInternalLinks($s, $a_wiki_id, $a_collect_non_ex=false)
Collect internal wiki links of a string.
static lookupAdvancedMetadataHidden($a_page_id)
static getPageIdForTitle($a_wiki_id, $a_title)
Get wiki page object for id and title.
static getWikiContributors($a_wiki_id)
Get all contributors of wiki.
static processInternalLinks( $s, $a_wiki_id, $a_mode=IL_WIKI_MODE_REPLACE, $a_collect_non_ex=false, $a_offline=false)
Process internal links.
static getRandomPage($a_wiki_id)
Get a random page.
setBlocked($a_val)
Set blocked.
static getPagesForSearch($a_wiki_id, $a_term)
Get pages for search.
static lookupWikiId($a_page_id)
Lookup wiki id.
createFromXML()
Create page from xml.
static sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment=null)
static _getPageIdForWikiTitle($a_wiki_id, $a_title)
Checks whether a page with given title exists.
foreach($_POST as $key=> $value) $res
static getLastNewsIdForContext( $a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="", $a_only_today=false)
Get last news id of news set related to a certain context.
rename($a_new_name)
Rename page.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
static _getSourcesOfTarget($a_target_type, $a_target_id, $a_target_inst)
get all sources of a link target
static handleEvent($a_event, ilWikiPage $a_page_obj, $a_user_id=null, array $a_additional_data=null)
Handle wiki page event.
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.
static makeDbTitle($a_par)
Handle page GET parameter.
static countPages($a_wiki_id)
Count pages of wiki.
read($a_omit_page_read=false)
Read wiki data.
static getOrphanedPages($a_wiki_id)
Get orphaned pages of wiki.
static _wikiPageExists($a_wiki_id, $a_title)
Check whether page exists for wiki or not.
static exists($a_wiki_id, $a_title)
Checks whether a page with given title exists.
getPageConfig()
Get page config object.
const IL_WIKI_MODE_EXT_COLLECT
saveInternalLinks($a_domdoc)
save internal links of page
create($a_prevent_page_creation=false)
Create new wiki page.
static deleteAllPagesOfWiki($a_wiki_id)
delete wiki page and al related data
static _saveLink( $a_source_type, $a_source_id, $a_target_type, $a_target_id, $a_target_inst=0, $a_source_lang="-")
save internal link information
static getLinksToPage($a_wiki_id, $a_page_id)
Get links to a page.
update($a_validate=true, $a_no_history=false)
update object data
static getWikiPageContributors($a_page_id)
Get all contributors of wiki.
setWikiId($a_wikiid)
Set Wiki Object Id.
hideAdvancedMetadata($a_val)
Toggle adv md visibility.
setWikiRefId($a_wiki_ref_id)
Set Wiki Ref Id.
static getIdForPageTitle($a_wiki_id, $a_title)
Checks whether a page with given title exists.
static _deleteAllLinksToTarget($a_target_type, $a_target_id, $a_target_inst=0)
Delete all links to a given target.
static getGotoForWikiPageTarget($a_target, $a_offline=false)
Get goto href for internal wiki page link target.
static writeStartPage($a_id, $a_name)
Write start page.
setRating($a_val)
Set rating.
static lookupObjIdByPage($a_page_id)
returns the wiki/object id to a given page id
afterConstructor()
After constructor.