33 if (!defined(
'UTF8_REPLACEMENT')) {
    34     define(
'UTF8_REPLACEMENT', 
"\xef\xbf\xbd" );
    55         bool $a_offline = 
false,
    58         return self::processInternalLinks(
    74         bool $a_collect_non_ex = 
false,
    79         $log->debug(
"collect interna links wiki id: " . $a_wiki_id . 
", collect nonex: " . $a_collect_non_ex);
    81         $result = self::processInternalLinks(
    87         $log->debug(
"content: " . $s);
    88         $log->debug(
"found: " . print_r($result, 
true));
   101         bool $a_collect_non_ex = 
false,
   102         bool $a_offline = 
false,
   106         $page_repo = $DIC->wiki()->internal()->repo()->page();
   110         $wgLegalTitleChars = 
" %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
   113         $GLOBALS[
"wgContLang"] = 
new class () {
   114             public function getNsIndex($a_p): 
bool   118             public function lc($a_key): 
bool   123         $GLOBALS[
"wgInterWikiCache"] = 
false;
   125         # the % is needed to support urlencoded titles as well   127         $tc = $wgLegalTitleChars . 
'#%';
   131         #split the entire text string on occurences of [[   132         $a = explode(
'[[', 
' ' . $s);
   133         #get the first element (all text up to first [[), and remove the space we added   134         $s = array_shift(
$a);
   137         # Match a link having the form [[namespace:link|alternate]]trail   138         $e1 = 
"/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
   140         # Match cases where there is no "]]", which might still be images   144         # Match the end of a line for a word that's not followed by whitespace,   145         # e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched   166         $useSubpages = 
false;
   169         for ($k = 0; isset(
$a[$k]); $k++) {
   173             $might_be_img = 
false;
   176             if (preg_match($e1, $line, $m)) { # page with normal text or alt
   178                 # If we get a ] at the beginning of $m[3] that means we have a link that's something like:   179                 # [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up,   180                 # the real problem is with the $e1 regex   183                 # Still some problems for cases where the ] is meant to be outside punctuation,   184                 # and no image is in sight. See bug 2095.   187                     strpos($m[3], 
']') === 0 &&
   188                     strpos($text, 
'[') !== false
   190                     $text .= 
']'; # so that replaceExternalLinks($text) works later
   191                     $m[3] = substr($m[3], 1);
   193                 # fix up urlencoded title texts   194                 if (strpos($m[1], 
'%') !== 
false) {
   195                     # Should anchors '#' also be rejected?   196                     $m[1] = str_replace(array(
'<', 
'>'), array(
'<', 
'>'), urldecode($m[1]));
   206             } 
else { # Invalid 
form; output directly
   207                 $s .= $prefix . 
'[[' . $line ;
   214             # Don't allow internal links to pages containing   215             # PROTO: where PROTO is a valid URL protocol; these   216             # should be external links.   217             if (preg_match(
'/^\b%na' . self::wfUrlProtocols() . 
'me/', $m[1])) {
   218                 $s .= $prefix . 
'[[' . $line ;
   222             # Make subpage if necessary   229             $noforce = (strpos($m[1], 
':') !== 0);
   231                 # Strip off leading ':'   232                 $link = substr($link, 1);
   241                 $s .= $prefix . 
