ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilWikiUtil.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
18 define("IL_WIKI_MODE_REPLACE", "replace");
19 define("IL_WIKI_MODE_COLLECT", "collect");
20 define("IL_WIKI_MODE_EXT_COLLECT", "ext_collect");
21 
31 {
32 
42  public static function replaceInternalLinks($s, $a_wiki_id, $a_offline = false)
43  {
45  $s,
46  $a_wiki_id,
48  false,
49  $a_offline
50  );
51  }
52 
59  public static function collectInternalLinks($s, $a_wiki_id, $a_collect_non_ex = false)
60  {
62  $s,
63  $a_wiki_id,
65  $a_collect_non_ex
66  );
67  }
68 
76  public static function processInternalLinks(
77  $s,
78  $a_wiki_id,
79  $a_mode = IL_WIKI_MODE_REPLACE,
80  $a_collect_non_ex = false,
81  $a_offline = false
82  ) {
83  $collect = array();
84  // both from mediawiki DefaulSettings.php
85  $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
86 
87  // Adapter for media wiki classes
88  include_once("./Modules/Wiki/classes/class.ilMediaWikiAdapter.php");
89  $GLOBALS["wgContLang"] = new ilMediaWikiAdapter();
90  $GLOBALS["wgInterWikiCache"] = false;
91 
92  # the % is needed to support urlencoded titles as well
93  //$tc = Title::legalChars().'#%';
94  $tc = $wgLegalTitleChars . '#%';
95 
96  //$sk = $this->mOptions->getSkin();
97 
98  #split the entire text string on occurences of [[
99  $a = explode('[[', ' ' . $s);
100  #get the first element (all text up to first [[), and remove the space we added
101  $s = array_shift($a);
102  $s = substr($s, 1);
103 
104  # Match a link having the form [[namespace:link|alternate]]trail
105  $e1 = "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
106 
107  # Match cases where there is no "]]", which might still be images
108  // static $e1_img = FALSE;
109  // if ( !$e1_img ) { $e1_img = "/^([{$tc}]+)\\|(.*)\$/sD"; }
110 
111  # Match the end of a line for a word that's not followed by whitespace,
112  # e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
113  // $e2 = wfMsgForContent( 'linkprefix' );
114 
115  /* $useLinkPrefixExtension = $wgContLang->linkPrefixExtension();
116  if( is_null( $this->mTitle ) ) {
117  throw new MWException( __METHOD__.": \$this->mTitle is null\n" );
118  }
119  $nottalk = !$this->mTitle->isTalkPage();*/
120  $nottalk = true;
121 
122  /* if ( $useLinkPrefixExtension ) {
123  $m = array();
124  if ( preg_match( $e2, $s, $m ) ) {
125  $first_prefix = $m[2];
126  } else {
127  $first_prefix = false;
128  }
129  } else {*/
130  $prefix = '';
131  // }
132 
133  $useSubpages = false;
134 
135  # Loop for each link
136  for ($k = 0; isset($a[$k]); $k++) {
137  $line = $a[$k];
138 
139 
140  $might_be_img = false;
141 
142  //wfProfileIn( "$fname-e1" );
143  if (preg_match($e1, $line, $m)) { # page with normal text or alt
144  $text = $m[2];
145  # If we get a ] at the beginning of $m[3] that means we have a link that's something like:
146  # [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up,
147  # the real problem is with the $e1 regex
148  # See bug 1300.
149  #
150  # Still some problems for cases where the ] is meant to be outside punctuation,
151  # and no image is in sight. See bug 2095.
152  #
153  if ($text !== '' &&
154  substr($m[3], 0, 1) === ']' &&
155  strpos($text, '[') !== false
156  ) {
157  $text .= ']'; # so that replaceExternalLinks($text) works later
158  $m[3] = substr($m[3], 1);
159  }
160  # fix up urlencoded title texts
161  if (strpos($m[1], '%') !== false) {
162  # Should anchors '#' also be rejected?
163  $m[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), urldecode($m[1]));
164  }
165  $trail = $m[3];
166  /* } elseif( preg_match($e1_img, $line, $m) ) { # Invalid, but might be an image with a link in its caption
167  $might_be_img = true;
168  $text = $m[2];
169  if ( strpos( $m[1], '%' ) !== false ) {
170  $m[1] = urldecode($m[1]);
171  }
172  $trail = "";*/
173  } else { # Invalid form; output directly
174  $s .= $prefix . '[[' . $line ;
175  //wfProfileOut( "$fname-e1" );
176  continue;
177  }
178  //wfProfileOut( "$fname-e1" );
179  //wfProfileIn( "$fname-misc" );
180 
181  # Don't allow internal links to pages containing
182  # PROTO: where PROTO is a valid URL protocol; these
183  # should be external links.
184  if (preg_match('/^\b(?:' . ilWikiUtil::wfUrlProtocols() . ')/', $m[1])) {
185  $s .= $prefix . '[[' . $line ;
186  continue;
187  }
188 
189  # Make subpage if necessary
190  /* if( $useSubpages ) {
191  $link = $this->maybeDoSubpageLink( $m[1], $text );
192  } else {*/
193  $link = $m[1];
194  // }
195 
196  $noforce = (substr($m[1], 0, 1) != ':');
197  if (!$noforce) {
198  # Strip off leading ':'
199  $link = substr($link, 1);
200  }
201 
202  // wfProfileOut( "$fname-misc" );
203  // wfProfileIn( "$fname-title" );
204 
205  // todo
206  include_once("./Modules/Wiki/mediawiki/Title.php");
207  include_once("./Services/Utilities/classes/Sanitizer.php");
208  //$nt = Title::newFromText( $this->mStripState->unstripNoWiki($link) );
209 
210  // todo: check step by step
211  //echo "<br>".htmlentities($link)."---";
212  $nt = Title::newFromText($link);
213 
214  if (!$nt) {
215  $s .= $prefix . '[[' . $line;
216  //wfProfileOut( "$fname-title" );
217  continue;
218  }
219 
220  /* $ns = $nt->getNamespace();
221  $iw = $nt->getInterWiki();
222  wfProfileOut( "$fname-title" );
223 
224  /* if ($might_be_img) { # if this is actually an invalid link
225  wfProfileIn( "$fname-might_be_img" );
226  if ($ns == NS_IMAGE && $noforce) { #but might be an image
227  $found = false;
228  while (isset ($a[$k+1]) ) {
229  #look at the next 'line' to see if we can close it there
230  $spliced = array_splice( $a, $k + 1, 1 );
231  $next_line = array_shift( $spliced );
232  $m = explode( ']]', $next_line, 3 );
233  if ( count( $m ) == 3 ) {
234  # the first ]] closes the inner link, the second the image
235  $found = true;
236  $text .= "[[{$m[0]}]]{$m[1]}";
237  $trail = $m[2];
238  break;
239  } elseif ( count( $m ) == 2 ) {
240  #if there's exactly one ]] that's fine, we'll keep looking
241  $text .= "[[{$m[0]}]]{$m[1]}";
242  } else {
243  #if $next_line is invalid too, we need look no further
244  $text .= '[[' . $next_line;
245  break;
246  }
247  }
248  if ( !$found ) {
249  # we couldn't find the end of this imageLink, so output it raw
250  #but don't ignore what might be perfectly normal links in the text we've examined
251  $text = $this->replaceInternalLinks($text);
252  $s .= "{$prefix}[[$link|$text";
253  # note: no $trail, because without an end, there *is* no trail
254  wfProfileOut( "$fname-might_be_img" );
255  continue;
256  }
257  } else { #it's not an image, so output it raw
258  $s .= "{$prefix}[[$link|$text";
259  # note: no $trail, because without an end, there *is* no trail
260  wfProfileOut( "$fname-might_be_img" );
261  continue;
262  }
263  wfProfileOut( "$fname-might_be_img" );
264  }
265  */
266 
267  $wasblank = ('' == $text);
268  if ($wasblank) {
269  $text = $link;
270  }
271 
272  # Link not escaped by : , create the various objects
273  if ($noforce) {
274  # Interwikis
275  /*wfProfileIn( "$fname-interwiki" );
276  if( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName( $iw ) ) {
277  $this->mOutput->addLanguageLink( $nt->getFullText() );
278  $s = rtrim($s . $prefix);
279  $s .= trim($trail, "\n") == '' ? '': $prefix . $trail;
280  wfProfileOut( "$fname-interwiki" );
281  continue;
282  }
283  wfProfileOut( "$fname-interwiki" );*/
284 
285 /* if ( $ns == NS_IMAGE ) {
286  wfProfileIn( "$fname-image" );
287  if ( !wfIsBadImage( $nt->getDBkey(), $this->mTitle ) ) {
288  # recursively parse links inside the image caption
289  # actually, this will parse them in any other parameters, too,
290  # but it might be hard to fix that, and it doesn't matter ATM
291  $text = $this->replaceExternalLinks($text);
292  $text = $this->replaceInternalLinks($text);
293 
294  # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
295  $s .= $prefix . $this->armorLinks( $this->makeImage( $nt, $text ) ) . $trail;
296  $this->mOutput->addImage( $nt->getDBkey() );
297 
298  wfProfileOut( "$fname-image" );
299  continue;
300  } else {
301  # We still need to record the image's presence on the page
302  $this->mOutput->addImage( $nt->getDBkey() );
303  }
304  wfProfileOut( "$fname-image" );
305 
306  }
307 */
308 /* if ( $ns == NS_CATEGORY ) {
309  wfProfileIn( "$fname-category" );
310  $s = rtrim($s . "\n"); # bug 87
311 
312  if ( $wasblank ) {
313  $sortkey = $this->getDefaultSort();
314  } else {
315  $sortkey = $text;
316  }
317  $sortkey = Sanitizer::decodeCharReferences( $sortkey );
318  $sortkey = str_replace( "\n", '', $sortkey );
319  $sortkey = $wgContLang->convertCategoryKey( $sortkey );
320  $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
321 */
326 // $s .= trim($prefix . $trail, "\n") == '' ? '': $prefix . $trail;
327 
328 // wfProfileOut( "$fname-category" );
329 // continue;
330 // }
331  }
332 
333  # Self-link checking
334  /* if( $nt->getFragment() === '' ) {
335  if( in_array( $nt->getPrefixedText(), $selflink, true ) ) {
336  $s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail );
337  continue;
338  }
339  }*/
340 
341  # Special and Media are pseudo-namespaces; no pages actually exist in them
342  /* if( $ns == NS_MEDIA ) {
343  $link = $sk->makeMediaLinkObj( $nt, $text );
344  # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
345  $s .= $prefix . $this->armorLinks( $link ) . $trail;
346  $this->mOutput->addImage( $nt->getDBkey() );
347  continue;
348  } elseif( $ns == NS_SPECIAL ) {
349  $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
350  continue;
351  } elseif( $ns == NS_IMAGE ) {
352  $img = new Image( $nt );
353  if( $img->exists() ) {
354  // Force a blue link if the file exists; may be a remote
355  // upload on the shared repository, and we want to see its
356  // auto-generated page.
357  $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
358  $this->mOutput->addLink( $nt );
359  continue;
360  }
361  }*/
362 
363  // Media wiki performs an intermediate step here (Parser->makeLinkHolder)
364  if ($a_mode == IL_WIKI_MODE_REPLACE) {
366  $nt,
367  $a_wiki_id,
368  $text,
369  '',
370  $trail,
371  $prefix,
372  $a_offline
373  );
374  //echo "<br>-".htmlentities($s)."-";
375  }
376  if ($a_mode == IL_WIKI_MODE_EXT_COLLECT) {
377  if (is_object($nt)) {
378  $url_title = ilWikiUtil::makeUrlTitle($nt->mTextform);
379  $db_title = ilWikiUtil::makeDbTitle($nt->mTextform);
380  list($inside, $trail) = ilWikiUtil::splitTrail($trail);
381  $collect[] = array("nt" => $nt, "text" => $text,
382  "trail" => $trail, "db_title" => $db_title,
383  "url_title" => $url_title);
384  }
385  } else {
386  $url_title = ilWikiUtil::makeUrlTitle($nt->mTextform);
387  $db_title = ilWikiUtil::makeDbTitle($nt->mTextform);
388 
389  //$s .= ilWikiUtil::makeLink($nt, $a_wiki_id, $text, '', $trail, $prefix);
390  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
391  if ((ilWikiPage::_wikiPageExists($a_wiki_id, $db_title) ||
392  $a_collect_non_ex)
393  &&
394  !in_array($db_title, $collect)) {
395  $collect[] = $db_title;
396  }
397  }
398  }
399 
400  //wfProfileOut( $fname );
401 
402  if ($a_mode == IL_WIKI_MODE_COLLECT ||
403  $a_mode == IL_WIKI_MODE_EXT_COLLECT) {
404  return $collect;
405  } else {
406  return $s;
407  }
408  }
409 
413  public static function removeUnsafeCharacters($a_str)
414  {
415  return str_replace(array("\x00", "\n", "\r", "\\", "'", '"', "\x1a"), "", $a_str);
416  }
417 
427  public static function makeLink(
428  &$nt,
429  $a_wiki_id,
430  $text = '',
431  $query = '',
432  $trail = '',
433  $prefix = '',
434  $a_offline = false
435  ) {
436  global $DIC;
437 
438  $ilCtrl = $DIC->ctrl();
439 
440  //wfProfileIn( __METHOD__ );
441  if (!is_object($nt)) {
442  # Fail gracefully
443  $retVal = "<!-- ERROR -->{$prefix}{$text}{$trail}";
444  } else {
445 
446 //var_dump($trail);
447  //var_dump($nt);
448 
449  // remove anchor from text, define anchor
450  $anc = "";
451  if ($nt->mFragment != "") {
452  if (substr($text, strlen($text) - strlen("#" . $nt->mFragment))
453  == "#" . $nt->mFragment) {
454  $text = substr($text, 0, strlen($text) - strlen("#" . $nt->mFragment));
455  $anc = "#" . $nt->mFragment;
456  } else {
457  $anc = "#" . $nt->mFragment;
458  }
459  }
460 
461  # Separate the link trail from the rest of the link
462  // outcommented due to bug #14590
463  // list( $inside, $trail ) = ilWikiUtil::splitTrail( $trail );
464 
465  $retVal = '***' . $text . "***" . $trail;
466  $url_title = ilWikiUtil::makeUrlTitle($nt->mTextform);
467  $db_title = ilWikiUtil::makeDbTitle($nt->mTextform);
468  if ($db_title != "") {
469  $pg_exists = ilWikiPage::_wikiPageExists($a_wiki_id, $db_title);
470  } else {
471  // links on same page (only anchor used)
472  $pg_exists = true;
473  }
474 
475  //var_dump($nt);
476  //var_dump($inside);
477  //var_dump($trail);
478  $wiki_link_class = (!$pg_exists)
479  ? ' class="ilc_link_IntLink ilWikiPageMissing" '
480  : ' class="ilc_link_IntLink" ';
481 
482  if (!$a_offline) {
483  if ($url_title != "") {
484  $ilCtrl->setParameterByClass("ilobjwikigui", "page", $url_title);
485  $retVal = '<a ' . $wiki_link_class . ' href="' .
486  $ilCtrl->getLinkTargetByClass("ilobjwikigui", "gotoPage") . $anc .
487  '">' . $text . '</a>' . $trail;
488  $ilCtrl->setParameterByClass("ilobjwikigui", "page", $_GET["page"]);
489  } else {
490  $retVal = '<a ' . $wiki_link_class . ' href="' .
491  $anc .
492  '">' . $text . '</a>' . $trail;
493  }
494  } else {
495  if ($pg_exists) {
496  if ($db_title != "") {
497  $pg_id = ilWikiPage::getIdForPageTitle($a_wiki_id, $db_title);
498  $retVal = '<a ' . $wiki_link_class . ' href="' .
499  "wpg_" . $pg_id . ".html" . $anc .
500  '">' . $text . '</a>' . $trail;
501  } else {
502  $retVal = '<a ' . $wiki_link_class . ' href="' .
503  $anc .
504  '">' . $text . '</a>' . $trail;
505  }
506  } else {
507  $retVal = $text . $trail;
508  }
509  }
510 
511  //$ilCtrl->debug("ilWikiUtil::makeLink:-$inside-$trail-");
512 /* if ( $nt->isExternal() ) {
513  $nr = array_push( $this->mInterwikiLinkHolders['texts'], $prefix.$text.$inside );
514  $this->mInterwikiLinkHolders['titles'][] = $nt;
515  $retVal = '<!--IWLINK '. ($nr-1) ."-->{$trail}";
516  } else {
517  $nr = array_push( $this->mLinkHolders['namespaces'], $nt->getNamespace() );
518  $this->mLinkHolders['dbkeys'][] = $nt->getDBkey();
519  $this->mLinkHolders['queries'][] = $query;
520  $this->mLinkHolders['texts'][] = $prefix.$text.$inside;
521  $this->mLinkHolders['titles'][] = $nt;
522 
523  $retVal = '<!--LINK '. ($nr-1) ."-->{$trail}";
524  }
525 */
526  }
527  //wfProfileOut( __METHOD__ );
528  //echo "<br>".$retVal; exit;
529  return $retVal;
530  }
531 
535  public static function wfUrlProtocols()
536  {
537  $wgUrlProtocols = array(
538  'http://',
539  'https://',
540  'ftp://',
541  'irc://',
542  'gopher://',
543  'telnet://', // Well if we're going to support the above.. -ævar
544  'nntp://', // @bug 3808 RFC 1738
545  'worldwind://',
546  'mailto:',
547  'news:'
548  );
549 
550  // Support old-style $wgUrlProtocols strings, for backwards compatibility
551  // with LocalSettings files from 1.5
552  if (is_array($wgUrlProtocols)) {
553  $protocols = array();
554  foreach ($wgUrlProtocols as $protocol) {
555  $protocols[] = preg_quote($protocol, '/');
556  }
557 
558  return implode('|', $protocols);
559  } else {
560  return $wgUrlProtocols;
561  }
562  }
563 
567  public static function wfUrlencode($s)
568  {
569  $s = urlencode($s);
570  // $s = preg_replace( '/%3[Aa]/', ':', $s );
571  // $s = preg_replace( '/%2[Ff]/', '/', $s );
572 
573  return $s;
574  }
575 
576 
580  public static function makeDbTitle($a_par)
581  {
582  $a_par = ilWikiUtil::removeUnsafeCharacters($a_par);
583  return str_replace("_", " ", $a_par);
584  }
585 
589  public static function makeUrlTitle($a_par)
590  {
591  $a_par = ilWikiUtil::removeUnsafeCharacters($a_par);
592  $a_par = str_replace(" ", "_", $a_par);
593  return ilWikiUtil::wfUrlencode($a_par);
594  }
595 
596  // from Linker.php
597  public static function splitTrail($trail)
598  {
599  $regex = '/^([a-z]+)(.*)$/sD';
600 
601  $inside = '';
602  if ('' != $trail) {
603  $m = array();
604 
605  if (preg_match($regex, $trail, $m)) {
606  $inside = $m[1];
607  $trail = $m[2];
608  }
609  }
610 
611  return array( $inside, $trail );
612  }
613 
614  public static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null)
615  {
616  global $DIC;
617 
618  $ilUser = $DIC->user();
619  $ilObjDataCache = $DIC["ilObjDataCache"];
620  $ilAccess = $DIC->access();
621 
622  include_once "./Services/Notification/classes/class.ilNotification.php";
623  include_once "./Modules/Wiki/classes/class.ilObjWiki.php";
624  include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
625 
626  $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
627  $wiki = new ilObjWiki($a_wiki_ref_id, true);
628  $page = new ilWikiPage($a_page_id);
629 
630  // #11138
631  $ignore_threshold = ($a_action == "comment");
632 
633  // 1st update will be converted to new - see below
634  if ($a_action == "new") {
635  return;
636  }
637 
639  $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold);
640  $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
641  $users = array_merge($users, $wiki_users);
642  if (!sizeof($users)) {
643  return;
644  }
645 
647  } else {
648  $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
649  if (!sizeof($users)) {
650  return;
651  }
652  }
653 
655 
656  // #15192 - should always be present
657  include_once "./Services/Link/classes/class.ilLink.php";
658  if ($a_page_id) {
659  // #18804 - see ilWikiPageGUI::preview()
660  $link = ilLink::_getLink("", "wiki", null, "wpage_" . $a_page_id . "_" . $a_wiki_ref_id);
661  } else {
662  $link = ilLink::_getLink($a_wiki_ref_id);
663  }
664 
665  include_once "./Services/Mail/classes/class.ilMail.php";
666  include_once "./Services/User/classes/class.ilObjUser.php";
667  include_once "./Services/Language/classes/class.ilLanguageFactory.php";
668  include_once("./Services/User/classes/class.ilUserUtil.php");
669 
670 
671  // see ilBlogPostingGUI::getSnippet()
672  // see ilBlogPosting::getNotificationAbstract()
673 
674  include_once "Modules/Wiki/classes/class.ilWikiPageGUI.php";
675  $pgui = new ilWikiPageGUI($page->getId());
676  $pgui->setRawPageContent(true);
677  $pgui->setAbstractOnly(true);
678  $pgui->setFileDownloadLink(".");
679  $pgui->setFullscreenLink(".");
680  $pgui->setSourcecodeDownloadScript(".");
681  $snippet = $pgui->showPage();
682  $snippet = ilPageObject::truncateHTML($snippet, 500, "...");
683 
684  // making things more readable
685  $snippet = str_replace('<br/>', "\n", $snippet);
686  $snippet = str_replace('<br />', "\n", $snippet);
687  $snippet = str_replace('</p>', "\n", $snippet);
688  $snippet = str_replace('</div>', "\n", $snippet);
689 
690  $snippet = trim(strip_tags($snippet));
691 
692  // "fake" new (to enable snippet - if any)
693  $current_version = array_shift($page->getHistoryEntries());
694  $current_version = $current_version["nr"];
695  if (!$current_version) {
697  $a_action = "new";
698  }
699 
700 
701  foreach (array_unique($users) as $idx => $user_id) {
702  if ($user_id != $ilUser->getId() &&
703  $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) {
704  // use language of recipient to compose message
705  $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
706  $ulng->loadLanguageModule('wiki');
707 
708  $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
709  $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
710 
712  // update/delete
713  $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n";
714  $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
715  $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
716  $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n";
717 
718  if ($snippet) {
719  $message .= "\n" . $ulng->txt('content') . "\n" .
720  "----------------------------------------\n" .
721  $snippet . "\n" .
722  "----------------------------------------\n";
723  }
724 
725  // include comment/note text
726  if ($a_comment) {
727  $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n";
728  }
729 
730  $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link;
731  } else {
732  // new
733  $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n";
734  $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
735  $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
736  $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n";
737 
738  if ($snippet) {
739  $message .= $ulng->txt('content') . "\n" .
740  "----------------------------------------\n" .
741  $snippet . "\n" .
742  "----------------------------------------\n\n";
743  }
744 
745  $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link;
746  }
747 
748  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
749  $mail_obj->appendInstallationSignature(true);
750  $mail_obj->sendMail(
751  ilObjUser::_lookupLogin($user_id),
752  "",
753  "",
754  $subject,
755  $message,
756  array(),
757  array("system")
758  );
759  } else {
760  unset($users[$idx]);
761  }
762  }
763  }
764 }
static _lookupLogin($a_user_id)
lookup login
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static _lookupFullname($a_user_id)
Lookup Full Name.
static makeLink(&$nt, $a_wiki_id, $text='', $query='', $trail='', $prefix='', $a_offline=false)
Make a wiki link, the following formats are supported:
This class implements some dummy methods, normally provided by media wiki classes.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:124
$s
Definition: pwgen.php:45
static updateNotificationTime($type, $id, array $user_ids, $page_id=false)
Update the last mail timestamp for given object and users.
static collectInternalLinks($s, $a_wiki_id, $a_collect_non_ex=false)
Collect internal wiki links of a string.
static getNotificationsForObject($type, $id, $page_id=null, $ignore_threshold=false)
Get all users for given object.
static processInternalLinks( $s, $a_wiki_id, $a_mode=IL_WIKI_MODE_REPLACE, $a_collect_non_ex=false, $a_offline=false)
Process internal links.
const IL_WIKI_MODE_COLLECT
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:92
static sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment=null)
catch(Exception $e) $message
static removeUnsafeCharacters($a_str)
See class.ilInitialisation.php.
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
This class handles base functions for mail handling.
Class ilObjWiki.
$text
Definition: errorreport.php:18
const IL_WIKI_MODE_REPLACE
Wiki link / page title handling:
setRawPageContent($a_rawpagecontent)
Set Get raw page content only.
Class ilWikiPage GUI class.
$ilUser
Definition: imgupload.php:18
Class ilWikiPage.
$query
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static makeDbTitle($a_par)
Handle page GET parameter.
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
Utility class for wiki.
static _getLanguageOfUser($a_usr_id)
Get language object of user.
static truncateHTML($a_text, $a_length=100, $a_ending='...', $a_exact=false, $a_consider_html=true)
Truncate (html) string.
static _wikiPageExists($a_wiki_id, $a_title)
Check whether page exists for wiki or not.
static wfUrlProtocols()
From mediawiki GlobalFunctions.php.
const IL_WIKI_MODE_EXT_COLLECT
static wfUrlencode($s)
From GlobalFunctions.php.
static replaceInternalLinks($s, $a_wiki_id, $a_offline=false)
This one is based on Mediawiki Parser->replaceInternalLinks since we display images in another way...
static splitTrail($trail)
static getIdForPageTitle($a_wiki_id, $a_title)
Checks whether a page with given title exists.