コード例 #1
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Initialize resource strings
        rqfWordExpression.ErrorMessage = GetString("general.requiresvalue");

        if (badWordId > 0)
        {
            badWordObj = BadWordInfoProvider.GetBadWordInfo(badWordId);

            // Set edited object
            EditedObject = badWordObj;

            if (badWordObj != null)
            {
                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(badWordObj);

                    // Show that the badWord was created or updated successfully
                    if (QueryHelper.GetString("saved", string.Empty) == "1")
                    {
                        ShowChangesSaved();
                    }
                }
                else
                {
                    // Set selected action
                    SetSelectedAction(badWordObj);
                }
            }
        }
        else
        {
            PageTitle.TitleText = GetString("BadWords_Edit.NewItemCaption");
            // Initialize breadcrumbs
            List <BreadcrumbItem> breadCrumbItems = new List <BreadcrumbItem>();
            breadCrumbItems.Add(new BreadcrumbItem
            {
                Text        = GetString("badwords_edit.itemlistlink"),
                RedirectUrl = "~/CMSModules/BadWords/BadWords_List.aspx",
                Target      = "_self",
            });
            breadCrumbItems.Add(new BreadcrumbItem
            {
                Text = GetString("badwords_list.newitemcaption"),
            });
            PageBreadcrumbs.Items = breadCrumbItems;
            SetSelectedAction(null);
        }

        // Enable / disable actions (depending on inheritance)
        SelectBadWordActionControl.Enabled = !chkInheritAction.Checked;
        txtWordReplacement.Enabled         = !chkInheritReplacement.Checked;

        // Show / hide replacement textbox depending on action
        plcReplacement.Visible = ((BadWordActionEnum)Enum.Parse(typeof(BadWordActionEnum), SelectBadWordActionControl.Value.ToString())) == BadWordActionEnum.Replace;
    }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: tvelzy/RadstackMedia
    /// <summary>
    /// Gets and updates the first single bad word matching the condition. Called when the "Get and update bad word" button is pressed.
    /// Expects the CreateBadWord method to be run first.
    /// </summary>
    private bool GetAndUpdateBadWord()
    {
        // Prepare the parameters
        string where = "[WordExpression] = 'testbadword'";

        // Get the data
        DataSet words = BadWordInfoProvider.GetBadWords(where, null);

        if (!DataHelper.DataSourceIsEmpty(words))
        {
            // Get the bad word's data row
            DataRow wordDr = words.Tables[0].Rows[0];

            // Create object from DataRow
            BadWordInfo modifyWord = new BadWordInfo(wordDr);

            // Update the properties
            modifyWord.WordAction      = BadWordActionEnum.Replace;
            modifyWord.WordReplacement = "testpoliteword";

            // Save the changes
            BadWordInfoProvider.SetBadWordInfo(modifyWord);

            return(true);
        }

        return(false);
    }
