ArticleHasAMajorChange() private method

private ArticleHasAMajorChange ( ) : void
return void
        /// <summary>
        /// Checks for the existence of a parameter and adds it if missing/optionally changes it
        /// </summary>
        /// <returns>True if made a change</returns>
        internal bool NewOrReplaceTemplateParm(string ParameterName, string ParameterValue, Article TheArticle, bool LogItAndUpdateEditSummary, bool ParamHasAlternativeName, bool DontChangeIfSet = false, string ParamAlternativeName = "", string PluginName = "", bool MinorEditOnlyIfAdding = false)
        {
            bool res;

            if (Parameters.ContainsKey(ParameterName))
            {
                res = ReplaceTemplateParm(ParameterName, ParameterValue, TheArticle, LogItAndUpdateEditSummary, DontChangeIfSet, PluginName);
            }
            else if (ParamHasAlternativeName && Parameters.ContainsKey(ParamAlternativeName))
            {
                res = ReplaceTemplateParm(ParamAlternativeName, ParameterValue, TheArticle, LogItAndUpdateEditSummary, DontChangeIfSet, PluginName);
                // Doesn't contain parameter
            }
            else
            {
                NewTemplateParm(ParameterName, ParameterValue, LogItAndUpdateEditSummary, TheArticle, PluginName, MinorEditOnlyIfAdding);

                if (MinorEditOnlyIfAdding)
                {
                    TheArticle.ArticleHasAMinorChange();
                }
                else
                {
                    TheArticle.ArticleHasAMajorChange();
                }
                return(true);
            }

            if (res)
            {
                TheArticle.ArticleHasAMajorChange();
            }
            return(res);
        }
示例#2
0
 protected virtual void TemplateNotFound()
 {
     TheArticle.ArticleHasAMajorChange();
     if (TheArticle.Namespace == Namespace.Talk)
     {
         Template.NewTemplateParm("class", "");
     }
     TheArticle.TemplateAdded(PreferredTemplateName);
 }
        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);
        }
        /// <summary>
        /// Checks for the existence of a parameter and adds it if missing/optionally changes it
        /// </summary>
        /// <returns>True if made a change</returns>
        internal bool NewOrReplaceTemplateParm(string parameterName, string parameterValue, Article theArticle,
                                               bool logItAndUpdateEditSummary, bool paramHasAlternativeName, bool dontChangeIfSet = false,
                                               string paramAlternativeName = "", string pluginName = "", bool minorEditOnlyIfAdding = false)
        {
            bool res;

            if (Parameters.ContainsKey(parameterName))
            {
                res = ReplaceTemplateParm(parameterName, parameterValue, theArticle, logItAndUpdateEditSummary,
                                          dontChangeIfSet);
            }
            else if (paramHasAlternativeName && Parameters.ContainsKey(paramAlternativeName))
            {
                res = ReplaceTemplateParm(paramAlternativeName, parameterValue, theArticle, logItAndUpdateEditSummary,
                                          dontChangeIfSet);
                // Doesn't contain parameter
            }
            else
            {
                NewTemplateParm(parameterName, parameterValue, logItAndUpdateEditSummary, theArticle, pluginName,
                                minorEditOnlyIfAdding);

                if (minorEditOnlyIfAdding)
                {
                    theArticle.ArticleHasAMinorChange();
                }
                else
                {
                    theArticle.ArticleHasAMajorChange();
                }
                return(true);
            }

            if (res)
            {
                theArticle.ArticleHasAMajorChange();
            }
            return(res);
        }
