// Note: if we work with the api.php interface, we can have separate
// data for the edit summary and the description page, which is far
// better than the way the index.php interface does it.
// TO DO: need to actually define an input element for a manually
// entered edit summary. Must be obligatory when overwriting files.
// In other cases we'll use an automatic edit summary.
// ===================================================================
fuwGlobal.prototype.getEditSummary = function {
var opts = this.opts;
return (
(opts.EditSummary ? (opts.EditSummary + ' (File Upload Wizard)') : null)||
("Uploading " +
(
(opts.OptionOwnWork ? 'a self-made file ' : false) ||
(opts.OptionThirdParty ? 'a free file from somebody else ' : false) ||
(opts.OptionFreeWebsite ? 'a file from a free published source ' : false) ||
(opts.OptionPDOld ? 'an old public-domain work ' : false) ||
(opts.OptionPDOther ? 'a public-domain item ' : false) ||
(opts.OptionNFSubject ? 'a non-free work, as object of commentary ' : false) ||
(opts.OptionNF3D ? 'a depiction of a non-free 3D artwork ' : false) ||
(opts.OptionNFExcerpt ? 'an excerpt from a non-free work ' : false) ||
(opts.OptionNFCover ? 'a piece of non-free cover art ' : false) ||
(opts.OptionNFLogo ? 'a non-free logo ' : false) ||
(opts.OptionNFPortrait ? 'a non-free historic portrait ' : false) ||
(opts.OptionNFMisc ? 'a non-free file ' : "")
+
("using File Upload Wizard")
));
};  
function fuwPackInfo(text, forCommons) {
if (forCommons) {
// reformat wikilinks embedded in description fields to adapt them for Commons
text = text.replace(/\[\[([^\]]+)\]\]/g,
function(str, p1, offset, s) {  
// mark File links as local
if (p1.match(/^:(File|Image):/)) {
return ":en" + p1 + "";
}
// leave prefixed links unchanged:
else if (p1.match(/^:[\w\-]+:/)) {
return str;
}
// if the link is piped, add a prefix only
else if (p1.match(/.+\|/)) {
return ":en:" + p1 + "";
}
// introduce a pipe
else {
return "" + p1 + "";
}
}
);
return "";
} else return text;
}  
// ================================================================
// This is the main method called by the event handler for the
// (experimental) submit button. Its main task is to collect the
// input into a single string of wikitext for the description page.
// ================================================================
fuwGlobal.prototype.collectInput = function {
var opts = this.opts;  
// object representing template fields for filling in
// the description template. Pre-loaded with some
// standard settings:
var descFields = this.descFields = {
'Description' : opts.InputDesc,
'Author' : opts.Author,
'Date' : opts.Date,
'Source' : opts.Source
};
// "other information" (outside the template)
this.otherInfo = null;  
if (opts.OptionNonFree) {
descFields.Article = opts.NFArticle;
}  
// add/modify option-specific fields:
switch (opts.MainOption) {
case 'OptionOwnWork':  
// use standard "source" field for optional "how created?" and
// "previously published" input fields.
descFields.Source = fuwAppendLines([
(opts.OwnWorkCreation || ""),
"
\n",
fuwSurroundString("**Previously published:** ", opts.OwnWorkPublication)]);
var username = mw.user.getName;
descFields.Author = * + username + *;
break;  
case 'OptionThirdParty':  
// use standard "permission" field for a compilation of the
// "permission" input field and the various "evidence" options
var evidence = (
opts.ThirdPartyEvidenceOptionLink ?
("The license statement can be found online at: " + opts.ThirdPartyEvidenceLink) :
(opts.ThirdPartyEvidenceOptionOTRS ?
("The license agreement has been forwarded to OTRS." +
fuwSurroundString(" Ticket: ", opts.ThirdPartyOTRSTicket) + "\{\{OTRS pending|year=" + fuwSubst("CURRENTYEAR") +
"|month=" + fuwSubst("CURRENTMONTH") +
"|day=" + fuwSubst("CURRENTDAY2") + "\}\}") :
(opts.ThirdPartyEvidenceOptionOTRSForthcoming ?
"The license agreement will be forwarded to OTRS shortly. \{\{OTRS pending|year=" + fuwSubst("CURRENTYEAR") +
"|month=" + fuwSubst("CURRENTMONTH") +
"|day=" + fuwSubst("CURRENTDAY2") + "\}\}" :
(opts.ThirdPartyEvidenceOptionNone ?
"Will be provided on request." : null))));
descFields.Permission = fuwAppendLines([
opts.ThirdPartyPermission,
"
\n",
fuwSurroundString("**Evidence:** ", evidence)]);
break;  
case 'OptionFreeWebsite':
descFields.Permission = opts.Permission;
break;  
case 'OptionPDOld':
// add "lifetime" input to "author" field
descFields.Author = fuwAppendLines([
opts.Author,
"
\n",
fuwSurroundString("(Life time: ", opts.PDOldAuthorLifetime, ")")
]);  
// combine original and direct source into standard "source" field:
descFields.Source = fuwAppendLines([
fuwSurroundString("**Original publication**: ", opts.Publication),
"
\n",
fuwSurroundString("**Immediate source**: ", opts.Source)
]);  
// no standard tag available for "lack-of-registration" PD-US. Need
// to put this into the "permission" field
if (opts.PDFormality)
descFields.Permission =
"Copyright expired because the work was published without a copyright " +
"notice and/or without the necessary copyright registration.";  
// add optional "explanation" input to "permission" field
if (opts.PDOldPermission) {
descFields.Permission = fuwAppendLines([
descFields.Permission,
"\n\n",
opts.PDOldPermission
]);
}
break;  
case 'OptionPDOther':
// Need "permission" field in case of "official item" option
if (opts.PDOtherOfficial)
descFields.Permission = opts.PDOfficialPermission;
break;  
case 'OptionNFSubject':
// most FUR elements can be automatically provided:
descFields.Purpose = (
opts.NFSubjectCheckDedicated ?
("For visual identification of the object of the article. " +
"The article as a whole is dedicated specifically to a discussion of this work.") :
(opts.NFSubjectCheckDiscussed ?
("To support encyclopedic discussion of this work in this article. " +
"The illustration is specifically needed to support the following point(s): " +
"
\n" + opts.NFSubjectPurpose) : null)
);
// I hate FURs filled with trivial/predictable/redundant verbiage,
// so we'll just cut it short. And don't anybody dare complain that
// that's not a valid FUR.
descFields.Replaceability = "n.a.";
descFields.Commercial = "n.a.";
break;  
case 'OptionNF3D':
// complex case: we need to assemble attribution and FUR both for the
// original 3D work and for the photographic depiction. Both might be
// non-free.
descFields.Author = fuwAppendLines([
fuwSurroundString("**Original work:** ", opts.NF3DCreator),
"
\n",
fuwSurroundString("**Depiction:** ", opts.Author)
]);
descFields.Date = fuwAppendLines([
fuwSurroundString("**Original work:** ", opts.NF3DOrigDate),
"
\n",
fuwSurroundString("**Depiction:** ", opts.Date)
]);
descFields.Purpose = (
opts.NF3DCheckDedicated ?
("For visual identification of the object of the article. " +
"The article as a whole is dedicated specifically to a discussion of this work.") :
(opts.NF3DCheckDiscussed ?
("To support encyclopedic discussion of this work in this article. " +
"The illustration is specifically needed to support the following point(s): " +
"
\n" + opts.NF3DPurpose) : null)
);
descFields.Replaceability = "n.a.";
descFields.Commercial = "n.a.";
descFields["Other information"] = (
opts.NF3DOptionSame ?
("The image was created and published by the same author who also " +
"holds the rights to the original object, and no alternative depiction " +
"could be suitably created.") :
("The author of the image has released the photographic work under a " +
"free license, or it is in the public domain: " + opts.NF3DPermission)
);
break;  
case 'OptionNFExcerpt':
// FURs for screenshots etc. don't normally need to bother
// about replaceability (with free images) and with commercial role,
// but do need to bother about purpose and about replaceability with text.
descFields.Purpose = opts.NFPurpose;
descFields.Replaceability_text = opts.NFReplaceableText;
descFields.Replaceability = "n.a.";
descFields.Commercial = "n.a.";
break;  
case 'OptionNFCover':
// cover art gets standard rationales.