コード例 #3
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator().NotEmpty(txtWordExpression.Text, GetString("general.requiresvalue")).Result;

        if (errorMessage == string.Empty)
        {
            if (badWordObj == null)
            {
                badWordObj = new BadWordInfo();
            }

            // Set edited object
            EditedObject = badWordObj;

            // If bad word doesn't already exist, create new one
            if (!(((badWordId <= 0) || WordExpressionHasChanged()) && BadWordInfoProvider.BadWordExists(txtWordExpression.Text.Trim())))
            {
                badWordObj.WordExpression = txtWordExpression.Text.Trim();
                BadWordActionEnum action =
                    (BadWordActionEnum)Convert.ToInt32(SelectBadWordActionControl.Value.ToString().Trim());
                badWordObj.WordAction              = !chkInheritAction.Checked ? action : 0;
                badWordObj.WordReplacement         = (!chkInheritReplacement.Checked && (action == BadWordActionEnum.Replace)) ? txtWordReplacement.Text : null;
                badWordObj.WordLastModified        = DateTime.Now;
                badWordObj.WordIsRegularExpression = chkIsRegular.Checked;
                badWordObj.WordMatchWholeWord      = chkMatchWholeWord.Checked;

                if (badWordId <= 0)
                {
                    badWordObj.WordIsGlobal = true;
                }

                BadWordInfoProvider.SetBadWordInfo(badWordObj);

                if (badWordId <= 0)
                {
                    string redirectTo = badWordId <= 0 ? UIContextHelper.GetElementUrl("CMS.Badwords", "Administration.BadWords.Edit") : UIContextHelper.GetElementUrl("CMS.Badwords", "Administration.BadWords.Edit.General");
                    redirectTo = URLHelper.AddParameterToUrl(redirectTo, "objectid", badWordObj.WordID.ToString());
                    redirectTo = URLHelper.AddParameterToUrl(redirectTo, "saved", "1");
                    URLHelper.Redirect(redirectTo);
                }
                else
                {
                    ScriptHelper.RefreshTabHeader(Page, txtWordExpression.Text.Trim());
                    ShowChangesSaved();
                }
            }
            else
            {
                ShowError(GetString("badwords_edit.badwordexists"));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
コード例 #4
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator().NotEmpty(txtWordExpression.Text, GetString("general.requiresvalue")).Result;

        if (errorMessage == string.Empty)
        {
            if (badWordObj == null)
            {
                badWordObj = new BadWordInfo();
            }

            // Set edited object
            EditedObject = badWordObj;

            // If bad word doesn't already exist, create new one
            if (!(((badWordId <= 0) || WordExpressionHasChanged()) && BadWordInfoProvider.BadWordExists(txtWordExpression.Text.Trim())))
            {
                badWordObj.WordExpression = txtWordExpression.Text.Trim();
                BadWordActionEnum action =
                    (BadWordActionEnum)Convert.ToInt32(SelectBadWordActionControl.Value.ToString().Trim());
                badWordObj.WordAction = !chkInheritAction.Checked ? action : 0;
                badWordObj.WordReplacement = (!chkInheritReplacement.Checked && (action == BadWordActionEnum.Replace)) ? txtWordReplacement.Text : null;
                badWordObj.WordLastModified = DateTime.Now;
                badWordObj.WordIsRegularExpression = chkIsRegular.Checked;
                badWordObj.WordMatchWholeWord = chkMatchWholeWord.Checked;

                if (badWordId <= 0)
                {
                    badWordObj.WordIsGlobal = true;
                }

                BadWordInfoProvider.SetBadWordInfo(badWordObj);

                if (badWordId <= 0)
                {
                    string redirectTo = badWordId <= 0 ? UIContextHelper.GetElementUrl("CMS.Badwords", "Administration.BadWords.Edit") : UIContextHelper.GetElementUrl("CMS.Badwords", "Administration.BadWords.Edit.General");
                    redirectTo = URLHelper.AddParameterToUrl(redirectTo, "objectid", badWordObj.WordID.ToString());
                    redirectTo = URLHelper.AddParameterToUrl(redirectTo, "saved", "1");
                    URLHelper.Redirect(redirectTo);
                }
                else
                {
                    ScriptHelper.RefreshTabHeader(Page, txtWordExpression.Text.Trim());
                    ShowChangesSaved();
                }
            }
            else
            {
                ShowError(GetString("badwords_edit.badwordexists"));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
コード例 #5
0
    /// <summary>
    /// Load data of editing badWord.
    /// </summary>
    /// <param name="badWordObj">BadWord object</param>
    protected void LoadData(BadWordInfo badWordObj)
    {
        // Check inheritance
        chkInheritAction.Checked      = (badWordObj.WordAction == 0);
        chkInheritReplacement.Checked = (badWordObj.WordReplacement == null);

        // Set selected action
        SetSelectedAction(badWordObj);

        // Load rest of values
        txtWordExpression.Text    = badWordObj.WordExpression;
        chkIsRegular.Checked      = badWordObj.WordIsRegularExpression;
        chkMatchWholeWord.Checked = badWordObj.WordMatchWholeWord;
    }
コード例 #6
0
    /// <summary>
    /// Load data of editing badWord.
    /// </summary>
    /// <param name="badWordObj">BadWord object</param>
    protected void LoadData(BadWordInfo badWordObj)
    {
        // Check inheritance
        chkInheritAction.Checked = (badWordObj.WordAction == 0);
        chkInheritReplacement.Checked = (badWordObj.WordReplacement == null);

        // Set selected action
        SetSelectedAction(badWordObj);

        // Load rest of values
        txtWordExpression.Text = badWordObj.WordExpression;
        chkIsRegular.Checked = badWordObj.WordIsRegularExpression;
        chkMatchWholeWord.Checked = badWordObj.WordMatchWholeWord;
    }
コード例 #7
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator().NotEmpty(txtWordExpression.Text, GetString("general.requiresvalue")).Result;

        if (errorMessage == string.Empty)
        {
            if (badWordObj == null)
            {
                badWordObj = new BadWordInfo();
            }

            // Set edited object
            EditedObject = badWordObj;

            // If bad word doesn't already exist, create new one
            if (!BadWordInfoProvider.BadWordExists(txtWordExpression.Text.Trim()) || (badWordId != 0))
            {
                badWordObj.WordExpression = txtWordExpression.Text.Trim();
                BadWordActionEnum action =
                    (BadWordActionEnum)Convert.ToInt32(SelectBadWordActionControl.Value.ToString().Trim());
                badWordObj.WordAction              = !chkInheritAction.Checked ? action : 0;
                badWordObj.WordReplacement         = (!chkInheritReplacement.Checked && (action == BadWordActionEnum.Replace)) ? txtWordReplacement.Text : null;
                badWordObj.WordLastModified        = DateTime.Now;
                badWordObj.WordIsRegularExpression = chkIsRegular.Checked;
                badWordObj.WordMatchWholeWord      = chkMatchWholeWord.Checked;

                if (badWordId == 0)
                {
                    badWordObj.WordIsGlobal = true;
                }

                BadWordInfoProvider.SetBadWordInfo(badWordObj);
                string redirectTo = badWordId == 0 ? "BadWords_Edit.aspx" : "BadWords_Edit_General.aspx";

                URLHelper.Redirect(redirectTo + "?badwordid=" + Convert.ToString(badWordObj.WordID) + "&saved=1");
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("badwords_edit.badwordexists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
コード例 #8
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator().NotEmpty(txtWordExpression.Text, GetString("general.requiresvalue")).Result;

        if (errorMessage == string.Empty)
        {
            if (badWordObj == null)
            {
                badWordObj = new BadWordInfo();
            }

            // Set edited object
            EditedObject = badWordObj;

            // If bad word doesn't already exist, create new one
            if (!BadWordInfoProvider.BadWordExists(txtWordExpression.Text.Trim()) || (badWordId != 0))
            {
                badWordObj.WordExpression = txtWordExpression.Text.Trim();
                BadWordActionEnum action =
                    (BadWordActionEnum)Convert.ToInt32(SelectBadWordActionControl.Value.ToString().Trim());
                badWordObj.WordAction = !chkInheritAction.Checked ? action : 0;
                badWordObj.WordReplacement = (!chkInheritReplacement.Checked && (action == BadWordActionEnum.Replace)) ? txtWordReplacement.Text : null;
                badWordObj.WordLastModified = DateTime.Now;
                badWordObj.WordIsRegularExpression = chkIsRegular.Checked;
                badWordObj.WordMatchWholeWord = chkMatchWholeWord.Checked;

                if (badWordId == 0)
                {
                    badWordObj.WordIsGlobal = true;
                }

                BadWordInfoProvider.SetBadWordInfo(badWordObj);
                string redirectTo = badWordId == 0 ? "BadWords_Edit.aspx" : "BadWords_Edit_General.aspx";

                URLHelper.Redirect(redirectTo + "?badwordid=" + Convert.ToString(badWordObj.WordID) + "&saved=1");
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("badwords_edit.badwordexists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = errorMessage;
        }
    }
コード例 #9
0
ファイル: Default.aspx.cs プロジェクト: tvelzy/RadstackMedia
    /// <summary>
    /// Creates a "testbadword" bad word. Called when the "Create word" button is pressed.
    /// </summary>
    private bool CreateBadWord()
    {
        // Create new bad word object
        BadWordInfo newWord = new BadWordInfo();

        // Set the properties
        newWord.WordExpression          = "testbadword";
        newWord.WordAction              = BadWordActionEnum.ReportAbuse;
        newWord.WordIsGlobal            = true;
        newWord.WordIsRegularExpression = false;

        // Save the bad word
        BadWordInfoProvider.SetBadWordInfo(newWord);

        return(true);
    }
コード例 #10
0
    /// <summary>
    /// Sets selected action.
    /// </summary>
    protected void SetSelectedAction(BadWordInfo badWordObj)
    {
        // Find postback invoker
        string  invokerName   = Page.Request.Params.Get("__EVENTTARGET");
        Control invokeControl = !string.IsNullOrEmpty(invokerName) ? Page.FindControl(invokerName) : null;

        // Ensure right postback actions
        if ((invokeControl == chkInheritAction) || !RequestHelper.IsPostBack())
        {
            // Deselect all items
            SelectBadWordActionControl.ReloadData();

            // Check inheritance of settings
            if (chkInheritAction != null)
            {
                // Get action
                if ((!chkInheritAction.Checked) && (badWordObj != null))
                {
                    BadWordActionEnum action = badWordObj.WordAction;
                    SelectBadWordActionControl.Value = ((int)action).ToString();
                }
                else
                {
                    SelectBadWordActionControl.Value = ((int)BadWordsHelper.BadWordsAction(CMSContext.CurrentSiteName)).ToString();
                }
            }
        }

        // Get replacement
        if ((invokeControl == chkInheritReplacement) || !RequestHelper.IsPostBack())
        {
            if (chkInheritReplacement != null)
            {
                if (!chkInheritReplacement.Checked && (badWordObj != null))
                {
                    txtWordReplacement.Text = badWordObj.WordReplacement;
                }
                else
                {
                    txtWordReplacement.Text = BadWordsHelper.BadWordsReplacement(CMSContext.CurrentSiteName);
                }
            }
        }
    }
コード例 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int  badWordId         = QueryHelper.GetInteger("badWordId", 0);
        bool badWordIsSelected = (badWordId != 0);

        // Initialize PageTitle breadcrumbs
        string[,] pageTitleTabs = new string[2, 3];
        pageTitleTabs[0, 0]     = GetString("badwords_edit.itemlistlink");
        pageTitleTabs[0, 1]     = "~/CMSModules/BadWords/BadWords_List.aspx";
        pageTitleTabs[0, 2]     = "_parent";
        string badWord = string.Empty;

        // Get bad word name
        if (!badWordIsSelected)
        {
            badWord = GetString("badwords_list.newitemcaption");
        }
        else
        {
            BadWordInfo badWordInfo = BadWordInfoProvider.GetBadWordInfo(badWordId);
            if (badWordInfo != null)
            {
                badWord = badWordInfo.WordExpression;
            }
        }
        pageTitleTabs[1, 0] = badWord;
        pageTitleTabs[1, 1] = string.Empty;
        pageTitleTabs[1, 2] = string.Empty;

        // Initialize masterpage properties
        CurrentMaster.Title.Breadcrumbs = pageTitleTabs;
        CurrentMaster.Title.TitleText   = !badWordIsSelected?GetString("BadWords_List.HeaderCaption") : GetString("BadWords_Edit.badwordproperties");

        CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/Badwords_Word/object.png");
        CurrentMaster.Title.HelpTopicName = "general_badwords";
        CurrentMaster.Title.HelpName      = "helpTopic";

        if (!RequestHelper.IsPostBack())
        {
            InitalizeMenu();
        }
    }
コード例 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get ID of bad word
        badWordId = QueryHelper.GetInteger("badwordid", 0);

        if (badWordId > 0)
        {
            radAll.CheckedChanged      += isGlobal_CheckedChanged;
            radSelected.CheckedChanged += isGlobal_CheckedChanged;
            badWordObj = BadWordInfoProvider.GetBadWordInfo(badWordId);
            // Set edited object
            EditedObject = badWordObj;

            if (badWordObj != null)
            {
                if (!RequestHelper.IsPostBack())
                {
                    // Initialize radiobuttons
                    radAll.Checked      = badWordObj.WordIsGlobal;
                    radSelected.Checked = !badWordObj.WordIsGlobal;
                }
            }

            // Show / hide selector
            SetSelectorVisibility();

            // Get the word cultures
            if (!RequestHelper.IsPostBack() || (radSelected == ControlsHelper.GetPostBackControl(Page)))
            {
                usWordCultures.Value = GetCurrentValues();
            }
        }

        // Initialize selector properties
        usWordCultures.OnSelectionChanged           += usWordCultures_OnSelectionChanged;
        usWordCultures.ButtonRemoveSelected.CssClass = "XLongButton";
        usWordCultures.ButtonAddItems.CssClass       = "XLongButton";
    }
コード例 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get ID of bad word
        badWordId = QueryHelper.GetInteger("badwordid", 0);

        if (badWordId > 0)
        {
            radAll.CheckedChanged += isGlobal_CheckedChanged;
            radSelected.CheckedChanged += isGlobal_CheckedChanged;
            badWordObj = BadWordInfoProvider.GetBadWordInfo(badWordId);
            // Set edited object
            EditedObject = badWordObj;

            if (badWordObj != null)
            {
                if (!RequestHelper.IsPostBack())
                {
                    // Initialize radiobuttons
                    radAll.Checked = badWordObj.WordIsGlobal;
                    radSelected.Checked = !badWordObj.WordIsGlobal;
                }
            }

            // Show / hide selector
            SetSelectorVisibility();

            // Get the word cultures
            if (!RequestHelper.IsPostBack() || (radSelected == ControlsHelper.GetPostBackControl(Page)))
            {
                usWordCultures.Value = GetCurrentValues();
            }
        }

        // Initialize selector properties
        usWordCultures.OnSelectionChanged += usWordCultures_OnSelectionChanged;
        usWordCultures.ButtonRemoveSelected.CssClass = "XLongButton";
        usWordCultures.ButtonAddItems.CssClass = "XLongButton";
    }
コード例 #14
0
ファイル: Default.aspx.cs プロジェクト: tvelzy/RadstackMedia
    /// <summary>
    /// Deletes all "testbadword" bad words. Called when the "Delete bad word(s)" button is pressed.
    /// Expects the CreateBadWord method to be run first.
    /// </summary>
    private bool DeleteBadWord()
    {
        // Prepare the parameters
        string where = "[WordExpression] = 'testbadword' ";

        // Get the data
        DataSet words = BadWordInfoProvider.GetBadWords(where, null);

        if (!DataHelper.DataSourceIsEmpty(words))
        {
            foreach (DataRow wordDr in words.Tables[0].Rows)
            {
                // Create object from DataRow
                BadWordInfo deleteWord = new BadWordInfo(wordDr);

                // Delete the bad word
                BadWordInfoProvider.DeleteBadWordInfo(deleteWord);
            }

            return(true);
        }

        return(false);
    }
コード例 #15
0
ファイル: Default.aspx.cs プロジェクト: v-jli/jean0407large
    /// <summary>
    /// Checks the declared custom string for presence of the 'testbadword' bad word created by the first code example on this page.
    /// Expects the CreateBadWord method to be run first.
    /// </summary>
    private bool CheckSingleBadWord()
    {
        // Prepare parameters for selection of the checked bad word
        string where = "[WordExpression] = 'testbadword' ";

        // Get the data
        DataSet words = BadWordInfoProvider.GetBadWords(where, null);

        if (!DataHelper.DataSourceIsEmpty(words))
        {
            // Get DataRow with bad word
            DataRow wordDr = words.Tables[0].Rows[0];

            // Get BadWordInfo object
            BadWordInfo badWord = new BadWordInfo(wordDr);

            // String to be checked for presence of the bad word
            string text = "This is a string containing the sample testbadword, which can be created by the first code example on this page.";

            // Hashtable that will contain found bad words
            Hashtable foundWords = new Hashtable();

            // Modify the string according to found bad words and return which action should be performed
            BadWordActionEnum action = BadWordInfoProvider.CheckBadWord(badWord, null, null, ref text, foundWords, 0);

            if (foundWords.Count != 0)
            {
                switch (action)
                {
                    case BadWordActionEnum.Deny:
                        // Some additional actions performed here ...
                        break;

                    case BadWordActionEnum.RequestModeration:
                        // Some additional actions performed here ...
                        break;

                    case BadWordActionEnum.Remove:
                        // Some additional actions performed here ...
                        break;

                    case BadWordActionEnum.Replace:
                        // Some additional actions performed here ...
                        break;

                    case BadWordActionEnum.ReportAbuse:
                        // Some additional actions performed here ...
                        break;

                    case BadWordActionEnum.None:
                        // Some additional actions performed here ...
                        break;
                }

                return true;
            }

            apiCheckSingleBadWord.ErrorMessage = "Bad word 'testbadword' is not present in the checked string.";
            return false;
        }

        return false;
    }
コード例 #16
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Initialize resource strings
        rqfWordExpression.ErrorMessage = GetString("general.requiresvalue");

        if (badWordId > 0)
        {
            badWordObj = BadWordInfoProvider.GetBadWordInfo(badWordId);
            // Set edited object
            EditedObject = badWordObj;

            if (badWordObj != null)
            {
                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(badWordObj);

                    // Show that the badWord was created or updated successfully
                    if (QueryHelper.GetString("saved", string.Empty) == "1")
                    {
                        ShowChangesSaved();
                        // Refresh header
                        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "refreshBadwordsHeader", ScriptHelper.GetScript("parent.frames['badwordsMenu'].location = 'BadWords_Edit_Header.aspx?badwordid=" + badWordObj.WordID + "';"));
                    }
                }
                else
                {
                    // Set selected action
                    SetSelectedAction(badWordObj);
                }
            }
        }
        else
        {
            CurrentMaster.Title.TitleText = GetString("BadWords_Edit.NewItemCaption");
            CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Badwords_Word/new.png");
            CurrentMaster.Title.HelpTopicName = "general_badwords";
            CurrentMaster.Title.HelpName = "helpTopic";

            // Initialize breadcrumbs
            string[,] pageTitleTabs = new string[2,3];
            pageTitleTabs[0, 0] = GetString("badwords_edit.itemlistlink");
            pageTitleTabs[0, 1] = "~/CMSModules/BadWords/BadWords_List.aspx";
            pageTitleTabs[0, 2] = "_self";
            pageTitleTabs[1, 0] = GetString("badwords_list.newitemcaption");
            pageTitleTabs[1, 1] = "";
            pageTitleTabs[1, 2] = "";
            CurrentMaster.Title.Breadcrumbs = pageTitleTabs;
            SetSelectedAction(null);
        }

        // Enable / disable actions (depending on inheritance)
        SelectBadWordActionControl.Enabled = !chkInheritAction.Checked;
        txtWordReplacement.Enabled = !chkInheritReplacement.Checked;

        // Show / hide replacement textbox depending on action
        plcReplacement.Visible = ((BadWordActionEnum)Enum.Parse(typeof(BadWordActionEnum), SelectBadWordActionControl.Value.ToString())) == BadWordActionEnum.Replace;
    }
コード例 #17
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Initialize resource strings
        rqfWordExpression.ErrorMessage = GetString("general.requiresvalue");

        if (badWordId > 0)
        {
            badWordObj = BadWordInfoProvider.GetBadWordInfo(badWordId);

            // Set edited object
            EditedObject = badWordObj;

            if (badWordObj != null)
            {
                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(badWordObj);

                    // Show that the badWord was created or updated successfully
                    if (QueryHelper.GetString("saved", string.Empty) == "1")
                    {
                        ShowChangesSaved();
                    }
                }
                else
                {
                    // Set selected action
                    SetSelectedAction(badWordObj);
                }
            }
        }
        else
        {
            PageTitle.TitleText = GetString("BadWords_Edit.NewItemCaption");
            // Initialize breadcrumbs
            List<BreadcrumbItem> breadCrumbItems = new List<BreadcrumbItem>();
            breadCrumbItems.Add(new BreadcrumbItem
            {
                Text = GetString("badwords_edit.itemlistlink"),
                RedirectUrl = "~/CMSModules/BadWords/BadWords_List.aspx",
                Target = "_self",
            });
            breadCrumbItems.Add(new BreadcrumbItem
            {
                Text = GetString("badwords_list.newitemcaption"),
            });
            PageBreadcrumbs.Items = breadCrumbItems;
            SetSelectedAction(null);
        }

        // Enable / disable actions (depending on inheritance)
        SelectBadWordActionControl.Enabled = !chkInheritAction.Checked;
        txtWordReplacement.Enabled = !chkInheritReplacement.Checked;

        // Show / hide replacement textbox depending on action
        plcReplacement.Visible = ((BadWordActionEnum)Enum.Parse(typeof(BadWordActionEnum), SelectBadWordActionControl.Value.ToString())) == BadWordActionEnum.Replace;
    }
