public override MobileBlock GetMobile(string parameter)
        {
            var       pageGuid = GetAttributeValue("DetailPage");
            PageCache page     = PageCache.Read(pageGuid.AsGuid());

            if (page != null && page.IsAuthorized("View", CurrentPerson))
            {
                CustomAttributes["ActionType"] = "1";
            }

            CustomAttributes["InitialRequest"] = "0"; //Request for pull to refresh
            var groups = GetGroupElements(0);

            CustomAttributes["Content"] = JsonConvert.SerializeObject(groups);
            if (groups.Any())
            {
                CustomAttributes["NextReqest"] = "1"; //Next request
            }

            CustomAttributes["Component"] = "Avalanche.Components.ListView.ColumnListView";

            return(new MobileBlock()
            {
                BlockType = "Avalanche.Blocks.ListViewBlock",
                Attributes = CustomAttributes
            });
        }
示例#2
0
        /// <summary>
        /// Renders the page into the stream.
        /// </summary>
        /// <param name="stream">The stream to write the page contents to.</param>
        /// <returns>A task that can be awaited.</returns>
        public async Task <IActionResult> RenderAsync()
        {
            if (!PageCache.IsAuthorized(Authorization.VIEW, CurrentPerson))
            {
                if (CurrentPerson != null)
                {
                    return(new ForbidResult());
                }
                else
                {
                    return(Site.RedirectToLoginPageResult(true));
                }
            }

            FindZones();

            var preRenderTask = PreRenderAsync();

            AddScriptLink(ResolveRockUrl("~/Scripts/Bundles/RockLibs.js"));
            AddScriptLink(ResolveRockUrl("~/Scripts/Bundles/RockUi.js"));
            //AddScriptLink( ResolveRockUrl( "~/Scripts/Bundles/RockValidation.js" ) );

            await preRenderTask;

            GenerateAdminFooter();

            await RenderInternalAsync();

            FinalizePageContent();

            return(new HtmlObjectResult(LayoutDocument.DocumentElement.OuterHtml));
        }
示例#3
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var canAdministrateBlockOnPage = false;
            var pageBlocks = PageCache.Blocks;

            foreach (Rock.Web.Cache.BlockCache block in pageBlocks)
            {
                bool canAdministrate = block.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
                bool canEdit         = block.IsAuthorized(Authorization.EDIT, CurrentPerson);
                bool canView         = block.IsAuthorized(Authorization.VIEW, CurrentPerson);

                // Make sure user has access to view block instance
                if (canAdministrate || canEdit || canView)
                {
                    Control control = null;

                    // Check to see if block is configured to use a "Cache Duration'
                    if (block.OutputCacheDuration > 0)
                    {
                        RockMemoryCache cache         = RockMemoryCache.Default;
                        string          blockCacheKey = string.Format("Rock:BlockOutput:{0}", block.Id);
                        if (cache.Contains(blockCacheKey))
                        {
                            // If the current block exists in our custom output cache, add the cached output instead of adding the control
                            control = new LiteralControl(cache[blockCacheKey] as string);
                        }
                    }

                    if (control == null)
                    {
                        try
                        {
                            control = TemplateControl.LoadControl(block.BlockType.Path);
                            control.ClientIDMode = ClientIDMode.AutoID;
                        }
                        catch (Exception)
                        {
                            // Swallow this exception--NOM NOM
                        }
                    }

                    if (control != null)
                    {
                        if (canAdministrate || (canEdit && control is RockBlockCustomSettings))
                        {
                            canAdministrateBlockOnPage = true;
                        }
                    }
                }
            }

            if (PageCache.IncludeAdminFooter && (PageCache.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson) || canAdministrateBlockOnPage))
            {
                RockPage.AddCSSLink(ResolveRockUrl("~~/Styles/theme.css"));
            }
        }
