private ILinkBuilder BuildLink(ContentItem item, ContentItem selectedItem, string target) { StringBuilder className = new StringBuilder(); if (!item.Published.HasValue || item.Published > N2.Utility.CurrentTime()) { className.Append("unpublished "); } else if (item.Published > N2.Utility.CurrentTime().AddDays(-2)) { className.Append("new "); } if (item.Expires.HasValue && item.Expires <= N2.Utility.CurrentTime()) { className.Append("expired "); } if (item == selectedItem) { className.Append("selected "); } if (item.AuthorizedRoles != null && item.AuthorizedRoles.Count > 0) { className.Append("locked "); } string iconUrl = item.IconUrl; int iconIndex = icons.IndexOf(iconUrl); if (iconIndex < 0) { iconIndex = icons.Count; icons.Add(iconUrl); } className.Append("i" + iconIndex + " "); ILinkBuilder builder = Link.To(item).Target(target).Href(item.Url); if (className.Length > 0) { --className.Length; // remove trailing whitespace builder.Class(className.ToString()); } return(builder); }