$this->mDesiredDestName = $request->getText( 'wpDestFile' );
$this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' );
$this->mComment = $request->getText( 'wpUploadDescription' );
+ $this->mForReUpload = $request->getBool( 'wpForReUpload' );
$this->mReUpload = $request->getCheck( 'wpReUpload' );
if( !$request->wasPosted() ) {
# Placeholders for text injection by hooks (empty per default)
$this->uploadFormTextTop = "";
$this->uploadFormTextAfterSummary = "";
-
- $this->mReUpload = $request->getCheck( 'wpReUpload' );
$this->mUploadClicked = $request->getCheck( 'wpUpload' );
$this->mLicense = $request->getText( 'wpLicense' );
* Returns true if there was an error, false otherwise
*/
private function curlCopy( $url, $dest ) {
- global $wgUser, $wgOut;
+ global $wgUser, $wgOut, $wgHTTPProxy, $wgCopyUploadTimeout;
if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
$wgOut->permissionRequired( 'upload_by_url' );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HTTP_VERSION, 1.0); # Probably not needed, but apparently can work around some bug
- curl_setopt( $ch, CURLOPT_TIMEOUT, 10); # 10 seconds timeout
+ curl_setopt( $ch, CURLOPT_TIMEOUT, $wgCopyUploadTimeout); # Default 30 seconds timeout
curl_setopt( $ch, CURLOPT_LOW_SPEED_LIMIT, 512); # 0.5KB per second minimum transfer speed
curl_setopt( $ch, CURLOPT_URL, $url);
+ if( $wgHTTPProxy ) {
+ curl_setopt( $ch, CURLOPT_PROXY, $wgHTTPProxy );
+ }
curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) );
curl_exec( $ch );
$error = curl_errno( $ch ) ? true : false;
* @access private
*/
function processUpload(){
- global $wgUser, $wgOut, $wgFileExtensions, $wgLang;
+ global $wgOut, $wgFileExtensions, $wgLang;
$details = null;
$value = null;
$value = $this->internalProcessUpload( $details );
$warning .= self::getExistsWarning( $this->mLocalFile );
}
- $warning .= $this->getDupeWarning( $this->mTempPath, $finalExt );
+ $warning .= $this->getDupeWarning( $this->mTempPath, $finalExt, $nt );
if( $warning != '' ) {
/**
* Try actually saving the thing...
* It will show an error form on failure.
*/
- $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
- $this->mCopyrightStatus, $this->mCopyrightSource );
+ if( !$this->mForReUpload ) {
+ $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
+ $this->mCopyrightStatus, $this->mCopyrightSource );
+ }
$status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText,
File::DELETE_SOURCE, $this->mFileProps );
* Check for duplicate files and throw up a warning before the upload
* completes.
*/
- function getDupeWarning( $tempfile, $extension ) {
+ function getDupeWarning( $tempfile, $extension, $destinationTitle ) {
$hash = File::sha1Base36( $tempfile );
$dupes = RepoGroup::singleton()->findBySha1( $hash );
$archivedImage = new ArchivedFile( null, 0, $hash.".$extension" );
$msg = "<gallery>";
foreach( $dupes as $file ) {
$title = $file->getTitle();
- $msg .= $title->getPrefixedText() .
- "|" . $title->getText() . "\n";
+ # Don't throw the warning when the titles are the same, it's a reupload
+ # and highly redundant.
+ if ( !$title->equals( $destinationTitle ) || !$this->mForReUpload ) {
+ $msg .= $title->getPrefixedText() .
+ "|" . $title->getText() . "\n";
+ }
}
$msg .= "</gallery>";
return "<li>" .
}
// Show the relevant lines from deletion log (for still deleted files only)
- if( $title instanceof Title && $title->isDeleted() > 0 && !$title->exists() ) {
+ if( $title instanceof Title && $title->isDeletedQuick() && !$title->exists() ) {
$this->showDeletionLog( $wgOut, $title->getPrefixedText() );
}
}
$sourcefilename = wfMsgExt( 'sourcefilename', array( 'parseinline', 'escapenoentities' ) );
$destfilename = wfMsgExt( 'destfilename', array( 'parseinline', 'escapenoentities' ) );
- $msg = $this->mReUpload ? 'filereuploadsummary' : 'fileuploadsummary';
+ $msg = $this->mForReUpload ? 'filereuploadsummary' : 'fileuploadsummary';
$summary = wfMsgExt( $msg, 'parseinline' );
$licenses = new Licenses();
$watchChecked = $this->watchCheck() ? 'checked="checked"' : '';
# Re-uploads should not need "file exist already" warnings
- $warningChecked = ($this->mIgnoreWarning || $this->mReUpload) ? 'checked="checked"' : '';
+ $warningChecked = ($this->mIgnoreWarning || $this->mForReUpload) ? 'checked="checked"' : '';
// Prepare form for upload or upload/copy
if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) {
$warningRow = '';
$destOnkeyup = '';
}
- # Uploading a new version? If so, the name is fixed.
- $on = $this->mReUpload ? "disabled='disabled'" : "";
-
$encComment = htmlspecialchars( $this->mComment );
+
$wgOut->addHTML(
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL(),
<td class='mw-label'>
<label for='wpDestFile'>{$destfilename}</label>
</td>
- <td class='mw-input'>
- <input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='60'
- value=\"{$encDestName}\" onchange='toggleFilenameFiller()' $on $destOnkeyup />
- </td>
+ <td class='mw-input'>"
+ );
+ if( $this->mForReUpload ) {
+ $wgOut->addHTML(
+ Xml::hidden( 'wpDestFile', $this->mDesiredDestName, array('id'=>'wpDestFile','tabindex'=>2) ) .
+ "<tt>" .
+ $encDestName .
+ "</tt>"
+ );
+ }
+ else {
+ $wgOut->addHTML(
+ "<input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='60'
+ value=\"{$encDestName}\" onchange='toggleFilenameFiller()' $destOnkeyup />"
+ );
+ }
+
+
+ $wgOut->addHTML(
+ "</td>
</tr>
<tr>
<td class='mw-label'>
<tr>"
);
# Re-uploads should not need license info
- if ( !$this->mReUpload && $licenseshtml != '' ) {
+ if ( !$this->mForReUpload && $licenseshtml != '' ) {
global $wgStylePath;
$wgOut->addHTML( "
<td class='mw-label'>
}
}
- if ( !$this->mReUpload && $wgUseCopyrightUpload ) {
+ if ( !$this->mForReUpload && $wgUseCopyrightUpload ) {
$filestatus = wfMsgExt( 'filestatus', 'escapenoentities' );
$copystatus = htmlspecialchars( $this->mCopyrightStatus );
$filesource = wfMsgExt( 'filesource', 'escapenoentities' );
<tr>
<td></td>
<td class='mw-input'>
- <input tabindex='9' type='submit' name='wpUpload' value=\"{$ulb}\"" . $wgUser->getSkin()->tooltipAndAccesskey( 'upload' ) . " />
+ <input tabindex='9' type='submit' name='wpUpload' value=\"{$ulb}\"" .
+ $wgUser->getSkin()->tooltipAndAccesskey( 'upload' ) . " />
</td>
</tr>
<tr>
<td></td>
<td class='mw-input'>"
);
- $wgOut->addWikiText( wfMsgForContent( 'edittools' ) );
+ $wgOut->addHTML( '<div class="mw-editTools">' );
+ $wgOut->addWikiMsgArray( 'edittools', array(), array( 'content' ) );
+ $wgOut->addHTML( '</div>' );
$wgOut->addHTML( "
</td>
</tr>" .
Xml::closeElement( 'table' ) .
Xml::hidden( 'wpDestFileWarningAck', '', array( 'id' => 'wpDestFileWarningAck' ) ) .
+ Xml::hidden( 'wpForReUpload', $this->mForReUpload, array( 'id' => 'wpForReUpload' ) ) .
Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' )
);