User:Yobot/Football
Appearance
// Updates parameters in Infobox football biography. Archived for historical reasons.
private static readonly Regex Templ = Tools.NestedTemplateRegex(new List<string>("Infobox football biography".Split(',')));
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
Skip = false;
Summary = "Infobox parameter standardisation";
foreach(Match m in Templ.Matches(ArticleText))
{
string TemplCall = m.Value, newValue = m.Value;
newValue = Tools.RenameTemplateParameter(newValue, "playername", "name");
newValue = Tools.RenameTemplateParameter(newValue, "dateofbirth", "birth_date");
newValue = Tools.RenameTemplateParameter(newValue, "dateofdeath", "death_date");
string cityofbirth = Tools.GetTemplateParameterValue(TemplCall, "cityofbirth");
string countryofbirth = Tools.GetTemplateParameterValue(TemplCall, "countryofbirth");
string cityofdeath = Tools.GetTemplateParameterValue(TemplCall, "cityofdeath");
string countryofdeath = Tools.GetTemplateParameterValue(TemplCall, "countryofdeath");
if (cityofbirth.Length+countryofbirth.Length==0)
{
newValue = Tools.RemoveTemplateParameter(newValue, "cityofbirth");
newValue = Tools.RemoveTemplateParameter(newValue, "countryofbirth");
}
if (cityofbirth.Length==0 && countryofbirth.Length > 0)
{
newValue = Tools.RenameTemplateParameter(newValue, "countryofbirth", "birth_place");
newValue = Tools.RemoveTemplateParameter(newValue, "cityofbirth");
}
if (cityofbirth.Length > 0 && countryofbirth.Length == 0)
{
newValue = Tools.RenameTemplateParameter(newValue, "cityofbirth", "birth_place");
newValue = Tools.RemoveTemplateParameter(newValue, "countryofbirth");
}
if (cityofdeath.Length+countryofdeath.Length==0)
{
newValue = Tools.RemoveTemplateParameter(newValue, "cityofdeath");
newValue = Tools.RemoveTemplateParameter(newValue, "countryofdeath");
}
if (cityofdeath.Length==0 && countryofdeath.Length > 0)
{
newValue = Tools.RenameTemplateParameter(newValue, "countryofdeath", "death_place");
newValue = Tools.RemoveTemplateParameter(newValue, "cityofdeath");
}
if (cityofdeath.Length > 0 && countryofdeath.Length == 0)
{
newValue = Tools.RenameTemplateParameter(newValue, "cityofdeath", "death_place");
newValue = Tools.RemoveTemplateParameter(newValue, "countryofdeath");
}
if (cityofbirth.Length > 0 && countryofbirth.Length > 0)
{
string birthplace = cityofbirth+", "+countryofbirth;
string birthdate = Tools.GetTemplateParameterValue(TemplCall, "birth_date") + Tools.GetTemplateParameterValue(TemplCall, "dateofbirth");
birthdate=birthdate +"\r\n| birth_place = "+birthplace;
newValue = Tools.SetTemplateParameterValue(newValue, "birth_date",birthdate,false);
newValue = Tools.RemoveTemplateParameter(newValue, "cityofbirth");
newValue = Tools.RemoveTemplateParameter(newValue, "countryofbirth");
}
if (cityofdeath.Length > 0 && countryofdeath.Length > 0)
{
string deathplace = cityofdeath+", "+countryofdeath;
string deathdate = Tools.GetTemplateParameterValue(TemplCall, "death_date") + Tools.GetTemplateParameterValue(TemplCall, "dateofdeath");
deathdate=deathdate +"\r\n| death_place = "+deathplace;
newValue = Tools.SetTemplateParameterValue(newValue, "death_date",deathdate,false);
newValue = Tools.RemoveTemplateParameter(newValue, "cityofdeath");
newValue = Tools.RemoveTemplateParameter(newValue, "countryofdeath");
}
ArticleText = ArticleText.Replace(m.Value, newValue);
}
return ArticleText;
}