*/
function execute() {
global $wgUser, $wgOut;
- global $wgDisableUploads;
+ global $wgEnableUploads;
/** Show an error message if file upload is disabled */
- if( $wgDisableUploads ) {
+ if( ! $wgEnableUploads ) {
$wgOut->addWikiText( wfMsg( 'uploaddisabled' ) );
return;
}
global $wgUploadSizeWarning;
if ( $wgUploadSizeWarning && ( $this->mUploadSize > $wgUploadSizeWarning ) ) {
- $warning .= '<li>'.wfMsg( 'largefile' ).'</li>';
+ # TODO: Format $wgUploadSizeWarning to something that looks better than the raw byte
+ # value, perhaps add GB,MB and KB suffixes?
+ $warning .= '<li>'.wfMsg( 'largefile', $wgUploadSizeWarning, $this->mUploadSize ).'</li>';
}
if ( $this->mUploadSize == 0 ) {
$warning .= '<li>'.wfMsg( 'emptyfile' ).'</li>';
if( is_file( $this->mSavedFile ) ) {
$this->mUploadOldVersion = gmdate( 'YmdHis' ) . "!{$saveName}";
+ wfSuppressWarnings();
+ $success = rename( $this->mSavedFile, "${archive}/{$this->mUploadOldVersion}" );
+ wfRestoreWarnings();
- if( @!rename( $this->mSavedFile, "${archive}/{$this->mUploadOldVersion}" ) ) {
+ if( ! $success ) {
$wgOut->fileRenameError( $this->mSavedFile,
"${archive}/{$this->mUploadOldVersion}" );
return false;
}
if( $useRename ) {
- if( @!rename( $tempName, $this->mSavedFile ) ) {
+ wfSuppressWarnings();
+ $success = rename( $tempName, $this->mSavedFile );
+ wfRestoreWarnings();
+
+ if( ! $success ) {
$wgOut->fileCopyError( $tempName, $this->mSavedFile );
return false;
}
} else {
- if( @!move_uploaded_file( $tempName, $this->mSavedFile ) ) {
+ wfSuppressWarnings();
+ $success = move_uploaded_file( $tempName, $this->mSavedFile );
+ wfRestoreWarnings();
+
+ if( ! $success ) {
$wgOut->fileCopyError( $tempName, $this->mSavedFile );
return false;
}
* @access private
*/
function unsaveUploadedFile() {
- if ( ! @unlink( $this->mUploadTempName ) ) {
+ wfSuppressWarnings();
+ $success = unlink( $this->mUploadTempName );
+ wfRestoreWarnings();
+ if ( ! $success ) {
$wgOut->fileDeleteError( $this->mUploadTempName );
}
}
if ( $wgUseCopyrightUpload )
{
$copyright = "
- <input type='hidden' name=\"wpUploadCopyStatus\" value=\"" . htmlspecialchars( $this->mUploadCopyStatus ) . "\" />
- <input type='hidden' name=\"wpUploadSource\" value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" />
+ <input type='hidden' name='wpUploadCopyStatus' value=\"" . htmlspecialchars( $this->mUploadCopyStatus ) . "\" />
+ <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" />
";
} else {
$copyright = "";
}
$wgOut->addHTML( "
- <form id=\"uploadwarning\" method=\"post\" enctype=\"multipart/form-data\"
- action=\"{$action}\">
- <input type=hidden name=\"wpUploadAffirm\" value=\"1\" />
- <input type=hidden name=\"wpIgnoreWarning\" value=\"1\" />
- <input type=hidden name=\"wpSessionKey\" value=\"" . htmlspecialchars( $this->mSessionKey ) . "\" />
- <input type=hidden name=\"wpUploadDescription\" value=\"" . htmlspecialchars( $this->mUploadDescription ) . "\" />
+ <form id='uploadwarning' method='post' enctype='multipart/form-data' action='$action'>
+ <input type='hidden' name='wpUploadAffirm' value='1' />
+ <input type='hidden' name='wpIgnoreWarning' value='1' />
+ <input type='hidden' name='wpSessionKey' value=\"" . htmlspecialchars( $this->mSessionKey ) . "\" />
+ <input type='hidden' name='wpUploadDescription' value=\"" . htmlspecialchars( $this->mUploadDescription ) . "\" />
{$copyright}
- <table border='0'><tr>
- <tr><td align='right'>
- <input tabindex='2' type='submit' name=\"wpUpload\" value=\"{$save}\" />
- </td><td align='left'>{$iw}</td></tr>
- <tr><td align='right'>
- <input tabindex='2' type='submit' name=\"wpReUpload\" value=\"{$reupload}\" />
- </td><td align='left'>{$reup}</td></tr></table></form>\n" );
+ <table border='0'>
+ <tr>
+ <tr>
+ <td align='right'>
+ <input tabindex='2' type='submit' name='wpUpload' value='$save' />
+ </td>
+ <td align='left'>$iw</td>
+ </tr>
+ <tr>
+ <td align='right'>
+ <input tabindex='2' type='submit' name='wpReUpload' value='{$reupload}' />
+ </td>
+ <td align='left'>$reup</td>
+ </tr>
+ </tr>
+ </table></form>\n" );
}
/**
function mainUploadForm( $msg='' ) {
global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest;
global $wgUseCopyrightUpload;
+
+ $cols = intval($wgUser->getOption( 'cols' ));
+ $ew = $wgUser->getOption( 'editwidth' );
+ if ( $ew ) $ew = " style=\"width:100%\"";
+ else $ew = '';
if ( '' != $msg ) {
$sub = wfMsg( 'uploaderror' );
$source = "
<td align='right'>
- <input tabindex='3' type='checkbox' name=\"wpUploadAffirm\" value=\"1\" id=\"wpUploadAffirm\" />
- </td><td align='left'><label for=\"wpUploadAffirm\">{$ca}</label></td>
+ <input tabindex='3' type='checkbox' name='wpUploadAffirm' value='1' id='wpUploadAffirm' />
+ </td><td align='left'><label for='wpUploadAffirm'>{$ca}</label></td>
" ;
if ( $wgUseCopyrightUpload )
{
htmlspecialchars($this->mUploadCopyStatus). "\" size='40' /></td>
</tr><tr>
<td align='right'>". wfMsg ( 'filesource' ) . ":</td>
- <td><input tabindex='4' type='text' name=\"wpUploadSource\" value=\"" .
+ <td><input tabindex='4' type='text' name='wpUploadSource' value=\"" .
htmlspecialchars($this->mUploadSource). "\" size='40' /></td>
" ;
}
$wgOut->addHTML( "
- <form id=\"upload\" method=\"post\" enctype=\"multipart/form-data\"
- action=\"{$action}\">
+ <form id='upload' method='post' enctype='multipart/form-data' action='$action'>
<table border='0'><tr>
<td align='right'>{$fn}:</td><td align='left'>
- <input tabindex='1' type='file' name=\"wpUploadFile\" size='40' />
+ <input tabindex='1' type='file' name='wpUploadFile' size='40' />
</td></tr><tr>
<td align='right'>{$fd}:</td><td align='left'>
- <input tabindex='2' type='text' name=\"wpUploadDescription\" value=\""
- . htmlspecialchars( $this->mUploadDescription ) . "\" size='40' />
+ <textarea tabindex='2' name='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>"
+ . htmlspecialchars( $this->mUploadDescription ) .
+ "</textarea>
</td></tr><tr>
{$source}
</tr>
<tr><td></td><td align='left'>
- <input tabindex='5' type='submit' name=\"wpUpload\" value=\"{$ulb}\" />
+ <input tabindex='5' type='submit' name='wpUpload' value=\"{$ulb}\" />
</td></tr></table></form>\n" );
}
return true;
}
- $data = @getimagesize( $tmpfile );
+ wfSuppressWarnings();
+ $data = getimagesize( $tmpfile );
+ wfRestoreWarnings();
if( false === $data ) {
# Didn't recognize the image type.
# Either the image is corrupt or someone's slipping us some