'SpecialUploadComplete': Called after successfully uploading a file from
Special:Upload
-$form: The UploadForm object
+$form: The SpecialUpload object
'SpecialVersionExtensionTypes': called when generating the extensions credits,
use this to change the tables headers
$user: user that watched
$article: article object that was watched
-'UploadForm:initial': before the upload form is generated
-$form: UploadForm object
-You might set the member-variables $uploadFormTextTop and
-$uploadFormTextAfterSummary to inject text (HTML) either before
-or after the editform.
+'UploadCreateFromRequest': when UploadBase::createFromRequest has been called
+string $type: the requested upload type
+&$className: the class name of the Upload instance to be created
-'UploadForm:BeforeProcessing': at the beginning of processUpload()
-$form: UploadForm object
-Lets you poke at member variables like $mUploadDescription before the
-file is saved.
+'UploadComplete': when Upload completes an upload
+&$upload: an UploadBase child instance
+
+'UploadFormInitDescriptor': after the descriptor for the upload form as been
+assembled
+array $descriptor: the HTMLForm descriptor
+
+'UploadFormSourceDescriptors': after the standard source inputs have been
+added to the descriptor
+array $descriptor: the HTMLForm descriptor
'UploadVerification': additional chances to reject an uploaded file
string $saveName: destination file name
$this->mRequest = $request;
$this->mSourceType = $request->getVal( 'wpSourceType', 'file' );
$this->mUpload = UploadBase::createFromRequest( $request );
- $this->mUploadClicked = $request->getCheck( 'wpUpload' ) && $request->wasPosted();
+ $this->mUploadClicked = $request->wasPosted()
+ && ( $request->getCheck( 'wpUpload' )
+ || $request->getCheck( 'wpUploadIgnoreWarning' ) );
// Guess the desired name from the filename if not provided
$this->mDesiredDestName = $request->getText( 'wpDestFile' );
$this->mLicense = $request->getText( 'wpLicense' );
- $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' );
+ $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' )
+ || $request->getCheck( 'wpUploadIgnoreWarning' );
$this->mWatchthis = $request->getBool( 'wpWatchthis' );
$this->mCopyrightStatus = $request->getText( 'wpUploadCopyStatus' );
$this->mCopyrightSource = $request->getText( 'wpUploadSource' );
* @param string $sessionKey Session key in case this is a stashed upload
* @return UploadForm
*/
- protected function getUploadForm( $message = '', $sessionKey = '' ) {
+ protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) {
global $wgOut;
# Initialize form
- $form = new UploadForm( $this->watchCheck(), $this->mForReUpload, $sessionKey );
+ $form = new UploadForm( array(
+ 'watch' => $this->watchCheck(),
+ 'forreupload' => $this->mForReUpload,
+ 'sessionkey' => $sessionKey,
+ 'hideignorewarning' => $hideIgnoreWarning,
+ ) );
$form->setTitle( $this->getTitle() );
# Check the token, but only if necessary
$sessionKey = $this->mUpload->stashSession();
$message = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" .
'<div class="error">' . $message . "</div>\n";
- $this->showUploadForm( $this->getUploadForm( $message, $sessionKey ) );
+
+ $form = $this->getUploadForm( $message, $sessionKey );
+ $form->setSubmitText( wfMsg( 'upload-tryagain' ) );
+ $this->showUploadForm( $form );
}
/**
* Stashes the upload, shows the main form, but adds an "continue anyway button"
}
$warningHtml .= $msg;
}
- $warningHtml .= '</ul>';
+ $warningHtml .= "</ul>\n";
+ $warningHtml .= wfMsgExt( 'uploadwarning-text', 'parse' );
- $form = $this->getUploadForm( $warningHtml, $sessionKey );
- $form->setSubmitText( wfMsg( 'ignorewarning' ) );
+ $form = $this->getUploadForm( $warningHtml, $sessionKey, /* $hideIgnoreWarning */ true );
+ $form->setSubmitText( wfMsg( 'upload-tryagain' ) );
+ $form->addButton( 'wpUploadIgnoreWarning', wfMsg( 'ignorewarning' ) );
$form->addButton( 'wpCancelUpload', wfMsg( 'reuploaddesc' ) );
$this->showUploadForm( $form );
protected $mWatch;
protected $mForReUpload;
protected $mSessionKey;
+ protected $mHideIgnoreWarning;
+
protected $mSourceIds;
- public function __construct( $watch, $forReUpload = false, $sessionKey = '' ) {
+ public function __construct( $options = array() ) {
global $wgLang;
- $this->mWatch = $watch;
- $this->mForReUpload = $forReUpload;
- $this->mSessionKey = $sessionKey;
+ $this->mWatch = !empty( $options['watch'] );
+ $this->mForReUpload = !empty( $options['forreupload'] );
+ $this->mSessionKey = isset( $options['sessionkey'] )
+ ? $options['sessionkey'] : '';
+ $this->mHideIgnoreWarning = !empty( $options['hideignorewarning'] );
$sourceDescriptor = $this->getSourceSection();
$descriptor = $sourceDescriptor
'id' => 'wpWatchthis',
'label-message' => 'watchthisupload',
'section' => 'options',
- ),
- 'IgnoreWarning' => array(
+ )
+ );
+ if ( !$this->mHideIgnoreWarning ) {
+ $descriptor['IgnoreWarning'] = array(
'type' => 'check',
'id' => 'wpIgnoreWarning',
'label-message' => 'ignorewarnings',
'section' => 'options',
- ),
- );
+ );
+ }
return $descriptor;
// Get the upload class
$type = ucfirst( $type );
- $className = 'UploadFrom' . $type;
- wfDebug( __METHOD__ . ": class name: $className\n" );
- if( !in_array( $type, self::$uploadHandlers ) )
- return null;
+
+ // Give hooks the chance to handle this request
+ $className = null;
+ wfRunHooks( 'UploadCreateFromRequest', array( $type, &$className ) );
+ if ( is_null( $className ) ) {
+ $className = 'UploadFrom' . $type;
+ wfDebug( __METHOD__ . ": class name: $className\n" );
+ if( !in_array( $type, self::$uploadHandlers ) )
+ return null;
+ }
// Check whether this upload class is enabled
if( !call_user_func( array( $className, 'isEnabled' ) ) )
}
public function initializeFromRequest( &$request ) {
- $sessionKey = $request->getInt( 'wpSessionKey' );
+ $this->mSessionKey = $request->getInt( 'wpSessionKey' );
$sessionData = $request->getSessionData('wsUploadData');
$desiredDestName = $request->getText( 'wpDestFile' );
if( !$desiredDestName )
$desiredDestName = $request->getText( 'wpUploadFile' );
- return $this->initialize( $desiredDestName, $sessionData[$sessionKey], false );
+ return $this->initialize( $desiredDestName, $sessionData[$this->mSessionKey], false );
}
/**
return true;
}
+
/**
- * We're here from "ignore warnings anyway" so return just OK
+ * There is no need to stash the image twice
*/
- public function checkWarnings() {
- return array();
+ public function stashSession() {
+ if ( !empty( $this->mSessionKey ) )
+ return $this->mSessionKey;
+ return parent::stashSession();
}
/**
public function initializeFromRequest( &$request ) {
$desiredDestName = $request->getText( 'wpDestFile' );
if( !$desiredDestName )
- $desiredDestName = $request->getText( 'wpUploadFile' );
+ $desiredDestName = $request->getText( 'wpUploadFileURL' );
return $this->initialize(
$desiredDestName,
$request->getVal( 'wpUploadFileURL' ),
'upload' => 'Upload file',
'uploadbtn' => 'Upload file',
'reuploaddesc' => 'Cancel upload and return to the upload form',
+'upload-tryagain' => 'Submit modified file description',
'uploadnologin' => 'Not logged in',
'uploadnologintext' => 'You must be [[Special:UserLogin|logged in]] to upload files.',
'upload_directory_missing' => 'The upload directory ($1) is missing and could not be created by the webserver.',
You should check that file's deletion history before proceeding to re-upload it.",
'successfulupload' => 'Successful upload',
'uploadwarning' => 'Upload warning',
+'uploadwarning-text' => 'Please modify the file description below and try again.',
'savefile' => 'Save file',
'uploadedimage' => 'uploaded "[[$1]]"',
'overwroteimage' => 'uploaded a new version of "[[$1]]"',