42 public function setTitle(
string $a_title): void
64 $this->parent_ref_id = $a_wiki_ref_id;
74 $this->blocked = $a_val;
84 $this->rating = $a_val;
94 $this->hide_adv_md = $a_val;
112 "SELECT id FROM il_wiki_page " .
113 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
115 if ($rec =
$ilDB->fetchAssoc($set)) {
119 parent::createFromXML();
123 bool $a_import =
false
127 $id =
$ilDB->nextId(
"il_wiki_page");
129 $query =
"INSERT INTO il_wiki_page (" .
148 parent::create($a_import);
164 $this->log->debug(
"collect internal links");
167 $xpath =
new DOMXPath($domdoc);
170 $ext_links = count($xpath->query(
'//IntLink'));
171 $ext_links += count($xpath->query(
'//ExtLink'));
173 $footnotes = count($xpath->query(
'//Footnote'));
181 $num_words = count(explode(
" ",
$xml));
184 "int_links" => $int_links,
185 "ext_links" => $ext_links,
186 "footnotes" => $footnotes,
187 "num_words" => $num_words,
188 "num_chars" => $num_chars
190 $this->log->debug(
"handle stats");
199 bool $a_validate =
true,
200 bool $a_no_history =
false
203 $this->log->debug(
"start...");
205 $query =
"UPDATE il_wiki_page SET " .
206 " title = " .
$ilDB->quote($this->getTitle(),
"text") .
207 ",wiki_id = " .
$ilDB->quote($this->getWikiId(),
"integer") .
208 ",blocked = " .
$ilDB->quote((
int) $this->getBlocked(),
"integer") .
209 ",rating = " .
$ilDB->quote((
int) $this->getRating(),
"integer") .
210 ",hide_adv_md = " .
$ilDB->quote((
int) $this->isAdvancedMetadataHidden(),
"integer") .
211 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
213 $updated = parent::update($a_validate, $a_no_history);
216 $this->log->debug(
"send notification");
219 $this->log->debug(
"update news");
220 $this->updateNews(
true);
229 bool $a_omit_page_read =
false
233 $query =
"SELECT * FROM il_wiki_page WHERE id = " .
236 $rec =
$ilDB->fetchAssoc($set);
238 $this->setTitle($rec[
"title"]);
239 $this->setWikiId((
int) $rec[
"wiki_id"]);
240 $this->setBlocked((
bool) $rec[
"blocked"]);
241 $this->setRating((
bool) $rec[
"rating"]);
242 $this->hideAdvancedMetadata((
bool) $rec[
"hide_adv_md"]);
245 if (!$a_omit_page_read) {
251 public function delete():
void
256 $linking_pages = self::getLinksToPage(
264 $wiki =
new ilObjWiki($this->getWikiId(),
false);
265 if ($wiki->isImportantPage($this->getId())) {
266 $wiki->removeImportantPage($this->
getId());
281 $query =
"DELETE FROM il_wiki_page" .
282 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
289 foreach ($linking_pages as $lp) {
291 "DELETE FROM il_wiki_missing_page " .
292 " WHERE wiki_id = %s AND source_id = %s AND target_name = %s ",
293 array(
"integer",
"integer",
"text"),
294 array($this->getWikiId(), $lp[
"id"], $this->getTitle())
297 "INSERT INTO il_wiki_missing_page " .
298 "(wiki_id, source_id, target_name) VALUES " .
300 array(
"integer",
"integer",
"text"),
301 array($this->getWikiId(), $lp[
"id"], $this->getTitle())
313 $query =
"SELECT * FROM il_wiki_page" .
314 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
317 while ($rec =
$ilDB->fetchAssoc($set)) {
319 $wiki_page->delete();
336 $query =
"SELECT id FROM il_wiki_page" .
337 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
338 " AND title = " .
$ilDB->quote($a_title,
"text");
340 if ($rec =
$ilDB->fetchAssoc($set)) {
361 $query =
"SELECT * FROM il_wiki_page" .
362 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
363 " AND title = " .
$ilDB->quote($a_title,
"text");
365 if ($rec =
$ilDB->fetchAssoc($set)) {
366 return (
int) $rec[
"id"];
378 $query =
"SELECT * FROM il_wiki_page" .
379 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
381 if ($rec =
$ilDB->fetchAssoc($set)) {
382 return (
string) $rec[
"title"];
394 $query =
"SELECT wiki_id FROM il_wiki_page" .
395 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
397 if ($rec =
$ilDB->fetchAssoc($set)) {
398 return (
int) $rec[
"wiki_id"];
411 $pages = parent::getAllPages(
"wpg", $a_wiki_id);
413 $query =
"SELECT * FROM il_wiki_page" .
414 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
419 while ($rec =
$ilDB->fetchAssoc($set)) {
420 if (isset($pages[$rec[
"id"]])) {
421 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
422 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
440 foreach ($sources as
$source) {
441 if (
$source[
"type"] ===
"wpg:pg") {
446 $query =
"SELECT * FROM il_wiki_page wp, page_object p" .
447 " WHERE " .
$ilDB->in(
"wp.id", $ids,
false,
"integer") .
448 " AND wp.id = p.page_id AND p.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
449 " AND wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
454 while ($rec =
$ilDB->fetchAssoc($set)) {
455 $pages[] = array_merge($rec, array(
"user" => $rec[
"last_change_user"],
456 "date" => $rec[
"last_change"]));
469 $pages = self::getAllWikiPages($a_wiki_id);
472 foreach ($pages as $k => $page) {
475 foreach ($sources as
$source) {
476 if (
$source[
"type"] ===
"wpg:pg") {
480 $query =
"SELECT count(*) cnt FROM il_wiki_page" .
481 " WHERE " .
$ilDB->in(
"id", $ids,
false,
"integer") .
482 " AND wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
485 $rec =
$ilDB->fetchAssoc($set);
486 if (count($ids) === 0 || ($rec && (
int) $rec[
"cnt"] === 0)) {
506 $query =
"SELECT id FROM il_wiki_page" .
507 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
508 " AND title = " .
$ilDB->quote($a_title,
"text");
511 if (
$ilDB->fetchAssoc($set)) {
521 return parent::getParentObjectContributors(
"wpg", $a_wiki_id);
527 return parent::getPageContributors(
"wpg", $a_page_id);
531 DOMDocument $a_domdoc
535 $this->log->debug(
"start...");
538 parent::saveInternalLinks($a_domdoc);
542 $this->log->debug(
"this page <- other pages.");
546 $set =
$ilDB->queryF(
547 "SELECT * FROM il_wiki_missing_page WHERE " .
548 " wiki_id = %s AND target_name = %s",
549 array(
"integer",
"text"),
552 while ($anmiss =
$ilDB->fetchAssoc($set)) {
553 $this->log->debug(
"link found, source: " . $anmiss[
"source_id"] .
", target" .
558 $anmiss[
"source_id"],
567 "DELETE FROM il_wiki_missing_page WHERE " .
568 " wiki_id = %s AND target_name = %s",
569 array(
"integer",
"text"),
570 array($this->getWikiId(), $this->getTitle())
575 $this->log->debug(
"this page -> other pages.");
579 "DELETE FROM il_wiki_missing_page WHERE " .
580 " wiki_id = %s AND source_id = %s",
581 array(
"integer",
"integer"),
582 array($this->getWikiId(), $this->
getId())
586 $xml = $a_domdoc->saveXML();
588 foreach ($int_wiki_links as $wlink) {
589 $this->log->debug(
"found link : " . $wlink);
590 $page_id = self::_getPageIdForWikiTitle($this->getWikiId(), $wlink);
592 $this->log->debug(
"save link " .
593 $this->
getId() .
", target " . $page_id);
603 "DELETE FROM il_wiki_missing_page WHERE" .
604 " wiki_id = %s AND source_id = %s AND target_name = %s",
605 array(
"integer",
"integer",
"text"),
606 array($this->getWikiId(), $this->
getId(), $wlink)
608 $this->log->debug(
"target does not exist, save missing page source" .
609 $this->
getId() .
", target " . $wlink);
611 "INSERT INTO il_wiki_missing_page (wiki_id, source_id, target_name)" .
612 " VALUES (%s,%s,%s)",
613 array(
"integer",
"integer",
"text"),
614 array($this->getWikiId(), $this->
getId(), $wlink)
618 $this->log->debug(
"...end");
628 return self::getPageIdForTitle($a_wiki_id, $a_title);
638 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po" .
639 " WHERE wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
640 " AND wp.id = po.page_id " .
641 " AND po.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
" " .
642 " ORDER BY po.view_cnt";
646 while ($rec =
$ilDB->fetchAssoc($set)) {
661 $query =
"SELECT count(*) as cnt FROM il_wiki_page" .
662 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
664 $r =
$ilDB->fetchAssoc($s);
676 $cnt = self::countPages($a_wiki_id);
682 $random = new \ilRandom();
683 $rand = $random->int(1, $cnt);
686 $ilDB->setLimit(1, $rand);
687 $query =
"SELECT title FROM il_wiki_page" .
688 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
690 $r =
$ilDB->fetchAssoc($s);
698 $pages = parent::getNewPages(
"wpg", $a_wiki_id);
699 foreach ($pages as $k => $page) {
700 $pages[$k][
"title"] = self::lookupTitle($page[
"id"]);
717 $query =
"SELECT wiki_id FROM il_wiki_page" .
718 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
720 if ($rec =
$ilDB->fetchAssoc($set)) {
721 return (
int) $rec[
"wiki_id"];
736 $a_new_name = str_replace(array(
"<",
">"),
'', $a_new_name);
739 $a_new_name = trim(preg_replace(
'!\s+!',
' ', $a_new_name));
742 $pg_id = self::_getPageIdForWikiTitle($this->getWikiId(), $page_title);
744 $xml_new_name = str_replace(
"&",
"&", $a_new_name);
746 if ($pg_id == 0 || $pg_id == $this->
getId()) {
749 $this->log->debug(
"nr of pages linking to renamed page: " . count($sources));
750 foreach ($sources as $s) {
754 $this->log->debug(
"Getting links of page " . $s[
"id"]);
756 $wpage->getXMLContent(),
761 $this->log->debug(
"nr internal links: " . count($col));
762 $new_content = $wpage->getXMLContent();
763 foreach ($col as
$c) {
765 $this->log->debug(
"found link " . print_r(
$c,
true));
780 $t1 = preg_replace(
'/\xC2\xA0/',
' ', $t1);
781 $t2 = preg_replace(
'/\xC2\xA0/',
' ', $t2);
783 $set =
$ilDB->query($q =
"SELECT " .
$ilDB->quote($t1,
"text") .
" = " .
$ilDB->quote($t2,
"text") .
" isequal");
784 $rec =
$ilDB->fetchAssoc($set);
786 if ($rec[
"isequal"]) {
789 "[[" .
$c[
"nt"]->mTextform .
"]]",
790 "[[" . $xml_new_name .
"]]",
793 if (
$c[
"text"] !=
"") {
796 "[[" .
$c[
"text"] .
"]]",
797 "[[" . $xml_new_name .
"]]",
801 $add = (
$c[
"text"] !=
"")
806 "[[" .
$c[
"nt"]->mTextform . $add .
"]]",
807 "[[" . $xml_new_name . $add .
"]]",
812 $wpage->setXMLContent($new_content);
822 $this->setTitle($a_new_name);
832 bool $a_update =
false
837 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
838 ? $news_set->get(
"default_visibility")
843 $news_item->setContext(
850 $news_item->setTitle($this->getTitle());
851 $news_item->setContentTextIsLangVar(
true);
852 $news_item->setContent(
"wiki_news_page_created");
853 $news_item->setUserId(
$ilUser->getId());
854 $news_item->setVisibility($default_visibility);
855 $news_item->create();
868 $news_item->setContent(
"wiki_news_page_changed");
869 $news_item->setUserId(
$ilUser->getId());
870 $news_item->setTitle($this->getTitle());
871 $news_item->setContentTextIsLangVar(
true);
872 $news_item->update(
true);
875 $news_item->setContext(
882 $news_item->setTitle($this->getTitle());
883 $news_item->setContentTextIsLangVar(
true);
884 $news_item->setContent(
"wiki_news_page_changed");
885 $news_item->setUserId(
$ilUser->getId());
886 $news_item->setVisibility($default_visibility);
887 $news_item->create();
894 bool $a_offline =
false
897 $href =
"./goto.php?target=wiki_wpage_" . $a_target;
899 $href = ILIAS_HTTP_PATH .
"/goto.php?target=wiki_wpage_" . $a_target;
912 $templates = array();
914 $templates[] = array(
"id" => $t[
"wpage_id"],
"parent_type" =>
"wpg",
"title" => $t[
"title"]);
927 $set =
$ilDB->query(
"SELECT DISTINCT title FROM il_wiki_page" .
928 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
929 " AND " .
$ilDB->like(
"title",
"text",
"%" . $a_term .
"%") .
932 while ($rec =
$ilDB->fetchAssoc($set)) {
933 $res[] = $rec[
"title"];
946 $query =
"SELECT * FROM il_wiki_page" .
947 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
949 if ($rec =
$ilDB->fetchAssoc($set)) {
950 return (
bool) $rec[
"hide_adv_md"];
958 $page->setWikiRefId($this->getWikiRefId());
const NEWS_NOTICE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_WIKI_MODE_EXT_COLLECT
static _getSourcesOfTarget(string $a_target_type, int $a_target_id, int $a_target_inst)
get all sources of a link target
static _deleteAllLinksToTarget(string $a_target_type, int $a_target_id, int $a_target_inst=0)
Delete all links to a given target.
static _saveLink(string $a_source_type, int $a_source_id, string $a_target_type, int $a_target_id, int $a_target_inst=0, string $a_source_lang="-")
save internal link information
A news item can be created by different sources.
static getLastNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="", bool $a_only_today=false)
Get last news id of news set related to a certain context.
static removeForObject(int $type, int $id)
Remove all notifications for given object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static writeStartPage(int $a_id, string $a_name)
static _lookupStartPage(int $a_wiki_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static strLen(string $a_string)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isAdvancedMetadataHidden()
updateNews(bool $a_update=false)
static getAllWikiPages(int $a_wiki_id)
create(bool $a_import=false)
create new page (with current xml data)
getContentTemplates()
Get content templates.
static lookupObjIdByPage(int $a_page_id)
returns the wiki/object id to a given page id
static getPagesForSearch(int $a_wiki_id, string $a_term)
setWikiRefId(int $a_wiki_ref_id)
static exists(int $a_wiki_id, string $a_title)
Checks whether a page with given title exists.
update(bool $a_validate=true, bool $a_no_history=false)
static getWikiPageContributors(int $a_page_id)
static lookupWikiId(int $a_page_id)
createFromXML()
Create new page object with current xml content.
preparePageForCompare(ilPageObject $page)
afterUpdate(DOMDocument $domdoc, string $xml)
After update.
hideAdvancedMetadata(bool $a_val)
static lookupAdvancedMetadataHidden(int $a_page_id)
setTitle(string $a_title)
saveInternalLinks(DOMDocument $a_domdoc)
save internal links of page
static getWikiContributors(int $a_wiki_id)
read(bool $a_omit_page_read=false)
static getLinksToPage(int $a_wiki_id, int $a_page_id)
static getPageIdForTitle(int $a_wiki_id, string $a_title)
Get wiki page object for id and title.
rename(string $a_new_name)
Rename page.
static getPopularPages(int $a_wiki_id)
static countPages(int $a_wiki_id)
static getNewWikiPages(int $a_wiki_id)
static getGotoForWikiPageTarget(string $a_target, bool $a_offline=false)
static deleteAllPagesOfWiki(int $a_wiki_id)
static getRandomPage(int $a_wiki_id)
static _wikiPageExists(int $a_wiki_id, string $a_title)
static lookupTitle(int $a_page_id)
static _getPageIdForWikiTitle(int $a_wiki_id, string $a_title)
static getOrphanedPages(int $a_wiki_id)
static handleEvent(int $a_event, ilWikiPage $a_page_obj, ?int $a_user_id=null, array $a_additional_data=null)
Handle wiki page event.
static sendNotification(string $a_action, int $a_type, int $a_wiki_ref_id, int $a_page_id, ?string $a_comment=null)
static collectInternalLinks(string $s, int $a_wiki_id, bool $a_collect_non_ex=false, string $mode=IL_WIKI_MODE_COLLECT)
Collect internal wiki links of a string.
static makeDbTitle(string $a_par)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']