Ejemplo n.º 1
0
        protected void btnSave_Click( object sender, EventArgs e )
        {
            Rock.Model.Page page;

            int pageId = 0;
            if ( !Int32.TryParse( hfPageId.Value, out pageId ) )
                pageId = 0;

            if ( pageId == 0 )
            {
                page = new Rock.Model.Page();

                if ( _page != null )
                {
                    page.ParentPageId = _page.Id;
                    page.SiteId = _page.Site.Id;
                }
                else
                {
                    page.ParentPageId = null;
                    page.SiteId = CurrentPage.Site.Id;
                }

                page.Title = tbPageName.Text;
                page.EnableViewState = true;
                page.IncludeAdminFooter = true;

                Rock.Model.Page lastPage =
                    pageService.GetByParentPageId( _page.Id ).
                        OrderByDescending( b => b.Order ).FirstOrDefault();

                if ( lastPage != null )
                    page.Order = lastPage.Order + 1;
                else
                    page.Order = 0;

                pageService.Add( page, CurrentPersonId );

            }
            else
                page = pageService.Get( pageId );

            page.Layout = ddlLayout.Text;
            page.Name = tbPageName.Text;

            pageService.Save( page, CurrentPersonId );

            if ( _page != null )
            {
                Rock.Security.Authorization.CopyAuthorization( _page, page, CurrentPersonId );
                _page.FlushChildPages();
            }

            BindGrid();

            rGrid.Visible = true;
            pnlDetails.Visible = false;
        }
