public static bool ProcessTalkPage(ref string ArticleText, IMyTraceListener Trace, 
 DEFAULTSORT MoveDEFAULTSORT, string PluginName)
 {
     FoundTalkheader = false; FoundSkipTOC = false; FoundDefaultSort = false;
     ArticleText = TalkheaderTemplateRegex.Replace(ArticleText, new MatchEvaluator(TalkheaderMatchEvaluator), 1);
     ArticleText = SkipTOCTemplateRegex.Replace(ArticleText, new MatchEvaluator(SkipTOCMatchEvaluator), 1);
     if (FoundTalkheader)
         WriteHeaderTemplate("talkheader", ref ArticleText, Trace, PluginName);
     if (FoundSkipTOC)
         WriteHeaderTemplate("skiptotoctalk", ref ArticleText, Trace, PluginName);
     if (MoveDEFAULTSORT != DEFAULTSORT.NoChange)
     {
         ArticleText = WikiRegexes.Defaultsort.Replace(ArticleText, 
             new MatchEvaluator(DefaultSortMatchEvaluator), 1);
         if (FoundDefaultSort)
         {
             if (string.IsNullOrEmpty(DefaultSortKey))
             {
                 if (Trace != null)
                     Trace.WriteArticleActionLine("DEFAULTSORT has no key; removed", PluginName);
             }
             else
             {
                 WriteDefaultSortMagicWord(MoveDEFAULTSORT, Trace, PluginName, ref ArticleText);
             }
         }
         DefaultSortKey = "";
     }
     return (FoundTalkheader || FoundSkipTOC) || FoundDefaultSort;
 }
 private static void WriteHeaderTemplate(string Name, ref string ArticleText, IMyTraceListener Trace, string PluginName)
 {
     ArticleText = "{{" + Name + "}}\r\n" + ArticleText;
     if (Trace != null)
     {
         Trace.WriteArticleActionLine("{{tl|" + Name + "}} given top billing", PluginName, false);
     }
 }
Beispiel #3
0
 private static void WriteHeaderTemplate(string name, ref string articleText, IMyTraceListener trace, string pluginName)
 {
     articleText = "{{" + name + "}}\r\n" + articleText;
     if (trace != null)
     {
         trace.WriteArticleActionLine("{{tl|" + name + "}} given top billing", pluginName, false);
     }
 }
        // Helper routines:
        private static void WriteDefaultSortMagicWord(DEFAULTSORT Location, IMyTraceListener Trace, string PluginName, ref string ArticleText)
        {
            string strMovedTo;

            if (Location == DEFAULTSORT.MoveToTop)
            {
                ArticleText = "{{DEFAULTSORT:" + DefaultSortKey + "}}\r\n" + ArticleText;
                strMovedTo  = " given top billing";
            }
            else
            {
                ArticleText = ArticleText + "\r\n{{DEFAULTSORT:" + DefaultSortKey + "}}";
                strMovedTo  = " sent to the bottom";
            }
            if (Trace != null)
            {
                Trace.WriteArticleActionLine("DEFAULTSORT" + strMovedTo, PluginName, false);
            }
        }
Beispiel #5
0
        // Helper routines:
        private static string SetDefaultSort(string key, DEFAULTSORT location, IMyTraceListener trace, string pluginName, string articleText)
        {
            string strMovedTo;

            if (location == DEFAULTSORT.MoveToTop)
            {
                articleText = "{{DEFAULTSORT:" + key + "}}\r\n" + articleText;
                strMovedTo  = " given top billing";
            }
            else
            {
                articleText = articleText + "\r\n{{DEFAULTSORT:" + key + "}}";
                strMovedTo  = " sent to the bottom";
            }
            if (trace != null)
            {
                trace.WriteArticleActionLine("DEFAULTSORT" + strMovedTo, pluginName, false);
            }

            return(articleText);
        }
 public static bool ProcessTalkPage(ref string ArticleText, IMyTraceListener Trace,
                                    DEFAULTSORT MoveDEFAULTSORT, string PluginName)
 {
     FoundTalkheader = false; FoundSkipTOC = false; FoundDefaultSort = false;
     ArticleText     = TalkheaderTemplateRegex.Replace(ArticleText, new MatchEvaluator(TalkheaderMatchEvaluator), 1);
     ArticleText     = SkipTOCTemplateRegex.Replace(ArticleText, new MatchEvaluator(SkipTOCMatchEvaluator), 1);
     if (FoundTalkheader)
     {
         WriteHeaderTemplate("talkheader", ref ArticleText, Trace, PluginName);
     }
     if (FoundSkipTOC)
     {
         WriteHeaderTemplate("skiptotoctalk", ref ArticleText, Trace, PluginName);
     }
     if (MoveDEFAULTSORT != DEFAULTSORT.NoChange)
     {
         ArticleText = WikiRegexes.Defaultsort.Replace(ArticleText,
                                                       new MatchEvaluator(DefaultSortMatchEvaluator), 1);
         if (FoundDefaultSort)
         {
             if (string.IsNullOrEmpty(DefaultSortKey))
             {
                 if (Trace != null)
                 {
                     Trace.WriteArticleActionLine("DEFAULTSORT has no key; removed", PluginName);
                 }
             }
             else
             {
                 WriteDefaultSortMagicWord(MoveDEFAULTSORT, Trace, PluginName, ref ArticleText);
             }
         }
         DefaultSortKey = "";
     }
     if ((!FoundTalkheader && !FoundSkipTOC) && !FoundDefaultSort)
     {
         return(false);
     }
     return(true);
 }
