From 7f8036208a7a8d54c3e15b9c123c9a0d4f09e5f5 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Wed, 21 Oct 2009 21:29:05 +0000 Subject: [PATCH] * Bump wgStyleVersion for various upload javascript edits in this revision and r57868. * Show the upload footer message outside of the form * Document some remaining SpecialUpload functions * Move upload edittools to just below the textarea * Add the license preview table row in javascript entirely * Fill in a forgotten message --- includes/DefaultSettings.php | 2 +- includes/specials/SpecialUpload.php | 83 +++++++++++++++-------------- languages/messages/MessagesEn.php | 2 +- skins/common/upload.js | 21 +++++++- 4 files changed, 64 insertions(+), 44 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 94f41031f3..b8bbf6759a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1605,7 +1605,7 @@ $wgCacheEpoch = '20030516000000'; * to ensure that client-side caches do not keep obsolete copies of global * styles. */ -$wgStyleVersion = '244'; +$wgStyleVersion = '245'; # Server-side caching: diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index d3aeeb9161..3317b5ed47 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -183,6 +183,8 @@ class SpecialUpload extends SpecialPage { * @return UploadForm */ protected function getUploadForm( $message = '', $sessionKey = '' ) { + global $wgOut; + # Initialize form $form = new UploadForm( $this->watchCheck(), $this->mForReUpload, $sessionKey ); $form->setTitle( $this->getTitle() ); @@ -196,12 +198,20 @@ class SpecialUpload extends SpecialPage { $form->addPreText( '
' . wfMsgExt( 'uploadtext', 'parse' ) . '
'); # Add upload error message $form->addPreText( $message ); + + # Add footer to form + $uploadFooter = wfMsgNoTrans( 'uploadfooter' ); + if ( $uploadFooter != '-' && !wfEmptyMsg( 'uploadfooter', $uploadFooter ) ) { + $form->addPostText( '\n" ); + } + + return $form; - return $form; } /** - * TODO: DOCUMENT + * Shows the "view X deleted revivions link"" */ protected function showViewDeletedLinks() { global $wgOut, $wgUser; @@ -644,7 +654,10 @@ class UploadForm extends HTMLForm { } /** - * + * Get the descriptor of the fieldset that contains the file source + * selection. The section is 'source' + * + * @return array Descriptor array */ protected function getSourceSection() { global $wgLang, $wgUser, $wgRequest; @@ -710,8 +723,11 @@ class UploadForm extends HTMLForm { return $descriptor; } + /** - * + * Get the messages indicating which extensions are preferred and prohibitted. + * + * @return string HTML string containing the message */ protected function getExtensionsMessage() { # Print a list of allowed file extensions, if so configured. We ignore @@ -745,7 +761,10 @@ class UploadForm extends HTMLForm { } /** - * + * 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; @@ -773,6 +792,10 @@ class UploadForm extends HTMLForm { 'cols' => $cols, 'rows' => 8, ), + 'EditTools' => array( + 'type' => 'edittools', + 'section' => 'description', + ), 'License' => array( 'type' => 'select', 'class' => 'Licenses', @@ -784,13 +807,6 @@ class UploadForm extends HTMLForm { if ( $this->mForReUpload ) $descriptor['DestFile']['readonly'] = true; - global $wgUseAjax, $wgAjaxLicensePreview; - if ( $wgUseAjax && $wgAjaxLicensePreview ) - $descriptor['AjaxLicensePreview'] = array( - 'class' => 'UploadAjaxLicensePreview', - 'section' => 'description' - ); - global $wgUseCopyrightUpload; if ( $wgUseCopyrightUpload ) { $descriptor['UploadCopyStatus'] = array( @@ -811,7 +827,10 @@ class UploadForm extends HTMLForm { } /** - * + * 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 $wgOut; @@ -829,26 +848,14 @@ class UploadForm extends HTMLForm { 'label-message' => 'ignorewarnings', 'section' => 'options', ), - 'EditTools' => array( - 'type' => 'edittools', - 'section' => 'options', - ), ); - $uploadFooter = wfMsgNoTrans( 'uploadfooter' ); - if ( $uploadFooter != '-' && !wfEmptyMsg( 'uploadfooter', $uploadFooter ) ) - $descriptor['UploadFooter'] = array( - 'type' => 'info', - 'id' => 'mw-upload-footer-message', - 'default' => $wgOut->parse( $uploadFooter ), - ); - return $descriptor; } /** - * + * Add the upload JS and show the form. */ public function show() { $this->addUploadJS(); @@ -856,7 +863,10 @@ class UploadForm extends HTMLForm { } /** - * + * Add upload JS to $wgOut + * + * @param bool $autofill Whether or not to autofill the destination + * filename text box */ protected function addUploadJS( $autofill = true ) { global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview; @@ -886,6 +896,11 @@ class UploadForm extends HTMLForm { } } + /** + * Empty function; submission is handled elsewhere. + * + * @return bool false + */ function trySubmit() { return false; } @@ -893,7 +908,7 @@ class UploadForm extends HTMLForm { } /** - * TODO: DOCUMENT + * A form field that contains a radio box in the label */ class UploadSourceField extends HTMLTextField { function getLabelHtml() { @@ -921,15 +936,3 @@ class UploadSourceField extends HTMLTextField { } } -/** - * TODO: Document - * TODO: This can be migrated to JS only - */ -class UploadAjaxLicensePreview extends HTMLFormField { - public function getTableRow( $value ) { - return "\n"; - } - public function getInputHTML( $value ) { - return ''; - } -} \ No newline at end of file diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index d83bcf41da..234966c8fd 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2131,7 +2131,7 @@ Please check the file and upload again.', 'destfilename' => 'Destination filename:', 'upload-maxfilesize' => 'Maximum file size: $1', 'upload-description' => 'File description', -'upload-options' => '', # do not translate or duplicate this message to other languages +'upload-options' => 'Upload options', 'watchthisupload' => 'Watch this file', 'filewasdeleted' => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.', diff --git a/skins/common/upload.js b/skins/common/upload.js index 3d79209a71..bc051581ea 100644 --- a/skins/common/upload.js +++ b/skins/common/upload.js @@ -55,8 +55,25 @@ function wgUploadSetup() { optionsTable.appendChild( row ); } - // License selector check - document.getElementById( 'wpLicense' ).onchange = licenseSelectorCheck; + if ( wgAjaxLicensePreview ) { + // License selector check + document.getElementById( 'wpLicense' ).onchange = licenseSelectorCheck; + + // License selector table row + var wpLicense = document.getElementById( 'wpLicense' ); + var wpLicenseRow = wpLicense.parentNode.parentNode; + var wpLicenseTbody = wpLicenseRow.parentNode; + + var row = document.createElement( 'tr' ); + var td = document.createElement( 'td' ); + row.appendChild( td ); + td = document.createElement( 'td' ); + td.id = 'mw-license-preview'; + row.appendChild( td ); + + wpLicenseTbody.insertBefore( row, wpLicenseRow.nextSibling ); + } + // fillDestFile setup for ( var i = 0; i < wgUploadSourceIds.length; i++ ) -- 2.20.1