예제 #1
0
        /// <summary>
        /// Handles the SaveClick event of the mdBlockMove 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 mdBlockMove_SaveClick(object sender, EventArgs e)
        {
            int blockId      = hfBlockMoveBlockId.Value.AsInteger();
            var rockContext  = new RockContext();
            var blockService = new BlockService(rockContext);
            var block        = blockService.Get(blockId);

            var page = PageCache.Read(hfPageId.Value.AsInteger());

            if (block != null)
            {
                block.Zone = ddlMoveToZoneList.SelectedValue;
                if (cblBlockMovePageOrLayout.SelectedValue == "Page")
                {
                    block.PageId   = page.Id;
                    block.LayoutId = null;
                }
                else
                {
                    block.PageId   = null;
                    block.LayoutId = page.LayoutId;
                }

                rockContext.SaveChanges();

                // flush all the cache stuff that involves the block and page
                Rock.Web.Cache.BlockCache.Flush(block.Id);

                Rock.Web.Cache.LayoutCache.Flush(page.LayoutId);
                Rock.Web.Cache.PageCache.Flush(page.Id);

                // re-read the pageCache
                page = Rock.Web.Cache.PageCache.Read(page.Id);
                page.FlushBlocks();

                mdBlockMove.Hide();
                ShowDetailForZone(ddlZones.SelectedValue);
            }
        }
예제 #2
0
        /// <summary>
        /// Haves the workflow action.
        /// </summary>
        /// <param name="guidValue">The guid value of the action.</param>
        /// <returns>True/False if the workflow contains the action</returns>
        private bool HaveWorkflowAction(string guidValue)
        {
            using (var rockContext = new RockContext())
            {
                BlockService          blockService          = new BlockService(rockContext);
                AttributeService      attributeService      = new AttributeService(rockContext);
                AttributeValueService attributeValueService = new AttributeValueService(rockContext);

                var block = blockService.Get(Rock.SystemGuid.Block.BIO.AsGuid());

                var attribute      = attributeService.Get(Rock.SystemGuid.Attribute.BIO_WORKFLOWACTION.AsGuid());
                var attributeValue = attributeValueService.GetByAttributeIdAndEntityId(attribute.Id, block.Id);
                if (attributeValue == null || string.IsNullOrWhiteSpace(attributeValue.Value))
                {
                    return(false);
                }

                var  workflowActionValues = attributeValue.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                Guid guid = guidValue.AsGuid();
                return(workflowActionValues.Any(w => w.AsGuid() == guid));
            }
        }
예제 #3
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)
        {
            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;
        }
