コード例 #1
0
        internal static ILinkBuilder BuildLink(NodeAdapter adapter, ContentItem item, bool selected, string target)
        {
            INode  node      = item;
            string className = node.ClassNames;

            if (selected)
            {
                className += "selected ";
            }

            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());

            builder.Href(adapter.GetPreviewUrl(item));

            return(builder);
        }