38 define (
"IL_WIKI_MODE_REPLACE", 
"replace");
 
   39 define (
"IL_WIKI_MODE_COLLECT", 
"collect");
 
   90                 $wgLegalTitleChars = 
" %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
 
   93                 include_once(
"./Modules/Wiki/classes/class.ilMediaWikiAdapter.php");
 
   95                 $GLOBALS[
"wgInterWikiCache"] = 
false;
 
   97                 # the % is needed to support urlencoded titles as well 
   99                 $tc = $wgLegalTitleChars.
'#%';
 
  103                 #split the entire text string on occurences of [[ 
  104                 $a = explode( 
'[[', 
' ' . $s );
 
  105                 #get the first element (all text up to first [[), and remove the space we added 
  106                 $s = array_shift( $a );
 
  107                 $s = substr( $s, 1 );
 
  109                 # Match a link having the form [[namespace:link|alternate]]trail 
  110                 $e1 = 
"/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
 
  112                 # Match cases where there is no "]]", which might still be images 
  116                 # Match the end of a line for a word that's not followed by whitespace, 
  117                 # e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched 
  146                 $useSubpages = 
false;
 
  149                 for ($k = 0; isset( $a[$k] ); $k++)
 
  169                         $might_be_img = 
false;
 
  172                         if ( preg_match( $e1, $line, $m ) ) { # page with normal text or alt
 
  174                                 # If we get a ] at the beginning of $m[3] that means we have a link that's something like: 
  175                                 # [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up, 
  176                                 # the real problem is with the $e1 regex 
  179                                 # Still some problems for cases where the ] is meant to be outside punctuation, 
  180                                 # and no image is in sight. See bug 2095. 
  183                                         substr( $m[3], 0, 1 ) === 
']' &&
 
  184                                         strpos($text, 
'[') !== false
 
  187                                         $text .= 
']'; # so that replaceExternalLinks($text) works later
 
  188                                         $m[3] = substr( $m[3], 1 );
 
  190                                 # fix up urlencoded title texts 
  191                                 if( strpos( $m[1], 
'%' ) !== 
false ) {
 
  192                                         # Should anchors '#' also be rejected? 
  193                                         $m[1] = str_replace( array(
'<', 
'>'), array(
'<', 
'>'), urldecode($m[1]) );
 
  203                         } 
else { # Invalid form; output directly
 
  204                                 $s .= $prefix . 
'[[' . $line ;
 
  211                         # Don't allow internal links to pages containing 
  212                         # PROTO: where PROTO is a valid URL protocol; these 
  213                         # should be external links. 
  215                                 $s .= $prefix . 
'[[' . $line ;
 
  219                         # Make subpage if necessary 
  226                         $noforce = (substr($m[1], 0, 1) != 
':');
 
  228                                 # Strip off leading ':' 
  229                                 $link = substr($link, 1);
 
  236                         include_once(
"./Modules/Wiki/mediawiki/Title.php");
 
  237                         include_once(
"./Services/Utilities/classes/Sanitizer.php");
 
  245                                 $s .= $prefix . 
'[[' . $line;
 
  297                         $wasblank = ( 
'' == $text );
 
  298                         if( $wasblank ) $text = $link;
 
  300                         # Link not escaped by : , create the various objects 
  369                         # Special and Media are pseudo-namespaces; no pages actually exist in them 
  403                                 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
 
  407                                         !in_array($db_title, $collect))
 
  409                                         $collect[] = $db_title;
 
  431                 return str_replace(array(
"\x00", 
"\n", 
"\r", 
"\\", 
"'", 
'"', 
"\x1a"), 
"", $a_str);
 
  437         static function makeLink( &$nt, $a_wiki_id, $text = 
'', 
$query = 
'', $trail = 
'', $prefix = 
'' )
 
  442                 if ( ! is_object($nt) ) {
 
  444                         $retVal = 
"<!-- ERROR -->{$prefix}{$text}{$trail}";
 
  449                         # Separate the link trail from the rest of the link 
  456                                 ? 
' class="ilWikiPageMissing" ' : 
"";
 
  458                         $ilCtrl->setParameterByClass(
"ilobjwikigui", 
"page", $url_title);
 
  459                         $retVal = 
'<a '.$wiki_link_class.
' href="'.
 
  460                                 $ilCtrl->getLinkTargetByClass(
"ilobjwikigui", 
"gotoPage").
 
  461                                 '">'.$text.
'</a>'.$trail;
 
  488                 $wgUrlProtocols = array(
 
  503                 if ( is_array( $wgUrlProtocols ) ) {
 
  504                         $protocols = array();
 
  505                         foreach ($wgUrlProtocols as $protocol)
 
  506                                 $protocols[] = preg_quote( $protocol, 
'/' );
 
  508                         return implode( 
'|', $protocols );
 
  510                         return $wgUrlProtocols;
 
  519                 $s = urlencode( $s );
 
  533                 return str_replace(
"_", 
" ", $a_par);
 
  542                 $a_par = str_replace(
" ", 
"_", $a_par);
 
  554                 $regex = 
'/^([a-z]+)(.*)$/sD';
 
  557                 if ( 
'' != $trail ) {
 
  560                         if ( preg_match( $regex, $trail, $m ) ) {
 
  566                 return array( $inside, $trail );
 
  571                 global $ilUser, $ilObjDataCache;
 
  573                 include_once 
"./Services/Notification/classes/class.ilNotification.php";
 
  574                 include_once 
"./Modules/Wiki/classes/class.ilObjWiki.php";
 
  575                 include_once 
"./Modules/Wiki/classes/class.ilWikiPage.php";
 
  577                 $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
 
  578                 $wiki = 
new ilObjWiki($a_wiki_ref_id, 
true);
 
  585                         $users = array_merge($users, $wiki_users);
 
  591                         include_once 
"./Modules/Wiki/classes/class.ilObjWikiGUI.php";
 
  592                         $link = ILIAS_HTTP_PATH.
"/".ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle());
 
  604                         include_once 
"./classes/class.ilLink.php";
 
  610                 include_once 
"./Services/Mail/classes/class.ilMail.php";
 
  611                 include_once 
"./Services/User/classes/class.ilObjUser.php";
 
  612                 include_once 
"./Services/Language/classes/class.ilLanguageFactory.php";
 
  614                 foreach(array_unique($users) as $idx => $user_id)
 
  616                         if($user_id != $ilUser->getId())
 
  620                                 $ulng->loadLanguageModule(
'wiki');
 
  622                                 $subject = sprintf($ulng->txt(
'wiki_change_notification_subject'), $wiki->getTitle());
 
  628                                         $message .= $ulng->txt(
'wiki_change_notification_page_body_'.$a_action).
":\n\n";
 
  629                                         $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
 
  630                                         $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n\n";
 
  631                                         $message .= $ulng->txt(
'wiki_change_notification_page_link').
": ".$link;
 
  636                                         $message .= $ulng->txt(
'wiki_change_notification_body_'.$a_action).
":\n\n";
 
  637                                         $message .= $ulng->txt(
'wiki').
": ".$wiki->getTitle().
"\n";
 
  638                                         $message .= $ulng->txt(
'page').
": ".$page->getTitle().
"\n\n";
 
  639                                         $message .= $ulng->txt(
'wiki_change_notification_link').
": ".$link;
 
  642                                 $mail_obj = 
new ilMail(ANONYMOUS_USER_ID);
 
  643                                 $mail_obj->appendInstallationSignature(
true);
 
  645                                         "", 
"", $subject, $message, array(), array(
"system"));