예제 #4
0
        /// <summary>
        /// Handles the Click event of the btnDeleteBlock control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnDeleteBlock_Click(object sender, EventArgs e)
        {
            LinkButton btnDelete = sender as LinkButton;
            int?       blockId   = btnDelete.CommandArgument.AsIntegerOrNull();

            if (blockId.HasValue)
            {
                var rockContext  = new RockContext();
                var blockService = new BlockService(rockContext);
                var block        = blockService.Get(blockId.Value);

                if (block != null)
                {
                    int?pageId   = block.PageId;
                    int?layoutId = block.LayoutId;
                    blockService.Delete(block);
                    rockContext.SaveChanges();

                    ShowDetailForZone(ddlZones.SelectedValue);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Handles the Click event of the btnMoveBlock control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnMoveBlock_Click(object sender, EventArgs e)
        {
            LinkButton btnDelete = sender as LinkButton;
            int?       blockId   = btnDelete.CommandArgument.AsIntegerOrNull();

            if (blockId.HasValue)
            {
                var rockContext  = new RockContext();
                var blockService = new BlockService(rockContext);
                var block        = blockService.Get(blockId.Value);

                if (block != null)
                {
                    hfBlockMoveBlockId.Value = block.Id.ToString();
                    mdBlockMove.Title        = string.Format("Move {0} Block", block.Name);

                    ddlMoveToZoneList.SetValue(block.Zone);
                    cblBlockMovePageOrLayout.Items.Clear();

                    var page = PageCache.Read(hfPageId.Value.AsInteger());

                    var listItemPage = new ListItem();
                    listItemPage.Text     = "Page: " + page.ToString();
                    listItemPage.Value    = "Page";
                    listItemPage.Selected = block.PageId.HasValue;

                    var listItemLayout = new ListItem();
                    listItemLayout.Text     = string.Format("All Pages use the '{0}' Layout", page.Layout);
                    listItemLayout.Value    = "Layout";
                    listItemLayout.Selected = block.LayoutId.HasValue;

                    cblBlockMovePageOrLayout.Items.Add(listItemPage);
                    cblBlockMovePageOrLayout.Items.Add(listItemLayout);

                    mdBlockMove.Show();
                }
            }
        }
예제 #6
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();
        }
예제 #7
0
        /// <summary>
        /// Handles the Click event of the btnDeleteBlock control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnDeleteBlock_Click(object sender, EventArgs e)
        {
            LinkButton btnDelete = sender as LinkButton;
            int?       blockId   = btnDelete.CommandArgument.AsIntegerOrNull();

            if (blockId.HasValue)
            {
                var rockContext  = new RockContext();
                var blockService = new BlockService(rockContext);
                var block        = blockService.Get(blockId.Value);

                if (block != null)
                {
                    int?pageId   = block.PageId;
                    int?layoutId = block.LayoutId;
                    blockService.Delete(block);
                    rockContext.SaveChanges();

                    // flush all the cache stuff that involves the block
                    Rock.Web.Cache.BlockCache.Flush(blockId.Value);

                    if (layoutId.HasValue)
                    {
                        Rock.Web.Cache.PageCache.FlushLayoutBlocks(layoutId.Value);
                    }

                    if (pageId.HasValue)
                    {
                        Rock.Web.Cache.PageCache.Flush(pageId.Value);
                        var page = Rock.Web.Cache.PageCache.Read(pageId.Value);
                        page.FlushBlocks();
                    }

                    ShowDetailForZone(ddlZones.SelectedValue);
                }
            }
        }
예제 #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)
        {
            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>();
                    switch (location)
                    {
                    case BlockLocation.Site:
                        block.LayoutId = null;
                        block.PageId   = null;
                        block.SiteId   = _Page.SiteId;
                        break;

                    case BlockLocation.Layout:
                        block.LayoutId = _Page.LayoutId;
                        block.PageId   = null;
                        block.SiteId   = null;
                        break;

                    case BlockLocation.Page:
                        block.LayoutId = null;
                        block.PageId   = _Page.Id;
                        block.SiteId   = null;
                        break;
                    }


                    block.Zone = _ZoneName;

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

                    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;
        }
예제 #9
0
        /// <summary>
        /// Processes the drag events.
        /// </summary>
        private void ProcessDragEvents()
        {
            string argument = Request["__EVENTARGUMENT"].ToStringSafe();
            var    segments = argument.Split(new[] { '|' });

            //
            // Check for the event to add a new block.
            //
            if (segments.Length == 4 && segments[0] == "add-block")
            {
                var blockType = ComponentItemState.Where(c => c.Id == segments[1].AsInteger()).Single();
                var zoneName  = segments[2];
                var order     = segments[3].AsInteger();
                int pageId    = hfPageId.Value.AsInteger();

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

                    //
                    // Generate the new block.
                    //
                    var block = new Block
                    {
                        PageId      = pageId,
                        BlockTypeId = blockType.Id,
                        Name        = blockType.Name,
                        Zone        = zoneName,
                        Order       = order
                    };
                    blockService.Add(block);

                    //
                    // Get the current list of blocks in the zone.
                    //
                    var blocks = blockService.Queryable()
                                 .Where(b => b.PageId == pageId && b.Zone == zoneName)
                                 .OrderBy(a => a.Order)
                                 .ThenBy(a => a.Id)
                                 .ToList();

                    //
                    // Insert the new block and then fixup all the Order values.
                    //
                    blocks.Insert(order, block);
                    int index = 0;
                    blocks.ForEach(b => b.Order = index++);

                    rockContext.SaveChanges();
                }

                BindZones();
            }

            //
            // Check for the event to drag-reorder block.
            //
            else if (segments.Length == 4 && segments[0] == "reorder-block")
            {
                int pageId   = hfPageId.Value.AsInteger();
                var zoneName = segments[1];
                int blockId  = segments[2].AsInteger();
                int newIndex = segments[3].AsInteger();

                using (var rockContext = new RockContext())
                {
                    var blockService = new BlockService(rockContext);
                    var block        = blockService.Get(blockId);

                    //
                    // Get all blocks for this page and the destination zone except the current block.
                    //
                    var blocks = blockService.Queryable()
                                 .Where(b => b.PageId == pageId && b.Zone == zoneName)
                                 .Where(b => b.Id != block.Id)
                                 .OrderBy(a => a.Order)
                                 .ThenBy(a => a.Id)
                                 .ToList();

                    //
                    // Insert the block in the right position and update the zone name.
                    //
                    blocks.Insert(newIndex, block);
                    block.Zone = zoneName;

                    //
                    // Fixup the Order values of all the blocks.
                    //
                    int index = 0;
                    blocks.ForEach(b => b.Order = index++);

                    rockContext.SaveChanges();
                }

                BindZones();
            }
        }
예제 #10
0
        private void SortPanelWidgets(string eventParam, string[] values)
        {
            string      panelWidgetClientId = values[0];
            int         newIndex            = int.Parse(values[1]);
            Panel       pnlWidget           = pnlDetails.ControlsOfTypeRecursive <Panel>().FirstOrDefault(a => a.ClientID == panelWidgetClientId);
            HiddenField hfSiteBlockId       = pnlWidget.FindControl("hfSiteBlockId") as HiddenField;
            HiddenField hfLayoutBlockId     = pnlWidget.FindControl("hfLayoutBlockId") as HiddenField;
            HiddenField hfPageBlockId       = pnlWidget.FindControl("hfPageBlockId") as HiddenField;

            int?blockId = null;

            if (hfSiteBlockId != null)
            {
                blockId = hfSiteBlockId.Value.AsIntegerOrNull();
            }
            else if (hfLayoutBlockId != null)
            {
                blockId = hfLayoutBlockId.Value.AsIntegerOrNull();
            }
            else if (hfPageBlockId != null)
            {
                blockId = hfPageBlockId.Value.AsIntegerOrNull();
            }

            if (blockId.HasValue)
            {
                var rockContext  = new RockContext();
                var blockService = new BlockService(rockContext);
                var block        = blockService.Get(blockId.Value);
                var page         = Rock.Web.Cache.PageCache.Read(hfPageId.Value.AsInteger());
                if (block != null && page != null)
                {
                    List <Block> zoneBlocks = null;
                    switch (block.BlockLocation)
                    {
                    case BlockLocation.Page:
                        zoneBlocks = blockService.GetByPageAndZone(block.PageId.Value, block.Zone).ToList();
                        break;

                    case BlockLocation.Layout:
                        zoneBlocks = blockService.GetByLayoutAndZone(block.LayoutId.Value, block.Zone).ToList();
                        break;

                    case BlockLocation.Site:
                        zoneBlocks = blockService.GetBySiteAndZone(block.SiteId.Value, block.Zone).ToList();
                        break;
                    }

                    if (zoneBlocks != null)
                    {
                        var oldIndex = zoneBlocks.IndexOf(block);
                        blockService.Reorder(zoneBlocks, oldIndex, newIndex);

                        rockContext.SaveChanges();
                    }

                    foreach (var zoneBlock in zoneBlocks)
                    {
                        // make sure the BlockCache for all the re-ordered blocks get flushed so the new Order is updated
                        BlockCache.Flush(zoneBlock.Id);
                    }

                    page.FlushBlocks();
                    if (block.LayoutId.HasValue)
                    {
                        Rock.Web.Cache.PageCache.FlushLayoutBlocks(block.LayoutId.Value);
                    }

                    if (block.SiteId.HasValue)
                    {
                        Rock.Web.Cache.PageCache.FlushSiteBlocks(block.SiteId.Value);
                    }

                    ShowDetailForZone(ddlZones.SelectedValue);
                }
            }
        }
예제 #11
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() ?? 0;

            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;
        }
