Page MenuHomePhabricator
Authored By
bzimport
Nov 21 2014, 9:15 PM
Size
1 KB
Referenced Files
None
Subscribers
None
--- HEAD\Linker.php Thu Jun 22 16:32:17 2006
+++ Linker.php Thu Jun 22 16:34:42 2006
@@ -919,7 +915,6 @@
# format regular and media links - all other wiki formatting
# is ignored
- $medians = $wgContLang->getNsText( NS_MEDIA ) . ':';
while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
# Handle link renaming [[foo|text]] will show link as "text"
if( "" != $match[3] ) {
@@ -927,10 +922,22 @@
} else {
$text = $match[1];
}
- if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
- # Media link; trail not supported.
+ if ($match[1][0] == ':')
+ $match[1] = substr($match[1], 1);
+ $title = Title::newFromText( $match[1] );
+ $ns = $title->getNamespace();
+ if ( $ns == NS_IMAGE || $ns == NS_MEDIA ) {
+ # Media link; trail not supported, special existence check.
+ $image = Image::newFromTitle( $title );
+ if ( $image->exists() ) {
+ if ( $ns == NS_IMAGE )
+ $thelink = $this->makeKnownLinkObj( $title, $text );
+ else
+ $thelink = $this->makeMediaLinkObj( $title, $text );
+ } else {
+ $thelink = $this->makeBrokenImageLinkObj( $title );
+ }
$linkRegexp = '/\[\[(.*?)\]\]/';
- $thelink = $this->makeMediaLink( $submatch[1], "", $text );
} else {
# Other kind of link
if( preg_match( $wgContLang->linkTrail(), $match[4], $submatch ) ) {
@@ -939,9 +946,7 @@
$trail = "";
}
$linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
- if ($match[1][0] == ':')
- $match[1] = substr($match[1], 1);
- $thelink = $this->makeLink( $match[1], $text, "", $trail );
+ $thelink = $this->makeLinkObj( $title, $text, "", $trail );
}
$comment = preg_replace( $linkRegexp, wfRegexReplacement( $thelink ), $comment, 1 );
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2428
Default Alt Text
patch (1 KB)

Event Timeline