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";
234 $ext_links =
sizeof($xpath->query(
'//IntLink'));
235 $ext_links +=
sizeof($xpath->query(
'//ExtLink'));
237 $footnotes =
sizeof($xpath->query(
'//Footnote'));
242 $xml = strip_tags($a_xml);
244 include_once
"Services/Utilities/classes/class.ilStr.php";
246 $num_words =
sizeof(explode(
" ",
$xml));
249 "int_links" => $int_links,
250 "ext_links" => $ext_links,
251 "footnotes" => $footnotes,
252 "num_words" => $num_words,
253 "num_chars" => $num_chars
256 include_once
"./Modules/Wiki/classes/class.ilWikiStat.php";
266 public function update($a_validate =
true, $a_no_history =
false)
271 $query =
"UPDATE il_wiki_page SET " .
273 ",wiki_id = " .
$ilDB->quote((
int) $this->
getWikiId(),
"integer") .
275 ",rating = " .
$ilDB->quote((
int) $this->
getRating(),
"integer") .
277 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
281 if ($updated ===
true) {
282 include_once
"./Services/Notification/classes/class.ilNotification.php";
296 public function read($a_omit_page_read =
false)
300 $query =
"SELECT * FROM il_wiki_page WHERE id = " .
303 $rec =
$ilDB->fetchAssoc($set);
312 if (!$a_omit_page_read) {
323 public function delete()
334 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
337 include_once
"./Modules/Wiki/classes/class.ilWikiStat.php";
340 include_once
"./Services/Notification/classes/class.ilNotification.php";
344 include_once
"./Services/Notification/classes/class.ilNotification.php";
348 $query =
"DELETE FROM il_wiki_page" .
349 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
356 foreach ($linking_pages as $lp) {
358 "DELETE FROM il_wiki_missing_page " .
359 " WHERE wiki_id = %s AND source_id = %s AND target_name = %s ",
360 array(
"integer",
"integer",
"text"),
364 "INSERT INTO il_wiki_missing_page " .
365 "(wiki_id, source_id, target_name) VALUES " .
367 array(
"integer",
"integer",
"text"),
384 $ilDB = $DIC->database();
387 $query =
"SELECT * FROM il_wiki_page" .
388 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
391 while ($rec =
$ilDB->fetchAssoc($set)) {
393 $wiki_page->delete();
400 public static function exists($a_wiki_id, $a_title)
404 $ilDB = $DIC->database();
408 $query =
"SELECT id FROM il_wiki_page" .
409 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
410 " AND title = " .
$ilDB->quote($a_title,
"text");
412 if ($rec =
$ilDB->fetchAssoc($set)) {
426 $ilDB = $DIC->database();
430 $query =
"SELECT id FROM il_wiki_page" .
431 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
432 " AND title = " .
$ilDB->quote($a_title,
"text");
434 if ($rec =
$ilDB->fetchAssoc($set)) {
448 $ilDB = $DIC->database();
452 $query =
"SELECT * FROM il_wiki_page" .
453 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
454 " AND title = " .
$ilDB->quote($a_title,
"text");
456 if ($rec =
$ilDB->fetchAssoc($set)) {
470 $ilDB = $DIC->database();
472 $query =
"SELECT * FROM il_wiki_page" .
473 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
475 if ($rec =
$ilDB->fetchAssoc($set)) {
476 return $rec[
"title"];
489 $ilDB = $DIC->database();
491 $query =
"SELECT wiki_id FROM il_wiki_page" .
492 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
494 if ($rec =
$ilDB->fetchAssoc($set)) {
495 return $rec[
"wiki_id"];
510 $ilDB = $DIC->database();
512 $pages = parent::getAllPages(
"wpg", $a_wiki_id);
514 $query =
"SELECT * FROM il_wiki_page" .
515 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
520 while ($rec =
$ilDB->fetchAssoc($set)) {
521 if (isset($pages[$rec[
"id"]])) {
522 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
523 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
537 $ilDB = $DIC->database();
539 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
543 foreach ($sources as
$source) {
544 if ($source[
"type"] ==
"wpg:pg") {
545 $ids[] = $source[
"id"];
549 $query =
"SELECT * FROM il_wiki_page wp, page_object p" .
550 " WHERE " .
$ilDB->in(
"wp.id", $ids,
false,
"integer") .
551 " AND wp.id = p.page_id AND p.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
552 " AND wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
557 while ($rec =
$ilDB->fetchAssoc($set)) {
558 $pages[] = array_merge($rec,
array(
"user" => $rec[
"last_change_user"],
559 "date" => $rec[
"last_change"]));
574 $ilDB = $DIC->database();
578 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
581 foreach ($pages as $k => $page) {
585 foreach ($sources as
$source) {
586 if ($source[
"type"] ==
"wpg:pg") {
587 $ids[] = $source[
"id"];
590 $query =
"SELECT count(*) cnt FROM il_wiki_page" .
591 " WHERE " .
$ilDB->in(
"id", $ids,
false,
"integer") .
592 " AND wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
595 $rec =
$ilDB->fetchAssoc($set);
596 if ($rec[
"cnt"] == 0 &&
614 $ilDB = $DIC->database();
618 $query =
"SELECT id FROM il_wiki_page" .
619 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
620 " AND title = " .
$ilDB->quote($a_title,
"text");
624 if ($rec =
$ilDB->fetchAssoc($set)) {
640 $ilDB = $DIC->database();
642 $contributors = parent::getParentObjectContributors(
"wpg", $a_wiki_id);
644 return $contributors;
656 $ilDB = $DIC->database();
658 $contributors = parent::getPageContributors(
"wpg", $a_page_id);
660 return $contributors;
676 parent::saveInternalLinks($a_domdoc);
683 $set =
$ilDB->queryF(
684 "SELECT * FROM il_wiki_missing_page WHERE " .
685 " wiki_id = %s AND target_name = %s",
686 array(
"integer",
"text"),
689 while ($anmiss =
$ilDB->fetchAssoc($set)) {
693 $anmiss[
"source_id"],
702 "DELETE FROM il_wiki_missing_page WHERE " .
703 " wiki_id = %s AND target_name = %s",
704 array(
"integer",
"text"),
713 "DELETE FROM il_wiki_missing_page WHERE " .
714 " wiki_id = %s AND source_id = %s",
715 array(
"integer",
"integer"),
720 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
721 $xml = $a_domdoc->saveXML();
723 foreach ($int_wiki_links as $wlink) {
736 "DELETE FROM il_wiki_missing_page WHERE" .
737 " wiki_id = %s AND source_id = %s AND target_name = %s",
738 array(
"integer",
"integer",
"text"),
742 "INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)" .
743 " VALUES (%s,%s,%s)",
744 array(
"integer",
"integer",
"text"),
758 $ilDB = $DIC->database();
760 $query =
"SELECT id FROM il_wiki_page" .
761 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
762 " AND title = " .
$ilDB->quote($a_title,
"text");
764 if ($rec =
$ilDB->fetchAssoc($set)) {
780 $ilDB = $DIC->database();
782 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po" .
783 " WHERE wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
784 " AND wp.id = po.page_id " .
785 " AND po.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
" " .
786 " ORDER BY po.view_cnt";
790 while ($rec =
$ilDB->fetchAssoc($set)) {
806 $ilDB = $DIC->database();
809 $query =
"SELECT count(*) as cnt FROM il_wiki_page" .
810 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
826 $ilDB = $DIC->database();
834 $random = new \ilRandom();
835 $rand = $random->int(1, $cnt);
838 $ilDB->setLimit(1, $rand);
839 $query =
"SELECT title FROM il_wiki_page" .
840 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
856 $ilDB = $DIC->database();
858 $pages = parent::getNewPages(
"wpg", $a_wiki_id);
860 foreach ($pages as $k => $page) {
878 $ilDB = $DIC->database();
880 $query =
"SELECT wiki_id FROM il_wiki_page" .
881 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
883 if ($rec =
$ilDB->fetchAssoc($set)) {
884 return $rec[
"wiki_id"];
898 $a_new_name = str_replace(
array(
"<",
">"),
'', $a_new_name);
901 $a_new_name = trim(preg_replace(
'!\s+!',
' ', $a_new_name));
906 $xml_new_name = str_replace(
"&",
"&", $a_new_name);
908 if ($pg_id == 0 || $pg_id == $this->
getId()) {
909 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
912 foreach ($sources as
$s) {
917 $wpage->getXmlContent(),
921 $new_content = $wpage->getXmlContent();
922 foreach ($col as $c) {
937 $t1 = preg_replace(
'/\xC2\xA0/',
' ', $t1);
938 $t2 = preg_replace(
'/\xC2\xA0/',
' ', $t2);
940 $set =
$ilDB->query($q =
"SELECT " .
$ilDB->quote($t1,
"text") .
" = " .
$ilDB->quote($t2,
"text") .
" isequal");
941 $rec =
$ilDB->fetchAssoc($set);
943 if ($rec[
"isequal"]) {
946 "[[" . $c[
"nt"]->mTextform .
"]]",
947 "[[" . $xml_new_name .
"]]",
950 if ($c[
"text"] !=
"") {
953 "[[" . $c[
"text"] .
"]]",
954 "[[" . $xml_new_name .
"]]",
958 $add = ($c[
"text"] !=
"")
963 "[[" . $c[
"nt"]->mTextform . $add .
"]]",
964 "[[" . $xml_new_name . $add .
"]]",
969 $wpage->setXmlContent($new_content);
975 include_once(
"./Modules/Wiki/classes/class.ilObjWiki.php");
997 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
998 ? $news_set->get(
"default_visibility")
1001 include_once(
"./Services/News/classes/class.ilNewsItem.php");
1004 $news_item->setContext(
1011 $news_item->setTitle($this->
getTitle());
1012 $news_item->setContentTextIsLangVar(
true);
1013 $news_item->setContent(
"wiki_news_page_created");
1014 $news_item->setUserId(
$ilUser->getId());
1015 $news_item->setVisibility($default_visibility);
1016 $news_item->create();
1029 $news_item->setContent(
"wiki_news_page_changed");
1030 $news_item->setUserId(
$ilUser->getId());
1031 $news_item->setTitle($this->
getTitle());
1032 $news_item->setContentTextIsLangVar(
true);
1033 $news_item->update(
true);
1036 $news_item->setContext(
1043 $news_item->setTitle($this->
getTitle());
1044 $news_item->setContentTextIsLangVar(
true);
1045 $news_item->setContent(
"wiki_news_page_changed");
1046 $news_item->setUserId(
$ilUser->getId());
1047 $news_item->setVisibility($default_visibility);
1048 $news_item->create();
1058 return "12.1.1: Test User, Max";
1070 $href =
"./goto.php?target=wiki_wpage_" . $a_target;
1072 $href = ILIAS_HTTP_PATH .
"/goto.php?target=wiki_wpage_" . $a_target;
1085 include_once(
"./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
1087 $templates =
array();
1089 $templates[] =
array(
"id" =>
$t[
"wpage_id"],
"parent_type" =>
"wpg",
"title" =>
$t[
"title"]);
1104 $ilDB = $DIC->database();
1106 $set =
$ilDB->query(
"SELECT DISTINCT title FROM il_wiki_page" .
1107 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
1108 " AND " .
$ilDB->like(
"title",
"text",
"%" . $a_term .
"%") .
1111 while ($rec =
$ilDB->fetchAssoc($set)) {
1112 $res[] = $rec[
"title"];
1122 $ilDB = $DIC->database();
1124 $query =
"SELECT * FROM il_wiki_page" .
1125 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
1127 if ($rec =
$ilDB->fetchAssoc($set)) {
1128 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.
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.
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.
Create styles array
The data for the language used.
static countPages($a_wiki_id)
Count pages of wiki.
read($a_omit_page_read=false)
Read wiki data.
update($pash, $contents, Config $config)
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.