Fix for [ 965008 ] Links in edit summaries don't use linktrail
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 9 Aug 2004 02:45:38 +0000 (02:45 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 9 Aug 2004 02:45:38 +0000 (02:45 +0000)
includes/Skin.php

index 2bf9840..17ddf6e 100644 (file)
@@ -2501,22 +2501,28 @@ class Skin {
                # format regular and media links - all other wiki formatting
                # is ignored
                $medians = $wgLang->getNsText(Namespace::getMedia()).':';
-               while(preg_match('/\[\[(.*?)(\|(.*?))*\]\]/',$comment,$match)) {
+               while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
                        # Handle link renaming [[foo|text]] will show link as "text"
-                       if(isset($match[3]) ) {
+                       if( "" != $match[3] ) {
                                $text = $match[3];
                        } else {
                                $text = $match[1];
                        }
-                       if ( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
-                               # Media link
-                               $comment = preg_replace( '/\[\[(.*?)\]\]/', $this->makeMediaLink( $submatch[1], "", $text ),
-                                 $comment, 1 );
+                       if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
+                               # Media link; trail not supported.
+                               $linkRegexp = '/\[\[(.*?)\]\]/';
+                               $thelink = $this->makeMediaLink( $submatch[1], "", $text );
                        } else {
                                # Other kind of link
-                               $comment = preg_replace('/\[\[(.*?)\]\]/', $this->makeLink( $match[1], $match[1] ),
-                                 $comment , 1);
+                               if( preg_match( wfMsg( "linktrail" ), $match[4], $submatch ) ) {
+                                       $trail = $submatch[1];
+                               } else {
+                                       $trail = "";
+                               }
+                               $linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
+                               $thelink = $this->makeLink( $match[1], $text, "", $trail );
                        }
+                       $comment = preg_replace( $linkRegexp, $thelink, $comment, 1 );
                }
                return $comment;
        }