ForeignStructuredUpload.prototype.getText = function () {
return (
'== {{int:filedesc}} ==\n' +
- '{{' +
- this.getTemplateName() +
+ '{{Information' +
'\n|description=' +
this.getDescriptions() +
'\n|date=' +
return this.date.toString();
};
- /**
- * Gets the name of the template to use for creating the file metadata.
- * Override in subclasses for other templates.
- *
- * @private
- * @return {string}
- */
- ForeignStructuredUpload.prototype.getTemplateName = function () {
- return 'Information';
- };
-
/**
* Fetches the wikitext for any descriptions that have been added
* to the upload.
ForeignStructuredUpload.prototype.getCategories = function () {
var i, cat, categoryLinks = [];
+ if ( this.categories.length === 0 ) {
+ return '{{subst:unc}}';
+ }
+
for ( i = 0; i < this.categories.length; i++ ) {
cat = this.categories[ i ];
categoryLinks.push( '[[Category:' + cat + ']]' );
* @return {string}
*/
ForeignStructuredUpload.prototype.getUser = function () {
- var username = mw.config.get( 'wgUserName' );
- // Do not localise 'User:', we don't know the language of target wiki
- return '[[User:' + username + '|' + username + ']]';
+ var username, namespace;
+ // Do not localise, we don't know the language of target wiki
+ namespace = 'User';
+ username = mw.config.get( 'wgUserName' );
+ if ( !username ) {
+ // The user is not logged in locally. However, they might be logged in on the foreign wiki.
+ // We should record their username there. (If they're not logged in there either, this will
+ // record the IP address.) It's also possible that the user opened this dialog, got an error
+ // about not being logged in, logged in in another browser tab, then continued uploading.
+ username = '{{subst:REVISIONUSER}}';
+ }
+ return '[[' + namespace + ':' + username + '|' + username + ']]';
};
mw.ForeignStructuredUpload = ForeignStructuredUpload;