diff --git a/Rock/Badge/Component/Campus.cs b/Rock/Badge/Component/Campus.cs index 9eabb16880f..9b01cf76525 100644 --- a/Rock/Badge/Component/Campus.cs +++ b/Rock/Badge/Component/Campus.cs @@ -1,4 +1,4 @@ -// +// // Copyright by the Spark Development Network // // Licensed under the Rock Community License (the "License"); @@ -14,14 +14,14 @@ // limitations under the License. // // -using System; using System.ComponentModel; using System.ComponentModel.Composition; +using System.IO; using System.Linq; + using Rock.Data; using Rock.Model; using Rock.Web.Cache; -using Rock.Web.UI.Controls; namespace Rock.Badge.Component { @@ -32,7 +32,7 @@ namespace Rock.Badge.Component [Export( typeof( BadgeComponent ) )] [ExportMetadata( "ComponentName", "Campus" )] [Rock.SystemGuid.EntityTypeGuid( "D4B2BA9B-4F2C-47CB-A5BB-F3FF53A68F39")] - public class Campus : HighlightLabelBadge + public class Campus : BadgeComponent { /// /// Determines of this badge component applies to the given type @@ -44,38 +44,34 @@ public override bool DoesApplyToEntityType( string type ) return type.IsNullOrWhiteSpace() || typeof( Person ).FullName == type; } - /// - /// Gets the Entity's Campus badge label even if the campus is inactive. - /// - /// The entity. - /// - public override HighlightLabel GetLabel( IEntity entity ) + /// + public override void Render( BadgeCache badge, IEntity entity, TextWriter writer ) { - // This badge is only setup to work with a person - var person = entity as Person; + // This badge is only setup to work with a person. + if ( !( entity is Person person ) ) + { + return; + } - // If the entity is not a person or there is only one campus, then don't display a badge - if ( person == null || CampusCache.All().Count <= 1 ) + // If there is only one campus, then don't display a badge. + if ( CampusCache.All().Count <= 1 ) { - return null; + return; } var campusNames = person.GetCampusIds() .Select( id => CampusCache.Get( id )?.Name ) .Where( name => !name.IsNullOrWhiteSpace() ) .OrderBy( name => name ) + .Select( name => name.EncodeHtml() ) .ToList(); if ( !campusNames.Any() ) { - return null; + return; } - return new HighlightLabel - { - LabelType = LabelType.Campus, - Text = campusNames.AsDelimited( ", " ) - }; + writer.Write( $"{campusNames.AsDelimited( "," )}" ); } } } diff --git a/Rock/Badge/HighlightLabelBadge.cs b/Rock/Badge/HighlightLabelBadge.cs index 61cc78b8b82..82e5f7d8fc3 100644 --- a/Rock/Badge/HighlightLabelBadge.cs +++ b/Rock/Badge/HighlightLabelBadge.cs @@ -27,6 +27,8 @@ namespace Rock.Badge /// /// Base class for person profile icon badges /// + [RockObsolete( "1.14" )] + [Obsolete( "HighlightLabelBadge depends on Webforms, use BadgeComponent instead and render the HTML." )] public abstract class HighlightLabelBadge : BadgeComponent { ///