private void DeleteBBCode_Click(object sender, EventArgs e) { #region 除当前Discuz!NT代码信息 if (this.CheckCookie()) { //DbHelper.ExecuteNonQuery("DELETE FROM [" + BaseConfigs.GetTablePrefix + "bbcodes] WHERE [id]=" + DNTRequest.GetString("id")); BBCodes.DeleteBBCode(DNTRequest.GetString("id")); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "删除Discuz!NT代码", "TAB为:" + tag.Text); base.RegisterStartupScript("PAGE", "window.location.href='forum_bbcodegrid.aspx';"); } #endregion }
/// <summary> /// 增加Discuz!NT代码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddAdInfo_Click(object sender, EventArgs e) { #region 添加Discuz!NT代码 if (this.CheckCookie()) { BBCodes.CreateBBCCode(int.Parse(available.SelectedValue), Regex.Replace(tag.Text.Replace("<", "").Replace(">", ""), @"^[\>]|[\{]|[\}]|[\[]|[\]]|[\']|[\.]", ""), icon.UpdateFile(), replacement.Text, example.Text, explanation.Text, param.Text, nest.Text, paramsdescript.Text, paramsdefvalue.Text); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加Discuz!NT代码", "TAG为:" + tag.Text); base.RegisterStartupScript("", "<script>window.location.href='forum_bbcodegrid.aspx';</script>"); } #endregion }
private void SetUnAvailable_Click(object sender, EventArgs e) { #region 将选定的Discuz!NT代码置为无效状态 if (this.CheckCookie()) { if (DNTRequest.GetString("id") != "") { BBCodes.BatchUpdateAvailable(0, DNTRequest.GetString("id")); Response.Redirect("forum_bbcodegrid.aspx"); } else { base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='forum_bbcodegrid.aspx';</script>"); } } #endregion }
private void DelRec_Click(object sender, EventArgs e) { #region 除选定的discuz!NT代码 if (this.CheckCookie()) { if (DNTRequest.GetString("id") != "") { BBCodes.DeleteBBCode(DNTRequest.GetString("id")); Response.Redirect("forum_bbcodegrid.aspx"); } else { base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='forum_bbcodegrid.aspx';</script>"); } } #endregion }
public void LoadAnnounceInf(int id) { #region 加载当前Discuz!NT代码相关信息 DataTable dt = BBCodes.GetBBCode(id); if (dt.Rows.Count > 0) { available.SelectedValue = dt.Rows[0]["available"].ToString(); tag.Text = dt.Rows[0]["tag"].ToString(); replacement.Text = dt.Rows[0]["replacement"].ToString(); example.Text = dt.Rows[0]["example"].ToString(); explanation.Text = dt.Rows[0]["explanation"].ToString(); paramsdescript.Text = dt.Rows[0]["paramsdescript"].ToString(); paramsdefvalue.Text = dt.Rows[0]["paramsdefvalue"].ToString(); nest.Text = dt.Rows[0]["nest"].ToString(); param.Text = dt.Rows[0]["params"].ToString(); icon.Text = dt.Rows[0]["icon"].ToString(); ViewState["inco"] = dt.Rows[0]["icon"].ToString(); } #endregion }
private void UpdateBBCodeInfo_Click(object sender, EventArgs e) { #region 更新当前Discuz!NT代码信息 if (this.CheckCookie()) { SortedList sl = new SortedList(); sl.Add("参数个数", param.Text); sl.Add("嵌套次数", nest.Text); foreach (DictionaryEntry s in sl) { if (!Utils.IsInt(s.Value.ToString())) { base.RegisterStartupScript("", "<script>alert('输入错误:" + s.Key.ToString() + ",只能是0或者正整数');window.location.href='forum_editbbcode.aspx';</script>"); return; } } string filepath = icon.UpdateFile(); if (filepath == "") { filepath = ViewState["inco"].ToString(); } BBCodes.UpdateBBCode( int.Parse(available.SelectedValue), Regex.Replace(tag.Text.Replace("<", "").Replace(">", ""), @"^[\>]|[\{]|[\}]|[\[]|[\]]|[\']|[\.]", ""), filepath, replacement.Text, example.Text, explanation.Text, param.Text, nest.Text, paramsdescript.Text, paramsdefvalue.Text, DNTRequest.GetInt("id", 0)); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "更新Discuz!NT代码", "TAB为:" + tag.Text); base.RegisterStartupScript("PAGE", "window.location.href='forum_bbcodegrid.aspx';"); } #endregion }
public void BindData() { DataGrid1.AllowCustomPaging = false; DataGrid1.DataSource = BBCodes.GetBBCode(); DataGrid1.DataBind(); }
public static void Main() { var codigo = new BBCodes(BBCodes.Bold); Console.WriteLine(codigo.Wrap("StackOverflow")); }
public static string ToStringDescription(this BBCodes code) { var attributes = (DescriptionAttribute[])code.GetType().GetField(code.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : ""); }
public static string Wrap(this BBCodes code, string contents) => $"[{code.ToStringDescription()}]{contents}[/{code.ToStringDescription()}]";