public SitecoreContentEntity Map(Item input) { var output = new SitecoreContentEntity { Id = _enterspeedIdentityService.GetId(input), Type = input.TemplateName, Properties = _enterspeedPropertyService.GetProperties(input) }; EnterspeedSiteInfo siteInfo = _enterspeedConfigurationService.GetConfiguration().GetSite(input); if (siteInfo != null) { if (input.Paths.FullPath.StartsWith(siteInfo.HomeItemPath, StringComparison.OrdinalIgnoreCase)) { // Routable content resides on or below the Home item path. output.Url = _urlService.GetItemUrl(input); } if (!input.Paths.FullPath.Equals(siteInfo.SiteItemPath, StringComparison.OrdinalIgnoreCase)) { // If the input item is the Site item, we do not set a parent ID. output.ParentId = _enterspeedIdentityService.GetId(input.Parent); } } return(output); }
public IEnterspeedProperty Convert(Item item, Field field, EnterspeedSiteInfo siteInfo, List <IEnterspeedFieldValueConverter> fieldValueConverters) { LinkField linkField = field; if (linkField == null) { return(null); } var properties = new Dictionary <string, IEnterspeedProperty>(); if (!string.IsNullOrEmpty(linkField.Target)) { properties.Add(PropertyTarget, new StringEnterspeedProperty(PropertyTarget, linkField.Target)); } if (!string.IsNullOrEmpty(linkField.Anchor)) { properties.Add(PropertyAnchor, new StringEnterspeedProperty(PropertyAnchor, linkField.Anchor)); } if (!string.IsNullOrEmpty(linkField.Text)) { properties.Add(PropertyText, new StringEnterspeedProperty(PropertyText, linkField.Text)); } if (!string.IsNullOrEmpty(linkField.Title)) { properties.Add(PropertyTitle, new StringEnterspeedProperty(PropertyTitle, linkField.Title)); } if (!string.IsNullOrEmpty(linkField.Class)) { properties.Add(PropertyClass, new StringEnterspeedProperty(PropertyClass, linkField.Class)); } string url = null; if (linkField.LinkType == "media") { url = _urlService.GetMediaUrl(linkField.TargetItem); } else if (linkField.LinkType == "internal") { url = _urlService.GetItemUrl(linkField.TargetItem); if (linkField.TargetItem != null) { properties.Add(PropertyTargetType, new StringEnterspeedProperty(PropertyTargetType, linkField.TargetItem.TemplateName)); properties.Add(PropertyTargetId, new StringEnterspeedProperty(PropertyTargetId, _enterspeedIdentityService.GetId(linkField.TargetItem))); } } else if (linkField.LinkType == "external" || linkField.LinkType == "anchor" || linkField.LinkType == "mailto" || linkField.LinkType == "javascript") { url = linkField.GetFriendlyUrl(); } if (!string.IsNullOrEmpty(url)) { properties.Add(PropertyUrl, new StringEnterspeedProperty(PropertyUrl, url)); } else { return(null); } return(new ObjectEnterspeedProperty(_fieldService.GetFieldName(field), properties)); }