From e72c96772d8ce9b44aa9e5f35d13abd0e53e0e52 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Tue, 12 Jan 2010 19:43:03 +0000 Subject: [PATCH] Fix regression from r60593: The title attribute for links to NS_MEDIA titles no longer contains the namespace as before. Passed 559 of 559 tests (100%)... ALL TESTS PASSED! --- includes/Linker.php | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 27be4795cd..0183c4b506 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -679,17 +679,9 @@ class Linker { wfProfileOut( __METHOD__ ); return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix ); } + + $href = $this->getUploadUrl( $title, $query ); - $q = 'wpDestFile=' . $title->getPartialUrl(); - if( $query != '' ) - $q .= '&' . $query; - - if( $wgUploadNavigationUrl ) { - $href = wfAppendQuery( $wgUploadNavigationUrl, $q ); - } else { - $upload = SpecialPage::getTitleFor( 'Upload' ); - $href = $upload->getLocalUrl( $q ); - } list( $inside, $trail ) = self::splitTrail( $trail ); @@ -707,6 +699,27 @@ class Linker { return "{$prefix}{$text}{$trail}"; } } + + /** + * Get the URL to upload a certain file + * + * @param $destFile Title Title of the file to upload + * @param $query string Urlencoded query string to prepend + * @return string Urlencoded URL + */ + protected function getUploadUrl( $destFile, $query = '' ) { + global $wgUploadNavigationUrl; + $q = 'wpDestFile=' . $destFile->getPartialUrl(); + if( $query != '' ) + $q .= '&' . $query; + + if( $wgUploadNavigationUrl ) { + return wfAppendQuery( $wgUploadNavigationUrl, $q ); + } else { + $upload = SpecialPage::getTitleFor( 'Upload' ); + return $upload->getLocalUrl( $q ); + } + } /** * Create a direct link to a given uploaded file. @@ -729,7 +742,8 @@ class Linker { $url = $img->getURL(); $class = 'internal'; } else { - return $this->makeBrokenImageLinkObj( $title, $text, '', '', '', '', $time==true ); + $url = $this->getUploadUrl( $title ); + $class = 'new'; } $alt = htmlspecialchars( $title->getText() ); if( $text == '' ) { -- 2.20.1