コード例 #18
0
    /// <summary>
    /// Sets selected action.
    /// </summary>
    protected void SetSelectedAction(BadWordInfo badWordObj)
    {
        // Find postback invoker
        string invokerName = Page.Request.Params.Get("__EVENTTARGET");
        Control invokeControl = !string.IsNullOrEmpty(invokerName) ? Page.FindControl(invokerName) : null;

        // Ensure right postback actions
        if ((invokeControl == chkInheritAction) || !RequestHelper.IsPostBack())
        {
            // Deselect all items
            SelectBadWordActionControl.ReloadData();

            // Check inheritance of settings
            if (chkInheritAction != null)
            {
                // Get action
                if ((!chkInheritAction.Checked) && (badWordObj != null))
                {
                    BadWordActionEnum action = badWordObj.WordAction;
                    SelectBadWordActionControl.Value = ((int)action).ToString();
                }
                else
                {
                    SelectBadWordActionControl.Value = ((int)BadWordsHelper.BadWordsAction(CMSContext.CurrentSiteName)).ToString();
                }
            }
        }

        // Get replacement
        if ((invokeControl == chkInheritReplacement) || !RequestHelper.IsPostBack())
        {
            if (chkInheritReplacement != null)
            {
                if (!chkInheritReplacement.Checked && (badWordObj != null))
                {
                    txtWordReplacement.Text = badWordObj.WordReplacement;
                }
                else
                {
                    txtWordReplacement.Text = BadWordsHelper.BadWordsReplacement(CMSContext.CurrentSiteName);
                }
            }
        }
    }
