/// <summary> /// Resets the parent page. /// </summary> /// <param name="page">The page to reset.</param> private void ResetParentPage(BlogEngine.Core.Page page) { foreach (var child in BlogEngine.Core.Page.Pages.Where(child => page.Id == child.Parent)) { child.Parent = Guid.Empty; child.Save(); this.ResetParentPage(child); } }
/// <summary> /// Builds the child page list. /// </summary> /// <param name="page">The page to make a child list for.</param> /// <returns>The page list.</returns> private HtmlGenericControl BuildChildPageList(BlogEngine.Core.Page page) { var ul = new HtmlGenericControl("ul"); foreach (var childPage in BlogEngine.Core.Page.Pages.FindAll(p => p.Parent == page.Id)) { var cLi = new HtmlGenericControl("li"); cLi.Attributes.CssStyle.Add("font-weight", "normal"); var cA = new HtmlAnchor { HRef = string.Format("?id={0}", childPage.Id), InnerHtml = childPage.Title }; var childText = new LiteralControl(string.Format(" ({0}) ", childPage.DateCreated.ToString("yyyy-dd-MM HH:mm"))); const string DeleteText = "Are you sure you want to delete the page?"; var delete = new HtmlAnchor { InnerText = labels.delete }; delete.Attributes["onclick"] = string.Format("if (confirm('{0}')){{location.href='?delete={1}'}}", DeleteText, childPage.Id); delete.HRef = "javascript:void(0);"; delete.Style.Add(HtmlTextWriterStyle.FontWeight, "normal"); cLi.Controls.Add(cA); cLi.Controls.Add(childText); cLi.Controls.Add(delete); if (childPage.HasChildPages) { cLi.Attributes.CssStyle.Remove("font-weight"); cLi.Attributes.CssStyle.Add("font-weight", "bold"); cLi.Controls.Add(this.BuildChildPageList(childPage)); } ul.Controls.Add(cLi); } return(ul); }