예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var replacedId    = "";
        var replacedImage = "";

        var lastMessageSeries = new ContentChannelService(new RockContext())
                                .Get(MessageSeriesContentChannelGuid)
                                .Items
                                .Where(i => i.StartDateTime < DateTime.Now)
                                .OrderByDescending(i => i.StartDateTime)
                                .FirstOrDefault();

        if (lastMessageSeries != null)
        {
            replacedId = lastMessageSeries.Id.ToString();
            lastMessageSeries.LoadAttributes();
            replacedImage = lastMessageSeries.GetAttributeValue("SmallSeriesFeatureImage") ?? "";
        }

        var rootPageId = RockPage.Site.DefaultPageId;
        var menuData   = new HtmlContentService(new RockContext()).Queryable()
                         .Where(h => h.Block.Page.ParentPageId == rootPageId && h.Block.Page.InternalName != "support-pages")
                         .Select(h => new
        {
            h.Block.Page.Id,
            h.Block.Page.PageTitle,
            HtmlContent = h.Content.Replace("{{seriesid}}", replacedId).Replace("{{seriesimage}}", replacedImage)
        });

        rptMenuLinks.DataSource = rptMenuDivs.DataSource = menuData.ToList();
        rptMenuLinks.DataBind();
        rptMenuDivs.DataBind();
    }