示例#5
0
		/// <summary>
		/// Checks for the existence of a parameter and adds it if missing/optionally changes it
		/// </summary>
		/// <returns>True if made a change</returns>
		internal bool NewOrReplaceTemplateParm(string ParameterName, string ParameterValue, Article TheArticle, bool LogItAndUpdateEditSummary, bool ParamHasAlternativeName, bool DontChangeIfSet = false, string ParamAlternativeName = "", string PluginName = "", bool MinorEditOnlyIfAdding = false)
		{
			bool res;

			if (Parameters.ContainsKey(ParameterName)) {
				res = ReplaceTemplateParm(ParameterName, ParameterValue, TheArticle, LogItAndUpdateEditSummary, DontChangeIfSet, PluginName);
			} else if (ParamHasAlternativeName && Parameters.ContainsKey(ParamAlternativeName)) {
				res = ReplaceTemplateParm(ParamAlternativeName, ParameterValue, TheArticle, LogItAndUpdateEditSummary, DontChangeIfSet, PluginName);
			// Doesn't contain parameter
			} else {
				NewTemplateParm(ParameterName, ParameterValue, LogItAndUpdateEditSummary, TheArticle, PluginName, MinorEditOnlyIfAdding);

				if (MinorEditOnlyIfAdding)
					TheArticle.ArticleHasAMinorChange();
				else
					TheArticle.ArticleHasAMajorChange();
				return true;
			}

			if (res)
				TheArticle.ArticleHasAMajorChange();
			return res;
		}
示例#6
0
		private bool ReplaceTemplateParm(string ParameterName, string ParameterValue, Article TheArticle, bool LogItAndUpdateEditSummary, bool DontChangeIfSet, string PluginName)
		{
			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, PluginName);
						} else {
							TheArticle.DoneReplacement(ParameterName + "=" + ExistingValue, ParameterValue, true, PluginName);
						}
					}
					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;
		}
