global $wgUser, $wgOut;
global $wgEnableUploads, $wgUploadDirectory;
- /** Show an error message if file upload is disabled */
- if( ! $wgEnableUploads ) {
- $wgOut->addWikiText( wfMsg( 'uploaddisabled' ) );
+ # Check uploading enabled
+ if( !$wgEnableUploads ) {
+ $wgOut->errorPage( 'uploaddisabled', 'uploaddisabledtext' );
return;
}
- /** Various rights checks */
- if( !$wgUser->isAllowed( 'upload' ) || $wgUser->isBlocked() ) {
- $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
+ # Check permissions
+ if( $wgUser->isLoggedIn() ) {
+ if( !$wgUser->isAllowed( 'upload' ) ) {
+ $wgOut->permissionRequired( 'upload' );
+ return;
+ }
+ } else {
+ $wgOut->errorPage( 'uploadnologin', 'uploadnologintext' );
+ return;
+ }
+
+ # Check blocks
+ if( $wgUser->isBlocked() ) {
+ $wgOut->blockedPage();
return;
}
+
if( wfReadOnly() ) {
$wgOut->readOnlyPage();
return;
* @access private
*/
function processUpload() {
- global $wgUser, $wgOut, $wgLang, $wgContLang;
- global $wgUploadDirectory;
- global $wgUseCopyrightUpload, $wgCheckCopyrightUpload;
+ global $wgUser, $wgOut, $wgUploadDirectory;
/* Check for PHP error if any, requires php 4.2 or newer */
if ( $this->mUploadError == 1/*UPLOAD_ERR_INI_SIZE*/ ) {
# Chop off any directories in the given filename
if ( $this->mDestFile ) {
- $basename = basename( $this->mDestFile );
+ $basename = wfBaseName( $this->mDestFile );
} else {
- $basename = basename( $this->mOname );
+ $basename = wfBaseName( $this->mOname );
}
/**
if( !$nt->userCanEdit() ) {
return $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) );
}
-
+
/**
* In some cases we may forbid overwriting of existing files.
*/
return $this->uploadError( $veri->toString() );
}
}
-
+
/**
* Provide an opportunity for extensions to add futher checks
*/
*/
if ( ! $this->mIgnoreWarning ) {
$warning = '';
-
+
global $wgCapitalLinks;
if( $wgCapitalLinks ) {
$filtered = ucfirst( $filtered );
* @access private
*/
function uploadWarning( $warning ) {
- global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest;
+ global $wgOut, $wgUser, $wgUploadDirectory, $wgRequest;
global $wgUseCopyrightUpload;
$this->mSessionKey = $this->stashSession();
* @access private
*/
function mainUploadForm( $msg='' ) {
- global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest;
+ global $wgOut, $wgUser, $wgUploadDirectory, $wgRequest;
global $wgUseCopyrightUpload;
$cols = intval($wgUser->getOption( 'cols' ));
$wgOut->addHTML( "<h2>{$sub}</h2>\n" .
"<span class='error'>{$msg}</span>\n" );
}
+ $wgOut->addHTML( '<div id="uploadtext">' );
$wgOut->addWikiText( wfMsg( 'uploadtext' ) );
+ $wgOut->addHTML( '</div>' );
$sk = $wgUser->getSkin();
$license = wfMsgHtml( 'license' );
$nolicense = wfMsgHtml( 'nolicense' );
$licenseshtml = $licenses->getHtml();
-
+
$ulb = wfMsgHtml( 'uploadbtn' );
$watchChecked = $wgUser->getOption( 'watchdefault' )
? 'checked="checked"'
: '';
-
+
$wgOut->addHTML( "
<form id='upload' method='post' enctype='multipart/form-data' action=\"$action\">
- <table border='1'>
+ <table border='0'>
<tr>
- <td align='right'>{$sourcefilename}:</td>
+ <td align='right'><label for='wpUploadFile'>{$sourcefilename}:</label></td>
<td align='left'>
<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " . ($this->mDestFile?"":"onchange='fillDestFilename()' ") . "size='40' />
</td>
</tr>
<tr>
- <td align='right'>{$destfilename}:</td>
+ <td align='right'><label for='wpDestFile'>{$destfilename}:</label></td>
<td align='left'>
<input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='40' value=\"$encDestFile\" />
</td>
</tr>
<tr>
- <td align='right'>{$summary}</td>
+ <td align='right'><label for='wpUploadDescription'>{$summary}</label></td>
<td align='left'>
- <textarea tabindex='3' name='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars( $this->mUploadDescription ) . "</textarea>
+ <textarea tabindex='3' name='wpUploadDescription' id='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars( $this->mUploadDescription ) . "</textarea>
</td>
</tr>
<tr>" );
-
+
if ( $licenseshtml != '' ) {
+ global $wgStylePath;
$wgOut->addHTML( "
- <td align='right'>$license:</td>
+ <td align='right'><label for='wpLicense'>$license:</label></td>
<td align='left'>
- <select name='wpLicense' tabindex='4'>
+ <script type='text/javascript' src=\"$wgStylePath/common/upload.js\"></script>
+ <select name='wpLicense' id='wpLicense' tabindex='4'
+ onchange='licenseSelectorCheck()'>
<option value=''>$nolicense</option>
$licenseshtml
</select>
$copystatus = htmlspecialchars( $this->mUploadCopyStatus );
$filesource = wfMsgHtml ( 'filesource' );
$uploadsource = htmlspecialchars( $this->mUploadSource );
-
+
$wgOut->addHTML( "
- <td align='right' nowrap='nowrap'>$filestatus:</td>
- <td><input tabindex='5' type='text' name='wpUploadCopyStatus' value=\"$copystatus\" size='40' /></td>
+ <td align='right' nowrap='nowrap'><label for='wpUploadCopyStatus'>$filestatus:</label></td>
+ <td><input tabindex='5' type='text' name='wpUploadCopyStatus' id='wpUploadCopyStatus' value=\"$copystatus\" size='40' /></td>
</tr>
<tr>
- <td align='right'>$filesource:</td>
- <td><input tabindex='6' type='text' name='wpUploadSource' value=\"$uploadsource\" size='40' /></td>
+ <td align='right'><label for='wpUploadCopyStatus'>$filesource:</label></td>
+ <td><input tabindex='6' type='text' name='wpUploadSource' id='wpUploadCopyStatus' value=\"$uploadsource\" size='40' /></td>
</tr>
<tr>
");
}
-
-
+
+
$wgOut->addHtml( "
<td></td>
<td>
<input tabindex='7' type='checkbox' name='wpWatchthis' id='wpWatchthis' $watchChecked value='true' />
<label for='wpWatchthis'>" . wfMsgHtml( 'watchthis' ) . "</label>
<input tabindex='8' type='checkbox' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' />
- <label for='wpIgnoreWarning'>" . wfMsgHtml( 'ignorewarning' ) . "</label>
+ <label for='wpIgnoreWarning'>" . wfMsgHtml( 'ignorewarnings' ) . "</label>
</td>
</tr>
<tr>
<td></td>
<td align='left'><input tabindex='9' type='submit' name='wpUpload' value=\"{$ulb}\" /></td>
</tr>
+
+ <tr>
+ <td></td>
+ <td align='left'>
+ " );
+ $wgOut->addWikiText( wfMsgForContent( 'edittools' ) );
+ $wgOut->addHTML( "
+ </td>
+ </tr>
+
</table>
</form>" );
}
unlink( $this->mUploadTempName );
}
}
-
+
/**
* Check if there's an overwrite conflict and, if so, if restrictions
* forbid this user from performing the upload.
// But if it does, fall through to previous behavior
return false;
}
-
+
$error = '';
if( $img->exists() ) {
global $wgUser, $wgOut;
}
}
}
-
+
if( $error ) {
$errorText = wfMsg( $error, wfEscapeWikiText( $img->getName() ) );
return new WikiError( $wgOut->parse( $errorText ) );
}
-
+
// Rockin', go ahead and upload
return true;
}