(bug 18885) Red links for media files do not support shared repositories
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sun, 3 Jan 2010 22:45:34 +0000 (22:45 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sun, 3 Jan 2010 22:45:34 +0000 (22:45 +0000)
$wgUploadNavigationUrl now also affects images inline images that do not
exist. In that case the URL will get (?|&)wpDestFile=<filename> appended to
it as appropriate.

RELEASE-NOTES
includes/DefaultSettings.php
includes/Linker.php

index 551e2fb..c45bd6d 100644 (file)
@@ -81,7 +81,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   similarly to the category namespace.
 * $wgEnableSorbs renamed to $wgDnsBlacklistUrls ($wgEnableSorbs kept for
   backward compatibility)
-
+* $wgUploadNavigationUrl now also affects images inline images that do not 
+  exist. In that case the URL will get (?|&)wpDestFile=<filename> appended to 
+  it as appropriate.
+  
 === New features in 1.16 ===
 
 * Add CSS defintion of the 'wikitable' class to shared.css
@@ -279,6 +282,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 21826) Subsections of Special:Version now also have anchors
 * (bug 19791) Add URL of file source as comment to thumbs (for ImageMagick)
 * (bug 21946) Sorted wikitables do not properly handle minus signs
+* (bug 18885) Red links for media files do not support shared repositories
 
 === Bug fixes in 1.16 ===
 
index 51cccfd..ed4f047 100644 (file)
@@ -472,6 +472,9 @@ $wgMaxUploadSize = 1024*1024*100; # 100MB
  * Useful if you want to use a shared repository by default
  * without disabling local uploads (use $wgEnableUploads = false for that)
  * e.g. $wgUploadNavigationUrl = 'http://commons.wikimedia.org/wiki/Special:Upload';
+ * 
+ * This also affects images inline images that do not exist. In that case the URL will get
+ * (?|&)wpDestFile=<filename> appended to it as appropriate.
  */
 $wgUploadNavigationUrl = false;
 
index 2c16db4..17a6cea 100644 (file)
@@ -666,26 +666,39 @@ class Linker {
         * @return string
         */
        public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '', $time = false ) {
-               global $wgEnableUploads;
+               global $wgEnableUploads, $wgUploadNavigationUrl;
                if( $title instanceof Title ) {
                        wfProfileIn( __METHOD__ );
                        $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
-                       if( $wgEnableUploads && !$currentExists ) {
-                               $upload = SpecialPage::getTitleFor( 'Upload' );
+                       if( ( $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) {
                                if( $text == '' )
                                        $text = htmlspecialchars( $title->getPrefixedText() );
+
                                $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
                                if( $redir ) {
+                                       wfProfileOut( __METHOD__ );
                                        return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
                                }
+
                                $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 );
-                               $style = $this->getInternalLinkAttributesObj( $title, $text, 'new' );
+                               
                                wfProfileOut( __METHOD__ );
-                               return '<a href="' . $upload->escapeLocalUrl( $q ) . '"'
-                                       . $style . '>' . $prefix . $text . $inside . '</a>' . $trail;
+                               return Html::element( 'a', array(
+                                       'href' => $href,
+                                       'class' => 'new',
+                                       'title' => $title->getPrefixedText()
+                               ), $prefix . $text . $inside ) . $trail;
                        } else {
                                wfProfileOut( __METHOD__ );
                                return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
@@ -716,9 +729,7 @@ class Linker {
                                $url  = $img->getURL();
                                $class = 'internal';
                        } else {
-                               $upload = SpecialPage::getTitleFor( 'Upload' );
-                               $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $title->getDBkey() ) );
-                               $class = 'new';
+                               return $this->makeBrokenImageLinkObj( $title, $text, '', '', '', '', $time==true );
                        }
                        $alt = htmlspecialchars( $title->getText() );
                        if( $text == '' ) {