'[[' . $line;
   245             $wasblank = (
'' == 
$text);
   252                 $s .= self::makeLink(
   264                 if (is_object($nt)) {
   265                     $url_title = self::makeUrlTitle($nt->mTextform);
   266                     $db_title = self::makeDbTitle($nt->mTextform);
   267                     [$inside, $trail] = self::splitTrail($trail);
   268                     $collect[] = array(
"nt" => $nt, 
"text" => 
$text,
   269                         "trail" => $trail, 
"db_title" => $db_title,
   270                         "url_title" => $url_title);
   273                 $db_title = self::makeDbTitle($nt->mTextform);
   275                 if (($a_collect_non_ex || $page_repo->existsByTitle($a_wiki_id, $db_title, $lang))
   277                     !in_array($db_title, $collect)) {
   278                     $collect[] = $db_title;
   296         return str_replace(array(
"\x00", 
"\n", 
"\r", 
"\\", 
"'", 
'"', 
"\x1a"), 
"", $a_str);
   315         bool $a_offline = 
false,
   324         $page_repo = $DIC->wiki()->internal()->repo()->page();
   326         $ilCtrl = $DIC->ctrl();
   328         if (!is_object($nt)) {
   330             $retVal = 
"<!-- ERROR -->{$prefix}{$text}{$trail}";
   334             if ($nt->mFragment != 
"") {
   335                 if (substr(
$text, strlen(
$text) - strlen(
"#" . $nt->mFragment)) === 
"#" . $nt->mFragment) {
   336                     $text = substr(
$text, 0, strlen(
$text) - strlen(
"#" . $nt->mFragment));
   338                 $anc = 
"#copganc_" . $nt->mFragment;
   341             # Separate the link trail from the rest of the link   345             $retVal = 
'***' . 
$text . 
"***" . $trail;
   346             $url_title = self::makeUrlTitle($nt->mTextform);
   347             $db_title = self::makeDbTitle($nt->mTextform);
   348             if ($db_title != 
"") {
   349                 $pg_exists = $page_repo->existsByTitle($a_wiki_id, $db_title, $lang);
   358             $wiki_link_class = (!$pg_exists)
   359                 ? 
' class="ilc_link_IntLink ilWikiPageMissing" '   360                 : 
' class="ilc_link_IntLink" ';
   363                 if ($url_title != 
"") {
   364                     $ilCtrl->setParameterByClass(
"ilobjwikigui", 
"wpg_id", null);
   365                     $ilCtrl->setParameterByClass(
"ilwikipagegui", 
"wpg_id", null);
   366                     $ilCtrl->setParameterByClass(
"ilobjwikigui", 
"page", $url_title);
   367                     $retVal = 
'<a ' . $wiki_link_class . 
' href="' .
   368                         $ilCtrl->getLinkTargetByClass(
"ilobjwikigui", 
"gotoPage") . $anc .
   369                         '">' . 
$text . 
'</a>' . $trail;
   370                     $ilCtrl->setParameterByClass(
   376                     $retVal = 
'<a ' . $wiki_link_class . 
' href="' .
   378                         '">' . 
$text . 
'</a>' . $trail;
   382                     if ($db_title != 
"") {
   384                         $retVal = 
'<a ' . $wiki_link_class . 
' href="' .
   385                             "wpg_" . $pg_id . 
".html" . $anc .
   386                             '">' . 
$text . 
'</a>' . $trail;
   388                         $retVal = 
'<a ' . $wiki_link_class . 
' href="' .
   390                             '">' . 
$text . 
'</a>' . $trail;
   393                     $retVal = 
$text . $trail;
   406         $wgUrlProtocols = array(
   421         $protocols = array();
   422         foreach ($wgUrlProtocols as $protocol) {
   423             $protocols[] = preg_quote($protocol, 
'/');
   426         return implode(
'|', $protocols);
   439         $a_par = self::removeUnsafeCharacters($a_par);
   440         return str_replace(
"_", 
" ", $a_par);
   446         $a_par = self::removeUnsafeCharacters($a_par);
   447         $a_par = str_replace(
" ", 
"_", $a_par);
   448         return self::wfUrlencode($a_par);
   454         $regex = 
'/^([a-z]+)(.*)$/sD';
   460             if (preg_match($regex, $trail, $m)) {
   466         return array( $inside, $trail );
   474         ?
string $a_comment = null
   479         $log->debug(
"start... vvvvvvvvvvvvvvvvvvvvvvvvvvv");
   481         $ilUser = $DIC->user();
   482         $ilObjDataCache = $DIC[
"ilObjDataCache"];
   483         $ilAccess = $DIC->access();
   485         if ($a_wiki_ref_id === 0) {
   489         $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
   490         $wiki = 
new ilObjWiki($a_wiki_ref_id, 
true);
   494         $ignore_threshold = ($a_action === 
"comment");
   497         if ($a_action === 
"new") {
   501         $log->debug(
"-- get notifications");
   505             $users = array_merge($users, $wiki_users);
   506             if (!count($users)) {
   507                 $log->debug(
"no notifications... ^^^^^^^^^^^^^^^^^^");
   512             $log->debug(
"--->" . print_r($users));
   513             if (!count($users)) {
   514                 $log->debug(
"no notifications... ^^^^^^^^^^^^^^^^^^");
   524             $link = ilLink::_getLink(null, 
"wiki", [], 
"wpage_" . $a_page_id . 
"_" . $a_wiki_ref_id);
   526             $link = ilLink::_getLink($a_wiki_ref_id);
   529         $log->debug(
"-- prepare content");
   532         $pgui->setAbstractOnly(
true);
   533         $pgui->setFileDownloadLink(
".");
   534         $pgui->setFullscreenLink(
".");
   535         $pgui->setSourcecodeDownloadScript(
".");
   536         $snippet = $pgui->showPage();
   540         $snippet = str_replace([
'<br/>', 
'<br />', 
'</p>', 
'</div>'], 
"\n", $snippet);
   542         $snippet = trim(strip_tags($snippet));
   545         $hist = $page->getHistoryEntries();
   546         $current_version = array_shift($hist);
   547         $current_version = $current_version[
"nr"] ?? 0;
   548         if (!$current_version && $a_action !== 
"comment") {
   553         $log->debug(
"-- sending mails");
   555         foreach (array_unique($users) as $idx => 
$user_id) {
   557                 $ilAccess->checkAccessOfUser(
$user_id, 
'read', 
'', $a_wiki_ref_id)) {
   560                 $ulng->loadLanguageModule(
'wiki');
   562                 if ($a_action === 
"comment") {
   563                     $subject = sprintf($ulng->txt(
'wiki_notification_comment_subject'), $wiki->getTitle(), $page->getTitle());
   566                     $message .= $ulng->txt(
'wiki_notification_' . $a_action) . 
":\n\n";
   567                     $message .= $ulng->txt(
'wiki') . 
": " . $wiki->getTitle() . 
"\n";
   568                     $message .= $ulng->txt(
'page') . 
": " . $page->getTitle() . 
"\n";
   573                         $message .= 
"\n" . $ulng->txt(
'comment') . 
":\n\"" . trim($a_comment) . 
"\"\n";
   576                     $message .= 
"\n" . $ulng->txt(
'wiki_change_notification_page_link') . 
": " . $link;
   578                     $subject = sprintf($ulng->txt(
'wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
   583                         $message .= $ulng->txt(
'wiki_change_notification_page_body_' . $a_action) . 
":\n\n";
   584                         $message .= $ulng->txt(
'wiki') . 
": " . $wiki->getTitle() . 
"\n";
   585                         $message .= $ulng->txt(
'page') . 
": " . $page->getTitle() . 
"\n";
   589                             $message .= 
"\n" . $ulng->txt(
'content') . 
"\n" .
   590                                 "----------------------------------------\n" .
   592                                 "----------------------------------------\n";
   597                             $message .= 
"\n" . $ulng->txt(
'comment') . 
":\n\"" . trim($a_comment) . 
"\"\n";
   600                         $message .= 
"\n" . $ulng->txt(
'wiki_change_notification_page_link') . 
": " . $link;
   603                         $message .= $ulng->txt(
'wiki_change_notification_body_' . $a_action) . 
":\n\n";
   604                         $message .= $ulng->txt(
'wiki') . 
": " . $wiki->getTitle() . 
"\n";
   605                         $message .= $ulng->txt(
'page') . 
": " . $page->getTitle() . 
"\n";
   609                             $message .= $ulng->txt(
'content') . 
"\n" .
   610                                 "----------------------------------------\n" .
   612                                 "----------------------------------------\n\n";
   615                         $message .= $ulng->txt(
'wiki_change_notification_link') . 
": " . $link;
   620                 $mail_obj->appendInstallationSignature(
true);
   621                 $log->debug(
"before enqueue ($user_id)");
   643                 $log->debug(
"after enqueue");
   648         if (count($mails) > 0) {
   657         $log->debug(
"end... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
 static makeLink(object $nt, int $a_wiki_id, string $text='', string $query='', string $trail='', string $prefix='', bool $a_offline=false, string $lang="-")
Make a wiki link, the following formats are supported: 
 
static getLogger(string $a_component_id)
Get component logger. 
 
static _lookupFullname(int $a_user_id)
 
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link. 
 
if(!defined('UTF8_REPLACEMENT')) const IL_WIKI_MODE_REPLACE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static removeUnsafeCharacters(string $a_str)
 
static processInternalLinks(string $s, int $a_wiki_id, string $a_mode=IL_WIKI_MODE_REPLACE, bool $a_collect_non_ex=false, bool $a_offline=false, string $lang="-")
Process internal links (internal) 
 
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object. 
 
static replaceInternalLinks(string $s, int $a_wiki_id, bool $a_offline=false, string $lang="-")
This one is based on Mediawiki Parser->replaceInternalLinks since we display images in another way...
 
const IL_WIKI_MODE_COLLECT
 
static sendNotification(string $a_action, int $a_type, int $a_wiki_ref_id, int $a_page_id, ?string $a_comment=null)
 
static truncateHTML(string $a_text, int $a_length=100, string $a_ending='...', bool $a_exact=false, bool $a_consider_html=true)
Truncate (html) string. 
 
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is: 
 
static _getLanguageOfUser(int $a_usr_id)
Get language object of user. 
 
setRawPageContent(bool $a_rawpagecontent)
Set Get raw page content only. 
 
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. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Class ilWikiPage GUI class. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static updateNotificationTime(int $type, int $id, array $user_ids, ?int $page_id=null, bool $activate_new_entries=true)
Update the last mail timestamp for given object and users. 
 
static makeUrlTitle(string $a_par)
 
form( $class_path, string $cmd, string $submit_caption="")
 
static wfUrlProtocols()
From mediawiki GlobalFunctions.php. 
 
static makeDbTitle(string $a_par)
 
static getPageIdForTitle(int $a_wiki_id, string $a_title, string $lang="-")
Get wiki page object for id and title. 
 
const IL_WIKI_MODE_EXT_COLLECT
 
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples 
 
static wfUrlencode(string $s)
 
static splitTrail(string $trail)
 
static _getInstallationSignature()
 
static _lookupLogin(int $a_user_id)