Beispiel #7
0
        public static bool ProcessTalkPage(ref string articleText, IMyTraceListener trace,
                                           DEFAULTSORT moveDEFAULTSORT, string pluginName)
        {
            Processor pr = new Processor();

            articleText = TalkHeaderTemplateRegex.Replace(articleText,
                                                          new MatchEvaluator(pr.TalkHeaderMatchEvaluator),
                                                          1);
            articleText = SkipTOCTemplateRegex.Replace(articleText, new MatchEvaluator(pr.SkipTOCMatchEvaluator), 1);
            if (pr.FoundTalkHeader)
            {
                WriteHeaderTemplate("talkheader", ref articleText, trace, pluginName);
            }
            if (pr.FoundSkipTOC)
            {
                WriteHeaderTemplate("skiptotoctalk", ref articleText, trace, pluginName);
            }
            if (moveDEFAULTSORT != DEFAULTSORT.NoChange)
            {
                articleText = WikiRegexes.Defaultsort.Replace(articleText,
                                                              new MatchEvaluator(pr.DefaultSortMatchEvaluator), 1);
                if (pr.FoundDefaultSort)
                {
                    if (string.IsNullOrEmpty(pr.DefaultSortKey))
                    {
                        if (trace != null)
                        {
                            trace.WriteArticleActionLine("DEFAULTSORT has no key; removed", pluginName);
                        }
                    }
                    else
                    {
                        articleText = SetDefaultSort(pr.DefaultSortKey, moveDEFAULTSORT, trace, pluginName, articleText);
                    }
                }
            }
            return(pr.FoundTalkHeader || pr.FoundSkipTOC || pr.FoundDefaultSort);
        }
 public static bool ProcessTalkPage(ref string ArticleText, IMyTraceListener Trace, 
 DEFAULTSORT MoveDEFAULTSORT, string PluginName)
 {
     Processor pr = new Processor();
     ArticleText = TalkHeaderTemplateRegex.Replace(ArticleText, 
         new MatchEvaluator(pr.TalkHeaderMatchEvaluator),
         1);
     ArticleText = SkipTOCTemplateRegex.Replace(ArticleText, new MatchEvaluator(pr.SkipTOCMatchEvaluator), 1);
     if (pr.FoundTalkHeader)
         WriteHeaderTemplate("talkheader", ref ArticleText, Trace, PluginName);
     if (pr.FoundSkipTOC)
         WriteHeaderTemplate("skiptotoctalk", ref ArticleText, Trace, PluginName);
     if (MoveDEFAULTSORT != DEFAULTSORT.NoChange)
     {
         ArticleText = WikiRegexes.Defaultsort.Replace(ArticleText, 
             new MatchEvaluator(pr.DefaultSortMatchEvaluator), 1);
         if (pr.FoundDefaultSort)
         {
             if (string.IsNullOrEmpty(pr.DefaultSortKey))
             {
                 if (Trace != null)
                     Trace.WriteArticleActionLine("DEFAULTSORT has no key; removed", PluginName);
             }
             else
             {
                 ArticleText = SetDefaultSort(pr.DefaultSortKey, MoveDEFAULTSORT, Trace, PluginName, ArticleText);
             }
         }
     }
     return pr.FoundTalkHeader || pr.FoundSkipTOC || pr.FoundDefaultSort;
 }
 private static void WriteHeaderTemplate(string Name, ref string ArticleText, IMyTraceListener Trace, string PluginName)
 {
     ArticleText = "{{" + Name + "}}\r\n" + ArticleText;
     if (Trace != null)
         Trace.WriteArticleActionLine("{{tl|" + Name + "}} given top billing", PluginName, false);
 }
        // Helper routines:
        private static string SetDefaultSort(string key, DEFAULTSORT Location, IMyTraceListener Trace, string PluginName, string ArticleText)
        {
            string strMovedTo;
            if (Location == DEFAULTSORT.MoveToTop)
            {
                ArticleText = "{{DEFAULTSORT:" + key + "}}\r\n" + ArticleText;
                strMovedTo = " given top billing";
            }
            else
            {
                ArticleText = ArticleText + "\r\n{{DEFAULTSORT:" + key + "}}";
                strMovedTo = " sent to the bottom";
            }
            if (Trace != null)
                Trace.WriteArticleActionLine("DEFAULTSORT" + strMovedTo, PluginName, false);

            return ArticleText;
        }
 private static void WriteHeaderTemplate(string name, ref string articleText, IMyTraceListener trace, string pluginName)
 {
     articleText = "{{" + name + "}}\r\n" + articleText;
     if (trace != null)
         trace.WriteArticleActionLine("{{tl|" + name + "}} given top billing", pluginName, false);
 }