private bool ReplaceTemplateParm(string parameterName, string parameterValue, Article theArticle,
bool logItAndUpdateEditSummary, bool dontChangeIfSet)
{
string existingValue = WikiRegexes.Comments.Replace(Parameters[parameterName].Value, "").Trim();
// trim still needed because altho main regex shouldn't give us spaces at the end of vals any more, the .Replace here might
// Contains parameter with a different value
if (existingValue != parameterValue)
{
// Contains parameter with a different value, and _
if (string.IsNullOrEmpty(existingValue) || !dontChangeIfSet)
{
// we want to change it; or contains an empty parameter
Parameters[parameterName].Value = parameterValue;
theArticle.ArticleHasAMajorChange();
if (logItAndUpdateEditSummary)
{
if (string.IsNullOrEmpty(existingValue))
{
theArticle.ParameterAdded(parameterName, parameterValue);
}
else
{
theArticle.DoneReplacement(parameterName + "=" + existingValue, parameterValue);
}
}
return true;
// Contains param with a different value, and we don't want to change it
}
}
// Else: Already contains parameter and correct value; no need to change
return false;
}