Ejemplo n.º 2
0
        private void AddPage(Rock.Model.Page page, int level)
        {
            string pageName = new string( '-', level ) + page.Name;

            ddlParentPage.Items.Add(new ListItem(pageName, page.Id.ToString()));
            foreach (var childPage in page.Pages)
            {
                AddPage(childPage, level + 1);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This method generates a copy of the given page along with any descendant pages, as well as any blocks on
        /// any of those pages.
        /// </summary>
        /// <param name="sourcePage">The source page.</param>
        /// <param name="pageGuidDictionary">The dictionary containing the original page guids and the corresponding copied page guids.</param>
        /// <param name="blockGuidDictionary">The dictionary containing the original block guids and the corresponding copied block guids.</param>
        /// <param name="includeChildPages">if set to <c>true</c> [include child pages].</param>
        /// <param name="currentPersonAliasId">The current person alias identifier.</param>
        /// <returns></returns>
        private Rock.Model.Page GeneratePageCopy(Rock.Model.Page sourcePage, Dictionary <Guid, Guid> pageGuidDictionary, Dictionary <Guid, Guid> blockGuidDictionary, bool includeChildPages, int?currentPersonAliasId = null)
        {
            var targetPage = new Rock.Model.Page();

            targetPage = sourcePage.Clone(false);
            targetPage.CreatedByPersonAlias    = null;
            targetPage.CreatedByPersonAliasId  = currentPersonAliasId;
            targetPage.CreatedDateTime         = RockDateTime.Now;
            targetPage.ModifiedByPersonAlias   = null;
            targetPage.ModifiedByPersonAliasId = currentPersonAliasId;
            targetPage.ModifiedDateTime        = RockDateTime.Now;
            targetPage.BodyCssClass            = sourcePage.BodyCssClass;
            targetPage.Id           = 0;
            targetPage.Guid         = Guid.NewGuid();
            targetPage.PageTitle    = sourcePage.PageTitle + " - Copy";
            targetPage.InternalName = sourcePage.InternalName + " - Copy";
            targetPage.BrowserTitle = sourcePage.BrowserTitle + " - Copy";
            targetPage.IsSystem     = false;
            pageGuidDictionary.Add(sourcePage.Guid, targetPage.Guid);

            foreach (var block in sourcePage.Blocks)
            {
                var newBlock = block.Clone(false);
                newBlock.CreatedByPersonAlias    = null;
                newBlock.CreatedByPersonAliasId  = currentPersonAliasId;
                newBlock.CreatedDateTime         = RockDateTime.Now;
                newBlock.ModifiedByPersonAlias   = null;
                newBlock.ModifiedByPersonAliasId = currentPersonAliasId;
                newBlock.ModifiedDateTime        = RockDateTime.Now;
                newBlock.Id       = 0;
                newBlock.Guid     = Guid.NewGuid();
                newBlock.PageId   = 0;
                newBlock.IsSystem = false;

                blockGuidDictionary.Add(block.Guid, newBlock.Guid);
                targetPage.Blocks.Add(newBlock);
            }

            if (includeChildPages)
            {
                foreach (var oldchildPage in sourcePage.Pages)
                {
                    targetPage.Pages.Add(GeneratePageCopy(oldchildPage, pageGuidDictionary, blockGuidDictionary, includeChildPages, currentPersonAliasId));
                }
            }

            return(targetPage);
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
        protected void ShowEdit(int pageId)
        {
            Rock.Model.Page page = pageService.Get(pageId);
            if (page != null)
            {
                hfPageId.Value = page.Id.ToString();
                try { ddlLayout.Text = page.Layout; }
                catch { }
                tbPageName.Text = page.Name;

                lEditAction.Text = "Edit";
                btnSave.Text     = "Save";
            }
            else
            {
                hfPageId.Value = "0";

                try
                {
                    if (_page != null)
                    {
                        ddlLayout.Text = _page.Layout;
                    }
                    else
                    {
                        ddlLayout.Text = CurrentPage.Layout;
                    }
                }
                catch { }

                tbPageName.Text = string.Empty;

                lEditAction.Text = "Add";
                btnSave.Text     = "Add";
            }

            rGrid.Visible      = false;
            pnlDetails.Visible = true;
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Rock.Model.Page page;

            int pageId = 0;

            if (!Int32.TryParse(hfPageId.Value, out pageId))
            {
                pageId = 0;
            }

            if (pageId == 0)
            {
                page = new Rock.Model.Page();

                if (_page != null)
                {
                    page.ParentPageId = _page.Id;
                    page.SiteId       = _page.Site.Id;
                }
                else
                {
                    page.ParentPageId = null;
                    page.SiteId       = CurrentPage.Site.Id;
                }

                page.Title              = tbPageName.Text;
                page.EnableViewState    = true;
                page.IncludeAdminFooter = true;

                Rock.Model.Page lastPage =
                    pageService.GetByParentPageId(_page.Id).
                    OrderByDescending(b => b.Order).FirstOrDefault();

                if (lastPage != null)
                {
                    page.Order = lastPage.Order + 1;
                }
                else
                {
                    page.Order = 0;
                }

                pageService.Add(page, CurrentPersonId);
            }
            else
            {
                page = pageService.Get(pageId);
            }

            page.Layout = ddlLayout.Text;
            page.Name   = tbPageName.Text;

            pageService.Save(page, CurrentPersonId);

            if (_page != null)
            {
                Rock.Security.Authorization.CopyAuthorization(_page, page, CurrentPersonId);
                _page.FlushChildPages();
            }

            BindGrid();

            rGrid.Visible      = true;
            pnlDetails.Visible = false;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This method generates a copy of the given page along with any descendant pages, as well as any blocks on
        /// any of those pages.
        /// </summary>
        /// <param name="sourcePage">The source page.</param>
        /// <param name="pageGuidDictionary">The dictionary containing the original page guids and the corresponding copied page guids.</param>
        /// <param name="blockGuidDictionary">The dictionary containing the original block guids and the corresponding copied block guids.</param>
        /// <param name="currentPersonAliasId">The current person alias identifier.</param>
        /// <returns></returns>
        private Rock.Model.Page GeneratePageCopy( Rock.Model.Page sourcePage, Dictionary<Guid, Guid> pageGuidDictionary, Dictionary<Guid, Guid> blockGuidDictionary, int? currentPersonAliasId = null )
        {
            var targetPage = new Rock.Model.Page();
            targetPage = sourcePage.Clone( false );
            targetPage.CreatedByPersonAlias = null;
            targetPage.CreatedByPersonAliasId = currentPersonAliasId;
            targetPage.CreatedDateTime = RockDateTime.Now;
            targetPage.ModifiedByPersonAlias = null;
            targetPage.ModifiedByPersonAliasId = currentPersonAliasId;
            targetPage.ModifiedDateTime = RockDateTime.Now;
            targetPage.BodyCssClass = sourcePage.BodyCssClass;
            targetPage.Id = 0;
            targetPage.Guid = Guid.NewGuid();
            targetPage.PageTitle = sourcePage.PageTitle + " - Copy";
            targetPage.InternalName = sourcePage.InternalName + " - Copy";
            targetPage.BrowserTitle = sourcePage.BrowserTitle + " - Copy";
            targetPage.IsSystem = false;
            pageGuidDictionary.Add( sourcePage.Guid, targetPage.Guid );

            foreach ( var block in sourcePage.Blocks )
            {
                var newBlock = block.Clone( false );
                newBlock.CreatedByPersonAlias = null;
                newBlock.CreatedByPersonAliasId = currentPersonAliasId;
                newBlock.CreatedDateTime = RockDateTime.Now;
                newBlock.ModifiedByPersonAlias = null;
                newBlock.ModifiedByPersonAliasId = currentPersonAliasId;
                newBlock.ModifiedDateTime = RockDateTime.Now;
                newBlock.Id = 0;
                newBlock.Guid = Guid.NewGuid();
                newBlock.PageId = 0;
                newBlock.IsSystem = false;

                blockGuidDictionary.Add( block.Guid, newBlock.Guid );
                targetPage.Blocks.Add( newBlock );
            }

            foreach ( var oldchildPage in sourcePage.Pages )
            {
                targetPage.Pages.Add( GeneratePageCopy( oldchildPage, pageGuidDictionary, blockGuidDictionary ) );
            }

            return targetPage;
        }