diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs index c9995d53cc..fed9de16ea 100644 --- a/src/Umbraco.Core/Models/ContentExtensions.cs +++ b/src/Umbraco.Core/Models/ContentExtensions.cs @@ -532,17 +532,17 @@ namespace Umbraco.Core.Models /// Sets tags for the property - will add tags to the tags table and set the property value to be the comma delimited value of the tags. /// /// The content item to assign the tags to - /// The property alias to assign the tags to + /// The property alias to assign the tags to /// The tags to assign /// True to replace the tags on the current property with the tags specified or false to merge them with the currently assigned ones /// The group/category to assign the tags, the default value is "default" /// - public static void SetTags(this IContent content, string propertyAlias, IEnumerable tags, bool replaceTags, string tagGroup = "default") + public static void SetTags(this IContent content, string propertyTypeAlias, IEnumerable tags, bool replaceTags, string tagGroup = "default") { - var property = content.Properties["propertyAlias"]; + var property = content.Properties[propertyTypeAlias]; if (property == null) { - throw new IndexOutOfRangeException("No property exists with name " + propertyAlias); + throw new IndexOutOfRangeException("No property exists with name " + propertyTypeAlias); } var trimmedTags = tags.Select(x => x.Trim()).ToArray(); @@ -569,15 +569,15 @@ namespace Umbraco.Core.Models /// Remove any of the tags specified in the collection from the property if they are currently assigned. /// /// - /// + /// /// /// The group/category that the tags are currently assigned to, the default value is "default" - public static void RemoveTags(this IContent content, string propertyAlias, IEnumerable tags, string tagGroup = "default") + public static void RemoveTags(this IContent content, string propertyTypeAlias, IEnumerable tags, string tagGroup = "default") { - var property = content.Properties["propertyAlias"]; + var property = content.Properties[propertyTypeAlias]; if (property == null) { - throw new IndexOutOfRangeException("No property exists with name " + propertyAlias); + throw new IndexOutOfRangeException("No property exists with name " + propertyTypeAlias); } var trimmedTags = tags.Select(x => x.Trim()).ToArray(); diff --git a/src/Umbraco.Core/Models/PropertyExtensions.cs b/src/Umbraco.Core/Models/PropertyExtensions.cs index d013c3d88c..e73516e992 100644 --- a/src/Umbraco.Core/Models/PropertyExtensions.cs +++ b/src/Umbraco.Core/Models/PropertyExtensions.cs @@ -42,7 +42,7 @@ namespace Umbraco.Core.Models var propertyEditor = PropertyEditorResolver.Current.GetByAlias(property.PropertyType.PropertyEditorAlias); if (propertyEditor != null) { - var cacheValue = propertyEditor.ValueEditor.FormatValueForCache(property); + var cacheValue = propertyEditor.ValueEditor.ConvertDbToString(property); switch (property.PropertyType.DataTypeDatabaseType) { diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs index 303c34956a..4395564ed1 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueEditor.cs @@ -8,6 +8,14 @@ using Umbraco.Core.Models.Editors; namespace Umbraco.Core.PropertyEditors { + /// + /// An interface that indicates that a property editor supports tags and will store it's published tags into the tag db table + /// + public interface ISupportTags + { + + } + /// /// Represents the value editor for the property editor during content editing /// @@ -169,7 +177,7 @@ namespace Umbraco.Core.PropertyEditors /// If overridden then the object returned must match the type supplied in the ValueType, otherwise persisting the /// value to the DB will fail when it tries to validate the value type. /// - public virtual object FormatDataForPersistence(ContentPropertyData editorValue, object currentValue) + public virtual object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue) { var result = TryConvertValueToCrlType(editorValue.Value); if (result.Success == false) @@ -182,7 +190,7 @@ namespace Umbraco.Core.PropertyEditors //TODO: Change the result to object so we can pass back JSON or json converted clr types if we want! /// - /// A method used to format the databse value to a value that can be used by the editor + /// A method used to format the database value to a value that can be used by the editor /// /// /// @@ -190,7 +198,7 @@ namespace Umbraco.Core.PropertyEditors /// The object returned will automatically be serialized into json notation. For most property editors /// the value returned is probably just a string but in some cases a json structure will be returned. /// - public virtual object FormatDataForEditor(object dbValue) + public virtual object ConvertDbToEditor(object dbValue) { if (dbValue == null) return string.Empty; @@ -235,7 +243,7 @@ namespace Umbraco.Core.PropertyEditors /// /// /// - public virtual object FormatValueForCache(Property property) + public virtual string ConvertDbToString(Property property) { if (property.Value == null) { diff --git a/src/Umbraco.Tests/PropertyEditors/DropDownPropertyPreValueEditorTests.cs b/src/Umbraco.Tests/PropertyEditors/DropDownPropertyPreValueEditorTests.cs index e32085b6fe..73b3600055 100644 --- a/src/Umbraco.Tests/PropertyEditors/DropDownPropertyPreValueEditorTests.cs +++ b/src/Umbraco.Tests/PropertyEditors/DropDownPropertyPreValueEditorTests.cs @@ -25,7 +25,7 @@ namespace Umbraco.Tests.PropertyEditors var dataTypeService = dataTypeServiceMock.Object; var editor = new PublishValuesMultipleValueEditor(true, dataTypeService, new PropertyValueEditor()); - var result = editor.FormatValueForCache( + var result = editor.ConvertDbToString( new Property(1, Guid.NewGuid(), new PropertyType(new DataTypeDefinition(1, "Test.TestEditor")), "1234,4567,8910")); @@ -50,7 +50,7 @@ namespace Umbraco.Tests.PropertyEditors var dataTypeService = dataTypeServiceMock.Object; var editor = new PublishValuesMultipleValueEditor(false, dataTypeService, new PropertyValueEditor()); - var result = editor.FormatValueForCache( + var result = editor.ConvertDbToString( new Property(1, Guid.NewGuid(), new PropertyType(new DataTypeDefinition(1, "Test.TestEditor")), "1234,4567,8910")); @@ -74,7 +74,7 @@ namespace Umbraco.Tests.PropertyEditors var dataTypeService = dataTypeServiceMock.Object; var editor = new PublishValueValueEditor(dataTypeService, new PropertyValueEditor()); - var result = editor.FormatValueForCache( + var result = editor.ConvertDbToString( new Property(1, Guid.NewGuid(), new PropertyType(new DataTypeDefinition(1, "Test.TestEditor")), "1234")); diff --git a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs index 463e2ac3cb..22182a0dcc 100644 --- a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs +++ b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs @@ -19,7 +19,7 @@ namespace Umbraco.Tests.PropertyEditors ValueType = "STRING" }; - var result = valueEditor.FormatDataForEditor(value); + var result = valueEditor.ConvertDbToEditor(value); Assert.AreEqual(isOk, !(result is string)); } @@ -67,7 +67,7 @@ namespace Umbraco.Tests.PropertyEditors ValueType = valueType }; - var result = valueEditor.FormatDataForEditor(val); + var result = valueEditor.ConvertDbToEditor(val); Assert.AreEqual(expected, result); } @@ -80,7 +80,7 @@ namespace Umbraco.Tests.PropertyEditors ValueType = "DATE" }; - var result = valueEditor.FormatDataForEditor(now); + var result = valueEditor.ConvertDbToEditor(now); Assert.AreEqual(now.ToIsoString(), result); } } diff --git a/src/Umbraco.Web/Editors/ContentControllerBase.cs b/src/Umbraco.Web/Editors/ContentControllerBase.cs index 73e66bcc44..e7508f0b12 100644 --- a/src/Umbraco.Web/Editors/ContentControllerBase.cs +++ b/src/Umbraco.Web/Editors/ContentControllerBase.cs @@ -108,7 +108,7 @@ namespace Umbraco.Web.Editors //don't persist any bound value if the editor is readonly if (valueEditor.IsReadOnly == false) { - dboProperty.Value = p.PropertyEditor.ValueEditor.FormatDataForPersistence(data, dboProperty.Value); + dboProperty.Value = p.PropertyEditor.ValueEditor.ConvertEditorToDb(data, dboProperty.Value); } } diff --git a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs index 06a3924cea..3d2a857bcd 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentPropertyBasicConverter.cs @@ -34,7 +34,7 @@ namespace Umbraco.Web.Models.Mapping var result = new T { Id = property.Id, - Value = editor.ValueEditor.FormatDataForEditor(property.Value), + Value = editor.ValueEditor.ConvertDbToEditor(property.Value), Alias = property.Alias }; diff --git a/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs index df408cf09a..32473c6af7 100644 --- a/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/DatePropertyEditor.cs @@ -47,7 +47,7 @@ namespace Umbraco.Web.PropertyEditors Validators.Add(new DateTimeValidator()); } - public override object FormatDataForEditor(object dbValue) + public override object ConvertDbToEditor(object dbValue) { var date = dbValue.TryConvertTo(); if (date.Success == false || date.Result == null) diff --git a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs index be87b5d73c..681ffba662 100644 --- a/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/FileUploadPropertyValueEditor.cs @@ -39,7 +39,7 @@ namespace Umbraco.Web.PropertyEditors /// file path or use the existing file path. /// /// - public override object FormatDataForPersistence(ContentPropertyData editorValue, object currentValue) + public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue) { if (currentValue == null) { diff --git a/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs index ad61293a61..2b65c4f545 100644 --- a/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultipleTextStringPropertyEditor.cs @@ -123,7 +123,7 @@ namespace Umbraco.Web.PropertyEditors /// /// We will also check the pre-values here, if there are more items than what is allowed we'll just trim the end /// - public override object FormatDataForPersistence(ContentPropertyData editorValue, object currentValue) + public override object ConvertEditorToDb(ContentPropertyData editorValue, object currentValue) { var asArray = editorValue.Value as JArray; if (asArray == null) @@ -165,7 +165,7 @@ namespace Umbraco.Web.PropertyEditors /// /// The legacy property editor saved this data as new line delimited! strange but we have to maintain that. /// - public override object FormatDataForEditor(object dbValue) + public override object ConvertDbToEditor(object dbValue) { return dbValue == null ? new JObject[] {} diff --git a/src/Umbraco.Web/PropertyEditors/PublishValueValueEditor.cs b/src/Umbraco.Web/PropertyEditors/PublishValueValueEditor.cs index 4278635c1d..d6c81f7c09 100644 --- a/src/Umbraco.Web/PropertyEditors/PublishValueValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/PublishValueValueEditor.cs @@ -35,7 +35,7 @@ namespace Umbraco.Web.PropertyEditors /// /// /// - public override object FormatValueForCache(Property property) + public override string ConvertDbToString(Property property) { var idAttempt = property.Value.TryConvertTo(); if (idAttempt.Success) @@ -55,7 +55,7 @@ namespace Umbraco.Web.PropertyEditors - return base.FormatValueForCache(property); + return base.ConvertDbToString(property); } protected IDictionary GetPreValues(Property property) diff --git a/src/Umbraco.Web/PropertyEditors/PublishValuesMultipleValueEditor.cs b/src/Umbraco.Web/PropertyEditors/PublishValuesMultipleValueEditor.cs index 3ad47d0459..f9119109dc 100644 --- a/src/Umbraco.Web/PropertyEditors/PublishValuesMultipleValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/PublishValuesMultipleValueEditor.cs @@ -35,17 +35,17 @@ namespace Umbraco.Web.PropertyEditors /// /// /// - public override object FormatValueForCache(Property property) + public override string ConvertDbToString(Property property) { if (_publishIds) { - return base.FormatValueForCache(property); + return base.ConvertDbToString(property); } var selectedIds = property.Value.ToString().Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); if (selectedIds.Any() == false) { - return base.FormatValueForCache(property); + return base.ConvertDbToString(property); } var preValues = GetPreValues(property); @@ -56,7 +56,7 @@ namespace Umbraco.Web.PropertyEditors preValues.Where(x => selectedIds.Contains(x.Value.Id.ToInvariantString())).Select(x => x.Value.Value)); } - return base.FormatValueForCache(property); + return base.ConvertDbToString(property); } /// @@ -64,9 +64,9 @@ namespace Umbraco.Web.PropertyEditors /// /// /// - public override object FormatDataForEditor(object dbValue) + public override object ConvertDbToEditor(object dbValue) { - var delimited = base.FormatDataForEditor(dbValue).ToString(); + var delimited = base.ConvertDbToEditor(dbValue).ToString(); return delimited.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } @@ -77,7 +77,7 @@ namespace Umbraco.Web.PropertyEditors /// /// /// - public override object FormatDataForPersistence(Core.Models.Editors.ContentPropertyData editorValue, object currentValue) + public override object ConvertEditorToDb(Core.Models.Editors.ContentPropertyData editorValue, object currentValue) { var json = editorValue.Value as JArray; if (json == null) diff --git a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs index 5619743c8d..274e35d202 100644 --- a/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/RichTextPropertyEditor.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web.PropertyEditors /// /// /// - public override object FormatDataForEditor(object dbValue) + public override object ConvertDbToEditor(object dbValue) { if (dbValue == null) return dbValue; @@ -53,7 +53,7 @@ namespace Umbraco.Web.PropertyEditors /// /// /// - public override object FormatDataForPersistence(Core.Models.Editors.ContentPropertyData editorValue, object currentValue) + public override object ConvertEditorToDb(Core.Models.Editors.ContentPropertyData editorValue, object currentValue) { if (editorValue.Value == null) return null;