示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((KMBlogMaster)Page.Master).SetTitle("Blog Post Editor");

            if (KMAuthentication.IsUserAdmin(User) == false)
            {
                btnSavePost.Enabled    = false;
                btnPublishPost.Enabled = false;
            }

            if (Page.IsPostBack == false)
            {
                this.LoadMonthNames();
                this.GetPost();
                ClientScript.RegisterClientScriptBlock(
                    this.GetType(),
                    "jquery_start",
                    @"$(document).ready(function()
						{
							$('#editslug').click(function(){$('#slugdiv').fadeIn(100);$('#editslug').remove();
                            return false;});
						});"                        ,
                    true);
            }
        }
示例#2
0
        public void DeletePost(object sender, CommandEventArgs e)
        {
            if (KMAuthentication.IsUserAdmin(User) == false)
            {
                return;
            }

            int postId;

            if (Int32.TryParse(e.CommandArgument.ToString(), out postId) == false)
            {
                return;
            }

            Post.Delete(postId);
            this.GetPostList();
        }
示例#3
0
        public void DeleteCategory(object sender, CommandEventArgs e)
        {
            if (KMAuthentication.IsUserAdmin(User) == false)
            {
                return;
            }

            int categoryId;

            if (Int32.TryParse(e.CommandArgument.ToString(), out categoryId) == false)
            {
                return;
            }

            Category.Delete(categoryId);

            LoadCategories();
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((KMBlogMaster)Page.Master).SetTitle("Category Editor");

            newcategory.SetSaveAsDefaultButton();

            LoadCategories();
            if (KMAuthentication.IsUserAdmin(User) == false)
            {
                newcategory.DisableSave();
            }
            else
            {
                newcategory.CategorySaved += NewCategorySaved;
            }

            if (ClientScript.IsClientScriptBlockRegistered("confirmButtonScript") == false)
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(),
                                                       "confirmButtonScript",
                                                       "function __doConfirm(){if (confirm('Are you sure you want to delete this category?')){return true;}else{return false;}}",
                                                       true);
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((KMBlogMaster)Page.Master).SetTitle("Key Mapper Blog Admin");

            if (KMAuthentication.IsUserAdmin(User) == false)
            {
                lblUserLevel.Text = "Demonstration Mode - you won't be able to save any changes";
            }
            else
            {
                lblUserLevel.Style.Add("Display", "None");
            }

            if (ClientScript.IsClientScriptBlockRegistered("confirmButtonScript") == false)
            {
                ClientScript.RegisterClientScriptBlock(
                    this.GetType(),
                    "confirmButtonScript",
                    "function __doConfirm(){if (confirm('Are you sure you want to delete this post?')){return true;}else{return false;}}",
                    true);
            }

            this.GetPostList();
        }
示例#6
0
        public void SavePost(object sender, CommandEventArgs e)
        {
            if (KMAuthentication.IsUserAdmin(User) == false)
            {
                return;
            }

            Page.Validate();

            bool pageIsValid = Page.IsValid;

            DateTime dt = this.GetPostDate();

            if (dt == DateTime.MinValue)
            {
                string errors = this.GetPostDateErrors();
                date_error.Text = errors;
                pageIsValid     = false;
            }
            else
            {
                date_error.Text = String.Empty;
            }

            if (pageIsValid == false)
            {
                if (slugValidator.IsValid == false)
                {
                    ClientScript.RegisterClientScriptBlock(
                        this.GetType(),
                        "jquery_start",
                        " $(document).ready(function(){$('#editslug').hide(0);$('#slugdiv').show(0);return false;});",
                        true);
                }

                return;
            }

            Post p = new Post();

            int postId;

            if (Int32.TryParse(hiddenPostId.Value, out postId) == false)
            {
                postId = 0;
                p.Slug = this.GetSlug(posttitle.Text);
            }
            else
            {
                p.Slug = postslug.Text;
                if (String.IsNullOrEmpty(p.Slug))
                {
                    p.Slug = this.GetSlug(posttitle.Text);
                }
            }

            p.Id = postId;

            p.Title    = posttitle.Text;
            p.Body     = blogpost.Value;
            p.Postdate = dt;

            p.Published = (e.CommandName == "Publish");

            if (Post.Save(p))
            {
                this.SyncCategories(p.Id);

                if (p.Published)
                {
                    Response.Redirect("admin.aspx");
                }
                else if (postId == 0)
                {
                    Response.Redirect("post-edit.aspx?p=" + Convert.ToString(p.Id));
                }
            }
        }