示例#7
0
        private static string FinaliseArticleProcessing(Article theArticle, ref bool skip, ref string summary,
                                                        string articleText, bool reqPhoto)
        {
            SkipReason skipReason = SkipReason.Other;

            if (theArticle.PluginManagerGetSkipResults == SkipResults.NotSet)
            {
                _pluginSettings.PluginStats.Tagged += 1;
            }
            else
            {
                switch (theArticle.PluginManagerGetSkipResults)
                {
                case SkipResults.SkipBadTag:
                    // always skip
                    if (_pluginSettings.SkipBadTags)
                    {
                        _pluginSettings.PluginStats.SkippedBadTagIncrement();
                        if (_pluginSettings.OpenBadInBrowser)
                        {
                            theArticle.EditInBrowser();
                        }
                        skip = true;
                        // always skip
                        skipReason = SkipReason.BadTag;
                    }
                    else
                    {
                        // the plugin manager stops processing when it gets a bad tag. We know however
                        // that one plugin found a bad template and possibly replaced it with
                        // conTemplatePlaceholder. We're also not skipping, so we need to remove the placeholder
                        theArticle.AlteredArticleText =
                            theArticle.AlteredArticleText.Replace(Constants.TemplaterPlaceholder, "");
                        MessageBox.Show("Bad tag. Please fix it manually or click ignore.", "Bad tag",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        _pluginSettings.PluginStats.Tagged += 1;
                    }
                    break;

                case SkipResults.SkipRegex:
                case SkipResults.SkipNoChange:
                    if (theArticle.ProcessIt)
                    {
                        _pluginSettings.PluginStats.Tagged += 1;
                    }
                    else
                    {
                        if (theArticle.PluginManagerGetSkipResults == SkipResults.SkipRegex)
                        {
                            _pluginSettings.PluginStats.SkippedMiscellaneousIncrement();
                            skip       = true;
                            skipReason = SkipReason.Regex;
                            // No change:
                        }
                        else
                        {
                            if (_pluginSettings.SkipWhenNoChange)
                            {
                                _pluginSettings.PluginStats.SkippedNoChangeIncrement();
                                skipReason = SkipReason.NoChange;
                                skip       = true;
                            }
                            else
                            {
                                _pluginSettings.PluginStats.Tagged += 1;
                                skip = false;
                            }
                        }
                    }
                    break;
                }
            }

            if (skip)
            {
                return(Skipping(ref summary, theArticle.EditSummary, skipReason, articleText, ref skip));
            }

            if (reqPhoto)
            {
                theArticle.AlteredArticleText = ReqPhotoNoParamsRegex.Replace(theArticle.AlteredArticleText, "");
                theArticle.DoneReplacement("{{reqphoto}}", "template param(s)");
                theArticle.ArticleHasAMajorChange();
            }

            theArticle.FinaliseEditSummary();
            summary = theArticle.EditSummary;
            return(theArticle.AlteredArticleText);
        }
示例#8
0
        private static string FinaliseArticleProcessing(Article theArticle, ref bool skip, ref string summary,
            string articleText, bool reqPhoto)
        {
            SkipReason skipReason = SkipReason.Other;

            if (theArticle.PluginManagerGetSkipResults == SkipResults.NotSet)
            {
                _pluginSettings.PluginStats.Tagged += 1;
            }
            else
            {
                switch (theArticle.PluginManagerGetSkipResults)
                {
                    case SkipResults.SkipBadTag:
                        // always skip
                        if (_pluginSettings.SkipBadTags)
                        {
                            _pluginSettings.PluginStats.SkippedBadTagIncrement();
                            if (_pluginSettings.OpenBadInBrowser)
                                theArticle.EditInBrowser();
                            skip = true;
                            // always skip
                            skipReason = SkipReason.BadTag;
                        }
                        else
                        {
                            // the plugin manager stops processing when it gets a bad tag. We know however
                            // that one plugin found a bad template and possibly replaced it with
                            // conTemplatePlaceholder. We're also not skipping, so we need to remove the placeholder
                            theArticle.AlteredArticleText =
                                theArticle.AlteredArticleText.Replace(Constants.TemplaterPlaceholder, "");
                            MessageBox.Show("Bad tag. Please fix it manually or click ignore.", "Bad tag",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            _pluginSettings.PluginStats.Tagged += 1;
                        }
                        break;
                    case SkipResults.SkipRegex:
                    case SkipResults.SkipNoChange:
                        if (theArticle.ProcessIt)
                        {
                            _pluginSettings.PluginStats.Tagged += 1;
                        }
                        else
                        {
                            if (theArticle.PluginManagerGetSkipResults == SkipResults.SkipRegex)
                            {
                                _pluginSettings.PluginStats.SkippedMiscellaneousIncrement();
                                skip = true;
                                skipReason = SkipReason.Regex;
                                // No change:
                            }
                            else
                            {
                                if (_pluginSettings.SkipWhenNoChange)
                                {
                                    _pluginSettings.PluginStats.SkippedNoChangeIncrement();
                                    skipReason = SkipReason.NoChange;
                                    skip = true;
                                }
                                else
                                {
                                    _pluginSettings.PluginStats.Tagged += 1;
                                    skip = false;
                                }
                            }
                        }
                        break;
                }
            }

            if (skip)
            {
                return Skipping(ref summary, theArticle.EditSummary, skipReason, articleText, ref skip);
            }

            if (reqPhoto)
            {
                theArticle.AlteredArticleText = ReqPhotoNoParamsRegex.Replace(theArticle.AlteredArticleText, "");
                theArticle.DoneReplacement("{{reqphoto}}", "template param(s)");
                theArticle.ArticleHasAMajorChange();
            }

            theArticle.FinaliseEditSummary();
            summary = theArticle.EditSummary;
            return theArticle.AlteredArticleText;
        }
示例#9
0
        /// <summary>
        /// Checks for the existence of a parameter and adds it if missing/optionally changes it
        /// </summary>
        /// <returns>True if made a change</returns>
        internal bool NewOrReplaceTemplateParm(string parameterName, string parameterValue, Article theArticle,
            bool logItAndUpdateEditSummary, bool paramHasAlternativeName, bool dontChangeIfSet = false,
            string paramAlternativeName = "", bool minorEditOnlyIfAdding = false)
        {
            bool res;

            if (Parameters.ContainsKey(parameterName))
            {
                res = ReplaceTemplateParm(parameterName, parameterValue, theArticle, logItAndUpdateEditSummary,
                    dontChangeIfSet);
            }
            else if (paramHasAlternativeName && Parameters.ContainsKey(paramAlternativeName))
            {
                res = ReplaceTemplateParm(paramAlternativeName, parameterValue, theArticle, logItAndUpdateEditSummary,
                    dontChangeIfSet);
                // Doesn't contain parameter
            }
            else
            {
                NewTemplateParm(parameterName, parameterValue, logItAndUpdateEditSummary, theArticle, minorEditOnlyIfAdding);

                if (minorEditOnlyIfAdding)
                    theArticle.ArticleHasAMinorChange();
                else
                    theArticle.ArticleHasAMajorChange();
                return true;
            }

            if (res)
                theArticle.ArticleHasAMajorChange();
            return res;
        }