/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); maContentChannelWarning.Hide(); if (!Page.IsPostBack) { int?contentChannelId = PageParameter("ContentChannelId").AsIntegerOrNull(); if (contentChannelId.HasValue) { upnlContent.Visible = true; ShowDetail(contentChannelId.Value); } else { upnlContent.Visible = false; } } else { if (pnlEditDetails.Visible) { var channel = new ContentChannel(); channel.Id = hfId.Value.AsInteger(); channel.ContentChannelTypeId = hfTypeId.Value.AsInteger(); channel.LoadAttributes(); phAttributes.Controls.Clear(); Rock.Attribute.Helper.AddEditControls(channel, phAttributes, false, BlockValidationGroup); ShowDialog(); } } }
/// <summary> /// Shows the readonly details. /// </summary> /// <param name="contentChannel">Type of the content.</param> private void ShowReadonlyDetails(ContentChannel contentChannel) { SetEditMode(false); if (contentChannel != null) { hfId.SetValue(contentChannel.Id); SetHeadingInfo(contentChannel, contentChannel.Name); SetEditMode(false); nbRoleMessage.Visible = false; if (contentChannel.RequiresApproval && !IsApproverConfigured(contentChannel)) { nbRoleMessage.Text = "<p>No role or person is configured to approve the items for this channel. Please configure one or more roles or people in the security settings under the "Approve" tab.</p>"; nbRoleMessage.Visible = true; } lGroupDescription.Text = contentChannel.Description; var descriptionListLeft = new DescriptionList(); var descriptionListRight = new DescriptionList(); descriptionListLeft.Add("Items Require Approval", contentChannel.RequiresApproval.ToYesNo()); // Only show index state if indexing is enabled on the server if (IndexContainer.IndexingEnabled) { descriptionListRight.Add("Is Indexed", contentChannel.IsIndexEnabled.ToYesNo()); } if (contentChannel.EnableRss) { descriptionListLeft.Add("Channel URL", contentChannel.ChannelUrl); descriptionListRight.Add("Item URL", contentChannel.ItemUrl); } contentChannel.LoadAttributes(); foreach (var attribute in contentChannel.Attributes .Where(a => a.Value.IsGridColumn) .OrderBy(a => a.Value.Order) .Select(a => a.Value)) { if (contentChannel.AttributeValues.ContainsKey(attribute.Key)) { string value = attribute.FieldType.Field.FormatValueAsHtml(null, attribute.EntityTypeId, contentChannel.Id, contentChannel.AttributeValues[attribute.Key].Value, attribute.QualifierValues, false); descriptionListLeft.Add(attribute.Name, value); } } lDetailsLeft.Text = descriptionListLeft.Html; lDetailsRight.Text = descriptionListRight.Html; } }
/// <summary> /// Adds the attribute controls. /// </summary> /// <param name="contentChannel">The content channel.</param> private void AddAttributeControls(ContentChannel contentChannel) { int typeId = ddlChannelType.SelectedValueAsInt() ?? 0; hfTypeId.Value = typeId.ToString(); contentChannel.ContentChannelTypeId = typeId; contentChannel.LoadAttributes(); phAttributes.Controls.Clear(); Rock.Attribute.Helper.AddEditControls(contentChannel, phAttributes, true, BlockValidationGroup); }
/// <summary> /// Shows the readonly details. /// </summary> /// <param name="contentChannel">Type of the content.</param> private void ShowReadonlyDetails(ContentChannel contentChannel) { SetEditMode(false); if (contentChannel != null) { hfId.SetValue(contentChannel.Id); SetHeadingInfo(contentChannel, contentChannel.Name); SetEditMode(false); lGroupDescription.Text = contentChannel.Description; var descriptionListLeft = new DescriptionList(); var descriptionListRight = new DescriptionList(); descriptionListLeft.Add("Items Require Approval", contentChannel.RequiresApproval.ToYesNo()); descriptionListRight.Add("Is Indexed", contentChannel.IsIndexEnabled.ToYesNo()); if (contentChannel.EnableRss) { descriptionListLeft.Add("Channel Url", contentChannel.ChannelUrl); descriptionListRight.Add("Item Url", contentChannel.ItemUrl); } contentChannel.LoadAttributes(); foreach (var attribute in contentChannel.Attributes .Where(a => a.Value.IsGridColumn) .OrderBy(a => a.Value.Order) .Select(a => a.Value)) { if (contentChannel.AttributeValues.ContainsKey(attribute.Key)) { string value = attribute.FieldType.Field.FormatValueAsHtml(null, attribute.EntityTypeId, contentChannel.Id, contentChannel.AttributeValues[attribute.Key].Value, attribute.QualifierValues, false); descriptionListLeft.Add(attribute.Name, value); } } lDetailsLeft.Text = descriptionListLeft.Html; lDetailsRight.Text = descriptionListRight.Html; } }
/// <summary> /// Shows the readonly details. /// </summary> /// <param name="contentChannel">Type of the content.</param> private void ShowReadonlyDetails( ContentChannel contentChannel ) { SetEditMode( false ); if ( contentChannel != null ) { hfId.SetValue( contentChannel.Id ); SetHeadingInfo( contentChannel, contentChannel.Name ); SetEditMode( false ); lGroupDescription.Text = contentChannel.Description; var descriptionList = new DescriptionList(); if ( contentChannel.EnableRss ) { descriptionList .Add( "Item's Require Approval", contentChannel.RequiresApproval.ToString() ) .Add( "Channel Url", contentChannel.ChannelUrl ) .Add( "Item Url", contentChannel.ItemUrl ); } contentChannel.LoadAttributes(); foreach ( var attribute in contentChannel.Attributes .Where( a => a.Value.IsGridColumn ) .OrderBy( a => a.Value.Order ) .Select( a => a.Value ) ) { if ( contentChannel.AttributeValues.ContainsKey( attribute.Key ) ) { string value = attribute.FieldType.Field.FormatValueAsHtml( null, contentChannel.AttributeValues[attribute.Key].Value, attribute.QualifierValues, false ); descriptionList.Add( attribute.Name, value ); } } lDetails.Text = descriptionList.Html; } }
/// <summary> /// Adds the attribute controls. /// </summary> /// <param name="contentChannel">The content channel.</param> private void AddAttributeControls( ContentChannel contentChannel ) { int typeId = ddlChannelType.SelectedValueAsInt() ?? 0; hfTypeId.Value = typeId.ToString(); contentChannel.ContentChannelTypeId = typeId; contentChannel.LoadAttributes(); phAttributes.Controls.Clear(); Rock.Attribute.Helper.AddEditControls( contentChannel, phAttributes, true, BlockValidationGroup ); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad( EventArgs e ) { base.OnLoad( e ); maContentChannelWarning.Hide(); if ( !Page.IsPostBack ) { int? contentChannelId = PageParameter( "contentChannelId" ).AsIntegerOrNull( ); if( contentChannelId.HasValue ) { upnlContent.Visible = true; ShowDetail( contentChannelId.Value ); } else { upnlContent.Visible = false; } } else { if ( pnlEditDetails.Visible ) { var channel = new ContentChannel(); channel.Id = hfId.Value.AsInteger(); channel.ContentChannelTypeId = hfTypeId.Value.AsInteger(); channel.LoadAttributes(); phAttributes.Controls.Clear(); Rock.Attribute.Helper.AddEditControls( channel, phAttributes, false, BlockValidationGroup ); ShowDialog(); } } }
/// <summary> /// Get all the content channel items that should be displayed. /// </summary> /// <param name="contentChannel">The content channel whose items are to be displayed.</param> /// <param name="rockContext">The context to load any extra data from.</param> /// <returns>A SignContents object that contains the formatted data for the client.</returns> private SignContents GetContentChannelItems(List <int> campusIds, ContentChannel contentChannel, RockContext rockContext, List <int> visitedContentChannels = null) { var contents = new SignContents(); var items = contentChannel.Items.Where(i => i.StartDateTime <= DateTime.Now && (i.ExpireDateTime == null || i.ExpireDateTime > DateTime.Now)); // // Add ourselves to the visited content channels so we don't recurse forever. // visitedContentChannels = visitedContentChannels ?? new List <int>(); visitedContentChannels.Add(contentChannel.Id); // // Get any configuration options from the content channel. // contentChannel.LoadAttributes(rockContext); if (contentChannel.GetAttributeValue("com_shepherdchurch_SlideInterval").AsInteger() >= 4) { contents.SlideInterval = contentChannel.GetAttributeValue("com_shepherdchurch_SlideInterval").AsInteger() * 1000; } if (!string.IsNullOrWhiteSpace(contentChannel.GetAttributeValue("com_shepherdchurch_Transitions"))) { contents.Transitions = contentChannel.GetAttributeValues("com_shepherdchurch_Transitions").ToArray(); } // // Order the items either manually or by start date time, depending on configuration. // if (contentChannel.ItemsManuallyOrdered) { items = items.OrderBy(i => i.Order); } else { items = items.OrderBy(i => i.StartDateTime); } // // Loop each content item and see if it contains something to display. // foreach (var item in items) { if (item.Attributes == null) { item.LoadAttributes(rockContext); } // // Check for valid campus. // var campusFilter = item.GetAttributeValues("com_shepherdchurch_CampusFilter") .AsGuidOrNullList() .Where(g => g.HasValue) .Select(g => CampusCache.Get(g.Value)) .Where(c => c != null) .Select(c => c.Id) .ToList(); if (campusFilter.Count > 0 && campusIds.Count > 0 && campusFilter.Intersect(campusIds).Count() == 0) { continue; } var duration = item.GetAttributeValue("com_shepherdchurch_Duration").AsIntegerOrNull(); // // Check which kind of slide to include. // if (!string.IsNullOrWhiteSpace(item.GetAttributeValue("com_shepherdchurch_IncludeContentFrom"))) { // // Process the "Include Content From" attribute. // var guid = item.GetAttributeValue("com_shepherdchurch_IncludeContentFrom").AsGuid(); var childContentChannel = new ContentChannelService(rockContext).Get(guid); if (childContentChannel != null && !visitedContentChannels.Contains(childContentChannel.Id)) { var childContents = GetContentChannelItems(campusIds, childContentChannel, rockContext, visitedContentChannels); contents.Audio.AddRange(childContents.Audio); contents.Slides.AddRange(childContents.Slides); } } else if (!string.IsNullOrWhiteSpace(item.GetAttributeValue("com_shepherdchurch_SlideUrl"))) { // // Process the "Slide Url" attribute. // var fileUrl = item.GetAttributeValue("com_shepherdchurch_SlideUrl"); if (Regex.IsMatch(fileUrl, "\\.mp3(\\?|$)", RegexOptions.IgnoreCase)) { contents.Audio.Add(fileUrl); } else { contents.Slides.Add(new Slide(fileUrl, duration)); } } else { // // Process the "Slide" attribute. // Check if it contains either an audio file or an image. // var guid = item.GetAttributeValue("com_shepherdchurch_Slide").AsGuid(); var binaryFile = new BinaryFileService(rockContext).Get(guid); if (binaryFile != null && binaryFile.Id != 0) { if (binaryFile.MimeType.StartsWith("audio/")) { contents.Audio.Add(VirtualPathUtility.ToAbsolute(string.Format("~/GetFile.ashx?id={0}", binaryFile.Id))); } else if (binaryFile.MimeType.StartsWith("image/")) { contents.Slides.Add(new Slide(VirtualPathUtility.ToAbsolute(string.Format("~/GetImage.ashx?id={0}", binaryFile.Id)), duration)); } } } } return(contents); }