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
474 $retVal =
'***'.$text.
"***".$trail;
490 $wiki_link_class = (!$pg_exists)
491 ?
' class="ilc_link_IntLink ilWikiPageMissing" '
492 :
' class="ilc_link_IntLink" ';
496 if ($url_title !=
"")
498 $ilCtrl->setParameterByClass(
"ilobjwikigui",
"page", $url_title);
499 $retVal =
'<a '.$wiki_link_class.
' href="'.
500 $ilCtrl->getLinkTargetByClass(
"ilobjwikigui",
"gotoPage").$anc.
501 '">'.$text.
'</a>'.$trail;
502 $ilCtrl->setParameterByClass(
"ilobjwikigui",
"page",
$_GET[
"page"]);
506 $retVal =
'<a '.$wiki_link_class.
' href="'.
508 '">'.$text.
'</a>'.$trail;
518 $retVal =
'<a '.$wiki_link_class.
' href="'.
519 "wpg_".$pg_id.
".html".$anc.
520 '">'.$text.
'</a>'.$trail;
524 $retVal =
'<a '.$wiki_link_class.
' href="'.
526 '">'.$text.
'</a>'.$trail;
531 $retVal = $text.$trail;
561 $wgUrlProtocols = array(
576 if ( is_array( $wgUrlProtocols ) ) {
577 $protocols = array();
578 foreach ($wgUrlProtocols as $protocol)
579 $protocols[] = preg_quote( $protocol,
'/' );
581 return implode(
'|', $protocols );
583 return $wgUrlProtocols;
592 $s = urlencode( $s );
606 return str_replace(
"_",
" ", $a_par);
615 $a_par = str_replace(
" ",
"_", $a_par);
627 $regex =
'/^([a-z]+)(.*)$/sD';
630 if (
'' != $trail ) {
633 if ( preg_match( $regex, $trail, $m ) ) {
639 return array( $inside, $trail );
642 static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null)
644 global
$ilUser, $ilObjDataCache, $ilAccess;
646 include_once
"./Services/Notification/classes/class.ilNotification.php";
647 include_once
"./Modules/Wiki/classes/class.ilObjWiki.php";
648 include_once
"./Modules/Wiki/classes/class.ilWikiPage.php";
650 $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
651 $wiki =
new ilObjWiki($a_wiki_ref_id,
true);
655 $ignore_threshold = ($a_action ==
"comment");
658 if($a_action ==
"new")
667 $users = array_merge($users, $wiki_users);
689 include_once
"./Modules/Wiki/classes/class.ilObjWikiGUI.php";
690 $link = ILIAS_HTTP_PATH.
"/".ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle());
694 include_once
"./Services/Link/classes/class.ilLink.php";
698 include_once
"./Services/Mail/classes/class.ilMail.php";
699 include_once
"./Services/User/classes/class.ilObjUser.php";
700 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
701 include_once(
"./Services/User/classes/class.ilUserUtil.php");
707 include_once
"Modules/Wiki/classes/class.ilWikiPageGUI.php";
710 $pgui->setAbstractOnly(
true);
711 $pgui->setFileDownloadLink(
".");
712 $pgui->setFullscreenLink(
".");
713 $pgui->setSourcecodeDownloadScript(
".");
714 $snippet = $pgui->showPage();
718 $snippet = str_replace(
'<br/>',
"\n", $snippet);
719 $snippet = str_replace(
'<br />',
"\n", $snippet);
720 $snippet = str_replace(
'</p>',
"\n", $snippet);
721 $snippet = str_replace(
'</div>',
"\n", $snippet);
723 $snippet = trim(strip_tags($snippet));
726 $current_version = array_shift($page->getHistoryEntries());
727 $current_version = $current_version[
"nr"];
728 if(!$current_version)
735 foreach(array_unique($users) as $idx => $user_id)
737 if($user_id != $ilUser->getId() &&
738 $ilAccess->checkAccessOfUser($user_id,
'read',
'', $a_wiki_ref_id))
742 $ulng->loadLanguageModule(
'wiki');
744 $subject = sprintf($ulng->txt(
'wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
750 $message .= $ulng->txt(
'wiki_change_notification_page_body_'.$a_action).
":\n\n";
751 $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
752 $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n";
757 $message .=
"\n".$ulng->txt(
'content').
"\n".
758 "----------------------------------------\n".
760 "----------------------------------------\n";
766 $message .=
"\n".$ulng->txt(
'comment').
":\n\"".trim($a_comment).
"\"\n";
769 $message .=
"\n".$ulng->txt(
'wiki_change_notification_page_link').
": ".$link;
774 $message .= $ulng->txt(
'wiki_change_notification_body_'.$a_action).
":\n\n";
775 $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
776 $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n";
781 $message .= $ulng->txt(
'content').
"\n".
782 "----------------------------------------\n".
784 "----------------------------------------\n\n";
787 $message .= $ulng->txt(
'wiki_change_notification_link').
": ".$link;
790 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
791 $mail_obj->appendInstallationSignature(
true);
793 "",
"", $subject, $message, array(), array(
"system"));