18 define (
"IL_WIKI_MODE_REPLACE",
"replace");
19 define (
"IL_WIKI_MODE_COLLECT",
"collect");
20 define (
"IL_WIKI_MODE_EXT_COLLECT",
"ext_collect");
73 $wgLegalTitleChars =
" %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
76 include_once(
"./Modules/Wiki/classes/class.ilMediaWikiAdapter.php");
78 $GLOBALS[
"wgInterWikiCache"] =
false;
80 # the % is needed to support urlencoded titles as well
82 $tc = $wgLegalTitleChars.
'#%';
86 #split the entire text string on occurences of [[
87 $a = explode(
'[[',
' ' . $s );
88 #get the first element (all text up to first [[), and remove the space we added
89 $s = array_shift( $a );
92 # Match a link having the form [[namespace:link|alternate]]trail
93 $e1 =
"/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
95 # Match cases where there is no "]]", which might still be images
99 # Match the end of a line for a word that's not followed by whitespace,
100 # e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
129 $useSubpages =
false;
132 for ($k = 0; isset( $a[$k] ); $k++)
152 $might_be_img =
false;
155 if ( preg_match( $e1, $line, $m ) ) { # page with normal text or alt
157 # If we get a ] at the beginning of $m[3] that means we have a link that's something like:
158 # [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up,
159 # the real problem is with the $e1 regex
162 # Still some problems for cases where the ] is meant to be outside punctuation,
163 # and no image is in sight. See bug 2095.
166 substr( $m[3], 0, 1 ) ===
']' &&
167 strpos($text,
'[') !== false
170 $text .=
']'; # so that replaceExternalLinks($text) works later
171 $m[3] = substr( $m[3], 1 );
173 # fix up urlencoded title texts
174 if( strpos( $m[1],
'%' ) !==
false ) {
175 # Should anchors '#' also be rejected?
176 $m[1] = str_replace( array(
'<',
'>'), array(
'<',
'>'), urldecode($m[1]) );
186 }
else { # Invalid form; output directly
187 $s .= $prefix .
'[[' . $line ;
194 # Don't allow internal links to pages containing
195 # PROTO: where PROTO is a valid URL protocol; these
196 # should be external links.
198 $s .= $prefix .
'[[' . $line ;
202 # Make subpage if necessary
209 $noforce = (substr($m[1], 0, 1) !=
':');
211 # Strip off leading ':'
212 $link = substr($link, 1);
219 include_once(
"./Modules/Wiki/mediawiki/Title.php");
220 include_once(
"./Services/Utilities/classes/Sanitizer.php");
228 $s .= $prefix .
'[[' . $line;
280 $wasblank = (
'' == $text );
281 if( $wasblank ) $text = $link;
283 # Link not escaped by : , create the various objects
352 # Special and Media are pseudo-namespaces; no pages actually exist in them
388 $collect[] = array(
"nt" => $nt,
"text" => $text,
389 "trail" => $trail,
"db_title" => $db_title,
390 "url_title" => $url_title);
399 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
403 !in_array($db_title, $collect))
405 $collect[] = $db_title;
428 return str_replace(array(
"\x00",
"\n",
"\r",
"\\",
"'",
'"',
"\x1a"),
"", $a_str);
440 static function makeLink( &$nt, $a_wiki_id, $text =
'',
$query =
'', $trail =
'', $prefix =
'',
446 if ( ! is_object($nt) ) {
448 $retVal =
"<!-- ERROR -->{$prefix}{$text}{$trail}";
456 if ($nt->mFragment !=
"")
458 if (substr($text, strlen($text) - strlen(
"#".$nt->mFragment))
459 ==
"#".$nt->mFragment)
461 $text = substr($text, 0, strlen($text) - strlen(
"#".$nt->mFragment));
462 $anc =
"#".$nt->mFragment;
466 $anc =
"#".$nt->mFragment;
470 # Separate the link trail from the rest of the link
489 $wiki_link_class = (!$pg_exists)
490 ?
' class="ilWikiPageMissing" ' :
"";
494 if ($url_title !=
"")
496 $ilCtrl->setParameterByClass(
"ilobjwikigui",
"page", $url_title);
497 $retVal =
'<a '.$wiki_link_class.
' href="'.
498 $ilCtrl->getLinkTargetByClass(
"ilobjwikigui",
"gotoPage").$anc.
499 '">'.$text.
'</a>'.$trail;
503 $retVal =
'<a '.$wiki_link_class.
' href="'.
505 '">'.$text.
'</a>'.$trail;
515 $retVal =
'<a '.$wiki_link_class.
' href="'.
516 "wpg_".$pg_id.
".html".$anc.
517 '">'.$text.
'</a>'.$trail;
521 $retVal =
'<a '.$wiki_link_class.
' href="'.
523 '">'.$text.
'</a>'.$trail;
528 $retVal = $text.$trail;
557 $wgUrlProtocols = array(
572 if ( is_array( $wgUrlProtocols ) ) {
573 $protocols = array();
574 foreach ($wgUrlProtocols as $protocol)
575 $protocols[] = preg_quote( $protocol,
'/' );
577 return implode(
'|', $protocols );
579 return $wgUrlProtocols;
588 $s = urlencode( $s );
602 return str_replace(
"_",
" ", $a_par);
611 $a_par = str_replace(
" ",
"_", $a_par);
623 $regex =
'/^([a-z]+)(.*)$/sD';
626 if (
'' != $trail ) {
629 if ( preg_match( $regex, $trail, $m ) ) {
635 return array( $inside, $trail );
640 global $ilUser, $ilObjDataCache, $ilAccess;
642 include_once
"./Services/Notification/classes/class.ilNotification.php";
643 include_once
"./Modules/Wiki/classes/class.ilObjWiki.php";
644 include_once
"./Modules/Wiki/classes/class.ilWikiPage.php";
646 $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
647 $wiki =
new ilObjWiki($a_wiki_ref_id,
true);
654 $users = array_merge($users, $wiki_users);
660 include_once
"./Modules/Wiki/classes/class.ilObjWikiGUI.php";
661 $link = ILIAS_HTTP_PATH.
"/".ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle());
673 include_once
"./classes/class.ilLink.php";
679 include_once
"./Services/Mail/classes/class.ilMail.php";
680 include_once
"./Services/User/classes/class.ilObjUser.php";
681 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
682 include_once(
"./Services/User/classes/class.ilUserUtil.php");
684 foreach(array_unique($users) as $idx => $user_id)
686 if($user_id != $ilUser->getId() &&
687 $ilAccess->checkAccessOfUser($user_id,
'read',
'', $a_wiki_ref_id))
691 $ulng->loadLanguageModule(
'wiki');
693 $subject = sprintf($ulng->txt(
'wiki_change_notification_subject'), $wiki->getTitle());
699 $message .= $ulng->txt(
'wiki_change_notification_page_body_'.$a_action).
":\n\n";
700 $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
701 $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n";
703 $message .= $ulng->txt(
'wiki_change_notification_page_link').
": ".$link;
708 $message .= $ulng->txt(
'wiki_change_notification_body_'.$a_action).
":\n\n";
709 $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
710 $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n";
712 $message .= $ulng->txt(
'wiki_change_notification_link').
": ".$link;
715 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
716 $mail_obj->appendInstallationSignature(
true);
718 "",
"", $subject, $message, array(), array(
"system"));