Пример #1
0
        protected void gLayoutBlocks_Delete(object sender, RowEventArgs e)
        {
            Rock.Model.Block block = blockService.Get(( int )gLayoutBlocks.DataKeys[e.RowIndex]["id"]);
            if (CurrentBlock != null)
            {
                blockService.Delete(block, CurrentPersonId);
                blockService.Save(block, CurrentPersonId);
                Rock.Web.Cache.PageCache.FlushLayoutBlocks(_page.Layout);
            }

            BindGrids();
        }
Пример #2
0
        /// <summary>
        /// Handles the OnSave event of the masterPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void masterPage_OnSave(object sender, EventArgs e)
        {
            int blockId = Convert.ToInt32(PageParameter("BlockId"));

            if (Page.IsValid)
            {
                var rockContext  = new RockContext();
                var blockService = new Rock.Model.BlockService(rockContext);
                var block        = blockService.Get(blockId);

                block.LoadAttributes();

                block.Name                = tbBlockName.Text;
                block.CssClass            = tbCssClass.Text;
                block.PreHtml             = cePreHtml.Text;
                block.PostHtml            = cePostHtml.Text;
                block.OutputCacheDuration = 0; //Int32.Parse( tbCacheDuration.Text );
                rockContext.SaveChanges();

                Rock.Attribute.Helper.GetEditValues(phAttributes, block);
                if (phAdvancedAttributes.Controls.Count > 0)
                {
                    Rock.Attribute.Helper.GetEditValues(phAdvancedAttributes, block);
                }
                block.SaveAttributeValues(rockContext);

                Rock.Web.Cache.BlockCache.Flush(block.Id);

                string script = string.Format("window.parent.Rock.controls.modal.close('BLOCK_UPDATED:{0}');", blockId);
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "close-modal", script, true);
            }
        }
Пример #3
0
        /// <summary>
        /// Handles the Delete event of the gPageBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gPageBlocks_Delete( object sender, RowEventArgs e )
        {
            using ( var rockContext = new RockContext() )
            {
                BlockService blockService = new BlockService( rockContext );
                Rock.Model.Block block = blockService.Get( e.RowKeyId );
                if ( block != null )
                {
                    blockService.Delete( block );
                    rockContext.SaveChanges();

                    _Page.FlushBlocks();
                    PageUpdated = true;
                }
            }

            BindGrids();
        }
Пример #4
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <param name="blockId">The block id.</param>
        protected void ShowEdit( BlockLocation location, int blockId )
        {
            using ( var rockContext = new RockContext() )
            {
                BlockService blockService = new BlockService( rockContext );
                Rock.Model.Block block = blockService.Get( blockId );
                hfBlockLocation.Value = location.ConvertToString();

                if ( block != null )
                {
                    lAction.Text = "Edit ";
                    hfBlockId.Value = block.Id.ToString();
                    ddlBlockType.SelectedValue = block.BlockType.Id.ToString();
                    tbBlockName.Text = block.Name;
                }
                else
                {
                    lAction.Text = "Add ";
                    hfBlockId.Value = "0";

                    // Select HTML Content block by default
                    var blockType = new Rock.Model.BlockTypeService( rockContext )
                        .GetByGuid( new Guid( Rock.SystemGuid.BlockType.HTML_CONTENT ) );
                    if ( blockType != null )
                    {
                        ddlBlockType.SelectedValue = blockType.Id.ToString();
                    }
                    else
                    {
                        ddlBlockType.SelectedIndex = -1;
                    }

                    tbBlockName.Text = string.Empty;
                }
            }

            lAction.Text += hfBlockLocation.Value;

            pnlLists.Visible = false;
            pnlDetails.Visible = true;
        }