예제 #12
0
        public PageType(PageService pageService, BlockService blockService, UrlService urlService,
                        FieldTemplateService fieldTemplateService, RouteInfoService routeInfoService)
        {
            Name        = "Page";
            Description = "Page data";
            Field(p => p.SystemId, type: typeof(IdGraphType)).Description("The System Id");
            Field(p => p.Slug, nullable: true).Description("The slug")
            .Argument <GlobalInputType>("global")
            .Resolve(context =>
            {
                var globalModel = context.GetArgument <GlobalModel>("global");
                var page        = pageService.Get(context.Source.SystemId);
                return(urlService.GetUrl(page, new PageUrlArgs(globalModel.ChannelSystemId)));
            });

            Field <ListGraphType <BlockAreaType> >(nameof(PageModel.Areas), "Block areas",
                                                   resolve: context =>
            {
                var page = pageService.Get(context.Source.SystemId);
                return(page.Blocks.Items.Select(container =>
                                                new BlockAreaModel()
                {
                    Id = container.Id,
                    Blocks = blockService.Get(container.Items.Select(block => ((BlockItemLink)block).BlockSystemId))
                             .MapEnumerableTo <BlockModel>()
                             .Select(b => { b.PageSystemId = context.Source.SystemId; return b; }).ToList()
                }).ToList());
            });

            Field <StringGraphType>(nameof(PageModel.TemplateId), "Template id",
                                    resolve: context =>
            {
                var page     = pageService.Get(context.Source.SystemId);
                var template = fieldTemplateService.Get <PageFieldTemplate>(page.FieldTemplateSystemId);
                return(template.Id);
            });

            Field <StringGraphType>(nameof(PageModel.Name), "The page name",
                                    arguments: new QueryArguments(
                                        new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            }
                                        ),
                                    resolve: context =>
            {
                var page        = pageService.Get(context.Source.SystemId);
                var globalModel = context.GetArgument <GlobalModel>("global");
                return(page.GetEntityName(true, CultureInfo.GetCultureInfo(globalModel.CurrentCulture)) ?? page.Id ?? "general.NameIsMissing".AsAngularResourceString());
            });

            Field <PageInfoPageType>(nameof(PageModel.Children), description: "Sub pages",
                                     arguments: new QueryArguments(
                                         new QueryArgument <IntGraphType> {
                Name = "offset"
            },
                                         new QueryArgument <IntGraphType> {
                Name = "take"
            }
                                         ),
                                     resolve: context =>
                                     new PageInfoModel <Page, PageModel>(pageService.GetChildPages(context.Source.SystemId),
                                                                         context.GetArgument("offset", 0), context.GetArgument("take", 10)));

            FieldAsync <StringGraphType>(nameof(PageModel.ValueAsJSON), "Value as JSON string",
                                         arguments: new QueryArguments(
                                             new QueryArgument <GlobalInputType> {
                Name = "global", Description = "The global object"
            }
                                             ),
                                         resolve: async context =>
            {
                var page     = pageService.Get(context.Source.SystemId);
                var template = fieldTemplateService.Get <PageFieldTemplate>(page.FieldTemplateSystemId);
                // Special treatment for scoped services https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#scoped-services-with-a-singleton-schema-lifetime
                // and make sure it is thread safe https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/#thread-safety-with-scoped-services
                using var scope = context.RequestServices.CreateScope();
                var builder     = scope.ServiceProvider.GetNamedService <IPageDataBuilder>(template.Id);
                if (builder == null)
                {
                    return(null);
                }
                var globalModel = context.GetArgument <GlobalModel>("global");
                routeInfoService.Setup(globalModel, context.Source.SystemId);
                var buildMethod = builder.GetType().GetMethod(nameof(IPageDataBuilder <IViewModel> .BuildAsync));
                var value       = await(dynamic) buildMethod.Invoke(builder,
                                                                    new object[] { scope, new Web.Models.Websites.PageModel(page, page.Fields) });
                // ((IDictionary<string, object>)value).Remove("blocks");
                var jsonSerializerSettings = ApplicationConverter.JsonSerializerSettings();
                return(JsonConvert.SerializeObject(value, jsonSerializerSettings));
            });
        }
