From 21f8f5c0246d3ef4fbe2a8f78ab01f6b7ec875fe Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 24 Jul 2004 07:27:11 +0000 Subject: [PATCH] * Fixed bug with media links in formatComment() --- includes/Skin.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index bc67c384e7..8357926f6d 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1957,7 +1957,7 @@ class Skin { { if ( ! isset( $nt ) ) { - ### HOTFIX. Instead of breaking, return empry string. + ### HOTFIX. Instead of breaking, return empty string. $s = $alt; } else { $name = $nt->getDBKey(); @@ -2489,27 +2489,25 @@ class Skin { # format regular and media links - all other wiki formatting # is ignored + $medians = $wgLang->getNsText(Namespace::getMedia()).':'; while(preg_match('/\[\[(.*?)(\|(.*?))*\]\]/',$comment,$match)) { - - $medians = $wgLang->getNsText(Namespace::getMedia()).':'; - $func='makeLink'; - if(preg_match('/^'.$medians.'/i',$match[1])) { - $func='makeMediaLink'; - } # Handle link renaming [[foo|text]] will show link as "text" if(isset($match[3]) ) { - $comment= - preg_replace('/\[\[(.*?)\]\]/', - $this->$func($match[1],$match[3]),$comment,1); + $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 ); } else { - $comment= - preg_replace('/\[\[(.*?)\]\]/', - $this->$func($match[1],$match[1]),$comment,1); + # Other kind of link + $comment = preg_replace('/\[\[(.*?)\]\]/', $this->$func( $match[1], $match[1] ), + $comment , 1); } } - return $comment; - } function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description ) -- 2.20.1