* Bump wgStyleVersion for various upload javascript edits in this revision and r57868.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 21 Oct 2009 21:29:05 +0000 (21:29 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Wed, 21 Oct 2009 21:29:05 +0000 (21:29 +0000)
* 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
includes/specials/SpecialUpload.php
languages/messages/MessagesEn.php
skins/common/upload.js

index 94f4103..b8bbf67 100644 (file)
@@ -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:
index d3aeeb9..3317b5e 100644 (file)
@@ -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( '<div id="uploadtext">' . wfMsgExt( 'uploadtext', 'parse' ) . '</div>');
                # Add upload error message
                $form->addPreText( $message );
+               
+               # Add footer to form
+               $uploadFooter = wfMsgNoTrans( 'uploadfooter' );
+               if ( $uploadFooter != '-' && !wfEmptyMsg( 'uploadfooter', $uploadFooter ) ) {
+                       $form->addPostText( '<div id="mw-upload-footer-message">'
+                               . $wgOut->parse( $uploadFooter ) . "</div>\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 "<tr><td></td><td id=\"mw-license-preview\"></td></tr>\n";
-       }
-       public function getInputHTML( $value ) {
-               return '';
-       }
-}
\ No newline at end of file
index d83bcf4..234966c 100644 (file)
@@ -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.',
index 3d79209..bc05158 100644 (file)
@@ -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++ )