public void UpdateContents(int blockId, [FromBody] HtmlContents htmlContents) { // Enable proxy creation since security is being checked and need to navigate parent authorities SetProxyCreation(true); var person = GetPerson(); var block = new BlockService((RockContext)Service.Context).Get(blockId); if (block != null && block.IsAuthorized(Rock.Security.Authorization.EDIT, person)) { var htmlContentService = (HtmlContentService)Service; var htmlContent = htmlContentService.GetActiveContent(blockId, htmlContents.EntityValue); if (htmlContent != null) { htmlContent.Content = htmlContents.Content; if (!System.Web.HttpContext.Current.Items.Contains("CurrentPerson")) { System.Web.HttpContext.Current.Items.Add("CurrentPerson", person); } Service.Context.SaveChanges(); HtmlContentService.FlushCachedContent(blockId, htmlContents.EntityValue); } } }
public int AddSiteMaps(SiteMaps siteMaps, HtmlContents contents) { var siteMap = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.UrlSegment == siteMaps.UrlSegment); if (siteMap != null) { throw new Exception("Url has exists, please try another Url"); } if (siteMaps.IsHomePage.HasValue && siteMaps.IsHomePage.Value) { var homePage = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.IsHomePage.HasValue && x.IsHomePage.Value); if (homePage != null) { homePage.IsHomePage = false; } } DayaxeDbContext.SiteMaps.InsertOnSubmit(siteMaps); Commit(); contents.SiteMapId = siteMaps.Id; DayaxeDbContext.HtmlContents.InsertOnSubmit(contents); Commit(); return(siteMaps.Id); }
protected void SaveHtmlContentsClick(object sender, EventArgs e) { LblMessage.Visible = false; if (Request.Params["id"] == "0") { _siteMaps = new SiteMaps { Code = string.Empty, IsActive = IsActiveCheckBox.Checked, Name = PageNameText.Text.Trim(), UrlSegment = GetPermalink(PageNameText.Text), IsHomePage = IsHomePageCheckBox.Checked }; _htmlContents = new HtmlContents { Title = PageTitleText.Text, Data = ContentHtmlEditor.Text, ScriptAnalyticsHeader = ScriptAnalyticsEditor.Text, BodyClass = BodyClassText.Text, MetaDescription = DescriptionText.Text, MetaKeyword = KeywordText.Text }; int siteMapId; try { siteMapId = _helper.AddSiteMaps(_siteMaps, _htmlContents); } catch (Exception ex) { LblMessage.Text = ex.Message; LblMessage.Visible = true; return; } Response.Redirect(string.Format("/ContentPage.aspx?id=" + siteMapId)); } _siteMaps.Name = PageNameText.Text.Trim(); _siteMaps.UrlSegment = GetPermalink(PageNameText.Text); _siteMaps.IsHomePage = IsHomePageCheckBox.Checked; _siteMaps.IsActive = IsActiveCheckBox.Checked; _htmlContents.Title = PageTitleText.Text; _htmlContents.Data = ContentHtmlEditor.Text; _htmlContents.ScriptAnalyticsHeader = ScriptAnalyticsEditor.Text; _htmlContents.BodyClass = BodyClassText.Text; _htmlContents.MetaDescription = DescriptionText.Text; _htmlContents.MetaKeyword = KeywordText.Text; _helper.UpdateSiteMaps(_siteMaps, _htmlContents); _helper.ResetCache(); }
public void UpdateSiteMaps(SiteMaps siteMaps, HtmlContents contents) { var siteMap = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.Id == siteMaps.Id); if (siteMap != null) { if (siteMaps.IsHomePage.HasValue && siteMaps.IsHomePage.Value) { var homePage = DayaxeDbContext.SiteMaps.FirstOrDefault(x => x.IsHomePage.HasValue && x.IsHomePage.Value); if (homePage != null) { homePage.IsHomePage = false; } } siteMap.Name = siteMaps.Name; siteMap.UrlSegment = siteMaps.UrlSegment; siteMap.IsHomePage = siteMaps.IsHomePage; siteMap.IsActive = siteMaps.IsActive; var htmlContents = DayaxeDbContext.HtmlContents.FirstOrDefault(x => x.ContentId == contents.ContentId); if (htmlContents != null) { htmlContents.Title = contents.Title; htmlContents.Data = contents.Data; htmlContents.ScriptAnalyticsHeader = contents.ScriptAnalyticsHeader; htmlContents.BodyClass = contents.BodyClass; htmlContents.MetaDescription = contents.MetaDescription; htmlContents.MetaKeyword = contents.MetaKeyword; htmlContents.ImageLandingDesktop = contents.ImageLandingDesktop; htmlContents.ImageLandingMobile = contents.ImageLandingMobile; } Commit(); } }
protected void Page_Init(object sender, EventArgs e) { Session["Active"] = "ContentsPage"; if (!IsPostBack) { Session["UserHotel"] = null; Session["CurrentPage"] = 1; if (Request.Params["id"] == null) { MarketMultiView.ActiveViewIndex = 0; ContentPageRpt.DataSource = _helper.GetAllSiteMaps(); ContentPageRpt.DataBind(); } else { MarketMultiView.ActiveViewIndex = 1; int id = int.Parse(Request.Params["id"]); // Add New if (id > 0) { _siteMaps = _helper.GetSiteMapsById(id); if (_siteMaps != null) { string json = JsonConvert.SerializeObject(_siteMaps, CustomSettings.SerializerSettings()); Session["SiteMaps"] = json; PageNameText.Text = _siteMaps.Name; UrlSegmentText.Text = _siteMaps.UrlSegment; IsHomePageCheckBox.Checked = _siteMaps.IsHomePage.HasValue && _siteMaps.IsHomePage.Value; IsActiveCheckBox.Checked = _siteMaps.IsActive; _htmlContents = _helper.GetHtmlContentsBySiteMapsId(id); if (_htmlContents != null) { json = JsonConvert.SerializeObject(_htmlContents, CustomSettings.SerializerSettings()); Session["HtmlContents"] = json; PageTitleText.Text = _htmlContents.Title; ScriptAnalyticsEditor.Text = _htmlContents.ScriptAnalyticsHeader; ContentHtmlEditor.Text = _htmlContents.Data; BodyClassText.Text = _htmlContents.BodyClass; DescriptionText.Text = _htmlContents.MetaDescription; KeywordText.Text = _htmlContents.MetaKeyword; LandingImageDesktop.ImageUrl = _htmlContents.ImageLandingDesktop; LandingImageMobile.ImageUrl = _htmlContents.ImageLandingMobile; } } } else { IsActiveCheckBox.Checked = true; } } } else { string sessionSiteMaps = Session["SiteMaps"] != null ? Session["SiteMaps"].ToString() : string.Empty; _siteMaps = JsonConvert.DeserializeObject <SiteMaps>(sessionSiteMaps); string sessionHtmlContents = Session["HtmlContents"] != null ? Session["HtmlContents"].ToString() : string.Empty; _htmlContents = JsonConvert.DeserializeObject <HtmlContents>(sessionHtmlContents); } }
protected void Page_Init(object sender, EventArgs e) { if (Master == null) { throw new HttpException(404, ErrorMessage.MasterNotFound); } HtmlGenericControl body = (HtmlGenericControl)Master.FindControl("body"); if (Page.RouteData.Values["urlSegment"] != null) { var urlSegment = (string)Page.RouteData.Values["urlSegment"]; bool isInvalidTicket = false; switch (urlSegment) { case "signup": case "signin": var signupControl = (AuthControlWithoutPopup)LoadControl("~/Controls/AuthControlWithoutPopup.ascx"); var multiView = (MultiView)ControlExtensions.FindControlRecursive(signupControl, "AuthMultiView"); if (multiView != null) { if (urlSegment == "signup") { multiView.ActiveViewIndex = 0; TitleLiteral.Text = "Sign Up"; } else { if (PublicCustomerInfos != null && Request.Params["ReturnUrl"] != null) { if (Request.RawUrl.Contains(Constant.ConfirmPageProduct)) { var ticketControl = (InvalidTicket)LoadControl("~/Controls/InvalidTicket.ascx"); ContentPlaceHolder.Controls.Add(ticketControl); isInvalidTicket = true; } else { Response.Redirect(HttpUtility.UrlDecode(Request.Params["ReturnUrl"])); } } TitleLiteral.Text = "Sign In"; multiView.ActiveViewIndex = 1; } if (Request.Params["sp"] != null && (Session["UserSession"] == null || (Session["UserSession"] != null && string.Equals(Request.Params["sp"], (string)Session["UserSession"], StringComparison.OrdinalIgnoreCase)))) { ShowAuth = true; multiView.ActiveViewIndex = 3; } } AuthControl.Visible = false; // Sign in but do not have permission if (!isInvalidTicket) { ContentPlaceHolder.Controls.Add(signupControl); } break; case "invalid-ticket": var invalidTicketControl = (InvalidTicket)LoadControl("~/Controls/InvalidTicket.ascx"); ContentPlaceHolder.Controls.Add(invalidTicketControl); AuthControl.Visible = false; break; case "my-account": body.Attributes["class"] += " my-account-page"; // Users Do not log in if (PublicCustomerInfos == null) { var loginLinkButton = (HtmlAnchor)ControlExtensions.FindControlRecursive(Master, "LoginLinkButton"); loginLinkButton.Visible = false; Response.Redirect(string.Format(Constant.SignIpPage, HttpUtility.UrlEncode(Request.Url.PathAndQuery))); } var myAccountControl = (MyAccount)LoadControl("~/Controls/MyAccount.ascx"); ContentPlaceHolder.Controls.Add(myAccountControl); AuthControl.Visible = false; footer.Visible = false; NewsletterControl.Visible = false; break; default: if (urlSegment == "my-day-passes") { if (PublicCustomerInfos == null) { Response.Redirect(string.Format(Constant.SignIpPage, HttpUtility.UrlEncode(Request.Url.PathAndQuery))); } } _content = _helper.GetHtmlContentsByUrlSegment(urlSegment); if (_content == null) { throw new HttpException(404, ErrorMessage.NotFound); } break; } } else { _content = _helper.GetDefaultHtmlContents(); //var homeControl = (HomePageContent)LoadControl("~/LandingTemplate/homepage.ascx"); //ContentPlaceHolder.Controls.Add(homeControl); //IsHome = true; body.Attributes["class"] += " home-page"; } if (_content != null) { body.Attributes["class"] += string.Format(" {0} {1}", Page.RouteData.Values["urlSegment"], _content.BodyClass); BindHeaderInfo(); BindContentInfo(); BindMyDayPassInfo(); BindImageLanding(); BindHomeProductFeatured(); } }