diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs index c260b10418..30a51f157e 100644 --- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs +++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs @@ -248,7 +248,9 @@ namespace Umbraco.Core.Services { var tab = new XElement("Tab", new XElement("Id", propertyGroup.Id.ToString(CultureInfo.InvariantCulture)), - new XElement("Caption", propertyGroup.Name)); + new XElement("Caption", propertyGroup.Name), + new XElement("SortOrder", propertyGroup.SortOrder)); + tabs.Add(tab); } @@ -354,7 +356,8 @@ namespace Umbraco.Core.Services { var tab = new XElement("Tab", new XElement("Id", propertyGroup.Id.ToString(CultureInfo.InvariantCulture)), - new XElement("Caption", propertyGroup.Name)); + new XElement("Caption", propertyGroup.Name), + new XElement("SortOrder", propertyGroup.SortOrder)); tabs.Add(tab); } diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index 47310ab1c3..ace4931b5b 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -74,7 +74,7 @@ namespace Umbraco.Core.Services public XElement Export(IContent content, bool deep = false, bool raiseEvents = true) { var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck(); - + if (raiseEvents) { if (ExportingContent.IsRaisedEventCancelled(new ExportEventArgs(content, nodeName), this)) @@ -84,13 +84,13 @@ namespace Umbraco.Core.Services var exporter = new EntityXmlSerializer(); var xml = exporter.Serialize(_contentService, _dataTypeService, content, deep); - if(raiseEvents) + if (raiseEvents) ExportedContent.RaiseEvent(new ExportEventArgs(content, xml, false), this); return xml; } - + /// /// Imports and saves package xml as @@ -107,7 +107,7 @@ namespace Umbraco.Core.Services if (ImportingContent.IsRaisedEventCancelled(new ImportEventArgs(element), this)) return Enumerable.Empty(); } - + var name = element.Name.LocalName; if (name.Equals("DocumentSet")) { @@ -120,7 +120,7 @@ namespace Umbraco.Core.Services if (contents.Any()) _contentService.Save(contents, userId); - if(raiseEvents) + if (raiseEvents) ImportedContent.RaiseEvent(new ImportEventArgs(contents, element, false), this); return contents; } @@ -134,7 +134,7 @@ namespace Umbraco.Core.Services if (contents.Any()) _contentService.Save(contents, userId); - if(raiseEvents) + if (raiseEvents) ImportedContent.RaiseEvent(new ImportEventArgs(contents, element, false), this); return contents; } @@ -248,7 +248,7 @@ namespace Umbraco.Core.Services //TODO: We need to refactor this so the packager isn't making direct db calls for an 'edge' case var database = ApplicationContext.Current.DatabaseContext.Database; - var dtos = database.Fetch("WHERE datatypeNodeId = @Id", new {Id = propertyType.DataTypeDefinitionId}); + var dtos = database.Fetch("WHERE datatypeNodeId = @Id", new { Id = propertyType.DataTypeDefinitionId }); var propertyValueList = new List(); foreach (var preValue in propertyValue.Split(',')) @@ -261,7 +261,7 @@ namespace Umbraco.Core.Services } //set property value - content.SetValue(propertyTypeAlias, propertyValue); + content.SetValue(propertyTypeAlias, propertyValue); } } } @@ -491,13 +491,13 @@ namespace Umbraco.Core.Services { contentType.AddPropertyGroup(caption); - int sortOrder; - if(tab.Element("SortOrder") != null && - int.TryParse(tab.Element("SortOrder").Value, out sortOrder)) - { - // Override the sort order with the imported value - contentType.PropertyGroups[caption].SortOrder = sortOrder; - } + } + + int sortOrder; + if (tab.Element("SortOrder") != null && int.TryParse(tab.Element("SortOrder").Value, out sortOrder)) + { + // Override the sort order with the imported value + contentType.PropertyGroups[caption].SortOrder = sortOrder; } } } @@ -549,7 +549,7 @@ namespace Umbraco.Core.Services dataTypeDefinition = dataTypeDefinitions.First(); } } - + // For backwards compatibility, if no datatype with that ID can be found, we're letting this fail silently. // This means that the property will not be created. if (dataTypeDefinition == null) @@ -786,15 +786,15 @@ namespace Umbraco.Core.Services var dataTypeDefinition = dataTypes.First(x => x.Name == dataTypeDefinitionName); var valuesWithoutKeys = prevaluesElement.Elements("PreValue") - .Where(x => ((string) x.Attribute("Alias")).IsNullOrWhiteSpace()) + .Where(x => ((string)x.Attribute("Alias")).IsNullOrWhiteSpace()) .Select(x => x.Attribute("Value").Value); var valuesWithKeys = prevaluesElement.Elements("PreValue") - .Where(x => ((string) x.Attribute("Alias")).IsNullOrWhiteSpace() == false) + .Where(x => ((string)x.Attribute("Alias")).IsNullOrWhiteSpace() == false) .ToDictionary( - key => (string) key.Attribute("Alias"), - val => new PreValue((string) val.Attribute("Value"))); - + key => (string)key.Attribute("Alias"), + val => new PreValue((string)val.Attribute("Value"))); + //save the values with keys _dataTypeService.SavePreValues(dataTypeDefinition, valuesWithKeys); @@ -841,7 +841,7 @@ namespace Umbraco.Core.Services var exporter = new EntityXmlSerializer(); var xml = exporter.Serialize(dictionaryItem); - + if (includeChildren) { var children = _localizationService.GetDictionaryItemChildren(dictionaryItem.Key); @@ -1115,7 +1115,7 @@ namespace Umbraco.Core.Services dontRender = bool.Parse(dontRenderElement.Value); } - var existingMacro = _macroService.GetByAlias(macroAlias) as Macro; + var existingMacro = _macroService.GetByAlias(macroAlias) as Macro; var macro = existingMacro ?? new Macro(macroAlias, macroName, controlType, controlAssembly, xsltPath, scriptPath, cacheByPage, cacheByMember, dontRender, useInEditor, cacheDuration); @@ -1210,7 +1210,7 @@ namespace Umbraco.Core.Services public XElement Export(IMedia media, bool deep = false, bool raiseEvents = true) { var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck(); - + if (raiseEvents) { if (ExportingMedia.IsRaisedEventCancelled(new ExportEventArgs(media, nodeName), this)) @@ -1220,7 +1220,7 @@ namespace Umbraco.Core.Services var exporter = new EntityXmlSerializer(); var xml = exporter.Serialize(_mediaService, _dataTypeService, media, deep); - if(raiseEvents) + if (raiseEvents) ExportedMedia.RaiseEvent(new ExportEventArgs(media, xml, false), this); return xml; @@ -1334,7 +1334,7 @@ namespace Umbraco.Core.Services if (templates.Any()) _fileService.SaveTemplate(templates, userId); - if(raiseEvents) + if (raiseEvents) ImportedTemplate.RaiseEvent(new ImportEventArgs(templates, element, false), this); return templates; @@ -1352,10 +1352,10 @@ namespace Umbraco.Core.Services IEnumerable styleSheets = Enumerable.Empty(); - if(element.Elements().Any()) + if (element.Elements().Any()) throw new NotImplementedException("This needs to be implimentet"); - + if (raiseEvents) ImportingStylesheets.RaiseEvent(new ImportEventArgs(styleSheets, element, false), this); @@ -1480,7 +1480,7 @@ namespace Umbraco.Core.Services /// public static event TypedEventHandler> ImportedContent; - + public static event TypedEventHandler> ExportingContent; /// @@ -1607,7 +1607,7 @@ namespace Umbraco.Core.Services /// Occurs before Importing Stylesheets /// public static event TypedEventHandler> ImportingStylesheets; - + /// /// Occurs after Template is Imported and Saved /// @@ -1622,7 +1622,7 @@ namespace Umbraco.Core.Services /// Occurs after Template is Exported to Xml /// public static event TypedEventHandler> ExportedTemplate; - + /// /// Occurs before Importing umbraco package ///