Пример #5
0
        /// <summary>
        /// Handles the Delete click event for the grid.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param>
        protected void DeleteBlock_Click( object sender, Rock.Web.UI.Controls.RowEventArgs e )
        {
            var rockContext = new RockContext();
            BlockService blockService = new BlockService( rockContext );
            Block block = blockService.Get( e.RowKeyId );
            if ( block != null )
            {
                string errorMessage;
                if ( !blockService.CanDelete( block, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                blockService.Delete( block );
                rockContext.SaveChanges();

                BlockCache.Flush( e.RowKeyId );
            }

            BindLayoutBlocksGrid();
        }
Пример #6
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click( object sender, EventArgs e )
        {
            bool newBlock = false;
            Rock.Model.Block block = null;

            using ( var rockContext = new RockContext() )
            {
                BlockService blockService = new BlockService( rockContext );

                int blockId = hfBlockId.ValueAsInt();

                if ( blockId != 0 )
                {
                    block = blockService.Get( blockId );
                }

                if ( block == null )
                {
                    newBlock = true;
                    block = new Rock.Model.Block();
                    blockService.Add( block );

                    BlockLocation location = hfBlockLocation.Value.ConvertToEnum<BlockLocation>();
                    if ( location == BlockLocation.Layout )
                    {
                        block.LayoutId = _Page.LayoutId;
                        block.PageId = null;
                    }
                    else
                    {
                        block.LayoutId = null;
                        block.PageId = _Page.Id;
                    }

                    block.Zone = _ZoneName;

                    Rock.Model.Block lastBlock = blockService.GetByPageAndZone( _Page.Id, _ZoneName ).OrderByDescending( b => b.Order ).FirstOrDefault();

                    if ( lastBlock != null )
                    {
                        block.Order = lastBlock.Order + 1;
                    }
                    else
                    {
                        block.Order = 0;
                    }
                }

                block.Name = tbBlockName.Text;
                block.BlockTypeId = Convert.ToInt32( ddlBlockType.SelectedValue );

                rockContext.SaveChanges();

                if ( newBlock )
                {
                    Rock.Security.Authorization.CopyAuthorization( _Page, block, rockContext );
                }

                if ( block.Layout != null )
                {
                    Rock.Web.Cache.PageCache.FlushLayoutBlocks( _Page.LayoutId );
                }
                else
                {
                    _Page.FlushBlocks();
                }
            }

            PageUpdated = true;

            BindGrids();

            pnlDetails.Visible = false;
            pnlLists.Visible = true;
        }
Пример #7
0
        /// <summary>
        /// Handles the Delete event of the gPageBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gPageBlocks_Delete( object sender, RowEventArgs e )
        {
            int pageId = PageParameter( "EditPage" ).AsInteger();
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );
            string zoneName = this.PageParameter( "ZoneName" );

            var rockContext = new RockContext();
            BlockService blockService = new BlockService( rockContext );
            Rock.Model.Block block = blockService.Get( e.RowKeyId );
            if ( block != null )
            {
                blockService.Delete( block );
                rockContext.SaveChanges();
                page.FlushBlocks();
            }

            BindGrids();
        }
Пример #8
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click( object sender, EventArgs e )
        {
            int pageId = PageParameter( "EditPage" ).AsInteger();
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );
            string zoneName = this.PageParameter( "ZoneName" );

            Rock.Model.Block block;

            var rockContext = new RockContext();
            BlockService blockService = new BlockService( rockContext );

            int blockId = hfBlockId.ValueAsInt();

            if ( blockId == 0 )
            {
                block = new Rock.Model.Block();

                BlockLocation location = hfBlockLocation.Value.ConvertToEnum<BlockLocation>();
                if ( location == BlockLocation.Layout )
                {
                    block.LayoutId = page.LayoutId;
                    block.PageId = null;
                }
                else
                {
                    block.LayoutId = null;
                    block.PageId = page.Id;
                }

                block.Zone = zoneName;

                Rock.Model.Block lastBlock = blockService.GetByPageAndZone( page.Id, zoneName ).OrderByDescending( b => b.Order ).FirstOrDefault();

                if ( lastBlock != null )
                {
                    block.Order = lastBlock.Order + 1;
                }
                else
                {
                    block.Order = 0;
                }

                blockService.Add( block );
            }
            else
            {
                block = blockService.Get( blockId );
            }

            block.Name = tbBlockName.Text;
            block.BlockTypeId = Convert.ToInt32( ddlBlockType.SelectedValue );

            rockContext.SaveChanges();

            Rock.Security.Authorization.CopyAuthorization( page, block );

            if ( block.Layout != null )
            {
                Rock.Web.Cache.PageCache.FlushLayoutBlocks( page.LayoutId );
            }
            else
            {
                page.FlushBlocks();
            }

            BindGrids();

            pnlDetails.Visible = false;
            pnlLists.Visible = true;
        }
