Creating bad words

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following code example shows how you can define a new bad word. The bad word will be checked in all website cultures.

 

[C#]

 

using System;

using CMS.SiteProvider;

 

...

 

        // Create a new bad word 

        BadWordInfo bwi = new BadWordInfo();

 

        bwi.WordExpression = "ass";

        bwi.WordAction = BadWordActionEnum.Replace;

        bwi.WordReplacement = "xxx";

        bwi.WordIsGlobal = true;

        bwi.WordIsRegularExpression = false;

        bwi.WordLastModified = DateTime.Now;

 

        // Save the object to the database

        BadWordInfoProvider.SetBadWordInfo(bwi);

 

This second code example demonstrates how a culture-specific bad word can be defined. The bad word defined in this code example will be checked only in the Czech (cs-cz) culture.

 

[C#]

 

using System;

using CMS.SiteProvider;

 

...

 

        // Create a new bad word

        BadWordInfo bwi = new BadWordInfo();

 

        bwi.WordExpression = "prdel";

        bwi.WordAction = BadWordActionEnum.Replace;

        bwi.WordReplacement = "xxx";

        bwi.WordIsGlobal = false;

        bwi.WordIsRegularExpression = false;

        bwi.WordLastModified = DateTime.Now;

 

        // Save the object to the database

        BadWordInfoProvider.SetBadWordInfo(bwi);

 

        // Get the culture where the bad word should be checked

        CultureInfo ci = CultureInfoProvider.GetCultureInfo("cs-cz");

 

        // Create a new bad word culture object 

        // for assigning the bad word to specified culture 

        BadWordCultureInfo bwci = new BadWordCultureInfo();

 

        bwci.CultureID = ci.CultureID;

        bwci.WordID = bwi.WordID;

 

        // Save the object to the database

        BadWordCultureInfoProvider.SetBadWordCultureInfo(bwci);

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_creating_bad_words.htm