mediawiki.ForeignStructuredUpload: Always use '|1=' for description templates
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.ForeignStructuredUpload.js
index 3a70a66..0117cea 100644 (file)
         *
         * @inheritdoc
         */
-       function ForeignStructuredUpload( targetHost, apiconfig ) {
+       function ForeignStructuredUpload( target, apiconfig ) {
                this.date = undefined;
                this.descriptions = [];
                this.categories = [];
 
-               mw.ForeignUpload.call( this, targetHost, apiconfig );
+               mw.ForeignUpload.call( this, target, apiconfig );
        }
 
        OO.inheritClass( ForeignStructuredUpload, mw.ForeignUpload );
                }
        };
 
+       /**
+        * Empty the list of categories for the upload.
+        */
+       ForeignStructuredUpload.prototype.clearCategories = function () {
+               this.categories = [];
+       };
+
        /**
         * Add a description to the upload.
         *
                } );
        };
 
+       /**
+        * Empty the list of descriptions for the upload.
+        */
+       ForeignStructuredUpload.prototype.clearDescriptions = function () {
+               this.descriptions = [];
+       };
+
        /**
         * Set the date of creation for the upload.
         *
@@ -70,6 +84,7 @@
         */
        ForeignStructuredUpload.prototype.getText = function () {
                return (
+                       '== {{int:filedesc}} ==\n' +
                        '{{' +
                        this.getTemplateName() +
                        '\n|description=' +
                        '\n|date=' +
                        this.getDate() +
                        '\n|source=' +
-                       this.getUser() +
+                       this.getSource() +
                        '\n|author=' +
                        this.getUser() +
                        '\n}}\n\n' +
+                       '== {{int:license-header}} ==\n' +
                        this.getLicense() +
                        '\n\n' +
                        this.getCategories()
 
                for ( i = 0; i < this.descriptions.length; i++ ) {
                        desc = this.descriptions[ i ];
-                       templateCalls.push( '{{' + desc.language + '|' + desc.text + '}}' );
+                       templateCalls.push( '{{' + desc.language + '|1=' + desc.text + '}}' );
                }
 
                return templateCalls.join( '\n' );
        };
 
        /**
-        * Gets the wikitext for the license of the upload. Abstract for now.
+        * Gets the wikitext for the license of the upload.
         *
         * @private
         * @return {string}
         */
        ForeignStructuredUpload.prototype.getLicense = function () {
-               return '';
+               // Make sure this matches the messages for different targets in
+               // mw.ForeignStructuredUpload.BookletLayout.prototype.renderUploadForm
+               return this.target === 'shared' ? '{{self|cc-by-sa-4.0}}' : '';
+       };
+
+       /**
+        * Get the source. This should be some sort of localised text for "Own work".
+        *
+        * @private
+        * @return {string}
+        */
+       ForeignStructuredUpload.prototype.getSource = function () {
+               return '{{own}}';
        };
 
        /**
         * @return {string}
         */
        ForeignStructuredUpload.prototype.getUser = function () {
-               return mw.config.get( 'wgUserName' );
+               var username = mw.config.get( 'wgUserName' );
+               // Do not localise 'User:', we don't know the language of target wiki
+               return '[[User:' + username + '|' + username + ']]';
        };
 
        mw.ForeignStructuredUpload = ForeignStructuredUpload;