Пример #9
0
        /// <summary>
        /// Handles the OnSave event of the masterPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void masterPage_OnSave(object sender, EventArgs e)
        {
            bool reloadPage = false;
            int  blockId    = Convert.ToInt32(PageParameter("BlockId"));

            if (Page.IsValid)
            {
                var rockContext  = new RockContext();
                var blockService = new Rock.Model.BlockService(rockContext);
                var block        = blockService.Get(blockId);

                block.LoadAttributes();

                block.Name                = tbBlockName.Text;
                block.CssClass            = tbCssClass.Text;
                block.PreHtml             = cePreHtml.Text;
                block.PostHtml            = cePostHtml.Text;
                block.OutputCacheDuration = 0; //Int32.Parse( tbCacheDuration.Text );
                rockContext.SaveChanges();

                Rock.Attribute.Helper.GetEditValues(phAttributes, block);
                if (phAdvancedAttributes.Controls.Count > 0)
                {
                    Rock.Attribute.Helper.GetEditValues(phAdvancedAttributes, block);
                }

                SaveCustomColumnsConfigToViewState();
                if (this.CustomGridColumnsConfigState != null && this.CustomGridColumnsConfigState.ColumnsConfig.Any())
                {
                    if (!block.Attributes.Any(a => a.Key == CustomGridColumnsConfig.AttributeKey))
                    {
                        block.Attributes.Add(CustomGridColumnsConfig.AttributeKey, null);
                    }

                    var customGridColumnsJSON = this.CustomGridColumnsConfigState.ToJson();
                    if (block.GetAttributeValue(CustomGridColumnsConfig.AttributeKey) != customGridColumnsJSON)
                    {
                        block.SetAttributeValue(CustomGridColumnsConfig.AttributeKey, customGridColumnsJSON);

                        // if the CustomColumns changed, reload the whole page so that we can avoid issues with columns changing between postbacks
                        reloadPage = true;
                    }
                }
                else
                {
                    if (block.Attributes.Any(a => a.Key == CustomGridColumnsConfig.AttributeKey))
                    {
                        if (block.GetAttributeValue(CustomGridColumnsConfig.AttributeKey) != null)
                        {
                            // if the CustomColumns were removed, reload the whole page so that we can avoid issues with columns changing between postbacks
                            reloadPage = true;
                        }

                        block.SetAttributeValue(CustomGridColumnsConfig.AttributeKey, null);
                    }
                }

                block.SaveAttributeValues(rockContext);

                Rock.Web.Cache.BlockCache.Flush(block.Id);

                StringBuilder scriptBuilder = new StringBuilder();

                if (reloadPage)
                {
                    scriptBuilder.AppendLine("window.parent.location.reload();");
                }
                else
                {
                    scriptBuilder.AppendLine(string.Format("window.parent.Rock.controls.modal.close('BLOCK_UPDATED:{0}');", blockId));
                }

                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "close-modal", scriptBuilder.ToString(), true);
            }
        }
Пример #10
0
        /// <summary>
        /// Handles the Delete event of the gLayoutBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gLayoutBlocks_Delete( object sender, RowEventArgs e )
        {
            int pageId = PageParameter( "EditPage" ).AsInteger();
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );

            var rockContext = new RockContext();
            BlockService blockService = new BlockService( rockContext );
            Rock.Model.Block block = blockService.Get( (int)gLayoutBlocks.DataKeys[e.RowIndex]["id"] );
            if ( block != null )
            {
                blockService.Delete( block );
                rockContext.SaveChanges();
                Rock.Web.Cache.PageCache.FlushLayoutBlocks( page.LayoutId );
            }

            BindGrids();
        }
