diff --git a/src/Umbraco.Core/Models/IMacroProperty.cs b/src/Umbraco.Core/Models/IMacroProperty.cs
index 13e3183c06..f02297c14c 100644
--- a/src/Umbraco.Core/Models/IMacroProperty.cs
+++ b/src/Umbraco.Core/Models/IMacroProperty.cs
@@ -27,13 +27,9 @@ namespace Umbraco.Core.Models
int SortOrder { get; set; }
///
- /// Gets or sets the Type for this Property
- ///
- ///
- /// The MacroPropertyTypes acts as a plugin for Macros.
- /// All types was previously contained in the database, but has been ported to code.
- ///
+ /// Gets or sets the parameter editor alias
+ ///
[DataMember]
- IMacroPropertyType PropertyType { get; set; }
+ string EditorAlias { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Models/MacroProperty.cs b/src/Umbraco.Core/Models/MacroProperty.cs
index 5db932f618..3ac6d7838d 100644
--- a/src/Umbraco.Core/Models/MacroProperty.cs
+++ b/src/Umbraco.Core/Models/MacroProperty.cs
@@ -17,23 +17,23 @@ namespace Umbraco.Core.Models
}
- public MacroProperty(string @alias, string name, int sortOrder, IMacroPropertyType propertyType)
+ public MacroProperty(string @alias, string name, int sortOrder, string editorAlias)
{
_alias = alias;
_name = name;
_sortOrder = sortOrder;
- _propertyType = propertyType;
+ _editorAlias = editorAlias;
}
private string _alias;
private string _name;
private int _sortOrder;
- private IMacroPropertyType _propertyType;
+ private string _editorAlias;
private static readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo(x => x.Alias);
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name);
private static readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo(x => x.SortOrder);
- private static readonly PropertyInfo PropertyTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.PropertyType);
+ private static readonly PropertyInfo PropertyTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.EditorAlias);
///
/// Gets or sets the Alias of the Property
@@ -94,17 +94,17 @@ namespace Umbraco.Core.Models
/// All types was previously contained in the database, but has been ported to code.
///
[DataMember]
- public IMacroPropertyType PropertyType
+ public string EditorAlias
{
- get { return _propertyType; }
+ get { return _editorAlias; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
- _propertyType = value;
- return _propertyType;
- }, _propertyType, PropertyTypeSelector);
+ _editorAlias = value;
+ return _editorAlias;
+ }, _editorAlias, PropertyTypeSelector);
}
}
}
diff --git a/src/Umbraco.Core/Models/Rdbms/MacroPropertyDto.cs b/src/Umbraco.Core/Models/Rdbms/MacroPropertyDto.cs
index 67cab8081b..e2efddc829 100644
--- a/src/Umbraco.Core/Models/Rdbms/MacroPropertyDto.cs
+++ b/src/Umbraco.Core/Models/Rdbms/MacroPropertyDto.cs
@@ -11,15 +11,9 @@ namespace Umbraco.Core.Models.Rdbms
[Column("id")]
[PrimaryKeyColumn]
public int Id { get; set; }
-
- //NOTE: This column is not used, we always show the properties
- [Column("macroPropertyHidden")]
- [Constraint(Default = "0")]
- public bool Hidden { get; set; }
-
- [Column("macroPropertyType")]
- [ForeignKey(typeof(MacroPropertyTypeDto))]
- public short Type { get; set; }
+
+ [Column("editorAlias")]
+ public string EditorAlias { get; set; }
[Column("macro")]
[ForeignKey(typeof(MacroDto))]
diff --git a/src/Umbraco.Core/Persistence/Factories/MacroFactory.cs b/src/Umbraco.Core/Persistence/Factories/MacroFactory.cs
index 4203a9f564..859714393f 100644
--- a/src/Umbraco.Core/Persistence/Factories/MacroFactory.cs
+++ b/src/Umbraco.Core/Persistence/Factories/MacroFactory.cs
@@ -60,8 +60,7 @@ namespace Umbraco.Core.Persistence.Factories
Name = p.Name,
Macro = entity.Id,
SortOrder = (byte)p.SortOrder,
- //TODO: WE need to change this column to store an alias!!!! for now I'm just hard coding this until we go to that part.
- Type = 16
+ EditorAlias = p.EditorAlias
};
list.Add(text);
diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs
index 11f544bb2d..bc7f955902 100644
--- a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaResult.cs
@@ -69,9 +69,9 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
return new Version(6, 0, 0);
}
- //if the error indicates a problem with the column cmsDataType.controlId then it is not version 7 and the
- // last db change we made was the umbracoServer in 6.2
- if (Errors.Any(x => x.Item1.Equals("Column") && (x.Item2.Equals("cmsDataType,controlId"))))
+ //if the error indicates a problem with the column cmsMacroProperty.macroPropertyType then it is not version 7 and the
+ // last db change we made was the umbracoServer in 6.1
+ if (Errors.Any(x => x.Item1.Equals("Column") && (x.Item2.Equals("cmsMacroProperty,macroPropertyType"))))
{
return new Version(6, 1, 0);
}
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/AddEditorAliasToCmsMacroProperty.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/AddEditorAliasToCmsMacroProperty.cs
new file mode 100644
index 0000000000..b1a7fd0816
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/AddEditorAliasToCmsMacroProperty.cs
@@ -0,0 +1,35 @@
+using System;
+using Umbraco.Core.Configuration;
+
+namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
+{
+ ///
+ /// We are removing the cmsMacroPropertyType which the cmsMacroProperty references and the cmsMacroProperty.macroPropertyType column
+ /// needs to be changed to editorAlias, we'll do this by removing the constraint,changing the macroPropertyType to the new
+ /// editorAlias column (and maintaing data so we can reference it)
+ ///
+ [Migration("7.0.0", 5, GlobalSettings.UmbracoMigrationName)]
+ public class AddEditorAliasToCmsMacroProperty : MigrationBase
+ {
+ public override void Up()
+ {
+ //"DF_cmsMacroProperty_macroPropertyHidden""
+ Delete.DefaultConstraint().OnTable("cmsMacroProperty").OnColumn("macroPropertyHidden");
+
+ Delete.Column("macroPropertyHidden").FromTable("cmsMacroProperty");
+
+ Delete.ForeignKey("FK_cmsMacroProperty_cmsMacroPropertyType_id").OnTable("cmsMacroProperty");
+
+ //change the type (keep the data)
+ Alter.Table("cmsMacroProperty").AlterColumn("macroPropertyType").AsString(255);
+ //rename the column
+ Rename.Column("macroPropertyType").OnTable("cmsMacroProperty").To("editorAlias");
+
+ }
+
+ public override void Down()
+ {
+ throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/RemoveCmsMacroPropertyTypeTable.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/RemoveCmsMacroPropertyTypeTable.cs
new file mode 100644
index 0000000000..5405724458
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/RemoveCmsMacroPropertyTypeTable.cs
@@ -0,0 +1,19 @@
+using System;
+using Umbraco.Core.Configuration;
+
+namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
+{
+ [Migration("7.0.0", 7, GlobalSettings.UmbracoMigrationName)]
+ public class RemoveCmsMacroPropertyTypeTable : MigrationBase
+ {
+ public override void Up()
+ {
+ Delete.Table("cmsMacroPropertyType");
+ }
+
+ public override void Down()
+ {
+ throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/UpdateCmsMacroPropertyEditorAliasFromCmsMacroPropertyType.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/UpdateCmsMacroPropertyEditorAliasFromCmsMacroPropertyType.cs
new file mode 100644
index 0000000000..5ef468a268
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/UpdateCmsMacroPropertyEditorAliasFromCmsMacroPropertyType.cs
@@ -0,0 +1,44 @@
+using System;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.PropertyEditors;
+
+namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSeven
+{
+ ///
+ /// We are removing the cmsMacroPropertyType which the cmsMacroProperty references and the cmsMacroProperty.macroPropertyType column
+ /// needs to be changed to editorAlias. Then running a data migration to populate the editorAlias column based on the data in the cmsMacroPropertyType
+ /// table.
+ ///
+ [Migration("7.0.0", 6, GlobalSettings.UmbracoMigrationName)]
+ public class UpdateCmsMacroPropertyEditorAliasFromCmsMacroPropertyType : MigrationBase
+ {
+ public override void Up()
+ {
+ //now that the controlId column is renamed and now a string we need to convert
+ if (Context == null || Context.Database == null) return;
+
+ //we need to get the data and create the migration scripts before we change the actual schema bits below!
+ var list = Context.Database.Fetch("SELECT * FROM cmsMacroPropertyType");
+ foreach (var item in list)
+ {
+
+ var alias = item.macroPropertyTypeAlias;
+ //check if there's a map created
+ var newAlias = (string)LegacyParameterEditorAliasConverter.GetNewAliasFromLegacyAlias(alias);
+ if (newAlias.IsNullOrWhiteSpace() == false)
+ {
+ alias = newAlias;
+ }
+
+ //update the table with the alias, the current editorAlias will contain the original id
+ Update.Table("cmsMacroProperty").Set(new { editorAlias = alias }).Where(new { editorAlias = item.id });
+
+ }
+ }
+
+ public override void Down()
+ {
+ throw new NotSupportedException("Cannot downgrade from a version 7 database to a prior version");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs b/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs
new file mode 100644
index 0000000000..297e141514
--- /dev/null
+++ b/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+
+namespace Umbraco.Core.PropertyEditors
+{
+ ///
+ /// Used to map the legacy parameter editor aliases to the new ones, this is really just used during
+ /// installation but has been put in a separate class in case we need it for other purposes
+ ///
+ internal static class LegacyParameterEditorAliasConverter
+ {
+ ///
+ /// The map consists of a key which is always the legacy alias + new alias (trimmed))
+ ///
+ private static ConcurrentDictionary> _map = new ConcurrentDictionary>();
+
+ ///
+ /// Creates a map for the specified legacy alias and property editor alias
+ ///
+ ///
+ ///
+ /// true if the map was created or false if it was already created
+ public static bool CreateMap(string legacyAlias, string alias)
+ {
+ var key = legacyAlias.ToLowerInvariant() + alias.Trim();
+ return _map.TryAdd(key, new Tuple(legacyAlias, alias));
+ }
+
+ ///
+ /// Gets an alias based on the legacy alias
+ ///
+ ///
+ /// if set to true will throw an exception if the map isn't found
+ /// Returns the alias if found otherwise null if not found
+ public static string GetNewAliasFromLegacyAlias(string legacyAlias, bool throwIfNotFound = false)
+ {
+ var found = _map.FirstOrDefault(x => x.Value.Item1 == legacyAlias);
+ if (found.Equals(default(KeyValuePair>)))
+ {
+ if (throwIfNotFound)
+ {
+ throw new ObjectNotFoundException("Could not find a map for a property editor with a legacy alias of " + legacyAlias);
+ }
+ return null;
+ }
+ return found.Value.Item2;
+ }
+
+ ///
+ /// Gets a legacy Id based on the alias
+ ///
+ ///
+ /// if set to true will throw an exception if the map isn't found
+ /// Returns the legacy GUID of a property editor if found, otherwise returns null
+ public static string GetLegacyAliasFromNewAlias(string alias, bool throwIfNotFound = false)
+ {
+ var found = _map.FirstOrDefault(x => x.Value.Item2 == alias);
+ if (found.Equals(default(KeyValuePair>)))
+ {
+ if (throwIfNotFound)
+ {
+ throw new ObjectNotFoundException("Could not find a map for a property editor with an alias of " + alias);
+ }
+ return null;
+ }
+ return found.Value.Item1;
+ }
+
+ internal static int Count()
+ {
+ return _map.Count;
+ }
+
+ internal static void Reset()
+ {
+ _map = new ConcurrentDictionary>();
+ }
+
+ ///
+ /// A method that should be called on startup to register the mappings for the internal core editors
+ ///
+ internal static void CreateMappingsForCoreEditors()
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs b/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs
index 92be126c86..9cbb561fec 100644
--- a/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs
+++ b/src/Umbraco.Core/PropertyEditors/LegacyPropertyEditorIdToAliasConverter.cs
@@ -6,7 +6,6 @@ using System.Linq;
namespace Umbraco.Core.PropertyEditors
{
-
///
/// This is used to map old legacy property editor GUID's to the new Property Editor alias (string) format.
///
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index a870d4f397..49a428dc14 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -405,13 +405,17 @@
+
+
+
+
diff --git a/src/Umbraco.Web.UI/install/steps/theend.ascx b/src/Umbraco.Web.UI/install/steps/theend.ascx
index 224cb6bdeb..2df9c738ca 100644
--- a/src/Umbraco.Web.UI/install/steps/theend.ascx
+++ b/src/Umbraco.Web.UI/install/steps/theend.ascx
@@ -1,5 +1,6 @@
<%@ Control Language="c#" AutoEventWireup="True" CodeBehind="TheEnd.ascx.cs" Inherits="Umbraco.Web.UI.Install.Steps.TheEnd"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
+<%@ Import Namespace="Umbraco.Core.IO" %>