Exemple #1
0
        /// <summary>
        /// The add_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Add_Click(object sender, EventArgs e)
        {
            short sortOrder = 0;

            if (!ValidationHelper.IsValidPosShort(this.txtExecOrder.Text.Trim()))
            {
                PageContext.AddLoadMessage("The sort order value should be a positive integer from 0 to 32767.");
                return;
            }

            if (!short.TryParse(this.txtExecOrder.Text.Trim(), out sortOrder))
            {
                PageContext.AddLoadMessage("You must enter an number value from 0 to 32767 for sort order.");
                return;
            }

            DB.bbcode_save(
                BBCodeID,
                PageContext.PageBoardID,
                this.txtName.Text.Trim(),
                this.txtDescription.Text,
                this.txtOnClickJS.Text,
                this.txtDisplayJS.Text,
                this.txtEditJS.Text,
                this.txtDisplayCSS.Text,
                this.txtSearchRegEx.Text,
                this.txtReplaceRegEx.Text,
                this.txtVariables.Text,
                this.chkUseModule.Checked,
                this.txtModuleClass.Text,
                sortOrder);
            PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.CustomBBCode));
            ReplaceRulesCreator.ClearCache();
            YafBuildLink.Redirect(ForumPages.admin_bbcode);
        }
        /// <summary>
        /// The save_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void save_Click(object sender, EventArgs e)
        {
            string code    = this.Code.Text.Trim();
            string emotion = this.Emotion.Text.Trim();
            string icon    = this.Icon.SelectedItem.Text.Trim();
            int    sortOrder;

            if (emotion.Length > 50)
            {
                PageContext.AddLoadMessage("An emotion description is too long.");
                return;
            }

            if (code.Length == 0)
            {
                PageContext.AddLoadMessage("Please enter the code to use for this emotion.");
                return;
            }

            if (code.Length > 10)
            {
                PageContext.AddLoadMessage("The code to use for this emotion should not be more then 10 symbols.");
                return;
            }

            if (!new System.Text.RegularExpressions.Regex(@"\[.+\]").IsMatch(code))
            {
                PageContext.AddLoadMessage("Please enter the code to use for this emotion in square brackets.");
                return;
            }

            if (emotion.Length == 0)
            {
                PageContext.AddLoadMessage("Please enter an emotion for this icon.");
                return;
            }

            if (this.Icon.SelectedIndex < 1)
            {
                PageContext.AddLoadMessage("Please select an icon to use for this emotion.");
                return;
            }

            // Ederon 9/4/2007
            if (!int.TryParse(this.SortOrder.Text, out sortOrder) || sortOrder < 0 || sortOrder > 255)
            {
                PageContext.AddLoadMessage("Sort order must be number between 0 and 255.");
                return;
            }

            DB.smiley_save(Request.QueryString.GetFirstOrDefault("s"), PageContext.PageBoardID, code, icon, emotion, sortOrder, 0);

            // invalidate the cache...
            PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.Smilies));
            ReplaceRulesCreator.ClearCache();

            YafBuildLink.Redirect(ForumPages.admin_smilies);
        }
Exemple #3
0
        /// <summary>
        /// The list_ item command.
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void List_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "add":
                YafBuildLink.Redirect(ForumPages.admin_smilies_edit);
                break;

            case "edit":
                YafBuildLink.Redirect(ForumPages.admin_smilies_edit, "s={0}", e.CommandArgument);
                break;

            case "moveup":
                DB.smiley_resort(PageContext.PageBoardID, e.CommandArgument, -1);

                // invalidate the cache...
                PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.Smilies));
                BindData();
                ReplaceRulesCreator.ClearCache();
                break;

            case "movedown":
                DB.smiley_resort(PageContext.PageBoardID, e.CommandArgument, 1);

                // invalidate the cache...
                PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.Smilies));
                BindData();
                ReplaceRulesCreator.ClearCache();
                break;

            case "delete":
                DB.smiley_delete(e.CommandArgument);

                // invalidate the cache...
                PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.Smilies));
                BindData();
                ReplaceRulesCreator.ClearCache();
                break;

            case "import":
                YafBuildLink.Redirect(ForumPages.admin_smilies_import);
                break;
            }
        }
        /// <summary>
        /// The import_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void import_Click(object sender, EventArgs e)
        {
            if (long.Parse(this.File.SelectedValue) < 1)
            {
                PageContext.AddLoadMessage("You must select a .pak file to import.");
                return;
            }

            string fileName = Request.MapPath("{0}{1}/{2}".FormatWith(YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Emoticons, this.File.SelectedItem.Text));
            string split    = Regex.Escape("=+:");

            using (var file = new StreamReader(fileName))
            {
                int sortOrder = 1;

                // Delete existing smilies?
                if (this.DeleteExisting.Checked)
                {
                    DB.smiley_delete(null);
                }
                else
                {
                    // Get max value of SortOrder
                    using (DataView dv = DB.smiley_listunique(PageContext.PageBoardID).DefaultView)
                    {
                        dv.Sort = "SortOrder desc";
                        if (dv.Count > 0)
                        {
                            DataRowView dr = dv[0];
                            if (dr != null)
                            {
                                object o = dr["SortOrder"];
                                if (int.TryParse(o.ToString(), out sortOrder))
                                {
                                    sortOrder++;
                                }
                            }
                        }
                    }
                }

                do
                {
                    string line = file.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    string[] lineSplit = Regex.Split(line, split, RegexOptions.None);

                    if (lineSplit.Length == 3)
                    {
                        DB.smiley_save(null, PageContext.PageBoardID, lineSplit[2], lineSplit[0], lineSplit[1], sortOrder, 0);
                        sortOrder++;
                    }
                }while (true);

                file.Close();

                // invalidate the cache...
                PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.Smilies));
                ReplaceRulesCreator.ClearCache();
            }

            YafBuildLink.Redirect(ForumPages.admin_smilies);
        }
 /// <summary>
 /// The replace rules cache reset_ click.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 protected void ReplaceRulesCacheReset_Click(object sender, EventArgs e)
 {
     ReplaceRulesCreator.ClearCache();
     this.CheckCache();
 }