コード例 #19
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Initialize resource strings
        rqfWordExpression.ErrorMessage = GetString("general.requiresvalue");

        if (badWordId > 0)
        {
            badWordObj = BadWordInfoProvider.GetBadWordInfo(badWordId);
            // Set edited object
            EditedObject = badWordObj;

            if (badWordObj != null)
            {
                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(badWordObj);

                    // Show that the badWord was created or updated successfully
                    if (QueryHelper.GetString("saved", string.Empty) == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                        // Refresh header
                        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "refreshBadwordsHeader", ScriptHelper.GetScript("parent.frames['badwordsMenu'].location = 'BadWords_Edit_Header.aspx?badwordid=" + badWordObj.WordID + "';"));
                    }
                }
                else
                {
                    // Set selected action
                    SetSelectedAction(badWordObj);
                }
            }
        }
        else
        {
            CurrentMaster.Title.TitleText     = GetString("BadWords_Edit.NewItemCaption");
            CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/Badwords_Word/new.png");
            CurrentMaster.Title.HelpTopicName = "general_badwords";
            CurrentMaster.Title.HelpName      = "helpTopic";

            // Initialize breadcrumbs
            string[,] pageTitleTabs         = new string[2, 3];
            pageTitleTabs[0, 0]             = GetString("badwords_edit.itemlistlink");
            pageTitleTabs[0, 1]             = "~/CMSModules/BadWords/BadWords_List.aspx";
            pageTitleTabs[0, 2]             = "_self";
            pageTitleTabs[1, 0]             = GetString("badwords_list.newitemcaption");
            pageTitleTabs[1, 1]             = "";
            pageTitleTabs[1, 2]             = "";
            CurrentMaster.Title.Breadcrumbs = pageTitleTabs;
            SetSelectedAction(null);
        }

        // Enable / disable actions (depending on inheritance)
        SelectBadWordActionControl.Enabled = !chkInheritAction.Checked;
        txtWordReplacement.Enabled         = !chkInheritReplacement.Checked;

        // Show / hide replacement textbox depending on action
        plcReplacement.Visible = ((BadWordActionEnum)Enum.Parse(typeof(BadWordActionEnum), SelectBadWordActionControl.Value.ToString())) == BadWordActionEnum.Replace;
    }
