internal static ILinkBuilder BuildLink(NodeAdapter adapter, ContentItem item, bool isSelected, string target, bool isSelectable) { INode node = item; string className = node.ClassNames; if (isSelected) className += "selected "; if (isSelectable) className += "selectable "; else className += "unselectable "; ILinkBuilder builder = Link.To(node) .Target(target) .Class(className) .Href(adapter.GetPreviewUrl(item)) .Text("<img src='" + adapter.GetIconUrl(item) + "'/>" + node.Contents) .Attribute("id", item.Path.Replace('/', '_')) .Attribute("title", "#" + item.ID + ": " + N2.Context.Current.Definitions.GetDefinition(item).Title) .Attribute("data-id", item.ID.ToString()) .Attribute("data-type", item.GetContentType().Name) .Attribute("data-path", item.Path) .Attribute("data-url", item.Url) .Attribute("data-page", item.IsPage.ToString().ToLower()) .Attribute("data-zone", item.ZoneName) .Attribute("data-permission", adapter.GetMaximumPermission(item).ToString()); if (isSelected) builder.Attribute("data-selected", "true"); if (isSelectable) builder.Attribute("data-selectable", "true"); builder.Href(adapter.GetPreviewUrl(item)); return builder; }
internal static ILinkBuilder BuildLink(NodeAdapter adapter, ContentItem item, bool isSelected, string target, bool isSelectable) { var node = adapter.GetTreeNode(item); string className = node.CssClass; if (isSelected) className += " selected"; if (isSelectable) className += " selectable"; else className += " unselectable"; StringBuilder text = new StringBuilder(); text.AppendFormat("<img src='{0}' alt='icon'/>", node.IconUrl); text.Append(node.Title); foreach(var mi in node.MetaInforation) { text.AppendFormat(" <span class='meta {0}' title='{1}'>{2}</span>", mi.Name, mi.ToolTip, mi.Text); } var builder = new Link(text.ToString(), node.ToolTip, node.Target ?? target, node.PreviewUrl, className) .Attribute("id", item.Path.Replace('/', '_')) .Attribute("data-id", item.ID.ToString()) .Attribute("data-type", item.GetContentType().Name) .Attribute("data-path", item.Path) .Attribute("data-url", item.Url) .Attribute("data-page", item.IsPage.ToString().ToLower()) .Attribute("data-zone", item.ZoneName) .Attribute("data-permission", node.MaximumPermission.ToString()); if (isSelected) builder.Attribute("data-selected", "true"); if (isSelectable) builder.Attribute("data-selectable", "true"); builder.Href(adapter.GetPreviewUrl(item)); return builder; }