示例#4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (_page == null)
            {
                int pageId = Convert.ToInt32(PageParameter("Page"));
                _page = Rock.Web.Cache.PageCache.Read(pageId);
            }

            if (!Page.IsPostBack && _page.IsAuthorized("Administrate", CurrentPerson))
            {
                PageService     pageService = new PageService();
                Rock.Model.Page page        = pageService.Get(_page.Id);

                LoadSites();
                if (_page.Layout != null)
                {
                    ddlSite.SelectedValue = _page.Layout.SiteId.ToString();
                    LoadLayouts(_page.Layout.Site);
                    ddlLayout.SelectedValue = _page.Layout.Id.ToString();
                }

                rptProperties.DataSource = _tabs;
                rptProperties.DataBind();

                tbPageName.Text     = _page.InternalName;
                tbPageTitle.Text    = _page.PageTitle;
                tbBrowserTitle.Text = _page.BrowserTitle;
                ppParentPage.SetValue(pageService.Get(page.ParentPageId ?? 0));
                tbIconCssClass.Text = _page.IconCssClass;

                cbPageTitle.Checked       = _page.PageDisplayTitle;
                cbPageBreadCrumb.Checked  = _page.PageDisplayBreadCrumb;
                cbPageIcon.Checked        = _page.PageDisplayIcon;
                cbPageDescription.Checked = _page.PageDisplayDescription;

                ddlMenuWhen.SelectedValue = ((int)_page.DisplayInNavWhen).ToString();
                cbMenuDescription.Checked = _page.MenuDisplayDescription;
                cbMenuIcon.Checked        = _page.MenuDisplayIcon;
                cbMenuChildPages.Checked  = _page.MenuDisplayChildPages;

                cbBreadCrumbIcon.Checked = _page.BreadCrumbDisplayIcon;
                cbBreadCrumbName.Checked = _page.BreadCrumbDisplayName;

                cbRequiresEncryption.Checked = _page.RequiresEncryption;
                cbEnableViewState.Checked    = _page.EnableViewState;
                cbIncludeAdminFooter.Checked = _page.IncludeAdminFooter;
                tbCacheDuration.Text         = _page.OutputCacheDuration.ToString();
                tbDescription.Text           = _page.Description;
                ceHeaderContent.Text         = _page.HeaderContent;
                tbPageRoute.Text             = string.Join(",", page.PageRoutes.Select(route => route.Route).ToArray());

                // Add enctype attribute to page's <form> tag to allow file upload control to function
                Page.Form.Attributes.Add("enctype", "multipart/form-data");
            }

            base.OnLoad(e);
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            try
            {
                int pageId = Convert.ToInt32(PageParameter("EditPage"));
                _page = PageCache.Get(pageId);

                if (_page != null)
                {
                    canConfigure = _page.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
                }
                else
                {
                    canConfigure = IsUserAuthorized(Authorization.ADMINISTRATE);
                }

                if (canConfigure)
                {
                    rGrid.DataKeyNames              = new string[] { "Id" };
                    rGrid.Actions.ShowAdd           = true;
                    rGrid.Actions.AddClick         += rGrid_GridAdd;
                    rGrid.Actions.ShowExcelExport   = false;
                    rGrid.Actions.ShowMergeTemplate = false;
                    rGrid.GridReorder += new GridReorderEventHandler(rGrid_GridReorder);
                    rGrid.GridRebind  += new GridRebindEventHandler(rGrid_GridRebind);

                    DialogPage dialogPage = this.Page as DialogPage;
                    if (dialogPage != null && _page.ParentPageId != null)
                    {
                        dialogPage.SubTitle = string.Format("<a href='{0}' target='_parent' >parent page</a>", ResolveRockUrl("~/page/" + _page.ParentPageId));
                    }
                }
                else
                {
                    DisplayError("You are not authorized to configure this page");
                }
            }
            catch (SystemException ex)
            {
                DisplayError(ex.Message);
            }

            base.OnInit(e);
        }
示例#6
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            nbMessage.Visible = false;

            if (_Page != null && _Page.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson))
            {
                if (!Page.IsPostBack)
                {
                    LoadDropDowns();
                    BindGrids();
                }
            }
            else
            {
                pnlLists.Visible  = false;
                nbMessage.Text    = "You are not authorized to edit these blocks";
                nbMessage.Visible = true;
            }

            base.OnLoad(e);
        }
