From a915dff4a8bc8804c8e334f75b61cdcb9cd02760 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 28 Oct 2013 11:02:04 +1100 Subject: [PATCH] Fixes packaging service up to export data type's properly, fixes legacy DataTypeDefinition to export data type's properly with the prop ed alias instead of id, obsoletes old content extension methods. --- src/Umbraco.Core/Services/PackagingService.cs | 3 +- .../developer/Packages/editPackage.aspx.cs | 9 ------ .../umbraco/uQuery/ContentExtensions.cs | 7 +++++ .../datatype/DataTypeDefinition.cs | 31 +++++++++++-------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index 0b6bd73bbc..873145166b 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -746,7 +746,8 @@ namespace Umbraco.Core.Services var xml = new XElement("DataType", prevalues); xml.Add(new XAttribute("Name", dataTypeDefinition.Name)); - xml.Add(new XAttribute("Id", dataTypeDefinition.Id)); + //The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id) + xml.Add(new XAttribute("Id", dataTypeDefinition.PropertyEditorAlias)); xml.Add(new XAttribute("Definition", dataTypeDefinition.Key)); xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString())); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs index 6e5467b5b0..ceae3d5659 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/editPackage.aspx.cs @@ -368,15 +368,6 @@ namespace umbraco.presentation.developer.packages packageFilesRepeater.DataBind(); } - private static string JoinList(List list, char seperator) { - string retVal = ""; - foreach (string str in list) { - retVal += str + seperator.ToString(); - } - - return retVal.Trim(seperator); - } - protected override void OnInit(EventArgs e) { // Tab setup diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/ContentExtensions.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/ContentExtensions.cs index ddd309064c..973d5acd72 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/ContentExtensions.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/ContentExtensions.cs @@ -22,6 +22,7 @@ namespace umbraco /// /// true if the specified content item has property; otherwise, false. /// + [Obsolete("Use the new Services APIs instead")] public static bool HasProperty(this Content item, string propertyAlias) { var property = item.getProperty(propertyAlias); @@ -35,6 +36,7 @@ namespace umbraco /// The content item. /// alias of property to get /// default(T) or property value cast to (T) + [Obsolete("Use the new Services APIs instead")] public static T GetProperty(this Content item, string propertyAlias) { // check to see if return object handles it's own object hydration @@ -106,6 +108,7 @@ namespace umbraco /// /// empty string, or property value as string /// + [Obsolete("Use the new Services APIs instead")] private static string GetPropertyAsString(this Content item, string propertyAlias) { var propertyValue = string.Empty; @@ -127,6 +130,7 @@ namespace umbraco /// /// true if can cast value, else false for all other circumstances /// + [Obsolete("Use the new Services APIs instead")] private static bool GetPropertyAsBoolean(this Content item, string propertyAlias) { var propertyValue = false; @@ -187,6 +191,7 @@ namespace umbraco /// The items. /// The property alias. /// + [Obsolete("Use the new Services APIs instead")] public static IEnumerable OrderByProperty(this IEnumerable items, string propertyAlias) { return items.OrderBy(x => x.GetProperty(propertyAlias)); @@ -213,6 +218,7 @@ namespace umbraco /// The items. /// The property alias. /// + [Obsolete("Use the new Services APIs instead")] public static IEnumerable OrderByPropertyDescending(this IEnumerable items, string propertyAlias) { return items.OrderByDescending(x => x.GetProperty(propertyAlias)); @@ -239,6 +245,7 @@ namespace umbraco /// /// The same content item on which this is an extension method. /// + [Obsolete("Use the new Services APIs instead")] public static Content SetProperty(this Content item, string propertyAlias, object value) { var property = item.getProperty(propertyAlias); diff --git a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs index 8ae006f9a6..a563549bcf 100644 --- a/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs +++ b/src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs @@ -152,15 +152,18 @@ namespace umbraco.cms.businesslogic.datatype public XmlElement ToXml(XmlDocument xd) { + //here we need to get the property editor alias from it's id + var alias = LegacyPropertyEditorIdToAliasConverter.GetAliasFromLegacyId(DataType.Id, true); + XmlElement dt = xd.CreateElement("DataType"); dt.Attributes.Append(xmlHelper.addAttribute(xd, "Name", Text)); - dt.Attributes.Append(xmlHelper.addAttribute(xd, "Id", this.DataType.Id.ToString())); - dt.Attributes.Append(xmlHelper.addAttribute(xd, "Definition", this.UniqueId.ToString())); - dt.Attributes.Append(xmlHelper.addAttribute(xd, "DatabaseType", this.DbType)); + dt.Attributes.Append(xmlHelper.addAttribute(xd, "Id", alias)); + dt.Attributes.Append(xmlHelper.addAttribute(xd, "Definition", UniqueId.ToString())); + dt.Attributes.Append(xmlHelper.addAttribute(xd, "DatabaseType", DbType)); // templates XmlElement prevalues = xd.CreateElement("PreValues"); - foreach (DictionaryEntry item in PreValues.GetPreValues(this.Id)) + foreach (DictionaryEntry item in PreValues.GetPreValues(Id)) { XmlElement prevalue = xd.CreateElement("PreValue"); prevalue.Attributes.Append(xmlHelper.addAttribute(xd, "Id", ((PreValue)item.Value).Id.ToString())); @@ -176,22 +179,24 @@ namespace umbraco.cms.businesslogic.datatype #endregion #region Static methods + + [Obsolete("Do not use this method, it will not function correctly because legacy property editors are not supported in v7")] public static DataTypeDefinition Import(XmlNode xmlData) { - string _name = xmlData.Attributes["Name"].Value; - string _id = xmlData.Attributes["Id"].Value; - string _def = xmlData.Attributes["Definition"].Value; + var name = xmlData.Attributes["Name"].Value; + var id = xmlData.Attributes["Id"].Value; + var def = xmlData.Attributes["Definition"].Value; //Make sure that the dtd is not already present - if (IsNode(new Guid(_def)) == false) + if (IsNode(new Guid(def)) == false) { var u = BusinessLogic.User.GetCurrent() ?? BusinessLogic.User.GetUser(0); - var dtd = MakeNew(u, _name, new Guid(_def)); - var dataType = DataTypesResolver.Current.GetById(new Guid(_id)); + var dtd = MakeNew(u, name, new Guid(def)); + var dataType = DataTypesResolver.Current.GetById(new Guid(id)); if (dataType == null) - throw new NullReferenceException("Could not resolve a data type with id " + _id); + throw new NullReferenceException("Could not resolve a data type with id " + id); dtd.DataType = dataType; dtd.Save(); @@ -199,11 +204,11 @@ namespace umbraco.cms.businesslogic.datatype //add prevalues foreach (XmlNode xmlPv in xmlData.SelectNodes("PreValues/PreValue")) { - XmlAttribute val = xmlPv.Attributes["Value"]; + var val = xmlPv.Attributes["Value"]; if (val != null) { - PreValue p = new PreValue(0, 0, val.Value); + var p = new PreValue(0, 0, val.Value); p.DataTypeId = dtd.Id; p.Save(); }