26 protected \ILIAS\Wiki\Page\PageDBRepository
$repo;
28 protected \ILIAS\Wiki\InternalService
$service;
43 $this->service =
$DIC->wiki()->internal();
45 $this->wiki_log = $this->service->domain()->log();
46 $this->repo = $this->service->repo()->page();
55 return $this->service->gui()->notification();
58 public function setTitle(
string $a_title): void
80 $this->parent_ref_id = $a_wiki_ref_id;
90 $this->blocked = $a_val;
100 $this->rating = $a_val;
110 $this->hide_adv_md = $a_val;
128 "SELECT id FROM il_wiki_page " .
129 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer") .
130 " AND lang = " .
$ilDB->quote($this->getLanguage(),
"text")
132 if ($rec =
$ilDB->fetchAssoc($set)) {
136 parent::createFromXML();
140 bool $a_import =
false
146 $id =
$ilDB->nextId(
"il_wiki_page");
150 $query =
"INSERT INTO il_wiki_page (" .
169 $this->wiki_log->debug($query);
170 $ilDB->manipulate($query);
174 parent::create($a_import);
197 $this->wiki_log->debug(
"collect internal links");
200 $xpath =
new DOMXPath($domdoc);
203 $ext_links = count($xpath->query(
'//IntLink'));
204 $ext_links += count($xpath->query(
'//ExtLink'));
206 $footnotes = count($xpath->query(
'//Footnote'));
211 $xml = strip_tags($xml);
214 $num_words = count(explode(
" ", $xml));
217 "int_links" => $int_links,
218 "ext_links" => $ext_links,
219 "footnotes" => $footnotes,
220 "num_words" => $num_words,
221 "num_chars" => $num_chars
223 $this->wiki_log->debug(
"handle stats");
232 bool $a_validate =
true,
233 bool $a_no_history =
false
236 $this->wiki_log->debug(
"start...");
238 $query =
"UPDATE il_wiki_page SET " .
240 ",wiki_id = " .
$ilDB->quote($this->getWikiId(),
"integer") .
241 ",blocked = " .
$ilDB->quote((
int) $this->getBlocked(),
"integer") .
242 ",rating = " .
$ilDB->quote((
int) $this->getRating(),
"integer") .
243 ",hide_adv_md = " .
$ilDB->quote((
int) $this->isAdvancedMetadataHidden(),
"integer") .
244 " WHERE id = " .
$ilDB->quote($this->
getId(),
"integer") .
246 $ilDB->manipulate($query);
247 $updated = parent::update($a_validate, $a_no_history);
248 if ($updated ===
true) {
249 $this->wiki_log->debug(
"send notification");
250 $this->getNotificationGUI()->send(
253 $this->getWikiRefId(),
259 $this->wiki_log->debug(
"update news");
261 $this->updateNews(
true);
270 bool $a_omit_page_read =
false
274 $query =
"SELECT * FROM il_wiki_page WHERE id = " .
278 $set =
$ilDB->query($query);
279 $rec =
$ilDB->fetchAssoc($set);
281 $this->setTitle($rec[
"title"]);
282 $this->setWikiId((
int) $rec[
"wiki_id"]);
283 $this->setBlocked((
bool) $rec[
"blocked"]);
284 $this->setRating((
bool) $rec[
"rating"]);
285 $this->hideAdvancedMetadata((
bool) $rec[
"hide_adv_md"]);
288 if (!$a_omit_page_read) {
294 public function delete():
void
296 $imp_pages = $this->service->domain()->importantPage($this->getWikiRefId());
301 $linking_pages = self::getLinksToPage(
308 if (!$this->isTranslationPage()) {
309 if ($imp_pages->isImportantPage($this->getId())) {
310 $imp_pages->removeImportantPage($this->
getId());
319 $this->getNotificationGUI()->send(
322 $this->getWikiRefId(),
338 $missing_page_repo = $this->service->repo()->missingPage();
339 foreach ($linking_pages as $lp) {
340 $missing_page_repo->save(
356 $query =
"SELECT * FROM il_wiki_page" .
357 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
358 $set =
$ilDB->query($query);
360 while ($rec =
$ilDB->fetchAssoc($set)) {
362 $wiki_page =
new ilWikiPage($rec[
"id"], 0, $rec[
"lang"]);
363 $wiki_page->delete();
382 $query =
"SELECT id FROM il_wiki_page" .
383 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
384 " AND title = " .
$ilDB->quote($a_title,
"text") .
385 " AND lang = " .
$ilDB->quote($lang,
"text");
386 $set =
$ilDB->query($query);
387 if ($rec =
$ilDB->fetchAssoc($set)) {
413 $query =
"SELECT * FROM il_wiki_page" .
414 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
415 " AND title = " .
$ilDB->quote($a_title,
"text") .
416 " AND lang = " .
$ilDB->quote($lang,
"text");
417 $set =
$ilDB->query($query);
418 if ($rec =
$ilDB->fetchAssoc($set)) {
419 return (
int) $rec[
"id"];
425 public static function lookupTitle(
int $a_page_id,
string $lang =
"-"): ?string
431 $query =
"SELECT * FROM il_wiki_page" .
432 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer") .
433 " AND lang = " .
$ilDB->quote($lang,
"text");
434 $set =
$ilDB->query($query);
435 if ($rec =
$ilDB->fetchAssoc($set)) {
436 return (
string) $rec[
"title"];
448 $query =
"SELECT wiki_id FROM il_wiki_page" .
449 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
450 $set =
$ilDB->query($query);
451 if ($rec =
$ilDB->fetchAssoc($set)) {
452 return (
int) $rec[
"wiki_id"];
466 $pages = parent::getAllPages(
"wpg", $a_wiki_id);
468 $query =
"SELECT * FROM il_wiki_page" .
469 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
470 " AND lang = " .
$ilDB->quote($lang,
"text") .
472 $set =
$ilDB->query($query);
475 while ($rec =
$ilDB->fetchAssoc($set)) {
476 if (isset($pages[$rec[
"id"]])) {
477 $pg[$rec[
"id"]] = $pages[$rec[
"id"]];
478 $pg[$rec[
"id"]][
"title"] = $rec[
"title"];
499 foreach ($sources as $source) {
500 if ($source[
"type"] ===
"wpg:pg" && $source[
"lang"] === $lang) {
501 $ids[] = $source[
"id"];
506 $query =
"SELECT * FROM il_wiki_page wp, page_object p" .
507 " WHERE " .
$ilDB->in(
"wp.id", $ids,
false,
"integer") .
508 " AND wp.id = p.page_id AND wp.lang = p.lang AND p.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
509 " AND wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
510 " AND wp.lang = " .
$ilDB->quote($lang,
"text") .
512 $set =
$ilDB->query($query);
515 while ($rec =
$ilDB->fetchAssoc($set)) {
516 $pages[] = array_merge($rec, array(
"user" => $rec[
"last_change_user"],
517 "date" => $rec[
"last_change"]));
537 $query =
"SELECT id FROM il_wiki_page" .
538 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
539 " AND title = " .
$ilDB->quote($a_title,
"text") .
540 " AND lang = " .
$ilDB->quote($lang,
"text");
541 $set =
$ilDB->query($query);
543 if (
$ilDB->fetchAssoc($set)) {
553 return parent::getParentObjectContributors(
"wpg", $a_wiki_id);
559 return parent::getPageContributors(
"wpg", $a_page_id);
563 DOMDocument $a_domdoc
565 parent::saveInternalLinks($a_domdoc);
567 if ($this->getWikiRefId() > 0) {
568 $link_manager = $this->service->domain()->links($this->getWikiRefId());
569 $link_manager->saveInternalLinksForPage(
585 return self::getPageIdForTitle($a_wiki_id, $a_title);
595 $query =
"SELECT wp.*, po.view_cnt as cnt FROM il_wiki_page wp, page_object po" .
596 " WHERE wp.wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
597 " AND wp.id = po.page_id " .
598 " AND po.parent_type = " .
$ilDB->quote(
"wpg",
"text") .
" " .
599 " ORDER BY po.view_cnt";
600 $set =
$ilDB->query($query);
603 while ($rec =
$ilDB->fetchAssoc($set)) {
618 $query =
"SELECT count(*) as cnt FROM il_wiki_page" .
619 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
620 " WHERE lang = " .
$ilDB->quote(
"-",
"text");
621 $s =
$ilDB->query($query);
622 $r =
$ilDB->fetchAssoc($s);
634 $cnt = self::countPages($a_wiki_id);
640 $random = new \Random\Randomizer();
641 $rand = $random->getInt(1, $cnt);
643 $ilDB->setLimit(1, $rand);
644 $query =
"SELECT title FROM il_wiki_page" .
645 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer");
646 $s =
$ilDB->query($query);
647 $r =
$ilDB->fetchAssoc($s);
655 $pages = parent::getNewPages(
"wpg", $a_wiki_id);
656 foreach ($pages as $k => $page) {
657 $pages[$k][
"title"] = self::lookupTitle($page[
"id"]);
674 $query =
"SELECT wiki_id FROM il_wiki_page" .
675 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
676 $set =
$ilDB->query($query);
677 if ($rec =
$ilDB->fetchAssoc($set)) {
678 return (
int) $rec[
"wiki_id"];
693 $a_new_name = str_replace(array(
"<",
">"),
'', $a_new_name);
696 $a_new_name = trim(preg_replace(
'!\s+!',
' ', $a_new_name));
699 $pg_id = self::getPageIdForTitle($this->getWikiId(), $page_title, $this->
getLanguage());
701 $xml_new_name = str_replace(
"&",
"&", $a_new_name);
703 if ($pg_id == 0 || $pg_id == $this->
getId()) {
706 $this->log->debug(
"nr of pages linking to renamed page: " . count($sources));
707 foreach ($sources as $s) {
709 $wpage =
new ilWikiPage($s[
"id"], 0, $s[
"lang"]);
710 $wpage->setWikiRefId($this->getWikiRefId());
714 $wpage->getXMLContent(),
719 $this->log->debug(
"nr internal links: " . count($col));
720 $new_content = $wpage->getXMLContent();
721 foreach ($col as
$c) {
735 $t1 = preg_replace(
'/\xC2\xA0/',
' ', $t1);
736 $t2 = preg_replace(
'/\xC2\xA0/',
' ', $t2);
738 $set =
$ilDB->query(
$q =
"SELECT " .
$ilDB->quote($t1,
"text") .
" = " .
$ilDB->quote($t2,
"text") .
" isequal");
739 $rec =
$ilDB->fetchAssoc($set);
741 if ($rec[
"isequal"]) {
744 "[[" .
$c[
"nt"]->mTextform .
"]]",
745 "[[" . $xml_new_name .
"]]",
748 if (
$c[
"text"] !=
"") {
751 "[[" .
$c[
"text"] .
"]]",
752 "[[" . $xml_new_name .
"]]",
756 $add = (
$c[
"text"] !=
"")
761 "[[" .
$c[
"nt"]->mTextform . $add .
"]]",
762 "[[" . $xml_new_name . $add .
"]]",
767 $wpage->setXMLContent($new_content);
777 $this->setTitle($a_new_name);
787 bool $a_update =
false
789 $ilUser = $this->
user;
792 $default_visibility = ($news_set->get(
"default_visibility") !=
"")
793 ? $news_set->get(
"default_visibility")
798 $news_item->setContext(
805 $news_item->setTitle($this->
getTitle());
806 $news_item->setContentTextIsLangVar(
true);
807 $news_item->setContent(
"wiki_news_page_created");
808 $news_item->setUserId($ilUser->getId());
809 $news_item->setVisibility($default_visibility);
810 $news_item->create();
823 $news_item->setContent(
"wiki_news_page_changed");
824 $news_item->setUserId($ilUser->getId());
825 $news_item->setTitle($this->
getTitle());
826 $news_item->setContentTextIsLangVar(
true);
827 $news_item->update(
true);
830 $news_item->setContext(
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();
849 bool $a_offline =
false
852 $href =
"./goto.php?target=wiki_wpage_" . $a_target;
854 $href = ILIAS_HTTP_PATH .
"/goto.php?target=wiki_wpage_" . $a_target;
867 $templates = array();
869 $templates[] = array(
"id" => $t[
"wpage_id"],
"parent_type" =>
"wpg",
"title" => $t[
"title"]);
882 $set =
$ilDB->query(
"SELECT DISTINCT title FROM il_wiki_page" .
883 " WHERE wiki_id = " .
$ilDB->quote($a_wiki_id,
"integer") .
884 " AND " .
$ilDB->like(
"title",
"text",
"%" . $a_term .
"%") .
887 while ($rec =
$ilDB->fetchAssoc($set)) {
888 $res[] = $rec[
"title"];
901 $query =
"SELECT * FROM il_wiki_page" .
902 " WHERE id = " .
$ilDB->quote($a_page_id,
"integer");
903 $set =
$ilDB->query($query);
904 if ($rec =
$ilDB->fetchAssoc($set)) {
905 return (
bool) $rec[
"hide_adv_md"];
913 $page->setWikiRefId($this->getWikiRefId());
918 parent::setTranslationProperties($transl_page);
919 $transl_page->setWikiRefId($this->getWikiRefId());
925 if ($new_page->getWikiId() === 0 || $new_page->getWikiId() === $this->getWikiId()) {
926 $new_page->setWikiRefId($this->getWikiRefId());
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.
Component logger with individual log levels by component id.
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.
static writeStartPage(int $a_id, string $a_name)
static _lookupStartPage(int $a_wiki_id)
static raiseContentChanged(int $obj_id)
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.
getDomDoc()
Get dom doc (DOMDocument)
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...
setTranslationProperties(ilPageObject $transl_page)
isAdvancedMetadataHidden()
updateNews(bool $a_update=false)
static exists(int $a_wiki_id, string $a_title, string $lang="-")
Checks whether a page with given title exists.
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)
static getPageIdForTitle(int $a_wiki_id, string $a_title, string $lang="-")
Get wiki page object for id and title.
setWikiRefId(int $a_wiki_ref_id)
setCopyProperties(ilPageObject $new_page)
getNotificationGUI()
This currently violates the layer model, since notifications render the abstracts with a GUI class.
update(bool $a_validate=true, bool $a_no_history=false)
static getWikiPageContributors(int $a_page_id)
static lookupWikiId(int $a_page_id)
ILIAS Wiki InternalService $service
createFromXML()
Create new page object with current xml content.
preparePageForCompare(ilPageObject $page)
afterUpdate(DOMDocument $domdoc, string $xml)
After update.
static getLinksToPage(int $a_wiki_id, int $a_page_id, string $lang="-")
hideAdvancedMetadata(bool $a_val)
static lookupAdvancedMetadataHidden(int $a_page_id)
setTitle(string $a_title)
static lookupTitle(int $a_page_id, string $lang="-")
saveInternalLinks(DOMDocument $a_domdoc)
save internal links of page
static getWikiContributors(int $a_wiki_id)
read(bool $a_omit_page_read=false)
ILIAS Wiki Page PageDBRepository $repo
static _wikiPageExists(int $a_wiki_id, string $a_title, string $lang="-")
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 getAllWikiPages(int $a_wiki_id, string $lang="-")
static getRandomPage(int $a_wiki_id)
static _getPageIdForWikiTitle(int $a_wiki_id, string $a_title)
static handleEvent(int $a_event, ilWikiPage $a_page_obj, ?int $a_user_id=null, ?array $a_additional_data=null)
Handle wiki page event.
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)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))