示例#7
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            try
            {
                int pageId = int.MinValue;
                if (int.TryParse(PageParameter("Page"), out pageId))
                {
                    _page = Rock.Web.Cache.PageCache.Read(pageId);

                    DialogMasterPage masterPage = this.Page.Master as DialogMasterPage;
                    if (masterPage != null)
                    {
                        masterPage.OnSave  += new EventHandler <EventArgs>(masterPage_OnSave);
                        masterPage.SubTitle = string.Format("Id: {0}", _page.Id);
                    }

                    if (_page.IsAuthorized("Administrate", CurrentPerson))
                    {
                        ddlMenuWhen.BindToEnum(typeof(DisplayInNavWhen));

                        phAttributes.Controls.Clear();
                        Rock.Attribute.Helper.AddEditControls(_page, phAttributes, !Page.IsPostBack);

                        var blockContexts = new Dictionary <string, string>();
                        foreach (var block in _page.Blocks)
                        {
                            var blockControl = TemplateControl.LoadControl(block.BlockType.Path) as RockBlock;
                            if (blockControl != null)
                            {
                                blockControl.SetBlock(block);
                                foreach (var context in blockControl.ContextTypesRequired)
                                {
                                    if (!blockContexts.ContainsKey(context.Name))
                                    {
                                        blockContexts.Add(context.Name, context.FriendlyName);
                                    }
                                }
                            }
                        }

                        phContextPanel.Visible = blockContexts.Count > 0;

                        foreach (var context in blockContexts)
                        {
                            var tbContext = new RockTextBox();
                            tbContext.ID       = string.Format("context_{0}", context.Key.Replace('.', '_'));
                            tbContext.Required = true;
                            tbContext.Label    = context.Value + " Parameter Name";
                            tbContext.Help     = "The page parameter name that contains the id of this context entity.";
                            if (_page.PageContexts.ContainsKey(context.Key))
                            {
                                tbContext.Text = _page.PageContexts[context.Key];
                            }

                            phContext.Controls.Add(tbContext);
                        }
                    }
                    else
                    {
                        DisplayError("You are not authorized to edit this page");
                    }
                }
                else
                {
                    DisplayError("Invalid Page Id value");
                }
            }
            catch (SystemException ex)
            {
                DisplayError(ex.Message);
            }

            base.OnInit(e);
        }
        /// <summary>
        /// Processes the action.
        /// </summary>
        /// <param name="controller">The API controller that initiated this action.</param>
        /// <param name="pageGuid">The page unique identifier.</param>
        /// <param name="blockGuid">The block unique identifier.</param>
        /// <param name="actionName">Name of the action.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        internal static IHttpActionResult ProcessAction(ApiControllerBase controller, Guid?pageGuid, Guid?blockGuid, string actionName, JToken parameters)
        {
            try
            {
                BlockCache blockCache = null;
                PageCache  pageCache  = null;

                //
                // Find the block.
                //
                if (blockGuid.HasValue)
                {
                    blockCache = BlockCache.Get(blockGuid.Value);
                }

                if (blockCache == null)
                {
                    return(new NotFoundResult(controller));
                }

                // Find the page.
                if (pageGuid.HasValue)
                {
                    pageCache = PageCache.Get(pageGuid.Value);
                }
                else
                {
                    // This can be removed once the obsolete API endpoints
                    // that allowed for sending an action to a block identifier
                    // without a page identifier are removed.
                    pageCache = blockCache.Page;
                }

                if (blockCache == null || pageCache == null)
                {
                    return(new NotFoundResult(controller));
                }

                //
                // Get the authenticated person and make sure it's cached.
                //
                var person = GetPerson(controller, null);
                HttpContext.Current.AddOrReplaceItem("CurrentPerson", person);

                //
                // Ensure the user has access to both the page and block.
                //
                if (!pageCache.IsAuthorized(Security.Authorization.VIEW, person) || !blockCache.IsAuthorized(Security.Authorization.VIEW, person))
                {
                    return(new StatusCodeResult(HttpStatusCode.Unauthorized, controller));
                }

                //
                // Get the class that handles the logic for the block.
                //
                var blockCompiledType = blockCache.BlockType.GetCompiledType();
                var block             = Activator.CreateInstance(blockCompiledType);

                if (!(block is Blocks.IRockBlockType rockBlock))
                {
                    return(new NotFoundResult(controller));
                }

                var requestContext = controller.RockRequestContext;

                //
                // Set the basic block parameters.
                //
                rockBlock.BlockCache     = blockCache;
                rockBlock.PageCache      = pageCache;
                rockBlock.RequestContext = requestContext;

                var actionParameters = new Dictionary <string, JToken>(StringComparer.InvariantCultureIgnoreCase);

                //
                // Parse any posted parameter data.
                //
                if (parameters != null)
                {
                    try
                    {
                        foreach (var kvp in parameters.ToObject <Dictionary <string, JToken> >())
                        {
                            if (kvp.Key == "__context")
                            {
                                // If we are given any page parameters then
                                // override the query string parameters. This
                                // is what allows mobile and obsidian blocks to
                                // pass in the original page parameters.
                                if (kvp.Value["pageParameters"] != null)
                                {
                                    var pageParameters = kvp.Value["pageParameters"].ToObject <Dictionary <string, string> >();

                                    rockBlock.RequestContext.SetPageParameters(pageParameters);
                                }
                            }
                            else
                            {
                                actionParameters.AddOrReplace(kvp.Key, kvp.Value);
                            }
                        }
                    }
                    catch
                    {
                        return(new BadRequestErrorMessageResult("Invalid parameter data.", controller));
                    }
                }

                //
                // Parse any query string parameter data.
                //
                foreach (var q in controller.Request.GetQueryNameValuePairs())
                {
                    actionParameters.AddOrReplace(q.Key, JToken.FromObject(q.Value.ToString()));
                }

                requestContext.AddContextEntitiesForPage(pageCache);

                return(InvokeAction(controller, rockBlock, actionName, actionParameters, parameters));
            }
            catch (Exception ex)
            {
                return(new BadRequestErrorMessageResult(ex.Message, controller));
            }
        }
        /// <summary>
        /// Processes the action.
        /// </summary>
        /// <param name="verb">The HTTP Method Verb that was used for the request.</param>
        /// <param name="pageIdentifier">The page identifier (either Guid or int).</param>
        /// <param name="blockIdentifier">The block identifier (either Guid or int).</param>
        /// <param name="actionName">Name of the action.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        private IHttpActionResult ProcessAction(string verb, string pageIdentifier, string blockIdentifier, string actionName, JToken parameters)
        {
            try
            {
                PageCache  pageCache  = null;
                BlockCache blockCache = null;

                var pageGuid  = pageIdentifier.AsGuidOrNull();
                var pageId    = pageIdentifier.AsIntegerOrNull();
                var blockGuid = blockIdentifier.AsGuidOrNull();
                var blockId   = blockIdentifier.AsIntegerOrNull();

                //
                // Find the page.
                //
                if (pageGuid.HasValue)
                {
                    pageCache = PageCache.Get(pageGuid.Value);
                }
                else if (pageId.HasValue)
                {
                    pageCache = PageCache.Get(pageId.Value);
                }

                //
                // Find the block.
                //
                if (blockGuid.HasValue)
                {
                    blockCache = BlockCache.Get(blockGuid.Value);
                }
                else if (blockId.HasValue)
                {
                    blockCache = BlockCache.Get(blockId.Value);
                }

                if (pageCache == null || blockCache == null)
                {
                    return(NotFound());
                }

                //
                // Get the authenticated person and make sure it's cached.
                //
                var person = GetPerson();
                HttpContext.Current.AddOrReplaceItem("CurrentPerson", person);

                //
                // Ensure the user has access to both the page and block.
                //
                if (!pageCache.IsAuthorized(Security.Authorization.VIEW, person) || !blockCache.IsAuthorized(Security.Authorization.VIEW, person))
                {
                    return(StatusCode(HttpStatusCode.Unauthorized));
                }

                //
                // Get the class that handles the logic for the block.
                //
                var blockCompiledType = blockCache.BlockType.GetCompiledType();
                var block             = Activator.CreateInstance(blockCompiledType);

                if (!(block is Blocks.IRockBlockType rockBlock))
                {
                    return(NotFound());
                }

                //
                // Set the basic block parameters.
                //
                rockBlock.BlockCache     = blockCache;
                rockBlock.PageCache      = pageCache;
                rockBlock.RequestContext = new Net.RockRequestContext(Request);

                var actionParameters = new Dictionary <string, JToken>();

                //
                // Parse any posted parameter data.
                //
                if (parameters != null)
                {
                    try
                    {
                        foreach (var kvp in parameters.ToObject <Dictionary <string, JToken> >())
                        {
                            actionParameters.AddOrReplace(kvp.Key, kvp.Value);
                        }
                    }
                    catch
                    {
                        return(BadRequest("Invalid parameter data."));
                    }
                }

                //
                // Parse any query string parameter data.
                //
                foreach (var q in Request.GetQueryNameValuePairs())
                {
                    actionParameters.AddOrReplace(q.Key, JToken.FromObject(q.Value.ToString()));
                }

                return(InvokeAction(rockBlock, verb, actionName, actionParameters));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            DialogMasterPage masterPage = this.Page.Master as DialogMasterPage;

            if (masterPage != null)
            {
                masterPage.OnSave += new EventHandler <EventArgs>(masterPage_OnSave);
            }

            try
            {
                int pageId = Convert.ToInt32(PageParameter("Page"));
                _page = Rock.Web.Cache.PageCache.Read(pageId);

                if (_page.IsAuthorized("Administrate", CurrentPerson))
                {
                    phAttributes.Controls.Clear();
                    Rock.Attribute.Helper.AddEditControls(_page, phAttributes, !Page.IsPostBack);

                    List <string> blockContexts = new List <string>();
                    foreach (var block in _page.Blocks)
                    {
                        var blockControl = TemplateControl.LoadControl(block.BlockType.Path) as RockBlock;
                        if (blockControl != null)
                        {
                            blockControl.CurrentPage  = _page;
                            blockControl.CurrentBlock = block;
                            foreach (var context in blockControl.ContextTypesRequired)
                            {
                                if (!blockContexts.Contains(context))
                                {
                                    blockContexts.Add(context);
                                }
                            }
                        }
                    }

                    phContextPanel.Visible = blockContexts.Count > 0;

                    int i = 0;
                    foreach (string context in blockContexts)
                    {
                        var tbContext = new RockTextBox();
                        tbContext.ID       = string.Format("context_{0}", i++);
                        tbContext.Required = true;
                        tbContext.Label    = context;

                        if (_page.PageContexts.ContainsKey(context))
                        {
                            tbContext.Text = _page.PageContexts[context];
                        }

                        phContext.Controls.Add(tbContext);
                    }
                }
                else
                {
                    DisplayError("You are not authorized to edit this page");
                }
            }
            catch (SystemException ex)
            {
                DisplayError(ex.Message);
            }

            base.OnInit(e);
        }
示例#11
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit( EventArgs e )
        {
            try
            {
                int pageId = int.MinValue;
                if ( int.TryParse( PageParameter( "Page" ), out pageId ) )
                {
                    _page = Rock.Web.Cache.PageCache.Read( pageId );

                    DialogMasterPage masterPage = this.Page.Master as DialogMasterPage;
                    if ( masterPage != null )
                    {
                        masterPage.OnSave += new EventHandler<EventArgs>( masterPage_OnSave );
                        masterPage.SubTitle = string.Format( "Id: {0}", _page.Id );
                    }

                    if ( _page.IsAuthorized( "Administrate", CurrentPerson ) )
                    {
                        ddlMenuWhen.BindToEnum( typeof( DisplayInNavWhen ) );

                        phAttributes.Controls.Clear();
                        Rock.Attribute.Helper.AddEditControls( _page, phAttributes, !Page.IsPostBack );

                        var blockContexts = new Dictionary<string, string>();
                        foreach ( var block in _page.Blocks )
                        {
                            var blockControl = TemplateControl.LoadControl( block.BlockType.Path ) as RockBlock;
                            if ( blockControl != null )
                            {
                                blockControl.SetBlock( block );
                                foreach ( var context in blockControl.ContextTypesRequired )
                                {
                                    if ( !blockContexts.ContainsKey( context.Name ) )
                                    {
                                        blockContexts.Add( context.Name, context.FriendlyName );
                                    }
                                }
                            }
                        }

                        phContextPanel.Visible = blockContexts.Count > 0;

                        foreach ( var context in blockContexts )
                        {
                            var tbContext = new RockTextBox();
                            tbContext.ID = string.Format( "context_{0}", context.Key.Replace( '.', '_' ) );
                            tbContext.Required = true;
                            tbContext.Label = context.Value + " Parameter Name";
                            tbContext.Help = "The page parameter name that contains the id of this context entity.";
                            if ( _page.PageContexts.ContainsKey( context.Key ) )
                            {
                                tbContext.Text = _page.PageContexts[context.Key];
                            }

                            phContext.Controls.Add( tbContext );
                        }
                    }
                    else
                    {
                        DisplayError( "You are not authorized to edit this page" );
                    }
                }
                else
                {
                    DisplayError( "Invalid Page Id value" );
                }
            }
            catch ( SystemException ex )
            {
                DisplayError( ex.Message );
            }

            base.OnInit( e );
        }
示例#12
0
        protected void GenerateAdminFooter(bool canAdministrateBlockOnPage = false)
        {
            bool canAdministratePage = PageCache.IsAuthorized(Rock.Security.Authorization.ADMINISTRATE, CurrentPerson);
            bool canEditPage         = PageCache.IsAuthorized(Rock.Security.Authorization.EDIT, CurrentPerson);

            if (PageCache.IncludeAdminFooter && (canAdministratePage || canAdministrateBlockOnPage || canEditPage))
            {
                // Add the page admin script
                AddScriptLink(ResolveRockUrl("~/Scripts/Bundles/RockAdmin.js"), false);

                var adminFooter = LayoutDocument.CreateElement("div");
                adminFooter.SetAttribute("id", "cms-admin-footer");
                LayoutDocument.Body.AppendChild(adminFooter);

                //phLoadStats = new PlaceHolder();
                //adminFooter.Controls.Add( phLoadStats );

                //// If the current user is Impersonated by another user, show a link on the admin bar to login back in as the original user
                //var impersonatedByUser = Session["ImpersonatedByUser"] as UserLogin;
                //var currentUserIsImpersonated = ( HttpContext.Current?.User?.Identity?.Name ?? string.Empty ).StartsWith( "rckipid=" );
                //if ( canAdministratePage && currentUserIsImpersonated && impersonatedByUser != null )
                //{
                //    HtmlGenericControl impersonatedByUserDiv = new HtmlGenericControl( "span" );
                //    impersonatedByUserDiv.AddCssClass( "label label-default margin-l-md" );
                //    _btnRestoreImpersonatedByUser = new LinkButton();
                //    _btnRestoreImpersonatedByUser.ID = "_btnRestoreImpersonatedByUser";
                //    //_btnRestoreImpersonatedByUser.CssClass = "btn";
                //    _btnRestoreImpersonatedByUser.Visible = impersonatedByUser != null;
                //    _btnRestoreImpersonatedByUser.Click += _btnRestoreImpersonatedByUser_Click;
                //    _btnRestoreImpersonatedByUser.Text = $"<i class='fa-fw fa fa-unlock'></i> " + $"Restore { impersonatedByUser?.Person?.ToString()}";
                //    impersonatedByUserDiv.Controls.Add( _btnRestoreImpersonatedByUser );
                //    adminFooter.Controls.Add( impersonatedByUserDiv );
                //}

                var buttonBar = LayoutDocument.CreateElement("div");
                adminFooter.AppendChild(buttonBar);
                buttonBar.SetAttribute("class", "button-bar");

                // RockBlock Config
                if (canAdministratePage || canAdministrateBlockOnPage)
                {
                    var aBlockConfig = JavascriptIconLinkElement("Block Configuration", "btn block-config", "fa fa-th-large", "Rock.admin.pageAdmin.showBlockConfig()");
                    buttonBar.AppendChild(aBlockConfig);
                }

                if (canEditPage || canAdministratePage)
                {
                    // RockPage Properties
                    var aPageProperties = ModalIconLinkElement("Page Properties", "btn properties", "fa fa-cog", ResolveRockUrl($"~/PageProperties/{PageId}?t=Page Properties"));
                    aPageProperties.SetAttribute("id", "aPageProperties");
                    buttonBar.AppendChild(aPageProperties);
                }

                if (canAdministratePage)
                {
                    // Child Pages
                    var aChildPages = ModalIconLinkElement("Child Pages", "btn page-child-pages", "fa fa-sitemap", ResolveRockUrl($"~/pages/{PageId}?t=Child Pages&pb=&sb=Done"));
                    aChildPages.SetAttribute("id", "aChildPages");
                    buttonBar.AppendChild(aChildPages);

                    // RockPage Zones
                    var aPageZones = JavascriptIconLinkElement("Page Zones", "btn page-zones", "fa fa-columns", "Rock.admin.pageAdmin.showPageZones()");
                    buttonBar.AppendChild(aPageZones);

                    // RockPage Security
                    //var pageEntityTypeId = EntityTypeCache.Get( typeof( Rock.Model.Page ) ).Id;
                    var pageEntityTypeId = 42;
                    var aPageSecurity    = ModalIconLinkElement("Page Security", "btn page-security", "fa fa-lock", ResolveRockUrl($"~/Secure/{pageEntityTypeId}/{PageId}?t=Page Security&pb=&sb=Done"));
                    buttonBar.AppendChild(aPageSecurity);

                    // ShorLink Properties
                    var aShortLink = ModalIconLinkElement("Add Short Link", "btn properties", "fa fa-link", ResolveRockUrl($"~/ShortLink/{PageId}?t=Shortened Link&url={Context.RawUrl}"));
                    aShortLink.SetAttribute("id", "aShortLink");
                    buttonBar.AppendChild(aShortLink);

                    // System Info
                    var aSystemInfo = ModalIconLinkElement("Rock Information", "btn system-info", "fa fa-info-circle", ResolveRockUrl("~/SystemInfo?t=System Information&pb=&sb=Done"));
                    buttonBar.AppendChild(aSystemInfo);
                }
            }
        }