Пример #1
0
        protected void rGrid_Delete(object sender, RowEventArgs e)
        {
            Rock.Model.Page page = pageService.Get(( int )rGrid.DataKeys[e.RowIndex]["id"]);
            if (page != null)
            {
                Rock.Web.Cache.PageCache.Flush(page.Id);

                pageService.Delete(page, CurrentPersonId);
                pageService.Save(page, CurrentPersonId);

                if (_page != null)
                {
                    _page.FlushChildPages();
                }
            }

            BindGrid();
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack && _page.IsAuthorized("Administrate", CurrentPerson))
            {
                Rock.Model.PageService pageService = new Rock.Model.PageService();
                Rock.Model.Page        page        = pageService.Get(_page.Id);

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

                LoadDropdowns();

                tbPageName.Text             = _page.Name;
                tbPageTitle.Text            = _page.Title;
                ddlParentPage.SelectedValue = _page.ParentPage != null?_page.ParentPage.Id.ToString() : "0";

                ddlLayout.Text               = _page.Layout;
                ddlMenuWhen.SelectedValue    = (( Int32 )_page.DisplayInNavWhen).ToString();
                cbMenuDescription.Checked    = _page.MenuDisplayDescription;
                cbMenuIcon.Checked           = _page.MenuDisplayIcon;
                cbMenuChildPages.Checked     = _page.MenuDisplayChildPages;
                cbRequiresEncryption.Checked = _page.RequiresEncryption;
                cbEnableViewState.Checked    = _page.EnableViewState;
                cbIncludeAdminFooter.Checked = _page.IncludeAdminFooter;
                tbCacheDuration.Text         = _page.OutputCacheDuration.ToString();
                tbDescription.Text           = _page.Description;
                tbPageRoute.Text             = string.Join(",", page.PageRoutes.Select(route => route.Route).ToArray());
                imgIcon.ImageId              = page.IconFileId;
            }

            base.OnLoad(e);

            if (Page.IsPostBack)
            {
                Rock.Attribute.Helper.SetErrorIndicators(phAttributes, _page);
            }
        }
Пример #3
0
        void masterPage_OnSave(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                using (new Rock.Data.UnitOfWorkScope())
                {
                    var pageService    = new Rock.Model.PageService();
                    var routeService   = new Rock.Model.PageRouteService();
                    var contextService = new Rock.Model.PageContextService();

                    var page = pageService.Get(_page.Id);

                    int parentPage = Int32.Parse(ddlParentPage.SelectedValue);
                    if (page.ParentPageId != parentPage)
                    {
                        if (page.ParentPageId.HasValue)
                        {
                            Rock.Web.Cache.PageCache.Flush(page.ParentPageId.Value);
                        }

                        if (parentPage != 0)
                        {
                            Rock.Web.Cache.PageCache.Flush(parentPage);
                        }
                    }

                    page.Name  = tbPageName.Text;
                    page.Title = tbPageTitle.Text;
                    if (parentPage != 0)
                    {
                        page.ParentPageId = parentPage;
                    }
                    else
                    {
                        page.ParentPageId = null;
                    }
                    page.Layout                 = ddlLayout.Text;
                    page.DisplayInNavWhen       = (Rock.Model.DisplayInNavWhen)Enum.Parse(typeof(Rock.Model.DisplayInNavWhen), ddlMenuWhen.SelectedValue);
                    page.MenuDisplayDescription = cbMenuDescription.Checked;
                    page.MenuDisplayIcon        = cbMenuIcon.Checked;
                    page.IconFileId             = imgIcon.ImageId;
                    page.MenuDisplayChildPages  = cbMenuChildPages.Checked;
                    page.RequiresEncryption     = cbRequiresEncryption.Checked;
                    page.EnableViewState        = cbEnableViewState.Checked;
                    page.IncludeAdminFooter     = cbIncludeAdminFooter.Checked;
                    page.OutputCacheDuration    = Int32.Parse(tbCacheDuration.Text);
                    page.Description            = tbDescription.Text;

                    foreach (var pageRoute in page.PageRoutes.ToList())
                    {
                        routeService.Delete(pageRoute, CurrentPersonId);
                    }
                    page.PageRoutes.Clear();

                    foreach (var pageContext in page.PageContexts.ToList())
                    {
                        contextService.Delete(pageContext, CurrentPersonId);
                    }
                    page.PageContexts.Clear();

                    foreach (string route in tbPageRoute.Text.SplitDelimitedValues())
                    {
                        var pageRoute = new Rock.Model.PageRoute();
                        pageRoute.Route = route;
                        pageRoute.Guid  = Guid.NewGuid();
                        page.PageRoutes.Add(pageRoute);
                    }

                    if (phContextPanel.Visible)
                    {
                        foreach (var control in phContext.Controls)
                        {
                            if (control is LabeledTextBox)
                            {
                                var tbContext   = control as LabeledTextBox;
                                var pageContext = new Rock.Model.PageContext();
                                pageContext.Entity      = tbContext.LabelText;
                                pageContext.IdParameter = tbContext.Text;
                                page.PageContexts.Add(pageContext);
                            }
                        }
                    }

                    pageService.Save(page, CurrentPersonId);

                    Rock.Attribute.Helper.GetEditValues(phAttributes, _page);
                    _page.SaveAttributeValues(CurrentPersonId);

                    Rock.Web.Cache.PageCache.Flush(_page.Id);
                }

                string script = "window.parent.closeModal()";
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "close-modal", script, true);
            }
        }