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; }
public override void SetUp() { base.SetUp(); root = CreateOneItem<Items.NormalPage>(1, "root", null); start = CreateOneItem<Items.NormalPage>(2, "start", root); adapter = new NodeAdapter(); adapter.ManagementPaths = new EditUrlManager(new N2.Configuration.EditSection()); adapter.FileSystem = fs = new FakeFileSystem2(); adapter.NodeFactory = new VirtualNodeFactory(); adapter.WebContext = new Fakes.FakeWebContextWrapper(); adapter.Security = new SecurityManager(adapter.WebContext, new N2.Configuration.EditSection()); adapter.Host = new Host(null, root.ID, start.ID); }
public override void SetUp() { base.SetUp(); root = CreateOneItem<Items.NormalPage>(1, "root", null); start = CreateOneItem<Items.NormalPage>(2, "start", root); part = CreateOneItem<Items.NormalItem>(3, "part", root); part.ZoneName = "Zone"; adapter = new NodeAdapter(); adapter.ManagementPaths = new EditUrlManager(null, new N2.Configuration.EditSection()); adapter.FileSystem = fs = new FakeMemoryFileSystem(); adapter.NodeFactory = new VirtualNodeFactory(); adapter.WebContext = new Fakes.FakeWebContextWrapper(); adapter.Security = new SecurityManager(adapter.WebContext, new N2.Configuration.EditSection()); adapter.Host = new Host(null, root.ID, start.ID); adapter.Settings = new FakeNavigationSettings(); adapter.Sources = TestSupport.SetupContentSource(adapter.WebContext, adapter.Host, persister.Repository); }
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(); if (!string.IsNullOrEmpty(node.IconClass)) text.AppendFormat("<b class='{0}'></b> ", node.IconClass); else if (!string.IsNullOrEmpty(node.IconUrl)) text.AppendFormat("<img src='{0}' alt='icon'/>", node.IconUrl); if (string.IsNullOrEmpty(node.Title)) text.Append(Utility.GetLocalResourceString("NoName") ?? "(no name)"); else text.Append(node.Title); foreach (var mi in node.MetaInformation) { text.AppendFormat(" <span class='meta {0}' title='{1}'>{2}</span>", mi.Key, mi.Value.ToolTip, mi.Value.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"); return builder; }