An object which wraps around a collection of template parameters
Exemplo n.º 1
0
        // Where we (possibly) add our template to an existing shell:
        internal void PrependTemplateOrWriteIntoShell(Templating Template, string ParameterBreak, string Text)
        {
            if (WeFoundBannerShells == BannerShellsEnum.NotChecked)
            {
                WeFoundBannerShells = WikiProjectBannerShellRegex.IsMatch(AlteredArticleText)
                            ? BannerShellsEnum.FoundWikiProjectBannerShell
                            : BannerShellsEnum.NoneFound;
            }

            Text += Template.ParametersToString(ParameterBreak);

            switch (WeFoundBannerShells)
            {
            case BannerShellsEnum.FoundWikiProjectBannerShell:
                MatchEvaluatorString = Text;

                AlteredArticleText   = WikiProjectBannerShellRegex.Replace(AlteredArticleText, WPBSRegexMatchEvaluator, 1);
                MatchEvaluatorString = null;
                break;

            case BannerShellsEnum.NoneFound:
                AlteredArticleText = Text + AlteredArticleText;
                break;
            }
        }
Exemplo n.º 2
0
        protected internal bool ProcessTalkPage(Article article, Classification classification, Importance importance,
                                                bool forceNeedsInfobox, bool forceNeedsAttention, bool removeAutoStub,
                                                ProcessTalkPageMode processTalkPageMode, bool addReqPhotoParm)
        {
            bool badTemplate = false;
            bool res         = false;

            TheArticle = article;

            if (SkipIfContains())
            {
                article.PluginIHaveFinished(SkipResults.SkipRegex, PluginShortName);
            }
            else
            {
                // MAIN
                string originalArticleText = article.AlteredArticleText;

                Template = new Templating();
                article.AlteredArticleText = MainRegex.Replace(article.AlteredArticleText, MatchEvaluator);

                if (Template.BadTemplate)
                {
                    badTemplate = true;
                }
                else if (Template.FoundTemplate)
                {
                    // Even if we've found a good template bizarrely the page could still contain a bad template too
                    if (SecondChanceRegex.IsMatch(article.AlteredArticleText) || TemplateFound())
                    {
                        badTemplate = true;
                    }
                }
                else
                {
                    if (SecondChanceRegex.IsMatch(originalArticleText))
                    {
                        badTemplate = true;
                    }
                    else
                    {
                        TemplateNotFound();
                    }
                }

                // OK, we're in business:
                res = true;
                if (HasReqPhotoParam && addReqPhotoParm)
                {
                    ReqPhoto();
                }

                ProcessArticleFinish();
                if (processTalkPageMode != ProcessTalkPageMode.Normal)
                {
                    ProcessArticleFinishNonStandardMode(classification, importance, forceNeedsInfobox,
                                                        forceNeedsAttention, removeAutoStub, processTalkPageMode);
                }

                if (TheArticle.ProcessIt)
                {
                    TemplateWritingAndPlacement();
                }
                else
                {
                    article.AlteredArticleText = originalArticleText;
                    article.PluginIHaveFinished(SkipResults.SkipNoChange, PluginShortName);
                }
            }

            if (badTemplate)
            {
                article.PluginIHaveFinished(SkipResults.SkipBadTag, PluginShortName);
                // TODO: We could get the template placeholder here
            }

            TheArticle = null;
            return(res);
        }
Exemplo n.º 3
0
        protected internal bool ProcessTalkPage(Article article, Classification classification, Importance importance,
            bool forceNeedsInfobox, bool forceNeedsAttention, bool removeAutoStub,
            ProcessTalkPageMode processTalkPageMode, bool addReqPhotoParm)
        {
            bool badTemplate = false;
            bool res = false;

            TheArticle = article;

            if (SkipIfContains())
            {
                article.PluginIHaveFinished(SkipResults.SkipRegex, PluginShortName);
            }
            else
            {
                // MAIN
                string originalArticleText = article.AlteredArticleText;

                Template = new Templating();
                article.AlteredArticleText = MainRegex.Replace(article.AlteredArticleText, MatchEvaluator);

                if (Template.BadTemplate)
                {
                    badTemplate = true;
                }
                else if (Template.FoundTemplate)
                {
                    // Even if we've found a good template bizarrely the page could still contain a bad template too
                    if (SecondChanceRegex.IsMatch(article.AlteredArticleText) || TemplateFound())
                    {
                        badTemplate = true;
                    }
                }
                else
                {
                    if (SecondChanceRegex.IsMatch(originalArticleText))
                    {
                        badTemplate = true;
                    }
                    else
                    {
                        TemplateNotFound();
                    }
                }

                // OK, we're in business:
                res = true;
                if (HasReqPhotoParam && addReqPhotoParm)
                {
                    ReqPhoto();
                }

                ProcessArticleFinish();
                if (processTalkPageMode != ProcessTalkPageMode.Normal)
                {
                    ProcessArticleFinishNonStandardMode(classification, importance, forceNeedsInfobox,
                        forceNeedsAttention, removeAutoStub);
                }

                if (TheArticle.ProcessIt)
                {
                    TemplateWritingAndPlacement();
                }
                else
                {
                    article.AlteredArticleText = originalArticleText;
                    article.PluginIHaveFinished(SkipResults.SkipNoChange, PluginShortName);
                }
            }

            if (badTemplate)
            {
                article.PluginIHaveFinished(SkipResults.SkipBadTag, PluginShortName);
                // TODO: We could get the template placeholder here
            }

            TheArticle = null;
            return res;
        }
Exemplo n.º 4
0
 // Add the template on the top. General fixes will put in a shell if it exists
 internal void PrependTemplate(Templating template, string parameterBreak, string text)
 {
     text += template.ParametersToString(parameterBreak);
     AlteredArticleText = text + AlteredArticleText;
 }
Exemplo n.º 5
0
 // Add the template on the top. General fixes will put in a shell if it exists
 internal void PrependTemplate(Templating template, string parameterBreak, string text)
 {
     text += template.ParametersToString(parameterBreak);
     AlteredArticleText = text + AlteredArticleText;
 }
Exemplo n.º 6
0
		// Where we (possibly) add our template to an existing shell:
		internal void PrependTemplateOrWriteIntoShell(Templating Template, string ParameterBreak, string Text)
		{
		    if (WeFoundBannerShells == BannerShellsEnum.NotChecked)
		    {
		        WeFoundBannerShells = WikiProjectBannerShellRegex.IsMatch(AlteredArticleText)
		            ? BannerShellsEnum.FoundWikiProjectBannerShell
		            : BannerShellsEnum.NoneFound;
		    }

		    Text += Template.ParametersToString(ParameterBreak);

			switch (WeFoundBannerShells) {
				case BannerShellsEnum.FoundWikiProjectBannerShell:
					MatchEvaluatorString = Text;

					AlteredArticleText = WikiProjectBannerShellRegex.Replace(AlteredArticleText, WPBSRegexMatchEvaluator, 1);
					MatchEvaluatorString = null;
					break;
				case BannerShellsEnum.NoneFound:
					AlteredArticleText = Text + AlteredArticleText;
					break;
			}
		}