Merge remote-tracking branch 'origin/v8/dev' into v8/feature/media-tracking

# Conflicts:
#	src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs
#	src/Umbraco.Core/Models/RelationType.cs
#	src/Umbraco.Web/PropertyEditors/NestedContentPropertyEditor.cs
#	src/Umbraco.Web/UmbracoComponentRenderer.cs
This commit is contained in:
Shannon
2019-12-18 15:28:27 +11:00
275 changed files with 4520 additions and 3266 deletions

View File

@@ -4,8 +4,6 @@ using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using Umbraco.Core.Composing;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models
@@ -229,8 +227,8 @@ namespace Umbraco.Core.Models
private void ClearCultureInfo(string culture)
{
if (culture.IsNullOrWhiteSpace())
throw new ArgumentNullOrEmptyException(nameof(culture));
if (culture == null) throw new ArgumentNullException(nameof(culture));
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
if (_cultureInfos == null) return;
_cultureInfos.Remove(culture);

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models
@@ -18,7 +17,9 @@ namespace Umbraco.Core.Models
/// </summary>
public ContentCultureInfos(string culture)
{
if (culture.IsNullOrWhiteSpace()) throw new ArgumentNullOrEmptyException(nameof(culture));
if (culture == null) throw new ArgumentNullException(nameof(culture));
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
Culture = culture;
}

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using Umbraco.Core.Collections;
using Umbraco.Core.Exceptions;
namespace Umbraco.Core.Models
{
@@ -23,7 +21,9 @@ namespace Umbraco.Core.Models
/// </summary>
public void AddOrUpdate(string culture, string name, DateTime date)
{
if (culture.IsNullOrWhiteSpace()) throw new ArgumentNullOrEmptyException(nameof(culture));
if (culture == null) throw new ArgumentNullException(nameof(culture));
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
culture = culture.ToLowerInvariant();
if (TryGetValue(culture, out var item))

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Exceptions;
namespace Umbraco.Core.Models
{
@@ -103,11 +102,11 @@ namespace Umbraco.Core.Models
public static void SetPublishInfo(this IContent content, string culture, string name, DateTime date)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullOrEmptyException(nameof(name));
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
if (culture.IsNullOrWhiteSpace())
throw new ArgumentNullOrEmptyException(nameof(culture));
if (culture == null) throw new ArgumentNullException(nameof(culture));
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
content.PublishCultureInfos.AddOrUpdate(culture, name, date);
}
@@ -153,11 +152,11 @@ namespace Umbraco.Core.Models
public static void SetCultureInfo(this IContentBase content, string culture, string name, DateTime date)
{
if (name.IsNullOrWhiteSpace())
throw new ArgumentNullOrEmptyException(nameof(name));
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
if (culture.IsNullOrWhiteSpace())
throw new ArgumentNullOrEmptyException(nameof(culture));
if (culture == null) throw new ArgumentNullException(nameof(culture));
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
content.CultureInfos.AddOrUpdate(culture, name, date);
}
@@ -276,8 +275,8 @@ namespace Umbraco.Core.Models
/// <returns></returns>
public static bool ClearPublishInfo(this IContent content, string culture)
{
if (culture.IsNullOrWhiteSpace())
throw new ArgumentNullOrEmptyException(nameof(culture));
if (culture == null) throw new ArgumentNullException(nameof(culture));
if (string.IsNullOrWhiteSpace(culture)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(culture));
var removed = content.PublishCultureInfos.Remove(culture);
if (removed)

View File

@@ -66,7 +66,7 @@ namespace Umbraco.Core.Models.Entities
public int ParentId { get; set; }
/// <inheritdoc />
public void SetParent(ITreeEntity parent) => throw new WontImplementException();
public void SetParent(ITreeEntity parent) => throw new InvalidOperationException("This property won't be implemented.");
/// <inheritdoc />
[DataMember]
@@ -116,7 +116,7 @@ namespace Umbraco.Core.Models.Entities
/// <inheritdoc />
public object DeepClone()
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
#endregion
@@ -128,47 +128,47 @@ namespace Umbraco.Core.Models.Entities
public bool IsDirty()
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public bool IsPropertyDirty(string propName)
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public IEnumerable<string> GetDirtyProperties()
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public void ResetDirtyProperties()
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public bool WasDirty()
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public bool WasPropertyDirty(string propertyName)
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public void ResetWereDirtyProperties()
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public void ResetDirtyProperties(bool rememberDirty)
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
public IEnumerable<string> GetWereDirtyProperties()
{
throw new WontImplementException();
throw new InvalidOperationException("This method won't be implemented.");
}
#endregion

View File

@@ -1,10 +1,8 @@
using System;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Models
{
@@ -18,29 +16,12 @@ namespace Umbraco.Core.Models
if (!media.Properties.TryGetValue(propertyAlias, out var property))
return string.Empty;
// TODO: would need to be adjusted to variations, when media become variants
if (!(property.GetValue() is string jsonString))
return string.Empty;
if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.UploadField)
return jsonString;
if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.ImageCropper)
if (Current.PropertyEditors.TryGet(property.PropertyType.PropertyEditorAlias, out var editor)
&& editor is IDataEditorWithMediaPath dataEditor)
{
if (jsonString.DetectIsJson() == false)
return jsonString;
try
{
var json = JsonConvert.DeserializeObject<JObject>(jsonString);
if (json["src"] != null)
return json["src"].Value<string>();
}
catch (Exception ex)
{
logger.Error<ImageCropperValueConverter>(ex, "Could not parse the string '{JsonString}' to a json object", jsonString);
return string.Empty;
}
// TODO: would need to be adjusted to variations, when media become variants
var value = property.GetValue();
return dataEditor.GetMediaPath(value);
}
// Without knowing what it is, just adding a string here might not be very nice

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Umbraco.Core.Composing;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Models
@@ -43,7 +42,8 @@ namespace Umbraco.Core.Models
public Member(string name, IMemberType contentType)
: base(name, -1, contentType, new PropertyCollection())
{
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
IsApproved = true;
@@ -63,9 +63,12 @@ namespace Umbraco.Core.Models
public Member(string name, string email, string username, IMemberType contentType, bool isApproved = true)
: base(name, -1, contentType, new PropertyCollection())
{
if (string.IsNullOrWhiteSpace(email)) throw new ArgumentNullOrEmptyException(nameof(email));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentNullOrEmptyException(nameof(username));
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
if (email == null) throw new ArgumentNullException(nameof(email));
if (string.IsNullOrWhiteSpace(email)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(email));
if (username == null) throw new ArgumentNullException(nameof(username));
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(username));
_email = email;
_username = username;

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models
@@ -9,7 +8,7 @@ namespace Umbraco.Core.Models
/// </summary>
/// <typeparam name="T"></typeparam>
[DataContract(Name = "pagedCollection", Namespace = "")]
public class PagedResult<T>
public abstract class PagedResult
{
public PagedResult(long totalItems, long pageNumber, long pageSize)
{
@@ -39,9 +38,6 @@ namespace Umbraco.Core.Models
[DataMember(Name = "totalItems")]
public long TotalItems { get; private set; }
[DataMember(Name = "items")]
public IEnumerable<T> Items { get; set; }
/// <summary>
/// Calculates the skip size based on the paged parameters specified
/// </summary>

View File

@@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models
{
/// <summary>
/// Represents a paged result for a model collection
/// </summary>
/// <typeparam name="T"></typeparam>
[DataContract(Name = "pagedCollection", Namespace = "")]
public class PagedResult<T> : PagedResult
{
public PagedResult(long totalItems, long pageNumber, long pageSize)
: base(totalItems, pageNumber, pageSize)
{ }
[DataMember(Name = "items")]
public IEnumerable<T> Items { get; set; }
}
}

View File

@@ -26,8 +26,10 @@ namespace Umbraco.Core.Models
private string _propertyEditorAlias;
private ValueStorageType _valueStorageType;
private bool _mandatory;
private string _mandatoryMessage;
private int _sortOrder;
private string _validationRegExp;
private string _validationRegExpMessage;
private ContentVariation _variations;
/// <summary>
@@ -183,7 +185,7 @@ namespace Umbraco.Core.Models
}
/// <summary>
/// Gets of sets a value indicating whether a value for this property type is required.
/// Gets or sets a value indicating whether a value for this property type is required.
/// </summary>
[DataMember]
public bool Mandatory
@@ -192,6 +194,16 @@ namespace Umbraco.Core.Models
set => SetPropertyValueAndDetectChanges(value, ref _mandatory, nameof(Mandatory));
}
/// <summary>
/// Gets or sets the custom validation message used when a value for this PropertyType is required
/// </summary>
[DataMember]
public string MandatoryMessage
{
get => _mandatoryMessage;
set => SetPropertyValueAndDetectChanges(value, ref _mandatoryMessage, nameof(MandatoryMessage));
}
/// <summary>
/// Gets of sets the sort order of the property type.
/// </summary>
@@ -212,6 +224,16 @@ namespace Umbraco.Core.Models
set => SetPropertyValueAndDetectChanges(value, ref _validationRegExp, nameof(ValidationRegExp));
}
/// <summary>
/// Gets or sets the custom validation message used when a pattern for this PropertyType must be matched
/// </summary>
[DataMember]
public string ValidationRegExpMessage
{
get => _validationRegExpMessage;
set => SetPropertyValueAndDetectChanges(value, ref _validationRegExpMessage, nameof(ValidationRegExpMessage));
}
/// <summary>
/// Gets or sets the content variation of the property type.
/// </summary>

View File

@@ -20,7 +20,9 @@ namespace Umbraco.Core.Models.PublishedContent
{
private ModelType(string contentTypeAlias)
{
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias));
if (contentTypeAlias == null) throw new ArgumentNullException(nameof(contentTypeAlias));
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(contentTypeAlias));
ContentTypeAlias = contentTypeAlias;
Name = "{" + ContentTypeAlias + "}";
}

View File

@@ -1,5 +1,4 @@
using System;
using Umbraco.Core.Exceptions;
namespace Umbraco.Core.Models.PublishedContent
{
@@ -13,7 +12,8 @@ namespace Umbraco.Core.Models.PublishedContent
/// </summary>
public PublishedCultureInfo(string culture, string name, string urlSegment, DateTime date)
{
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
if (name == null) throw new ArgumentNullException(nameof(name));
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
Culture = culture ?? throw new ArgumentNullException(nameof(culture));
Name = name;

View File

@@ -1,5 +1,4 @@
using System;
using Umbraco.Core.Exceptions;
namespace Umbraco.Core.Models.PublishedContent
{
@@ -19,7 +18,9 @@ namespace Umbraco.Core.Models.PublishedContent
/// <param name="contentTypeAlias">The content type alias.</param>
public PublishedModelAttribute(string contentTypeAlias)
{
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias));
if (contentTypeAlias == null) throw new ArgumentNullException(nameof(contentTypeAlias));
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(contentTypeAlias));
ContentTypeAlias = contentTypeAlias;
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Core.Exceptions;
using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models