public string ProcessArticle(IAutoWikiBrowser sender, IProcessArticleEventArgs eventargs)
{
string res;
if (!ActivePlugins.Any())
return eventargs.ArticleText;
Article theArticle;
StatusText.Text = "Processing " + eventargs.ArticleTitle;
AWBForm.TraceManager.ProcessingArticle(eventargs.ArticleTitle, eventargs.NameSpaceKey);
foreach (PluginBase p in ActivePlugins)
{
try
{
if (!p.AmReady && p.AmGeneric)
{
MessageBox.Show(
"The generic template plugin \"" + p.PluginShortName + "\"isn't properly configured.",
"Can't start", MessageBoxButtons.OK, MessageBoxIcon.Error);
StopAWB();
goto SkipOrStop;
}
}
catch
{
StopAWB();
goto SkipOrStop;
}
}
switch (eventargs.NameSpaceKey)
{
case Namespace.Article:
if (_pluginSettings.ManuallyAssess)
{
if (eventargs.Exists == Exists.Yes)
{
StatusText.Text += ": Click Preview to read the article; " +
"click Save or Ignore to load the assessments form";
_assessmentsObject.ProcessMainSpaceArticle(eventargs.ArticleTitle);
eventargs.EditSummary = "Clean up";
goto SkipOrStop;
}
//FIXME
var eaArticleES = eventargs.EditSummary;
var eaArticleSkip = eventargs.Skip;
res = Skipping(ref eaArticleES, "", SkipReason.ProcessingMainArticleDoesntExist,
eventargs.ArticleText, ref eaArticleSkip);
eventargs.EditSummary = eaArticleES;
eventargs.Skip = eaArticleSkip;
goto ExitMe;
}
goto SkipBadNamespace;
//break;
case Namespace.Talk:
AsyncApiEdit editor = AWBForm.TheSession.Editor.Clone();
editor.Open(Tools.ConvertFromTalk(eventargs.ArticleTitle), false);
editor.Wait();
if (!editor.Page.Exists)
{
// FIXME
var eaNotExistsES = eventargs.EditSummary;
var eaNotExistsSkip = eventargs.Skip;
res = Skipping(ref eaNotExistsES, "", SkipReason.ProcessingTalkPageArticleDoesntExist,
eventargs.ArticleText,
ref eaNotExistsSkip, eventargs.ArticleTitle);
eventargs.EditSummary = eaNotExistsES;
eventargs.Skip = eaNotExistsSkip;
}
else
{
theArticle = new Article(eventargs.ArticleText, eventargs.ArticleTitle, eventargs.NameSpaceKey);
bool reqPhoto = ReqPhotoParamNeeded(theArticle);
if (_pluginSettings.ManuallyAssess)
{
// reqphoto byref
if (!_assessmentsObject.ProcessTalkPage(theArticle, _pluginSettings, ref reqPhoto))
{
eventargs.Skip = true;
goto SkipOrStop;
}
}
else
{
reqPhoto = ProcessTalkPageAndCheckWeAddedReqPhotoParam(theArticle, reqPhoto);
// We successfully added a reqphoto param
}
// FIXME
var eaTalkSkip = eventargs.Skip;
var eaTalkES = eventargs.EditSummary;
res = FinaliseArticleProcessing(theArticle, ref eaTalkSkip, ref eaTalkES, eventargs.ArticleText,
reqPhoto);
eventargs.Skip = eaTalkSkip;
eventargs.EditSummary = eaTalkES;
}
break;
case Namespace.CategoryTalk:
case 101: // 101 is Portal Talk
case Namespace.ProjectTalk:
case Namespace.TemplateTalk:
case Namespace.FileTalk:
if (_pluginSettings.ManuallyAssess)
{
MessageBox.Show(
"The plugin has received a non-standard namespace talk page in " +
"manual assessment mode. Please remove this item from the list and start again.",
"Manual Assessments", MessageBoxButtons.OK, MessageBoxIcon.Error);
StopAWB();
goto SkipOrStop;
}
theArticle = new Article(eventargs.ArticleText, eventargs.ArticleTitle, eventargs.NameSpaceKey);
foreach (PluginBase p in ActivePlugins)
{
p.ProcessTalkPage(theArticle, Classification.Code, Importance.NA, false, false, false,
ProcessTalkPageMode.NonStandardTalk, false);
if (theArticle.PluginManagerGetSkipResults == SkipResults.SkipBadTag)
break; // TODO: might not be correct. Was : Exit For
}
// FIXME
var eaMiscSkip = eventargs.Skip;
var eaMiscES = eventargs.EditSummary;
res = FinaliseArticleProcessing(theArticle, ref eaMiscSkip, ref eaMiscES, eventargs.ArticleText,
false);
eventargs.Skip = eaMiscSkip;
eventargs.EditSummary = eaMiscES;
break;
default:
goto SkipBadNamespace;
}
if (!eventargs.Skip)
{
// TempHackInsteadOfDefaultSettings:
if (AWBForm.EditSummaryComboBox.Text == "clean up")
AWBForm.EditSummaryComboBox.Text = "Tagging";
}
ExitMe:
if (!_pluginSettings.ManuallyAssess)
DefaultStatusText();
AWBForm.TraceManager.Flush();
return res;
SkipBadNamespace:
// FIXME
var eaES = eventargs.EditSummary;
var eaSkip = eventargs.Skip;
res = Skipping(ref eaES, "", SkipReason.BadNamespace, eventargs.ArticleText, ref eaSkip);
eventargs.EditSummary = eaES;
eventargs.Skip = eaSkip;
goto ExitMe;
SkipOrStop:
res = eventargs.ArticleText;
goto ExitMe;
}