From 46ba9718ff42371ac0e280f059d427f92ccbb637 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 30 Oct 2013 14:36:07 +1100 Subject: [PATCH] Changes the explicit paramet editor implementations to simply use the already created property editors, updates the legacy parameter editor mappings and adjusts the resolver to use the mappings if one is not found. --- src/Umbraco.Core/CoreBootManager.cs | 1 + .../LegacyParameterEditorAliasConverter.cs | 10 ++++++++++ .../PropertyEditors/ParameterEditorResolver.cs | 9 ++++++++- .../ParameterEditors/TextAreaParameterEditor.cs | 9 --------- .../ParameterEditors/TextParameterEditor.cs | 9 --------- .../ParameterEditors/TrueFalseParameterEditor.cs | 9 --------- .../PropertyEditors/TextAreaPropertyEditor.cs | 2 +- .../PropertyEditors/TextboxPropertyEditor.cs | 2 +- .../PropertyEditors/TrueFalsePropertyEditor.cs | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 3 --- 10 files changed, 22 insertions(+), 34 deletions(-) delete mode 100644 src/Umbraco.Web/PropertyEditors/ParameterEditors/TextAreaParameterEditor.cs delete mode 100644 src/Umbraco.Web/PropertyEditors/ParameterEditors/TextParameterEditor.cs delete mode 100644 src/Umbraco.Web/PropertyEditors/ParameterEditors/TrueFalseParameterEditor.cs diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index d830ac8a48..da81d617c9 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -69,6 +69,7 @@ namespace Umbraco.Core //Create the legacy prop-eds mapping LegacyPropertyEditorIdToAliasConverter.CreateMappingsForCoreEditors(); + LegacyParameterEditorAliasConverter.CreateMappingsForCoreEditors(); //create database and service contexts for the app context var dbFactory = new DefaultDatabaseFactory(GlobalSettings.UmbracoConnectionName); diff --git a/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs b/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs index 297e141514..be9c4880ce 100644 --- a/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/LegacyParameterEditorAliasConverter.cs @@ -84,6 +84,16 @@ namespace Umbraco.Core.PropertyEditors /// internal static void CreateMappingsForCoreEditors() { + //All of these map to the content picker + CreateMap("contentSubs", Constants.PropertyEditors.ContentPickerAlias); + CreateMap("contentRandom", Constants.PropertyEditors.ContentPickerAlias); + CreateMap("contentPicker", Constants.PropertyEditors.ContentPickerAlias); + CreateMap("contentTree", Constants.PropertyEditors.ContentPickerAlias); + CreateMap("contentAll", Constants.PropertyEditors.ContentPickerAlias); + + CreateMap("textMultiLine", Constants.PropertyEditors.TextboxMultipleAlias); + CreateMap("text", Constants.PropertyEditors.TextboxAlias); + CreateMap("bool", Constants.PropertyEditors.TrueFalseAlias); } } diff --git a/src/Umbraco.Core/PropertyEditors/ParameterEditorResolver.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditorResolver.cs index 2dd302988d..787291a473 100644 --- a/src/Umbraco.Core/PropertyEditors/ParameterEditorResolver.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditorResolver.cs @@ -51,7 +51,14 @@ namespace Umbraco.Core.PropertyEditors /// public IParameterEditor GetByAlias(string alias) { - return ParameterEditors.SingleOrDefault(x => x.Alias == alias); + var found = ParameterEditors.SingleOrDefault(x => x.Alias == alias); + if (found != null) return found; + + //couldn't find one, so try the map + var mapped = LegacyParameterEditorAliasConverter.GetNewAliasFromLegacyAlias(alias); + return mapped == null + ? null + : ParameterEditors.SingleOrDefault(x => x.Alias == mapped); } } } \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/ParameterEditors/TextAreaParameterEditor.cs b/src/Umbraco.Web/PropertyEditors/ParameterEditors/TextAreaParameterEditor.cs deleted file mode 100644 index 7b95ad6f9f..0000000000 --- a/src/Umbraco.Web/PropertyEditors/ParameterEditors/TextAreaParameterEditor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors.ParameterEditors -{ - [ParameterEditor("textMultiLine", "Textarea", "textarea")] - public class TextAreaParameterEditor : ParameterEditor - { - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/ParameterEditors/TextParameterEditor.cs b/src/Umbraco.Web/PropertyEditors/ParameterEditors/TextParameterEditor.cs deleted file mode 100644 index 82fab3ae41..0000000000 --- a/src/Umbraco.Web/PropertyEditors/ParameterEditors/TextParameterEditor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors.ParameterEditors -{ - [ParameterEditor("text", "Text", "textbox")] - public class TextParameterEditor : ParameterEditor - { - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/ParameterEditors/TrueFalseParameterEditor.cs b/src/Umbraco.Web/PropertyEditors/ParameterEditors/TrueFalseParameterEditor.cs deleted file mode 100644 index cc02db9f8d..0000000000 --- a/src/Umbraco.Web/PropertyEditors/ParameterEditors/TrueFalseParameterEditor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Web.PropertyEditors.ParameterEditors -{ - [ParameterEditor("bool", "True/False", "boolean")] - public class TrueFalseParameterEditor : ParameterEditor - { - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs index ad761fba6d..e92a78dea8 100644 --- a/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs @@ -3,7 +3,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TextboxMultipleAlias, "Textarea", "textarea")] + [PropertyEditor(Constants.PropertyEditors.TextboxMultipleAlias, "Textarea", "textarea", IsParameterEditor = true)] public class TextAreaPropertyEditor : PropertyEditor { } diff --git a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs index f70132f4a0..69bc1452cf 100644 --- a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs @@ -10,7 +10,7 @@ using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TextboxAlias, "Textbox", "textbox")] + [PropertyEditor(Constants.PropertyEditors.TextboxAlias, "Textbox", "textbox", IsParameterEditor = true)] public class TextboxPropertyEditor : PropertyEditor { } diff --git a/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs index 4ba1d8330a..d9923b178e 100644 --- a/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TrueFalsePropertyEditor.cs @@ -3,7 +3,7 @@ using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors { - [PropertyEditor(Constants.PropertyEditors.TrueFalseAlias, "True/False", "boolean")] + [PropertyEditor(Constants.PropertyEditors.TrueFalseAlias, "True/False", "boolean", IsParameterEditor = true)] public class TrueFalsePropertyEditor : PropertyEditor { } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 3b04ef1f0e..5ab6e629d1 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -346,9 +346,6 @@ - - -