예제 #13
0
        private IEnumerable <Block> GetChildBlocks(IEnumerable <Page> pages)
        {
            var usedBlockIds = GetChildBlockSystemIds(pages);

            return(usedBlockIds.Any() ? _blockService.Get(usedBlockIds).ToList() : Enumerable.Empty <Block>());
        }
예제 #14
0
        public override IEnumerable <(CultureInfo, IDocument)> BuildIndexDocuments(IndexQueueItem item)
        {
            var page = _pageService.Get(item.SystemId);

            if (page == null)
            {
                yield break;
            }

            var cultureContentCache = new ConcurrentDictionary <CultureInfo, ISet <string> >();
            var permissions         = _searchPermissionService.GetPermissions(page);
            var blocks  = page.Blocks.Items.SelectMany(x => x.Items).Select(y => _blockService.Get(((BlockItemLink)y).BlockSystemId)).ToList();
            var isBrand = false;
            var isNews  = false;

            if (_keyLookupService.TryGetId <PageFieldTemplate>(page.FieldTemplateSystemId, out var templateId))
            {
                isBrand = PageTemplateNameConstants.Brand.Equals(templateId, StringComparison.OrdinalIgnoreCase);
                isNews  = PageTemplateNameConstants.News.Equals(templateId, StringComparison.OrdinalIgnoreCase);
            }

            foreach (var channelLink in page.ChannelLinks)
            {
                var channel = _channelService.Get(channelLink.ChannelSystemId);
                if (channel is null)
                {
                    // Orphaned category link exists, skip to create new index document.
                    continue;
                }

                var cultureInfo = _languageService.Get(channel.WebsiteLanguageSystemId.GetValueOrDefault())?.CultureInfo;
                if (cultureInfo is null)
                {
                    // Channel does not have a culture.
                    continue;
                }

                var pageFieldTemplate = _fieldTemplateService.Get <PageFieldTemplate>(page.FieldTemplateSystemId);
                if (!pageFieldTemplate.IndexThePage || !page.Fields.GetValue <bool>(SystemFieldDefinitionConstants.IndexThePage))
                {
                    yield return(cultureInfo, new RemoveDocument(new PageDocument {
                        PageSystemId = page.SystemId, ChannelSystemId = channel.SystemId
                    }));

                    yield break;
                }
                var localization = page.Localizations[cultureInfo];
                yield return(cultureInfo, new PageDocument
                {
                    PageSystemId = page.SystemId,
                    Content = cultureContentCache.GetOrAdd(cultureInfo, _ => _contentBuilderService.BuildContent <PageFieldTemplate, WebsiteArea>(page.FieldTemplateSystemId, cultureInfo, page.Fields)),
                    PublishDateTime = page.PublishedAtUtc ?? DateTimeOffset.MinValue,
                    Name = localization.Name,
                    ChannelSystemId = channel.SystemId,
                    WebsiteSystemId = page.WebsiteSystemId,
                    ChannelStartDateTime = channelLink.StartDateTimeUtc ?? DateTimeOffset.MinValue,
                    ChannelEndDateTime = channelLink.EndDateTimeUtc ?? DateTimeOffset.MaxValue,
                    Permissions = permissions,
                    Blocks = GetBlocks(blocks, cultureInfo, channel.SystemId),
                    IsBrand = isBrand,
                    IsNews = isNews,
                    NewsDate = isNews ? page.Fields.GetValue <DateTimeOffset>(PageFieldNameConstants.NewsDate) : DateTimeOffset.MinValue,
                    ParentPages = GetParenPages(page)
                });
            }
        }