protected void btnSavePage_Click(object sender, EventArgs e) { int iPostID = 0; int.TryParse(Request["PostID"], out iPostID); if (iPostID != 0) { BSPost bsPost = BSPost.GetPost(iPostID); bsPost.Title = txtTitle.Text; bsPost.Code = BSHelper.CreateCode(txtTitle.Text); bsPost.Content = tmcePageContent.Content; bsPost.State = (PostStates)short.Parse(ddState.SelectedValue); bsPost.AddComment = cblAddComment.Checked; bsPost.UpdateDate = DateTime.Now; if (bsPost.Save()) { MessageBox1.Message = Language.Admin["PageSaved"]; MessageBox1.Type = MessageBox.ShowType.Information; } else { MessageBox1.Message = Language.Admin["PageError"]; } } }
protected void btnDelete_Click(object sender, EventArgs e) { bool bRemoved = false; for (int i = 0; i < gvPosts.Rows.Count; i++) { CheckBox cb = gvPosts.Rows[i].FindControl("cb") as CheckBox; if (cb.Checked) { Literal literal = gvPosts.Rows[i].FindControl("PostID") as Literal; if (literal != null) { int iPostID = 0; int.TryParse(literal.Text, out iPostID); bRemoved = BSPost.GetPost(iPostID).Remove(); } } } if (bRemoved) { MessageBox1.Message = Language.Admin["PageDeleted"]; MessageBox1.Type = MessageBox.ShowType.Information; MessageBox1.Visible = true; gvPosts.DataBind(); } }
/// <summary> /// Delete Post(s) click action. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbDelete_Click(object sender, EventArgs e) { bool bRemove = false; for (int i = 0; i < gvPosts.Rows.Count; i++) { CheckBox cb = gvPosts.Rows[i].FindControl("cb") as CheckBox; if (cb.Checked) { string PostID = (gvPosts.Rows[i].FindControl("PostID") as Literal).Text; int iPostID = 0; int.TryParse(PostID, out iPostID); BSPost bsPost = BSPost.GetPost(iPostID); bRemove = bsPost.Remove(); } } if (bRemove) { MessageBox1.Message = Language.Admin["PostDeleted"]; MessageBox1.Type = MessageBox.ShowType.Information; gvPosts.DataBind(); } }
void Comment_Approved(object sender, EventArgs e) { BSComment bsComment = (BSComment)sender; if (bsComment.Approve) { using (DataProcess dp = new DataProcess()) { dp.AddParameter("PostID", bsComment.PostID); dp.AddParameter("NotifyMe", true); dp.AddParameter("Approve", true); dp.ExecuteReader("SELECT DISTINCT Email FROM Comments WHERE PostID=@PostID AND NotifyMe=@NotifyMe AND Approve=@Approve"); if (dp.Return.Status == DataProcessState.Success) { BSPost bsPost = BSPost.GetPost(bsComment.PostID); using (IDataReader dr = dp.Return.Value as IDataReader) { while (dr.Read()) { string strEmail = (string)dr["Email"]; System.Threading.ThreadPool.QueueUserWorkItem(delegate { BSHelper.SendMail(Language.Get["NewCommentNotice"], Blogsa.Settings["smtp_email"].ToString(), Blogsa.Settings["smtp_name"].ToString() , strEmail, "", Language.Get["NewCommentNoticeDescription"] + "<br><br><a href=\"" + bsPost.Link + "\">" + bsPost.Title + "</a>", true); }); } } } } } }
protected void btnSavePost_Click(object sender, EventArgs e) { try { int iFileID = 0; int.TryParse(Request["FileID"], out iFileID); BSPost bsPost = BSPost.GetPost(iFileID); bsPost.Content = tmceContent.Content; bsPost.State = (PostStates)Convert.ToInt16(ddState.SelectedValue); bsPost.AddComment = cblAddComment.Checked; bsPost.UpdateDate = DateTime.Now; Categories1.SaveData(bsPost.PostID); Tags1.SaveTags(bsPost.PostID); if (bsPost.Save()) { Response.Redirect("Library.aspx?FileID=" + bsPost.PostID + "&Message=1"); } else { MessageBox1.Message = "Error"; MessageBox1.Type = MessageBox.ShowType.Error; } } catch (Exception ex) { MessageBox1.Message = ex.Message; MessageBox1.Type = MessageBox.ShowType.Error; } }
protected void Page_Load(object sender, EventArgs e) { btnDelete.OnClientClick = "return confirm('" + Language.Admin["CategoryDeleteConfirm"] + "');"; HideAll(); int iFileID = 0; int.TryParse(Request["FileID"], out iFileID); if (!string.IsNullOrEmpty(Request["p"]) && Request["p"].Equals("new")) { divAddMedia.Visible = true; } else if (iFileID != 0) { divEditMedia.Visible = true; divEditMediaSide.Visible = true; divEditMedia.Visible = true; divEditMediaSide.Visible = true; if (!IsPostBack) { BSPost bsPost = BSPost.GetPost(iFileID); if (bsPost != null) { tmceContent.Content = bsPost.Content; txtTitle.Text = bsPost.Title; cblAddComment.Checked = bsPost.AddComment; ddState.SelectedValue = bsPost.State.ToString(); Categories1.TermType = TermTypes.Category; Categories1.LoadData(bsPost.PostID); Tags1.LoadTags(bsPost.PostID); ddState.Items[0].Text = Language.Admin["HiddenFile"]; ddState.Items[1].Text = Language.Admin["PublicFile"]; cblAddComment.Text = Language.Admin["CommentAdd"]; string strFolder = bsPost.Show == PostVisibleTypes.Hidden ? "Files/" : bsPost.Show == PostVisibleTypes.Public ? "Images/" : "Files/"; ltOpenAddress.Text = "Upload/" + strFolder + bsPost.Title; ltShowAddress.Text = "?FileID=" + bsPost.PostID; ltDownloadAdress.Text = "FileHandler.ashx?FileID=" + bsPost.PostID; } else { Response.Redirect("Library.aspx"); } } } else { if (!IsPostBack) { gvPosts.DataBind(); } divLibrary.Visible = true; } }
/// <summary> /// Page Pre Render /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_PreRender(object sender, EventArgs e) { GetControlsLanguage(); string Msg = Request.QueryString["Message"]; switch (Msg) { case "1": BSPost p = BSPost.GetPost(Convert.ToInt32(Request["PostID"])); MessageBox1.Message = Language.Admin["PostSaved"] + " - <a class=\"sbtn bsdarkblue\" href=\"" + p.Link + "\"><span>" + Language.Admin["ShowPost"] + "</span></a>"; break; default: break; } ClientScript.RegisterClientScriptBlock(this.GetType(), "autosavemode", "autosavemode=true;", true); }
/// <summary> /// Page Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { gvhDefault.SearchButton.Click += new EventHandler(lbSearch_Click); GenerateHeaderButtons(); if (!Page.IsPostBack) { HideAll(); string PostID = Request.QueryString["PostID"]; int iPostID = 0; int.TryParse(PostID, out iPostID); if (iPostID > 0) { BSPost bsPost = BSPost.GetPost(iPostID); divAddPost.Visible = true; divAddPostSide.Visible = true; if (bsPost != null) { tmceContent.Content = bsPost.Content; txtTitle.Text = bsPost.Title; cblAddComment.Checked = bsPost.AddComment; ddState.SelectedValue = bsPost.State.ToString(); Categories1.TermType = TermTypes.Category; Categories1.LoadData(bsPost.PostID); Tags1.LoadTags(bsPost.PostID); rblDate.Items[0].Text = Language.Admin["NowPublish"]; rblDate.Items[1].Text = Language.Admin["ChangeDateTime"]; dtsDateTime.SelectedDateTime = bsPost.Date; } else { Response.Redirect("Posts.aspx"); } } else { divPosts.Visible = true; gvPosts.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string commentID = Request["CommentID"]; int iCommentID = 0; int.TryParse(commentID, out iCommentID); if (iCommentID > 0) { divComments.Visible = false; divEditComment.Visible = true; divSideEditComment.Visible = true; BSComment bsComment = BSComment.GetComment(iCommentID); txtName.Text = bsComment.UserName; txtWebSite.Text = bsComment.WebPage; txtComment.Text = bsComment.Content; txtEMail.Text = bsComment.Email; ltIP.Text = bsComment.IP; rblState.SelectedValue = bsComment.Approve ? "1" : "0"; ltCommentedPost.Text = BSPost.GetPost(bsComment.PostID).LinkedTitle; // DateTime txtDateDay.Text = bsComment.Date.Day.ToString("00"); txtDateMonth.Text = bsComment.Date.Month.ToString("00"); txtDateYear.Text = bsComment.Date.Year.ToString("0000"); txtTimeHour.Text = bsComment.Date.Hour.ToString("00"); txtTimeMinute.Text = bsComment.Date.Minute.ToString("00"); txtTimeSecond.Text = bsComment.Date.Second.ToString("00"); } else { divComments.Visible = true; divEditComment.Visible = false; divSideEditComment.Visible = false; gvItems.DataBind(); } } btnDelete.OnClientClick = "return confirm('" + Language.Admin["CommentDeleteConfirm"] + "');"; }
/// <summary> /// Save Post(s) click action. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSavePost_Click(object sender, EventArgs e) { try { string PostID = Request.QueryString["PostID"]; int iPostID = 0; int.TryParse(PostID, out iPostID); BSPost bsPost = BSPost.GetPost(iPostID); bsPost.Title = txtTitle.Text; bsPost.Code = BSHelper.CreateCode(txtTitle.Text); bsPost.Content = tmceContent.Content; bsPost.State = (PostStates)Convert.ToInt16(ddState.SelectedValue); bsPost.AddComment = cblAddComment.Checked; bsPost.UpdateDate = DateTime.Now; if (rblDate.SelectedValue == "1") { bsPost.Date = dtsDateTime.SelectedDateTime; } Categories1.SaveData(bsPost.PostID); Tags1.SaveTags(bsPost.PostID); if (bsPost.Save()) { Response.Redirect("Posts.aspx?PostID=" + PostID + "&Message=1"); } else { MessageBox1.Message = Language.Admin["PostError"]; MessageBox1.Type = MessageBox.ShowType.Error; } } catch (Exception ex) { MessageBox1.Message = ex.Message; MessageBox1.Type = MessageBox.ShowType.Error; } }
protected void Page_Load(object sender, EventArgs e) { GenerateHeaderButtons(); ddState.Items[1].Text = Language.Admin["Draft"]; ddState.Items[0].Text = Language.Admin["Publish"]; cblAddComment.Text = Language.Admin["CommentAdd"]; if (!Page.IsPostBack) { HideAll(); int iPostID = 0; int.TryParse(Request["PostID"], out iPostID); if (iPostID != 0) { divAddPost.Visible = true; divAddPostSide.Visible = true; BSPost bsPost = BSPost.GetPost(iPostID); if (bsPost != null) { txtTitle.Text = bsPost.Title; tmcePageContent.Content = bsPost.Content; ddState.SelectedValue = bsPost.State.ToString(); cblAddComment.Checked = bsPost.AddComment; } else { Response.Redirect("Pages.aspx"); } } else { divPosts.Visible = true; gvPosts.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request["act"]) && Request["act"].Equals("delete")) { string strPostID = Request["PostID"]; int iPostID = 0; int.TryParse(strPostID, out iPostID); if (iPostID > 0) { BSPost bsPost = BSPost.GetPost(iPostID); if (bsPost != null) { bsPost.Remove(); } } Response.Redirect("AutoSaves.aspx"); } rpAutoSaves.DataSource = BSPost.GetPosts(PostTypes.AutoSave, PostStates.Draft, 10); rpAutoSaves.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string tag = Request["Tag"]; string postID = Request["PostID"]; string postCode = Request["Code"]; string category = Request["Category"]; string fileID = Request["FileID"]; string langCode = Request["Language"]; if (!string.IsNullOrEmpty(fileID)) { postID = fileID; } int iPostID = 0; int.TryParse(postID, out iPostID); BSPost bsPost = null; if (iPostID != 0) { bsPost = BSPost.GetPost(iPostID); } else if (!string.IsNullOrEmpty(postCode)) { bsPost = BSPost.GetPost(postCode); } if (bsPost != null) { if (bsPost.State == PostStates.Published && (bsPost.Type != PostTypes.AutoSave)) { PostDetail = true; bsPost.ReadCount++; bsPost.Save(); this.Page.Title = Blogsa.Title + " - " + bsPost.Title; BSHelper.AddHeader(this.Page, "keywords", bsPost.GetTagsWithComma()); System.Web.UI.HtmlControls.HtmlGenericControl gc = new System.Web.UI.HtmlControls.HtmlGenericControl(); gc.InnerHtml = bsPost.Content; BSHelper.AddHeader(this.Page, "description", gc.InnerText.Length > 160 ? gc.InnerText.Substring(0, 160) : gc.InnerText); BSHelper.AddHeader(this.Page, "robots", "index,follow"); List <BSPost> posts = new List <BSPost>(); posts.Add(bsPost); rpPosts.DataSource = posts; rpPosts.DataBind(); } } else if (tag != null) { tag = BSHelper.CreateCode(tag); List <BSPost> posts = BSPost.GetPostsByTerm(0, tag, TermTypes.Tag, PostTypes.Article, PostStates.Published); ObjectPager pager = new ObjectPager(); int pageCount = pager.PageCount(posts, 10); rpPosts.DataSource = pager.GetPage(posts, 0, 10); rpPosts.DataBind(); } else if (category != null) { category = BSHelper.CreateCode(category); List <BSPost> posts = BSPost.GetPostsByTerm(0, category, TermTypes.Category, PostTypes.Article, PostStates.Published); ObjectPager pager = new ObjectPager(); int pageCount = pager.PageCount(posts, 10); rpPosts.DataSource = pager.GetPage(posts, 0, 10); rpPosts.DataBind(); } else { int iCurrentPage = 0; int.TryParse(Request["Page"], out iCurrentPage); if (iCurrentPage <= 0) { iCurrentPage = 1; } List <BSPost> posts = BSPost.GetPosts(PostTypes.Article, PostStates.Published, 0); Panel pnlPaging = new Panel(); pnlPaging.CssClass = "paging"; Literal ltPaging = new Literal(); pnlPaging.Controls.Add(ltPaging); BSPlaceHolderPaging.Controls.Add(pnlPaging); rpPosts.DataSource = Data.Paging(posts, iCurrentPage, ltPaging); rpPosts.DataBind(); } if (rpPosts.Items.Count == 0) { Literal l = new Literal(); l.Text = Language.Get["NoWrite"]; Controls.AddAt(0, l); } }
// Call RSS public static void GetRSS(Page page, RssTypes type) { XmlTextWriter writer = new XmlTextWriter(page.Response.OutputStream, System.Text.Encoding.UTF8); WriteRSSPrologue(writer, type); List <BSPost> posts = new List <BSPost>(); int intFeedCount = Blogsa.Settings["show_feed_count"] != null?Convert.ToInt32(Blogsa.Settings["show_feed_count"]) : 10; if (type == RssTypes.Comments) { List <BSComment> comments = BSComment.GetComments(CommentStates.Approved); if (comments.Count > 0) { foreach (BSComment comment in comments) { BSPost bsPost = BSPost.GetPost(comment.PostID); AddRSSItem(writer, bsPost.Title, bsPost.Link + "#Comments" + comment.CommentID, comment.Content, comment.Date.ToString("EEE, dd MMMM yyyy HH:mm:ss Z"), comment.UserName); } WriteRSSClosing(writer); writer.Flush(); writer.Close(); page.Response.ContentEncoding = System.Text.Encoding.UTF8; page.Response.ContentType = "text/xml"; page.Response.Cache.SetCacheability(HttpCacheability.NoCache); page.Response.End(); } } else if (type == RssTypes.CommentsByPost) { List <BSComment> comments = BSComment.GetCommentsByPostID(Convert.ToInt32(HttpContext.Current.Request["PostID"]), CommentStates.Approved); if (comments.Count > 0) { BSPost bsPost = BSPost.GetPost(Convert.ToInt32(HttpContext.Current.Request["PostID"])); foreach (BSComment comment in comments) { AddRSSItem(writer, bsPost.Title, bsPost.Link + "#Comments" + comment.CommentID, comment.Content, comment.Date.ToString("EEE, dd MMMM yyyy HH:mm:ss Z"), comment.UserName); } WriteRSSClosing(writer); writer.Flush(); writer.Close(); page.Response.ContentEncoding = System.Text.Encoding.UTF8; page.Response.ContentType = "text/xml"; page.Response.Cache.SetCacheability(HttpCacheability.NoCache); page.Response.End(); } } else if (type == RssTypes.Posts) { posts = BSPost.GetPosts(PostTypes.Article, PostStates.Published, 10); if (posts.Count > 0) { foreach (BSPost post in posts) { AddRSSItem(writer, post.Title, post.Link, post.Content, post.Date.ToString("EEE, dd MMMM yyyy HH:mm:ss Z"), post.UserName); } WriteRSSClosing(writer); writer.Flush(); writer.Close(); page.Response.ContentEncoding = System.Text.Encoding.UTF8; page.Response.ContentType = "text/xml"; page.Response.Cache.SetCacheability(HttpCacheability.NoCache); page.Response.End(); } } }
private static void FillMenu(IDataReader dr, BSMenu menu) { menu.Description = (string)dr["Description"]; menu.MenuGroupID = (int)dr["MenuGroupID"]; menu.MenuID = (int)dr["MenuID"]; menu.MenuType = (MenuTypes)dr["MenuType"]; menu.ObjectID = (int)dr["ObjectID"]; menu.ObjectType = (ObjectTypes)dr["ObjectType"]; menu.ParentID = (int)dr["ParentID"]; menu.Sort = (short)dr["Sort"]; menu.Target = (string)dr["Target"]; menu.Title = (string)dr["Title"]; menu.Url = (string)dr["Url"]; if (menu.Url.StartsWith("~/")) { menu.Url = Blogsa.Url + menu.Url.Substring(2); } switch (menu.ObjectType) { case ObjectTypes.Article: BSPost article = BSPost.GetPost(menu.ObjectID); if (article != null) { menu.Title = article.Title; menu.Url = article.Link; } break; case ObjectTypes.Page: BSPost page = BSPost.GetPost(menu.ObjectID); if (page != null) { menu.Title = page.Title; menu.Url = page.Link; } break; case ObjectTypes.File: BSPost file = BSPost.GetPost(menu.ObjectID); if (file != null) { menu.Title = file.Title; menu.Url = file.Link; } break; case ObjectTypes.Link: BSLink link = BSLink.GetLink(menu.ObjectID); if (link != null) { menu.Title = link.Name; menu.Url = link.Url; } break; case ObjectTypes.Term: BSTerm term = BSTerm.GetTerm(menu.ObjectID); if (term != null) { menu.Title = term.Name; menu.Url = term.Link; } break; case ObjectTypes.Comment: BSComment comment = BSComment.GetComment(menu.ObjectID); if (comment != null) { menu.Title = comment.Content; menu.Url = comment.Link; } break; default: break; } }
protected void btnDelete_Click(object sender, EventArgs e) { string Command = ""; for (int i = 0; i < gvPosts.Rows.Count; i++) { CheckBox cb = gvPosts.Rows[i].FindControl("cb") as CheckBox; if (cb.Checked) { Literal literal = gvPosts.Rows[i].FindControl("PostID") as Literal; if (literal != null) { string PostID = literal.Text; BSPost bsPost = BSPost.GetPost(Convert.ToInt32(PostID)); string filePath = string.Empty; string filePathWeb = string.Empty; string filePathThumbnail = string.Empty; if (bsPost.Show == 0) { filePath = "~/Upload/Files/" + bsPost.Title; } else if (bsPost.Show == PostVisibleTypes.Public) { filePath = "~/Upload/Images/" + bsPost.Title; filePathWeb = "~/Upload/Images/_w/" + bsPost.Title; filePathThumbnail = "~/Upload/Images/_t/" + bsPost.Title; } else if (bsPost.Show == PostVisibleTypes.Custom) { filePath = "~/Upload/Medias/" + bsPost.Title; } filePath = Server.MapPath(filePath); filePathWeb = Server.MapPath(filePathWeb); filePathThumbnail = Server.MapPath(filePathThumbnail); try { if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } if (System.IO.File.Exists(filePathWeb)) { System.IO.File.Delete(filePathWeb); } if (System.IO.File.Exists(filePathThumbnail)) { System.IO.File.Delete(filePathThumbnail); } } catch { } if (bsPost.Remove()) { Command = "OK"; } } } } if (Command != "") { MessageBox1.Message = Language.Admin["MediaDeleted"]; MessageBox1.Type = MessageBox.ShowType.Information; gvPosts.DataBind(); } }
public static string GetLink(int iPostID) { return(GetLink(BSPost.GetPost(iPostID))); }