예제 #2
0
        /// <summary>
        /// Updates the social media dropdowns.
        /// </summary>
        /// <param name="channelGuid">The channel unique identifier.</param>
        private void UpdateSocialMediaDropdowns(Guid?channelGuid)
        {
            List <AttributeCache> channelAttributes = new List <AttributeCache>();
            List <AttributeCache> itemAttributes    = new List <AttributeCache>();

            if (channelGuid.HasValue)
            {
                var rockContext = new RockContext();
                var channel     = new ContentChannelService(rockContext).GetNoTracking(channelGuid.Value);

                // add channel attributes
                channel.LoadAttributes();
                channelAttributes = channel.Attributes.Select(a => a.Value).ToList();

                // add item attributes
                AttributeService attributeService = new AttributeService(rockContext);
                itemAttributes = attributeService.GetByEntityTypeId(new ContentChannelItem().TypeId, false).AsQueryable()
                                 .Where(a => (
                                            a.EntityTypeQualifierColumn.Equals("ContentChannelTypeId", StringComparison.OrdinalIgnoreCase) &&
                                            a.EntityTypeQualifierValue.Equals(channel.ContentChannelTypeId.ToString())
                                            ) || (
                                            a.EntityTypeQualifierColumn.Equals("ContentChannelId", StringComparison.OrdinalIgnoreCase) &&
                                            a.EntityTypeQualifierValue.Equals(channel.Id.ToString())
                                            ))
                                 .OrderByDescending(a => a.EntityTypeQualifierColumn)
                                 .ThenBy(a => a.Order)
                                 .ToAttributeCacheList();
            }

            RockDropDownList[] attributeDropDowns = new RockDropDownList[]
            {
                ddlMetaDescriptionAttribute,
                ddlOpenGraphTitleAttribute,
                ddlOpenGraphDescriptionAttribute,
                ddlOpenGraphImageAttribute,
                ddlTwitterTitleAttribute,
                ddlTwitterDescriptionAttribute,
                ddlTwitterImageAttribute,
                ddlMetaDescriptionAttribute
            };

            RockDropDownList[] attributeDropDownsImage = new RockDropDownList[]
            {
                ddlOpenGraphImageAttribute,
                ddlTwitterImageAttribute,
            };

            foreach (var attributeDropDown in attributeDropDowns)
            {
                attributeDropDown.Items.Clear();
                attributeDropDown.Items.Add(new ListItem());
                foreach (var attribute in channelAttributes)
                {
                    string computedKey = "C^" + attribute.Key;
                    if (attributeDropDownsImage.Contains(attributeDropDown))
                    {
                        if (attribute.FieldType.Name == "Image")
                        {
                            attributeDropDown.Items.Add(new ListItem("Channel: " + attribute.Name, computedKey));
                        }
                    }
                    else
                    {
                        attributeDropDown.Items.Add(new ListItem("Channel: " + attribute.Name, computedKey));
                    }
                }

                // get all the possible Item attributes for items in this Content Channel and add those as options too
                foreach (var attribute in itemAttributes.DistinctBy(a => a.Key).ToList())
                {
                    string computedKey = "I^" + attribute.Key;
                    if (attributeDropDownsImage.Contains(attributeDropDown))
                    {
                        if (attribute.FieldType.Name == "Image")
                        {
                            attributeDropDown.Items.Add(new ListItem("Item: " + attribute.Name, computedKey));
                        }
                    }
                    else
                    {
                        attributeDropDown.Items.Add(new ListItem("Item: " + attribute.Name, computedKey));
                    }
                }
            }
        }
        /// <summary>
        /// Shows the edit.
        /// </summary>
        public void ShowEdit()
        {
            int?filterId = hfDataFilterId.Value.AsIntegerOrNull();

            if (ChannelGuid.HasValue)
            {
                var rockContext = new RockContext();
                var channel     = new ContentChannelService(rockContext).Queryable("ContentChannelType")
                                  .FirstOrDefault(c => c.Guid.Equals(ChannelGuid.Value));
                if (channel != null)
                {
                    cblStatus.Visible = channel.RequiresApproval && !channel.ContentChannelType.DisableStatus;

                    var            filterService = new DataViewFilterService(rockContext);
                    DataViewFilter filter        = null;

                    if (filterId.HasValue)
                    {
                        filter = filterService.Get(filterId.Value);
                    }

                    if (filter == null || filter.ExpressionType == FilterExpressionType.Filter)
                    {
                        filter                = new DataViewFilter();
                        filter.Guid           = new Guid();
                        filter.ExpressionType = FilterExpressionType.GroupAll;
                    }

                    CreateFilterControl(channel, filter, true, rockContext);

                    kvlOrder.CustomKeys = new Dictionary <string, string>();
                    kvlOrder.CustomKeys.Add("", "");
                    kvlOrder.CustomKeys.Add("Title", "Title");
                    kvlOrder.CustomKeys.Add("Priority", "Priority");
                    kvlOrder.CustomKeys.Add("Status", "Status");
                    kvlOrder.CustomKeys.Add("StartDateTime", "Start");
                    kvlOrder.CustomKeys.Add("ExpireDateTime", "Expire");
                    kvlOrder.CustomKeys.Add("Order", "Order");

                    string currentMetaDescriptionAttribute = GetAttributeValue("MetaDescriptionAttribute") ?? string.Empty;
                    string currentMetaImageAttribute       = GetAttributeValue("MetaImageAttribute") ?? string.Empty;

                    // add channel attributes
                    channel.LoadAttributes();
                    foreach (var attribute in channel.Attributes)
                    {
                        var    field       = attribute.Value.FieldType.Field;
                        string computedKey = "C^" + attribute.Key;
                    }

                    // add item attributes
                    AttributeService attributeService = new AttributeService(rockContext);
                    var itemAttributes = attributeService.GetByEntityTypeId(new ContentChannelItem().TypeId).AsQueryable()
                                         .Where(a => (
                                                    a.EntityTypeQualifierColumn.Equals("ContentChannelTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(channel.ContentChannelTypeId.ToString())
                                                    ) || (
                                                    a.EntityTypeQualifierColumn.Equals("ContentChannelId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(channel.Id.ToString())
                                                    ))
                                         .OrderByDescending(a => a.EntityTypeQualifierColumn)
                                         .ThenBy(a => a.Order)
                                         .ToList();

                    foreach (var attribute in itemAttributes)
                    {
                        string attrKey = "Attribute:" + attribute.Key;
                        if (!kvlOrder.CustomKeys.ContainsKey(attrKey))
                        {
                            kvlOrder.CustomKeys.Add("Attribute:" + attribute.Key, attribute.Name);

                            string computedKey = "I^" + attribute.Key;

                            var field = attribute.FieldType.Name;
                        }
                    }
                }
            }
        }