Beispiel #1
0
        // exports an IContentBase (IContent, IMedia or IMember) as an XElement.
        private XElement SerializeContentBase(IContentBase contentBase, string urlValue, string nodeName, bool published)
        {
            var xml = new XElement(nodeName,
                                   new XAttribute("id", contentBase.Id.ToInvariantString()),
                                   new XAttribute("key", contentBase.Key),
                                   new XAttribute("parentID", (contentBase.Level > 1 ? contentBase.ParentId : -1).ToInvariantString()),
                                   new XAttribute("level", contentBase.Level),
                                   new XAttribute("creatorID", contentBase.CreatorId.ToInvariantString()),
                                   new XAttribute("sortOrder", contentBase.SortOrder),
                                   new XAttribute("createDate", contentBase.CreateDate.ToString("s")),
                                   new XAttribute("updateDate", contentBase.UpdateDate.ToString("s")),
                                   new XAttribute("nodeName", contentBase.Name),
                                   new XAttribute("urlName", urlValue),
                                   new XAttribute("path", contentBase.Path),
                                   new XAttribute("isDoc", ""));


            // Add culture specific node names
            foreach (var culture in contentBase.AvailableCultures)
            {
                xml.Add(new XAttribute("nodeName-" + culture, contentBase.GetCultureName(culture)));
            }

            foreach (var property in contentBase.Properties)
            {
                xml.Add(SerializeProperty(property, published));
            }

            return(xml);
        }
Beispiel #2
0
        private static string GetUrlSegmentSource(IContentBase content, string culture)
        {
            string source = null;

            if (content.HasProperty(Constants.Conventions.Content.UrlName))
            {
                source = (content.GetValue <string>(Constants.Conventions.Content.UrlName, culture) ?? string.Empty).Trim();
            }
            if (string.IsNullOrWhiteSpace(source))
            {
                source = content.GetCultureName(culture);
            }
            return(source);
        }
Beispiel #3
0
        private static string GetUrlSegmentSource(IContentBase content, string culture)
        {
            string source = null;

            if (content.HasProperty(Constants.Conventions.Content.UrlName))
            {
                source = (content.GetValue <string>(Constants.Conventions.Content.UrlName, culture) ?? string.Empty).Trim();
            }
            if (string.IsNullOrWhiteSpace(source))
            {
                // If the name of a node has been updated, but it has not been published, the url should use the published name, not the current node name
                // If this node has never been published (GetPublishName is null), use the unpublished name
                source = (content is IContent document) && document.Edited && document.GetPublishName(culture) != null
                    ? document.GetPublishName(culture)
                    : content.GetCultureName(culture);
            }
            return(source);
        }