protected override void OnInit( EventArgs e ) { Rock.Web.UI.DialogMasterPage masterPage = this.Page.Master as Rock.Web.UI.DialogMasterPage; if ( masterPage != null ) masterPage.OnSave += new EventHandler<EventArgs>( masterPage_OnSave ); try { int pageId = Convert.ToInt32( PageParameter( "Page" ) ); _page = Rock.Web.Cache.Page.Read( pageId ); if ( _page.Authorized( "Configure", CurrentUser ) ) { var attributeControls = Rock.Attribute.Helper.GetEditControls( _page, !Page.IsPostBack ); foreach ( HtmlGenericControl fs in attributeControls ) phAttributes.Controls.Add( fs ); } else { DisplayError( "You are not authorized to edit this page" ); } } catch ( SystemException ex ) { DisplayError( ex.Message ); } base.OnInit( e ); }
protected override void OnInit(EventArgs e) { Rock.Web.UI.DialogMasterPage masterPage = this.Page.Master as Rock.Web.UI.DialogMasterPage; if (masterPage != null) { masterPage.OnSave += new EventHandler <EventArgs>(masterPage_OnSave); } try { int pageId = Convert.ToInt32(PageParameter("Page")); _page = Rock.Web.Cache.Page.Read(pageId); if (_page.Authorized("Configure", CurrentUser)) { var attributeControls = Rock.Attribute.Helper.GetEditControls(_page, !Page.IsPostBack); foreach (HtmlGenericControl fs in attributeControls) { phAttributes.Controls.Add(fs); } } else { DisplayError("You are not authorized to edit this page"); } } catch (SystemException ex) { DisplayError(ex.Message); } base.OnInit(e); }
protected override void OnInit(EventArgs e) { PageInstance.AddScriptLink(Page, "~/Scripts/bootstrap-tabs.js"); int pageId = Convert.ToInt32(PageParameter("EditPage")); _page = Rock.Web.Cache.Page.Read(pageId); _zoneName = this.PageParameter("ZoneName"); lAllPages.Text = string.Format("All Pages Using '{0}' Layout", PageInstance.Layout); // TODO: Managing layout block instances should probably be controlled by site security if (_page.Authorized("Configure", CurrentUser)) { gLayoutBlocks.DataKeyNames = new string[] { "id" }; gLayoutBlocks.Actions.EnableAdd = true; gLayoutBlocks.Actions.AddClick += LayoutBlocks_Add; gLayoutBlocks.GridReorder += gLayoutBlocks_GridReorder; gLayoutBlocks.GridRebind += gLayoutBlocks_GridRebind; } if (_page.Authorized("Configure", CurrentUser)) { gPageBlocks.DataKeyNames = new string[] { "id" }; gPageBlocks.Actions.EnableAdd = true; gPageBlocks.Actions.AddClick += gPageBlocks_GridAdd; gPageBlocks.GridReorder += gPageBlocks_GridReorder; gPageBlocks.GridRebind += gPageBlocks_GridRebind; } string script = string.Format(@" Sys.Application.add_load(function () {{ $('td.grid-icon-cell.delete a').click(function(){{ return confirm('Are you sure you want to delete this block?'); }}); $('#modal-popup div.modal-header h3 small', window.parent.document).html('{1}'); $('#{2} a').click(function() {{ $('#{4}').val('Page'); }}); $('#{3} a').click(function() {{ $('#{4}').val('Layout'); }}); }}); ", gPageBlocks.ClientID, _zoneName, liPage.ClientID, liLayout.ClientID, hfOption.ClientID); this.Page.ClientScript.RegisterStartupScript(this.GetType(), string.Format("grid-confirm-delete-{0}", gPageBlocks.ClientID), script, true); base.OnInit(e); }
protected override void OnInit(EventArgs e) { try { int pageId = Convert.ToInt32(PageParameter("EditPage")); _page = Rock.Web.Cache.Page.Read(pageId); if (_page != null) { canConfigure = _page.Authorized("Configure", CurrentUser); } else { canConfigure = PageInstance.Authorized("Configure", CurrentUser); } if (canConfigure) { rGrid.DataKeyNames = new string[] { "id" }; rGrid.Actions.EnableAdd = true; rGrid.Actions.AddClick += rGrid_GridAdd; rGrid.GridReorder += new GridReorderEventHandler(rGrid_GridReorder); rGrid.GridRebind += new GridRebindEventHandler(rGrid_GridRebind); string script = string.Format(@" Sys.Application.add_load(function () {{ $('td.grid-icon-cell.delete a').click(function(){{ return confirm('Are you sure you want to delete this page?'); }}); }}); ", rGrid.ClientID); this.Page.ClientScript.RegisterStartupScript(this.GetType(), string.Format("grid-confirm-delete-{0}", rGrid.ClientID), script, true); } else { DisplayError("You are not authorized to configure this page"); } } catch (SystemException ex) { DisplayError(ex.Message); } base.OnInit(e); }
protected override void OnInit( EventArgs e ) { try { int pageId = Convert.ToInt32( PageParameter( "EditPage" ) ); _page = Rock.Web.Cache.Page.Read( pageId ); if ( _page != null ) canConfigure = _page.Authorized( "Configure", CurrentUser ); else canConfigure = PageInstance.Authorized( "Configure", CurrentUser ); if ( canConfigure ) { rGrid.DataKeyNames = new string[] { "id" }; rGrid.Actions.EnableAdd = true; rGrid.Actions.AddClick += rGrid_GridAdd; rGrid.GridReorder += new GridReorderEventHandler( rGrid_GridReorder ); rGrid.GridRebind += new GridRebindEventHandler( rGrid_GridRebind ); string script = string.Format( @" Sys.Application.add_load(function () {{ $('td.grid-icon-cell.delete a').click(function(){{ return confirm('Are you sure you want to delete this page?'); }}); }}); ", rGrid.ClientID ); this.Page.ClientScript.RegisterStartupScript( this.GetType(), string.Format( "grid-confirm-delete-{0}", rGrid.ClientID ), script, true ); } else { DisplayError( "You are not authorized to configure this page" ); } } catch ( SystemException ex ) { DisplayError( ex.Message ); } base.OnInit( e ); }
protected override void OnInit( EventArgs e ) { PageInstance.AddScriptLink( Page, "~/Scripts/bootstrap-tabs.js" ); int pageId = Convert.ToInt32( PageParameter( "EditPage" ) ); _page = Rock.Web.Cache.Page.Read( pageId ); _zoneName = this.PageParameter( "ZoneName" ); lAllPages.Text = string.Format( "All Pages Using '{0}' Layout", PageInstance.Layout ); // TODO: Managing layout block instances should probably be controlled by site security if ( _page.Authorized( "Configure", CurrentUser ) ) { gLayoutBlocks.DataKeyNames = new string[] { "id" }; gLayoutBlocks.Actions.EnableAdd = true; gLayoutBlocks.Actions.AddClick += LayoutBlocks_Add; gLayoutBlocks.GridReorder += gLayoutBlocks_GridReorder; gLayoutBlocks.GridRebind += gLayoutBlocks_GridRebind; } if ( _page.Authorized( "Configure", CurrentUser ) ) { gPageBlocks.DataKeyNames = new string[] { "id" }; gPageBlocks.Actions.EnableAdd = true; gPageBlocks.Actions.AddClick += gPageBlocks_GridAdd; gPageBlocks.GridReorder += gPageBlocks_GridReorder; gPageBlocks.GridRebind += gPageBlocks_GridRebind; } string script = string.Format( @" Sys.Application.add_load(function () {{ $('td.grid-icon-cell.delete a').click(function(){{ return confirm('Are you sure you want to delete this block?'); }}); $('#modal-popup div.modal-header h3 small', window.parent.document).html('{1}'); $('#{2} a').click(function() {{ $('#{4}').val('Page'); }}); $('#{3} a').click(function() {{ $('#{4}').val('Layout'); }}); }}); ", gPageBlocks.ClientID, _zoneName, liPage.ClientID, liLayout.ClientID, hfOption.ClientID ); this.Page.ClientScript.RegisterStartupScript( this.GetType(), string.Format( "grid-confirm-delete-{0}", gPageBlocks.ClientID ), script, true ); base.OnInit( e ); }
/// <summary> /// Determine the logical page being requested by evaluating the routedata, or querystring and /// then loading the appropriate layout (ASPX) page /// </summary> /// <param name="requestContext"></param> /// <returns></returns> System.Web.IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext) { if (requestContext == null) { throw new ArgumentNullException("requestContext"); } string pageId = ""; int routeId = -1; // Pages using the default routing URL will have the page id in the RouteData.Values collection if (requestContext.RouteData.Values["PageId"] != null) { pageId = (string)requestContext.RouteData.Values["PageId"]; } // Pages that use a custom URL route will have the page id in the RouteDate.DataTokens collection else if (requestContext.RouteData.DataTokens["PageId"] != null) { pageId = (string)requestContext.RouteData.DataTokens["PageId"]; routeId = Int32.Parse((string)requestContext.RouteData.DataTokens["RouteId"]); } // If page has not been specified get the site by the domain and use the site's default page else { string host = requestContext.HttpContext.Request.Url.Host; string cacheKey = "Rock:DomainSites"; ObjectCache cache = MemoryCache.Default; Dictionary <string, int> sites = cache[cacheKey] as Dictionary <string, int>; if (sites == null) { sites = new Dictionary <string, int>(); } Rock.Web.Cache.Site site = null; if (sites.ContainsKey(host)) { site = Rock.Web.Cache.Site.Read(sites[host]); } else { Rock.CMS.SiteDomainService siteDomainService = new Rock.CMS.SiteDomainService(); Rock.CMS.SiteDomain siteDomain = siteDomainService.GetByDomainContained(requestContext.HttpContext.Request.Url.Host); if (siteDomain != null) { sites.Add(host, siteDomain.SiteId); site = Rock.Web.Cache.Site.Read(siteDomain.SiteId); } } cache[cacheKey] = sites; if (site != null && site.DefaultPageId.HasValue) { pageId = site.DefaultPageId.Value.ToString(); } if (string.IsNullOrEmpty(pageId)) { throw new SystemException("Invalid Site Configuration"); } } Rock.Web.Cache.Page page = null; if (!string.IsNullOrEmpty(pageId)) { page = Rock.Web.Cache.Page.Read(Convert.ToInt32(pageId)); if (page == null) { return(new HttpHandlerError(404)); } } if (page != null && !String.IsNullOrEmpty(page.LayoutPath)) { // load the route id page.RouteId = routeId; // Return the page using the cached route Rock.Web.UI.Page cmsPage = (Rock.Web.UI.Page)BuildManager.CreateInstanceFromVirtualPath(page.LayoutPath, typeof(Rock.Web.UI.Page)); cmsPage.PageInstance = page; return(cmsPage); } else { string theme = "RockCMS"; string layout = "Default"; string layoutPath = Rock.Web.Cache.Page.FormatPath(theme, layout); if (page != null) { // load the route id page.RouteId = routeId; theme = page.Site.Theme; layout = page.Layout; layoutPath = Rock.Web.Cache.Page.FormatPath(theme, layout); page.LayoutPath = layoutPath; } else { page = Cache.Page.Read(new CMS.Page()); } try { // Return the page for the selected theme and layout Rock.Web.UI.Page cmsPage = (Rock.Web.UI.Page)BuildManager.CreateInstanceFromVirtualPath(layoutPath, typeof(Rock.Web.UI.Page)); cmsPage.PageInstance = page; return(cmsPage); } catch (System.Web.HttpException) { // The Selected theme and/or layout didn't exist, attempt first to use the default layout in the selected theme layout = "Default"; // If not using the Rock theme, verify that default Layout exists in the selected theme directory if (theme != "RockCMS" && !File.Exists(requestContext.HttpContext.Server.MapPath(string.Format("~/Themes/{0}/Layouts/Default.aspx", theme)))) { // If default layout doesn't exist in the selected theme, switch to the Default layout theme = "RockCMS"; layout = "Default"; } // Build the path to the aspx file to layoutPath = Rock.Web.Cache.Page.FormatPath(theme, layout); if (page != null) { page.LayoutPath = layoutPath; } // Return the default layout and/or theme Rock.Web.UI.Page cmsPage = (Rock.Web.UI.Page)BuildManager.CreateInstanceFromVirtualPath(layoutPath, typeof(Rock.Web.UI.Page)); cmsPage.PageInstance = page; return(cmsPage); } } }