コード例 #20
0
ファイル: Default.aspx.cs プロジェクト: tvelzy/RadstackMedia
    /// <summary>
    /// Checks the declared custom string for presence of the 'testbadword' bad word created by the first code example on this page.
    /// Expects the CreateBadWord method to be run first.
    /// </summary>
    private bool CheckSingleBadWord()
    {
        // Prepare parameters for selection of the checked bad word
        string where = "[WordExpression] = 'testbadword' ";

        // Get the data
        DataSet words = BadWordInfoProvider.GetBadWords(where, null);

        if (!DataHelper.DataSourceIsEmpty(words))
        {
            // Get DataRow with bad word
            DataRow wordDr = words.Tables[0].Rows[0];

            // Get BadWordInfo object
            BadWordInfo badWord = new BadWordInfo(wordDr);

            // String to be checked for presence of the bad word
            string text = "This is a string containing the sample testbadword, which can be created by the first code example on this page.";

            // Hashtable that will contain found bad words
            Hashtable foundWords = new Hashtable();

            // Modify the string according to found bad words and return which action should be performed
            BadWordActionEnum action = BadWordInfoProvider.CheckBadWord(badWord, null, null, ref text, foundWords, 0);

            if (foundWords.Count != 0)
            {
                switch (action)
                {
                case BadWordActionEnum.Deny:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.RequestModeration:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.Remove:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.Replace:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.ReportAbuse:
                    // Some additional actions performed here ...
                    break;

                case BadWordActionEnum.None:
                    // Some additional actions performed here ...
                    break;
                }

                return(true);
            }

            apiCheckSingleBadWord.ErrorMessage = "Bad word 'testbadword' is not present in the checked string.";
            return(false);
        }

        return(false);
    }