Пример #11
0
        /// <summary>
        /// Handles the OnSave event of the masterPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void masterPage_OnSave(object sender, EventArgs e)
        {
            bool reloadPage = false;
            int  blockId    = Convert.ToInt32(PageParameter("BlockId"));

            if (!Page.IsValid)
            {
                return;
            }

            var rockContext = new RockContext();

            rockContext.WrapTransaction(() =>
            {
                var blockService = new Rock.Model.BlockService(rockContext);
                var block        = blockService.Get(blockId);

                block.LoadAttributes();

                block.Name                = tbBlockName.Text;
                block.CssClass            = tbCssClass.Text;
                block.PreHtml             = cePreHtml.Text;
                block.PostHtml            = cePostHtml.Text;
                block.OutputCacheDuration = 0; //Int32.Parse( tbCacheDuration.Text );

                avcAttributes.GetEditValues(block);
                avcMobileAttributes.GetEditValues(block);
                avcAdvancedAttributes.GetEditValues(block);

                foreach (var kvp in CustomSettingsProviders)
                {
                    kvp.Key.WriteSettingsToEntity(block, kvp.Value, rockContext);
                }

                SaveCustomColumnsConfigToViewState();
                if (this.CustomGridColumnsConfigState != null && this.CustomGridColumnsConfigState.ColumnsConfig.Any())
                {
                    if (!block.Attributes.Any(a => a.Key == CustomGridColumnsConfig.AttributeKey))
                    {
                        block.Attributes.Add(CustomGridColumnsConfig.AttributeKey, null);
                    }

                    var customGridColumnsJSON = this.CustomGridColumnsConfigState.ToJson();
                    if (block.GetAttributeValue(CustomGridColumnsConfig.AttributeKey) != customGridColumnsJSON)
                    {
                        block.SetAttributeValue(CustomGridColumnsConfig.AttributeKey, customGridColumnsJSON);

                        // if the CustomColumns changed, reload the whole page so that we can avoid issues with columns changing between postbacks
                        reloadPage = true;
                    }
                }
                else
                {
                    if (block.Attributes.Any(a => a.Key == CustomGridColumnsConfig.AttributeKey))
                    {
                        if (block.GetAttributeValue(CustomGridColumnsConfig.AttributeKey) != null)
                        {
                            // if the CustomColumns were removed, reload the whole page so that we can avoid issues with columns changing between postbacks
                            reloadPage = true;
                        }

                        block.SetAttributeValue(CustomGridColumnsConfig.AttributeKey, null);
                    }
                }

                if (tglEnableStickyHeader.Checked)
                {
                    if (!block.Attributes.Any(a => a.Key == CustomGridOptionsConfig.EnableStickyHeadersAttributeKey))
                    {
                        block.Attributes.Add(CustomGridOptionsConfig.EnableStickyHeadersAttributeKey, null);
                    }
                }

                if (block.GetAttributeValue(CustomGridOptionsConfig.EnableStickyHeadersAttributeKey).AsBoolean() != tglEnableStickyHeader.Checked)
                {
                    block.SetAttributeValue(CustomGridOptionsConfig.EnableStickyHeadersAttributeKey, tglEnableStickyHeader.Checked.ToTrueFalse());

                    // if EnableStickyHeaders changed, reload the page
                    reloadPage = true;
                }

                rockContext.SaveChanges();
                block.SaveAttributeValues(rockContext);

                // If this is a page menu block then we need to also flush the LavaTemplateCache for the block ID
                if (block.BlockType.Guid == Rock.SystemGuid.BlockType.PAGE_MENU.AsGuid())
                {
                    var cacheKey = string.Format("Rock:PageMenu:{0}", block.Id);
                    LavaTemplateCache.Remove(cacheKey);
                }

                StringBuilder scriptBuilder = new StringBuilder();

                if (reloadPage)
                {
                    scriptBuilder.AppendLine("window.parent.location.reload();");
                }
                else
                {
                    scriptBuilder.AppendLine(string.Format("window.parent.Rock.controls.modal.close('BLOCK_UPDATED:{0}');", blockId));
                }

                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "close-modal", scriptBuilder.ToString(), true);
            });
        }
