Exemple #1
0
        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;
        }
 internal static ILinkBuilder GetLinkBuilder(ContentItem item, string url, string detailName, string target, string cssClass)
 {
     ILinkBuilder builder = new Link(item.GetDetail(detailName + "_Text", detailName), url);
     return builder.Target(item.GetDetail(detailName + "_Target", target))
         .Class(item.GetDetail(detailName + "_CssClass", cssClass));
 }