コード例 #21
0
ファイル: Default.aspx.cs プロジェクト: v-jli/jean0407large
    /// <summary>
    /// Creates a "testbadword" bad word. Called when the "Create word" button is pressed.
    /// </summary>
    private bool CreateBadWord()
    {
        // Create new bad word object
        BadWordInfo newWord = new BadWordInfo();

        // Set the properties
        newWord.WordExpression = "testbadword";
        newWord.WordAction = BadWordActionEnum.ReportAbuse;
        newWord.WordIsGlobal = true;
        newWord.WordIsRegularExpression = false;

        // Save the bad word
        BadWordInfoProvider.SetBadWordInfo(newWord);

        return true;
    }
コード例 #22
0
ファイル: Default.aspx.cs プロジェクト: v-jli/jean0407large
    /// <summary>
    /// Gets and updates the first single bad word matching the condition. Called when the "Get and update bad word" button is pressed.
    /// Expects the CreateBadWord method to be run first.
    /// </summary>
    private bool GetAndUpdateBadWord()
    {
        // Prepare the parameters
        string where = "[WordExpression] = 'testbadword'";

        // Get the data
        DataSet words = BadWordInfoProvider.GetBadWords(where, null);

        if (!DataHelper.DataSourceIsEmpty(words))
        {
            // Get the bad word's data row
            DataRow wordDr = words.Tables[0].Rows[0];

            // Create object from DataRow
            BadWordInfo modifyWord = new BadWordInfo(wordDr);

            // Update the properties
            modifyWord.WordAction = BadWordActionEnum.Replace;
            modifyWord.WordReplacement = "testpoliteword";

            // Save the changes
            BadWordInfoProvider.SetBadWordInfo(modifyWord);

            return true;
        }

        return false;
    }
コード例 #23
0
ファイル: Default.aspx.cs プロジェクト: v-jli/jean0407large
    /// <summary>
    /// Deletes all "testbadword" bad words. Called when the "Delete bad word(s)" button is pressed.
    /// Expects the CreateBadWord method to be run first.
    /// </summary>
    private bool DeleteBadWord()
    {
        // Prepare the parameters
        string where = "[WordExpression] = 'testbadword' ";

        // Get the data
        DataSet words = BadWordInfoProvider.GetBadWords(where, null);

        if (!DataHelper.DataSourceIsEmpty(words))
        {
            foreach (DataRow wordDr in words.Tables[0].Rows)
            {
                // Create object from DataRow
                BadWordInfo deleteWord = new BadWordInfo(wordDr);

                // Delete the bad word
                BadWordInfoProvider.DeleteBadWordInfo(deleteWord);
            }

            return true;
        }

        return false;
    }