Пример #12
0
        /// <summary>
        /// Handles the OnSave event of the masterPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void masterPage_OnSave(object sender, EventArgs e)
        {
            bool reloadPage = false;
            int  blockId    = Convert.ToInt32(PageParameter("BlockId"));

            if (!Page.IsValid)
            {
                return;
            }

            var rockContext = new RockContext();

            rockContext.WrapTransaction(() =>
            {
                var blockService = new Rock.Model.BlockService(rockContext);
                var block        = blockService.Get(blockId);

                block.LoadAttributes();

                block.Name                = tbBlockName.Text;
                block.CssClass            = tbCssClass.Text;
                block.PreHtml             = cePreHtml.Text;
                block.PostHtml            = cePostHtml.Text;
                block.OutputCacheDuration = 0; //Int32.Parse( tbCacheDuration.Text );

                avcAttributes.GetEditValues(block);
                avcMobileAttributes.GetEditValues(block);
                avcAdvancedAttributes.GetEditValues(block);

                foreach (var kvp in CustomSettingsProviders)
                {
                    kvp.Key.WriteSettingsToEntity(block, kvp.Value, rockContext);
                }

                SaveCustomColumnsConfigToViewState();
                if (this.CustomGridColumnsConfigState != null && this.CustomGridColumnsConfigState.ColumnsConfig.Any())
                {
                    if (!block.Attributes.Any(a => a.Key == CustomGridColumnsConfig.AttributeKey))
                    {
                        block.Attributes.Add(CustomGridColumnsConfig.AttributeKey, null);
                    }

                    var customGridColumnsJSON = this.CustomGridColumnsConfigState.ToJson();
                    if (block.GetAttributeValue(CustomGridColumnsConfig.AttributeKey) != customGridColumnsJSON)
                    {
                        block.SetAttributeValue(CustomGridColumnsConfig.AttributeKey, customGridColumnsJSON);

                        // if the CustomColumns changed, reload the whole page so that we can avoid issues with columns changing between postbacks
                        reloadPage = true;
                    }
                }
                else
                {
                    if (block.Attributes.Any(a => a.Key == CustomGridColumnsConfig.AttributeKey))
                    {
                        if (block.GetAttributeValue(CustomGridColumnsConfig.AttributeKey) != null)
                        {
                            // if the CustomColumns were removed, reload the whole page so that we can avoid issues with columns changing between postbacks
                            reloadPage = true;
                        }

                        block.SetAttributeValue(CustomGridColumnsConfig.AttributeKey, null);
                    }
                }

                // Save the custom action configs
                SaveCustomActionsConfigToViewState();

                if (CustomActionsConfigState != null && CustomActionsConfigState.Any())
                {
                    if (!block.Attributes.Any(a => a.Key == CustomGridOptionsConfig.CustomActionsConfigsAttributeKey))
                    {
                        block.Attributes.Add(CustomGridOptionsConfig.CustomActionsConfigsAttributeKey, null);
                    }

                    var json = CustomActionsConfigState.ToJson();

                    if (block.GetAttributeValue(CustomGridOptionsConfig.CustomActionsConfigsAttributeKey) != json)
                    {
                        block.SetAttributeValue(CustomGridOptionsConfig.CustomActionsConfigsAttributeKey, json);

                        // if the actions changed, reload the whole page so that we can avoid issues with launchers changing between postbacks
                        reloadPage = true;
                    }
                }
                else
                {
                    if (block.Attributes.Any(a => a.Key == CustomGridOptionsConfig.CustomActionsConfigsAttributeKey))
                    {
                        if (block.GetAttributeValue(CustomGridOptionsConfig.CustomActionsConfigsAttributeKey) != null)
                        {
                            // if the actions were removed, reload the whole page so that we can avoid issues with launchers changing between postbacks
                            reloadPage = true;
                        }

                        block.SetAttributeValue(CustomGridOptionsConfig.CustomActionsConfigsAttributeKey, null);
                    }
                }

                if (tglEnableStickyHeader.Checked)
                {
                    if (!block.Attributes.Any(a => a.Key == CustomGridOptionsConfig.EnableStickyHeadersAttributeKey))
                    {
                        block.Attributes.Add(CustomGridOptionsConfig.EnableStickyHeadersAttributeKey, null);
                    }
                }

                if (block.GetAttributeValue(CustomGridOptionsConfig.EnableStickyHeadersAttributeKey).AsBoolean() != tglEnableStickyHeader.Checked)
                {
                    block.SetAttributeValue(CustomGridOptionsConfig.EnableStickyHeadersAttributeKey, tglEnableStickyHeader.Checked.ToTrueFalse());

                    // if EnableStickyHeaders changed, reload the page
                    reloadPage = true;
                }

                // Save the default launcher enabled setting
                var isDefaultLauncherEnabled = tglEnableDefaultWorkflowLauncher.Checked;

                if (isDefaultLauncherEnabled && !block.Attributes.Any(a => a.Key == CustomGridOptionsConfig.EnableDefaultWorkflowLauncherAttributeKey))
                {
                    block.Attributes.Add(CustomGridOptionsConfig.EnableDefaultWorkflowLauncherAttributeKey, null);
                }

                if (block.GetAttributeValue(CustomGridOptionsConfig.EnableDefaultWorkflowLauncherAttributeKey).AsBoolean() != isDefaultLauncherEnabled)
                {
                    block.SetAttributeValue(CustomGridOptionsConfig.EnableDefaultWorkflowLauncherAttributeKey, isDefaultLauncherEnabled.ToTrueFalse());

                    // since the setting changed, reload the page
                    reloadPage = true;
                }

                rockContext.SaveChanges();
                block.SaveAttributeValues(rockContext);

                // If this is a PageMenu block then we need to also flush the lava template cache for the block here.
                // Changes to the PageMenu block configuration will handle this in the PageMenu_BlockUpdated event handler,
                // but here we address the situation where child pages are modified using the "CMS Configuration | Pages" menu option.
                if (block.BlockType.Guid == Rock.SystemGuid.BlockType.PAGE_MENU.AsGuid())
                {
                    var cacheKey = string.Format("Rock:PageMenu:{0}", block.Id);

                    if (LavaService.RockLiquidIsEnabled)
                    {
#pragma warning disable CS0618 // Type or member is obsolete
                        LavaTemplateCache.Remove(cacheKey);
#pragma warning restore CS0618 // Type or member is obsolete
                    }

                    LavaService.RemoveTemplateCacheEntry(cacheKey);
                }

                StringBuilder scriptBuilder = new StringBuilder();

                if (reloadPage)
                {
                    scriptBuilder.AppendLine("window.parent.location.reload();");
                }
                else
                {
                    scriptBuilder.AppendLine(string.Format("window.parent.Rock.controls.modal.close('BLOCK_UPDATED:{0}');", blockId));
                }

                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "close-modal", scriptBuilder.ToString(), true);
            });
        }
