Page MenuHomePhabricator

PATCH.remote_uploads

Authored By
bzimport
Nov 21 2014, 10:43 PM
Size
2 KB
Referenced Files
None
Subscribers
None

PATCH.remote_uploads

Index: includes/Linker.php
===================================================================
--- includes/Linker.php (revision 60582)
+++ includes/Linker.php (working copy)
@@ -666,25 +666,38 @@
* @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 ) {
+ if( strpos( $wgUploadNavigationUrl, "?" ) === false )
+ $href = $wgUploadNavigationUrl . "?" . $q;
+ else
+ $href = $wgUploadNavigationUrl . "&" . $q;
+ } else {
+ $upload = SpecialPage::getTitleFor( 'Upload' );
+ $href = $upload->escapeLocalUrl( $q );
+ }
+
list( $inside, $trail ) = self::splitTrail( $trail );
$style = $this->getInternalLinkAttributesObj( $title, $text, 'new' );
wfProfileOut( __METHOD__ );
- return '<a href="' . $upload->escapeLocalUrl( $q ) . '"'
+ return '<a href="' . $href . '"'
. $style . '>' . $prefix . $text . $inside . '</a>' . $trail;
} else {
wfProfileOut( __METHOD__ );
@@ -716,9 +729,7 @@
$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 == '' ) {

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5455
Default Alt Text
PATCH.remote_uploads (2 KB)

Event Timeline