- * Get the descriptor of the fieldset that contains the file description
- * input. The section is 'description'
- *
- * @return array Descriptor array
- */
- protected function getDescriptionSection() {
- global $wgUser, $wgOut;
-
- $cols = intval( $wgUser->getOption( 'cols' ) );
- if( $wgUser->getOption( 'editwidth' ) ) {
- $wgOut->addInlineStyle( '#mw-htmlform-description { width: 100%; }' );
- }
-
- $descriptor = array(
- 'DestFile' => array(
- 'type' => 'text',
- 'section' => 'description',
- 'id' => 'wpDestFile',
- 'label-message' => 'destfilename',
- 'size' => 60,
- 'default' => $this->mDestFile,
- # FIXME: hack to work around poor handling of the 'default' option in HTMLForm
- 'nodata' => strval( $this->mDestFile ) !== '',
- ),
- 'UploadDescription' => array(
- 'type' => 'textarea',
- 'section' => 'description',
- 'id' => 'wpUploadDescription',
- 'label-message' => $this->mForReUpload
- ? 'filereuploadsummary'
- : 'fileuploadsummary',
- 'cols' => $cols,
- 'rows' => 8,
- )
- );
- if ( $this->mTextAfterSummary ) {
- $descriptor['UploadFormTextAfterSummary'] = array(
- 'type' => 'info',
- 'section' => 'description',
- 'default' => $this->mTextAfterSummary,
- 'raw' => true,
- );
- }
-
- $descriptor += array(
- 'EditTools' => array(
- 'type' => 'edittools',
- 'section' => 'description',
- ),
- 'License' => array(
- 'type' => 'select',
- 'class' => 'Licenses',
- 'section' => 'description',
- 'id' => 'wpLicense',
- 'label-message' => 'license',
- ),
- );
- if ( $this->mForReUpload )
- $descriptor['DestFile']['readonly'] = true;
-
- global $wgUseCopyrightUpload;
- if ( $wgUseCopyrightUpload ) {
- $descriptor['UploadCopyStatus'] = array(
- 'type' => 'text',
- 'section' => 'description',
- 'id' => 'wpUploadCopyStatus',
- 'label-message' => 'filestatus',
- );
- $descriptor['UploadSource'] = array(
- 'type' => 'text',
- 'section' => 'description',
- 'id' => 'wpUploadSource',
- 'label-message' => 'filesource',
- );
- }
-
- return $descriptor;
- }
-
- /**
- * Get the descriptor of the fieldset that contains the upload options,
- * such as "watch this file". The section is 'options'
- *
- * @return array Descriptor array
- */
- protected function getOptionsSection() {
- global $wgUser, $wgOut;
-
- if( $wgUser->isLoggedIn() ) {
- $descriptor = array(
- 'Watchthis' => array(
- 'type' => 'check',
- 'id' => 'wpWatchthis',
- 'label-message' => 'watchthisupload',
- 'section' => 'options',
- 'default' => $wgUser->getOption( 'watchcreations' ),
- )
- );
- }
- if( !$this->mHideIgnoreWarning ) {
- $descriptor['IgnoreWarning'] = array(
- 'type' => 'check',
- 'id' => 'wpIgnoreWarning',
- 'label-message' => 'ignorewarnings',
- 'section' => 'options',
- );
- }
-
- $descriptor['wpDestFileWarningAck'] = array(
- 'type' => 'hidden',
- 'id' => 'wpDestFileWarningAck',
- 'default' => $this->mDestWarningAck ? '1' : '',
- );
-
- if ( $this->mForReUpload ) {
- $descriptor['wpForReUpload'] = array(
- 'type' => 'hidden',
- 'id' => 'wpForReUpload',
- 'default' => '1',
- );
- }
-
- return $descriptor;
-
- }
-
- /**
- * Add the upload JS and show the form.
- */
- public function show() {
- $this->addUploadJS();
- parent::show();
- }
-
- /**
- * Add upload JS to $wgOut
- *
- * @param bool $autofill Whether or not to autofill the destination
- * filename text box
- */
- protected function addUploadJS( ) {
- global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI;
- global $wgOut;
-
- $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
- $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
-
- $scriptVars = array(
- 'wgAjaxUploadDestCheck' => $useAjaxDestCheck,
- 'wgAjaxLicensePreview' => $useAjaxLicensePreview,
- 'wgUploadAutoFill' => !$this->mForReUpload &&
- // If we received mDestFile from the request, don't autofill
- // the wpDestFile textbox
- $this->mDestFile === '',
- 'wgUploadSourceIds' => $this->mSourceIds,
- );
-
- $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
-
- // For <charinsert> support
- $wgOut->addScriptFile( 'edit.js' );
- $wgOut->addScriptFile( 'upload.js' );
- }
-
- /**
- * Empty function; submission is handled elsewhere.
- *
- * @return bool false