Пример #13
0
        /// <summary>
        /// Handles the OnSave event of the masterPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void masterPage_OnSave( object sender, EventArgs e )
        {
            int blockId = Convert.ToInt32( PageParameter( "BlockId" ) );
            if ( Page.IsValid )
            {
                var rockContext = new RockContext();
                var blockService = new Rock.Model.BlockService( rockContext );
                var block = blockService.Get( blockId );

                block.LoadAttributes();

                block.Name = tbBlockName.Text;
                block.CssClass = tbCssClass.Text;
                block.PreHtml = cePreHtml.Text;
                block.PostHtml = cePostHtml.Text;
                block.OutputCacheDuration = Int32.Parse( tbCacheDuration.Text );
                rockContext.SaveChanges();

                Rock.Attribute.Helper.GetEditValues( phAttributes, block );
                if ( phAdvancedAttributes.Controls.Count > 0 )
                {
                    Rock.Attribute.Helper.GetEditValues( phAdvancedAttributes, block );
                }
                block.SaveAttributeValues( rockContext );

                Rock.Web.Cache.BlockCache.Flush( block.Id );

                string script = string.Format( "window.parent.Rock.controls.modal.close('BLOCK_UPDATED:{0}');", blockId );
                ScriptManager.RegisterStartupScript( this.Page, this.GetType(), "close-modal", script, true );
            }
        }
Пример #14
0
        /// <summary>
        /// Handles the Delete event of the gPageBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gPageBlocks_Delete( object sender, RowEventArgs e )
        {
            BlockService blockService = new BlockService();
            int pageId = PageParameter( "EditPage" ).AsInteger() ?? 0;
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );
            string zoneName = this.PageParameter( "ZoneName" );

            Rock.Model.Block block = blockService.Get( e.RowKeyId );
            if ( block != null )
            {
                blockService.Delete( block, CurrentPersonId );
                blockService.Save( block, CurrentPersonId );
                page.FlushBlocks();
            }

            BindGrids();
        }
Пример #15
0
        /// <summary>
        /// Handles the Delete event of the gLayoutBlocks control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gLayoutBlocks_Delete( object sender, RowEventArgs e )
        {
            BlockService blockService = new BlockService();
            int pageId = PageParameter( "EditPage" ).AsInteger() ?? 0;
            Rock.Web.Cache.PageCache page = Rock.Web.Cache.PageCache.Read( pageId );

            Rock.Model.Block block = blockService.Get( (int)gLayoutBlocks.DataKeys[e.RowIndex]["id"] );
            if ( block != null )
            {
                blockService.Delete( block, CurrentPersonId );
                blockService.Save( block, CurrentPersonId );
                Rock.Web.Cache.PageCache.FlushLayoutBlocks( page.LayoutId );
            }

            BindGrids();
        }